Marthee commited on
Commit
69d1aa6
·
verified ·
1 Parent(s): 5970288

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -18
app.py CHANGED
@@ -39,7 +39,7 @@ prjsectionsURL= 'https://docs.google.com/spreadsheets/d/1I4P7wiCXTAwnld0YQfUJC8b
39
 
40
  @app.route("/",methods=["GET", "POST"])
41
  def getInfotoMeasure():
42
- API.AppendtablestoSheets()
43
  return render_template("proposed-GUI.html")
44
 
45
  @app.route('/getprojectnames/',methods=['GET'])
@@ -66,7 +66,7 @@ def get_javascript_data(jsdata):
66
  #get project from the first dropdown
67
  # jsdata=eval(jsdata)
68
  documnetsToMeasure,RelevantDocuments=tsadropboxretrieval.retrieveProjects(jsdata)
69
- if documnetsToMeasure:
70
  return jsonify ([documnetsToMeasure, RelevantDocuments])
71
  else:
72
  return ['No projects found']
@@ -146,7 +146,7 @@ def measure2_1():
146
  arr=measureproject(result)
147
  return arr
148
  #MAIN FUNCTION -- calls python code to measure the chosen plan from the interface
149
-
150
  def measureproject(result,dataDoc,img=0):
151
  colorarr=[]
152
  # result = json.loads(jsdata)
@@ -410,6 +410,7 @@ def returnAPITables():
410
 
411
  @app.route('/refreshAPI',methods=["GET", "POST"])
412
  def checktables():
 
413
  table1,table2,table3=API.GenerateTables()
414
  url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
415
  url_2 = prjpartsURL.replace('/edit#gid=', '/export?format=csv&gid=')
@@ -418,33 +419,79 @@ def checktables():
418
  table1N = pd.read_csv(url_1)
419
  table2N = pd.read_csv(url_2)
420
  table3N = pd.read_csv(url_3)
421
-
 
 
422
  t1Diff=table1N[~table1N.isin(table1)].dropna()
 
 
423
  t2Diff=table2N[~table2N.isin(table2)].dropna()
 
 
424
  t3Diff=table3N[~table3N.isin(table3)].dropna()
 
425
  returnString=''
426
- if not t1Diff.empty:
427
- returnString=['Changes have been made in Projects. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','project']
428
- if not t2Diff.empty:
429
- returnString=['Changes have been made in Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','part']
430
- if not t3Diff.empty:
431
- returnString=['Changes have been made in Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','section']
432
- if (not t1Diff.empty) and (not t2Diff.empty):
433
- returnString=['Changes have been made in Projects and Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','projectpart']
434
- if (not t1Diff.empty) and (not t3Diff.empty):
435
- returnString=['Changes have been made in Projects and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','projectsection']
436
- if (not t2Diff.empty) and (not t3Diff.empty):
437
- returnString=['Changes have been made in Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the process(if any).','partsection']
438
- print(t1Diff)
 
 
 
 
 
 
 
 
 
 
 
 
439
  return jsonify(returnString)
440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
441
  @app.route('/refreshAPIAppendNewTables',methods=["GET", "POST"])
442
  def appendNewTables():
443
  value = request.args.get('keyword')
444
  print(value)
445
  API.AppendtablestoSheets()
446
  return jsonify('appended')
447
-
448
  #_________________________________________________________________________________________________________________________
449
  #_________________________________________________________________________________________________________________________
450
 
@@ -453,5 +500,7 @@ def appendNewTables():
453
 
454
  #_________________________________________________________________________________________________________________________
455
  #_________________________________________________________________________________________________________________________
 
 
456
  if __name__ == "__main__":
457
  app.run(host="0.0.0.0", port=7860)
 
39
 
40
  @app.route("/",methods=["GET", "POST"])
41
  def getInfotoMeasure():
42
+ # API.AppendtablestoSheets()
43
  return render_template("proposed-GUI.html")
44
 
45
  @app.route('/getprojectnames/',methods=['GET'])
 
66
  #get project from the first dropdown
67
  # jsdata=eval(jsdata)
68
  documnetsToMeasure,RelevantDocuments=tsadropboxretrieval.retrieveProjects(jsdata)
69
+ if RelevantDocuments:
70
  return jsonify ([documnetsToMeasure, RelevantDocuments])
71
  else:
72
  return ['No projects found']
 
146
  arr=measureproject(result)
147
  return arr
148
  #MAIN FUNCTION -- calls python code to measure the chosen plan from the interface
149
+ # @app.route('/projecttomeasure/<jsdata>',methods=["GET","POST"])
150
  def measureproject(result,dataDoc,img=0):
151
  colorarr=[]
152
  # result = json.loads(jsdata)
 
410
 
