Marthee commited on
Commit
d0760b8
·
verified ·
1 Parent(s): d48a1f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -29
app.py CHANGED
@@ -6,7 +6,7 @@ import fitz
6
  from PIL import Image
7
  import cv2
8
  import numpy as np
9
- import pilecaps_adr
10
  import base64
11
  from db import dropbox_connect
12
  import db
@@ -106,12 +106,12 @@ def getSearchinFolder():
106
  def measurementConsoleFn():
107
  return render_template("proposed-GUI.html")
108
 
109
- @app.route('/RetrieveMCTNames/<jsdata>',methods=['GET'])
110
- def CallAPIforMCTNames(jsdata):
111
  # print(jsdata)
112
  DictionaryOfTemplates=MC_Templates_API.RetrieveMC_Templates_API()
113
- jsdata=jsdata.replace('"', '')
114
- return jsonify(DictionaryOfTemplates[str(jsdata).lower()])
115
 
116
  #_________________________________________________________________________________________________________________________
117
  #_________________________________________________________________________________________________________________________
@@ -410,18 +410,22 @@ def returnAPITables():
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=')
417
  url_3 = prjsectionsURL.replace('/edit#gid=', '/export?format=csv&gid=')
418
 
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
 
@@ -430,6 +434,10 @@ def checktables():
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=''
@@ -439,6 +447,7 @@ def checktables():
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=''
@@ -453,35 +462,39 @@ def checktables():
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
 
@@ -501,6 +514,5 @@ def appendNewTables():
501
  #_________________________________________________________________________________________________________________________
502
  #_________________________________________________________________________________________________________________________
503
 
504
-
505
  if __name__ == "__main__":
506
  app.run(host="0.0.0.0", port=7860)
 
6
  from PIL import Image
7
  import cv2
8
  import numpy as np
9
+ import pilecaps_adr
10
  import base64
11
  from db import dropbox_connect
12
  import db
 
106
  def measurementConsoleFn():
107
  return render_template("proposed-GUI.html")
108
 
109
+ @app.route('/RetrieveMCTNames/',methods=['GET'])
110
+ def CallAPIforMCTNames():
111
  # print(jsdata)
112
  DictionaryOfTemplates=MC_Templates_API.RetrieveMC_Templates_API()
113
+ # jsdata=jsdata.replace('"', '')
114
+ return jsonify(DictionaryOfTemplates) #[str(jsdata).lower()]
115
 
116
  #_________________________________________________________________________________________________________________________
117
  #_________________________________________________________________________________________________________________________
 
410
 
411
  @app.route('/refreshAPI',methods=["GET", "POST"])
412
  def checktables():
413
+ # sectionData = request.args.get('sectionData')
414
+ # sectionData = request.args.get('sectionData')
415
+ # print(sectionData)
416
  table1,table2,table3=API.GenerateTables()
417
+ # if sectionData!='noSectionYet':
418
+ # DictionaryOfTemplates=MC_Templates_API.RetrieveMC_Templates_API()
419
+ # sectionData=sectionData.replace('"', '')
420
+ # DictionaryOfTemplates[str(sectionData).lower()]
421
  url_1 = prjnamesURL.replace('/edit#gid=', '/export?format=csv&gid=')
422
  url_2 = prjpartsURL.replace('/edit#gid=', '/export?format=csv&gid=')
423
  url_3 = prjsectionsURL.replace('/edit#gid=', '/export?format=csv&gid=')
424
 
425
  table1N = pd.read_csv(url_1)
426
  table2N = pd.read_csv(url_2)
427
+ table3N = pd.read_csv(url_3)
428
+
 
 
429
  t1Diff=table1N[~table1N.isin(table1)].dropna()
430
  t1Diff1=table1[~table1.isin(table1N)].dropna()
431
 
 
434
 
435
  t3Diff=table3N[~table3N.isin(table3)].dropna()
436
  t3Diff1=table3[~table3.isin(table3N)].dropna()
437
+
438
+ # print(t1Diff,t1Diff1)
439
+ # print(t2Diff,t2Diff1)
440
+ # print(t3Diff,t3Diff1)
441
  returnString=''
442
  if (not t1Diff.empty) or (not t1Diff1.empty) :
443
  returnString=''
 
447
  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']
448
  elif (not t3Diff.empty) or (not t3Diff1.empty):
449
  returnString=''
450
+
451
  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']
452
  elif ((not t1Diff.empty) or (not t1Diff1.empty)) and ((not t2Diff.empty) or ( not t2Diff1.empty)):
453
  returnString=''
 
462
  returnString=''
463
  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']
464
  else:
465
+ print('No updates in the API')
466
+ # if sectionData!='noSectionYet':
467
+ # return jsonify([returnString,DictionaryOfTemplates])
468
+ # else:
469
  return jsonify(returnString)
470
 
471
+
472
  @app.route('/refreshDropbox',methods=["GET", "POST"])
473
  def checkdropbox():
474
  print('checkingggdf')
475
  dfFromDropbox=tsadropboxretrieval.DropboxItemstoDF()
476
  dfParquet=tsadropboxretrieval.GetParquetDF()
477
+
478
+ dfParquet1 = dfParquet[['name', 'path_display', 'client_modified', 'server_modified']]
479
+ deletedrows = pd.concat([dfFromDropbox, dfParquet1]).drop_duplicates(keep=False)
480
+ deletedrows = deletedrows.reset_index(drop=True)
481
+ deletedrows.columns = ['name', 'path_display', 'client_modified', 'server_modified']
482
+ differences = deletedrows[~deletedrows.isin(dfFromDropbox)].dropna()
483
+ if (len(differences)>0):
484
+ print(differences)
485
+ dbxTeam=tsadropboxretrieval.dropbox_upload_file(dfFromDropbox)
486
+ stringReturned= 'Updated Sucessfully.'
487
  else:
488
+ stringReturned= 'Nothing to update.'
489
+ return stringReturned
490
+
491
+
492
 
493
  @app.route('/postdropboxprojects',methods=["GET", "POST"])
494
  def postDropboxprojectsinConsole():
495
+ stringReturned=checkdropbox()
496
+ print(stringReturned)
497
+ return stringReturned
 
 
 
498
 
499
 
500
 
 
514
  #_________________________________________________________________________________________________________________________
515
  #_________________________________________________________________________________________________________________________
516
 
 
517
  if __name__ == "__main__":
518
  app.run(host="0.0.0.0", port=7860)