Marthee commited on
Commit
eade826
·
verified ·
1 Parent(s): f0a6919

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -7
app.py CHANGED
@@ -480,9 +480,15 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0,pdf_content=0):
480
  SearchArray=result[6]
481
 
482
  if pdf_content:
483
- doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray, pdfpath,result[0],pdf_content)
 
 
 
484
  else:
485
- doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray,pdfpath,result[0])
 
 
 
486
  global colorsused
487
  colorsused=list(SimilarAreaDictionary['Color'])
488
  dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
@@ -494,7 +500,10 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0,pdf_content=0):
494
  pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=nameofpdf)
495
 
496
  _, buffer = cv2.imencode('.png', outputimg)
497
- arr=[ base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(), spreadsheet_url,spreadsheetId,[],list1.to_dict(),pdflink,hatched_areas,namepathArr]#,hatched_areas,namepathArr]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
 
 
 
498
  ################################# 2.7- #################################
499
  elif section.startswith('2.7') : #section value - 2.7 floor finishes
500
  print('code of 2.7')
@@ -550,23 +559,29 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0,pdf_content=0):
550
 
551
  pdf_contentSched = BytesIO(response.content)
552
  # pdf_contentSched = fitz.open(stream=pdf_contentSched, filetype="pdf")
553
- annotatedimg, pdf_document , list1, repeated_labels , not_found =Doors_Schedule.mainRun(pdf_contentSched, dataDoc, SearchArray,pdf_content,pdf_contentSched)
554
  else:
555
  pdfpathDoors,_=tsadropboxretrieval.getPathtoPDF_File(nameofPDF= str(result[6]))
556
  dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
557
  md, resDoors =dbxTeam.files_download(path=pdfpathDoors)
558
  dataDocDoorsSchedule = resDoors.content
559
- annotatedimg, pdf_document , list1, repeated_labels , not_found =Doors_Schedule.mainRun(dataDocDoorsSchedule, dataDoc, SearchArray)
 
560
  dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
561
  pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname="combined_output.pdf") #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/
562
- _, buffer = cv2.imencode('.png', annotatedimg)
563
  repeatedLabelsReturn=''
564
  NotFoundReturn=''
565
  if len(repeated_labels)>0:
566
  repeatedLabelsReturn=repeated_labels
567
  if len(not_found)>0:
568
  NotFoundReturn=not_found # , spreadsheetId, spreadsheet_url , list1.to_dict()]
569
- arr=[base64.b64encode(buffer).decode('utf-8') ,pdflink,list1.to_dict(),str(repeatedLabelsReturn), str(NotFoundReturn)] # , spreadsheetId, spreadsheet_url , list1.to_dict()]
 
 
 
 
 
570
  ################################# -2.1- #################################
571
  elif section.startswith('2.1'): #section value - 2.8 floor finishes
572
  #vv[0] array of pdf names
@@ -710,6 +725,8 @@ def modifyingcalcRefDynamic(img):
710
  return area, perimeter, blk , imgcopy
711
  #_________________________________________________________________________________________________________________________
712
  #_________________________________________________________________________________________________________________________
 
 
713
  @app.route('/downloadPDFfromLink')
714
  def downloadPDFfromLinkFunc():
715
  encoded_url = request.args.get('url')
 
480
  SearchArray=result[6]
481
 
482
  if pdf_content:
483
+ if section.startswith('3.3'):
484
+ doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas =deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray, pdfpath,result[0],pdf_content)
485
+ else:
486
+ doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas, bax_pretty_xml, column_xml=dxf__omar3_2.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray, pdfpath,result[0],pdf_content)
487
  else:
488
+ if section.startswith('3.3'):
489
+ doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas =deploying_3_3.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray,pdfpath,result[0])
490
+ else:
491
+ doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas, bax_pretty_xml, column_xml=dxf__omar3_2.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] ,SearchArray,pdfpath,result[0])
492
  global colorsused
493
  colorsused=list(SimilarAreaDictionary['Color'])
494
  dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
 
500
  pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=nameofpdf)
501
 
502
  _, buffer = cv2.imencode('.png', outputimg)
503
+ if section.startswith('3.3'):
504
+ arr=[ base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(), spreadsheet_url,spreadsheetId,[],list1.to_dict(),pdflink,hatched_areas,namepathArr]#,hatched_areas,namepathArr]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
505
+ else:
506
+ arr=[ base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(), spreadsheet_url,spreadsheetId,[],list1.to_dict(),pdflink,hatched_areas,namepathArr, base64.b64encode(bax_pretty_xml.encode("utf-8")).decode("utf-8"), base64.b64encode(column_xml.encode("utf-8")).decode("utf-8")]
507
  ################################# 2.7- #################################
508
  elif section.startswith('2.7') : #section value - 2.7 floor finishes
509
  print('code of 2.7')
 
559
 
560
  pdf_contentSched = BytesIO(response.content)
561
  # pdf_contentSched = fitz.open(stream=pdf_contentSched, filetype="pdf")
562
+ annotatedimgs, pdf_document , list1, repeated_labels , not_found, bax_pretty_xml, column_xml =Doors_Schedule.mainRun(pdf_contentSched, dataDoc, SearchArray,pdf_content,pdf_contentSched)
563
  else:
564
  pdfpathDoors,_=tsadropboxretrieval.getPathtoPDF_File(nameofPDF= str(result[6]))
565
  dbxTeam= tsadropboxretrieval.ADR_Access_DropboxTeam('user')
566
  md, resDoors =dbxTeam.files_download(path=pdfpathDoors)
567
  dataDocDoorsSchedule = resDoors.content
568
+ annotatedimgs, pdf_document , list1, repeated_labels , not_found, bax_pretty_xml, column_xml =Doors_Schedule.mainRun(dataDocDoorsSchedule, dataDoc, SearchArray)
569
+
570
  dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
571
  pdflink= tsadropboxretrieval.uploadanyFile(doc=pdf_document,path=dbPath,pdfname="combined_output.pdf") #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/
572
+
573
  repeatedLabelsReturn=''
574
  NotFoundReturn=''
575
  if len(repeated_labels)>0:
576
  repeatedLabelsReturn=repeated_labels
577
  if len(not_found)>0:
578
  NotFoundReturn=not_found # , spreadsheetId, spreadsheet_url , list1.to_dict()]
579
+ annotatedimgsBuffered=[]
580
+ for b in annotatedimgs:
581
+ _, buffer = cv2.imencode('.png', annotatedimg)
582
+ base64.b64encode(buffer).decode('utf-8')
583
+ annotatedimgsBuffered.append(buffer)
584
+ arr=[ annotatedimgsBuffered ,pdflink,list1.to_dict(),str(repeatedLabelsReturn), str(NotFoundReturn) , bax_pretty_xml, column_xml] # , spreadsheetId, spreadsheet_url , list1.to_dict()]
585
  ################################# -2.1- #################################
586
  elif section.startswith('2.1'): #section value - 2.8 floor finishes
587
  #vv[0] array of pdf names
 
725
  return area, perimeter, blk , imgcopy
726
  #_________________________________________________________________________________________________________________________
727
  #_________________________________________________________________________________________________________________________
728
+
729
+ #
730
  @app.route('/downloadPDFfromLink')
731
  def downloadPDFfromLinkFunc():
732
  encoded_url = request.args.get('url')