Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -36,6 +36,7 @@ import mainDBAlaa
|
|
| 36 |
import datetime
|
| 37 |
import doors_fasterrcnn
|
| 38 |
import deploying_3_3
|
|
|
|
| 39 |
|
| 40 |
import ezdxf
|
| 41 |
app = Flask(__name__)
|
|
@@ -191,7 +192,7 @@ def stringToRGB():
|
|
| 191 |
arr=measureproject(vv,dataDoc,opencv_img)
|
| 192 |
|
| 193 |
|
| 194 |
-
if vv[5][2].startswith('2.8'):
|
| 195 |
pdfpath,pdflink=tsadropboxretrieval.getPathtoPDF_File(nameofPDF= str(vv[0]))
|
| 196 |
dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 197 |
md, res =dbxTeam.files_download(path=pdfpath)
|
|
@@ -275,24 +276,27 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
|
| 275 |
dpxlinks=[]
|
| 276 |
legendLinks=[]
|
| 277 |
listofmarkups=[]
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
# dbpdfpath,pdflink=tsadropboxretrieval.getPathtoPDF_File(nameofPDF=result[0])
|
| 281 |
-
# dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 282 |
-
# md, res =dbxTeam.files_download(path=dbpdfpath)
|
| 283 |
-
# dataDoc = res.content
|
| 284 |
-
annotatedimg,pdf_document,spreadsheet_url, list1 , df_doors=doors_fasterrcnn.main_run(img,dataDoc,'separated_classes.pth',result[0],pdfpath, result[4]) #single_double.pth
|
| 285 |
|
| 286 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 287 |
-
#
|
| 288 |
-
pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
|
| 289 |
-
|
| 290 |
-
print(pdflink)
|
| 291 |
-
# dpxlinks.append(pdflink)
|
| 292 |
-
# legendLinks.append(spreadsheet_url)
|
| 293 |
-
# listofmarkups.append(list1.to_dict())
|
| 294 |
_, buffer = cv2.imencode('.png', annotatedimg)
|
| 295 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
arr=[base64.b64encode(buffer).decode('utf-8') ,pdflink,spreadsheet_url,list1.to_dict(), df_doors.to_dict()]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
|
| 297 |
|
| 298 |
################################# -2.2- #################################
|
|
@@ -301,18 +305,14 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
|
|
| 301 |
#
|
| 302 |
#link (add this to ur code)
|
| 303 |
# pdflink= db.dropbox_upload_file(doc=doc,pdfname=path,pdfpath=pdfpath)
|
| 304 |
-
|
| 305 |
# gc,spreadsheet_service,spreadsheetId, spreadsheet_url , namepathArr= pilecaps_adr.legendGoogleSheets(df,plan ,pdfpath)
|
| 306 |
-
|
| 307 |
-
|
| 308 |
#output img
|
| 309 |
# _, buffer = cv2.imencode('.png', outputimg)
|
| 310 |
-
|
| 311 |
#let first result to be the img
|
| 312 |
#return results in arr=[base64.b64encode(buffer).decode('utf-8'),pdflink,spreadsheetId,spreadsheet_url] like the previous sections in the above lines
|
| 313 |
-
elif result[5][2].startswith('2.1'): #section value - 2.1 frames
|
| 314 |
-
|
| 315 |
-
|
| 316 |
|
| 317 |
return arr
|
| 318 |
#_________________________________________________________________________________________________________________________
|
|
@@ -541,17 +541,17 @@ def dltmarkupslegend():
|
|
| 541 |
if section.startswith('1.0') or section.startswith('3.2') or section.startswith('3.3'):
|
| 542 |
newlgnd=google_sheet_Legend.deletefromlegend(deletedrows=deletedrows,SimilarAreaDictionarycopy=SimilarAreaDictionary, section=section,areaPermArr=areaPermArr)
|
| 543 |
elif section.startswith('2.8'):
|
| 544 |
-
newlgnd=google_sheet_Legend.
|
| 545 |
print('done wit 2.8 in deleting, didnt append yet ')
|
| 546 |
else:
|
| 547 |
newlgnd=google_sheet_Legend.deletefromlegend(deletedrows=deletedrows,SimilarAreaDictionarycopy=SimilarAreaDictionary, section=section)
|
| 548 |
try:
|
| 549 |
-
|
| 550 |
-
newlgnd1=google_sheet_Legend.legendGoogleSheets(SimilarAreaDictionary=newlgnd,path=path,spreadsheetId=spreadsheetId ,pdfpath=pdfpth) #new legend
|
| 551 |
except:
|
|
|
|
| 552 |
print("An exception occurred")
|
| 553 |
time.sleep(20)
|
| 554 |
-
|
| 555 |
|
| 556 |
return jsonify('donee')
|
| 557 |
|
|
@@ -745,6 +745,7 @@ def cvtSummarytoXML(jsdata):
|
|
| 745 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 746 |
return jsonify(xmllink)
|
| 747 |
|
|
|
|
| 748 |
|
| 749 |
#_________________________________________________________________________________________________________________________
|
| 750 |
#_________________________________________________________________________________________________________________________
|
|
|
|
| 36 |
import datetime
|
| 37 |
import doors_fasterrcnn
|
| 38 |
import deploying_3_3
|
| 39 |
+
import Counting_Columns_2_1
|
| 40 |
|
| 41 |
import ezdxf
|
| 42 |
app = Flask(__name__)
|
|
|
|
| 192 |
arr=measureproject(vv,dataDoc,opencv_img)
|
| 193 |
|
| 194 |
|
| 195 |
+
if vv[5][2].startswith('2.8') or vv[5][2].startswith('2.1'):
|
| 196 |
pdfpath,pdflink=tsadropboxretrieval.getPathtoPDF_File(nameofPDF= str(vv[0]))
|
| 197 |
dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
|
| 198 |
md, res =dbxTeam.files_download(path=pdfpath)
|
|
|
|
| 276 |
dpxlinks=[]
|
| 277 |
legendLinks=[]
|
| 278 |
listofmarkups=[]
|
| 279 |
+
|
| 280 |
+
annotatedimg,pdf_document,spreadsheet_url, list1 , df_doors=doors_fasterrcnn.main_run(img,dataDoc,'separated_classes_all.pth',result[0],pdfpath, result[4]) #single_double.pth
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 283 |
+
pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
_, buffer = cv2.imencode('.png', annotatedimg)
|
| 285 |
+
arr=[base64.b64encode(buffer).decode('utf-8') ,pdflink,spreadsheet_url,list1.to_dict(), df_doors.to_dict()]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
|
| 286 |
+
|
| 287 |
+
################################# -2.1- #################################
|
| 288 |
+
elif result[5][2].startswith('2.1'): #section value - 2.8 floor finishes
|
| 289 |
+
#vv[0] array of pdf names
|
| 290 |
+
imgss=[]
|
| 291 |
+
dpxlinks=[]
|
| 292 |
+
legendLinks=[]
|
| 293 |
+
listofmarkups=[]
|
| 294 |
+
|
| 295 |
+
annotatedimg,pdf_document,spreadsheet_url, list1 , df_doors=Counting_Columns_2_1.mainfun(dataDoc)
|
| 296 |
+
|
| 297 |
+
# dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
|
| 298 |
+
# pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/
|
| 299 |
+
# _, buffer = cv2.imencode('.png', annotatedimg)
|
| 300 |
arr=[base64.b64encode(buffer).decode('utf-8') ,pdflink,spreadsheet_url,list1.to_dict(), df_doors.to_dict()]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
|
| 301 |
|
| 302 |
################################# -2.2- #################################
|
|
|
|
| 305 |
#
|
| 306 |
#link (add this to ur code)
|
| 307 |
# pdflink= db.dropbox_upload_file(doc=doc,pdfname=path,pdfpath=pdfpath)
|
|
|
|
| 308 |
# gc,spreadsheet_service,spreadsheetId, spreadsheet_url , namepathArr= pilecaps_adr.legendGoogleSheets(df,plan ,pdfpath)
|
|
|
|
|
|
|
| 309 |
#output img
|
| 310 |
# _, buffer = cv2.imencode('.png', outputimg)
|
|
|
|
| 311 |
#let first result to be the img
|
| 312 |
#return results in arr=[base64.b64encode(buffer).decode('utf-8'),pdflink,spreadsheetId,spreadsheet_url] like the previous sections in the above lines
|
| 313 |
+
# elif result[5][2].startswith('2.1'): #section value - 2.1 frames
|
| 314 |
+
# url = tameem2_1.mainfun( result[0], pdfpath)
|
| 315 |
+
# return jsonify([url])
|
| 316 |
|
| 317 |
return arr
|
| 318 |
#_________________________________________________________________________________________________________________________
|
|
|
|
| 541 |
if section.startswith('1.0') or section.startswith('3.2') or section.startswith('3.3'):
|
| 542 |
newlgnd=google_sheet_Legend.deletefromlegend(deletedrows=deletedrows,SimilarAreaDictionarycopy=SimilarAreaDictionary, section=section,areaPermArr=areaPermArr)
|
| 543 |
elif section.startswith('2.8'):
|
| 544 |
+
newlgnd=google_sheet_Legend.deletedoors(deletedrows,SimilarAreaDictionary)
|
| 545 |
print('done wit 2.8 in deleting, didnt append yet ')
|
| 546 |
else:
|
| 547 |
newlgnd=google_sheet_Legend.deletefromlegend(deletedrows=deletedrows,SimilarAreaDictionarycopy=SimilarAreaDictionary, section=section)
|
| 548 |
try:
|
| 549 |
+
newlgnd=google_sheet_Legend.legendGoogleSheets(SimilarAreaDictionary=newlgnd,path=path,spreadsheetId=spreadsheetId ,pdfpath=pdfpth) #new legend
|
|
|
|
| 550 |
except:
|
| 551 |
+
|
| 552 |
print("An exception occurred")
|
| 553 |
time.sleep(20)
|
| 554 |
+
newlgnd=google_sheet_Legend.legendGoogleSheets(SimilarAreaDictionary=newlgnd,path=path,spreadsheetId=spreadsheetId,pdfpath=pdfpth)
|
| 555 |
|
| 556 |
return jsonify('donee')
|
| 557 |
|
|
|
|
| 745 |
xmllink=google_sheet_to_xml.create_xml(documentname=result[1],dbPath=path)
|
| 746 |
return jsonify(xmllink)
|
| 747 |
|
| 748 |
+
|
| 749 |
|
| 750 |
#_________________________________________________________________________________________________________________________
|
| 751 |
#_________________________________________________________________________________________________________________________
|