411
  @app.route('/refreshAPI',methods=["GET", "POST"])
412
  def checktables():
413
+ print('innn')
414
  table1,table2,table3=API.GenerateTables()
415
  url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
416
  url_2 = prjpartsURL.replace('/edit#gid=', '/export?format=csv&gid=')
 
419
  table1N = pd.read_csv(url_1)
420
  table2N = pd.read_csv(url_2)
421
  table3N = pd.read_csv(url_3)
422
+ # t1Diff=table1N[~table1N.apply(tuple,1).isin(table1.apply(tuple,1))]
423
+ # t2Diff=table2N[~table2N.apply(tuple,1).isin(table2.apply(tuple,1))]
424
+ # t3Diff=table3N[~table3N.apply(tuple,1).isin(table3.apply(tuple,1))]
425
  t1Diff=table1N[~table1N.isin(table1)].dropna()
426
+ t1Diff1=table1[~table1.isin(table1N)].dropna()
427
+
428
  t2Diff=table2N[~table2N.isin(table2)].dropna()
429
+ t2Diff1=table2[~table2.isin(table2N)].dropna()
430
+
431
  t3Diff=table3N[~table3N.isin(table3)].dropna()
432
+ t3Diff1=table3[~table3.isin(table3N)].dropna()
433
  returnString=''
434
+ if (not t1Diff.empty) or (not t1Diff1.empty) :
435
+ returnString=''
436
+ returnString=['Changes have been made in Projects. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','project']
437
+ elif (not t2Diff.empty) or (not t2Diff1.empty):
438
+ returnString=''
439
+ returnString=['Changes have been made in Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','part']
440
+ elif (not t3Diff.empty) or (not t3Diff1.empty):
441
+ returnString=''
442
+ returnString=['Changes have been made in Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','section']
443
+ elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t2Diff.empty) or ( not t2Diff1.empty)):
444
+ returnString=''
445
+ returnString=['Changes have been made in Projects and Parts. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','projectpart']
446
+ elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty) ):
447
+ returnString=''
448
+ returnString=['Changes have been made in Projects and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','projectsection']
449
+ elif ((not t2Diff.empty) or (not t2Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty)):
450
+ returnString=''
451
+ returnString=['Changes have been made in Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','partsection']
452
+ elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t2Diff.empty) or (not t2Diff1.empty)) and ((not t3Diff.empty) or (not t3Diff1.empty)):
453
+ returnString=''
454
+ returnString=['Changes have been made in Projects, Parts and Sections. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).','project']
455
+ else:
456
+ print('wala hagaaa')
457
+ print(t1Diff,t1Diff1)
458
+ print(returnString)
459
  return jsonify(returnString)
460
 
461
+ @app.route('/refreshDropbox',methods=["GET", "POST"])
462
+ def checkdropbox():
463
+ print('checkingggdf')
464
+ dfFromDropbox=tsadropboxretrieval.DropboxItemstoDF()
465
+ dfParquet=tsadropboxretrieval.GetParquetDF()
466
+ t1Diff=dfFromDropbox[~dfFromDropbox.isin(dfParquet)].dropna()
467
+ t1Diff1=dfParquet[~dfParquet.isin(dfFromDropbox)].dropna()
468
+ returnString=''
469
+
470
+ if (not t1Diff.empty) or (not t1Diff1.empty) :
471
+ print('changess')
472
+ returnString='Some changes have been made in the dropbox. Would you like to retrieve them in the console? By saying yes, you may need to repeat the website related processes(if any).'
473
+ else:
474
+ print('nochangess')
475
+ return jsonify([returnString,dfFromDropbox.to_dict()])
476
+
477
+ @app.route('/postdropboxprojects',methods=["GET", "POST"])
478
+ def postDropboxprojectsinConsole():
479
+ dfDropbox = request.args.get('dict')
480
+ dfDropbox=pd.DataFrame(dfDropbox)
481
+ print(dfDropbox)
482
+ print('uploading')
483
+ # dbxTeam=API.dropbox_upload_file(dfDropbox)
484
+ return jsonify('posted')
485
+
486
+
487
+
488
  @app.route('/refreshAPIAppendNewTables',methods=["GET", "POST"])
489
  def appendNewTables():
490
  value = request.args.get('keyword')
491
  print(value)
492
  API.AppendtablestoSheets()
493
  return jsonify('appended')
494
+
495
  #_________________________________________________________________________________________________________________________
496
  #_________________________________________________________________________________________________________________________
497
 
 
500
 
501
  #_________________________________________________________________________________________________________________________
502
  #_________________________________________________________________________________________________________________________
503
+
504
+
505
  if __name__ == "__main__":
506
  app.run(host="0.0.0.0", port=7860)