Marthee commited on
Commit
f757146
·
verified ·
1 Parent(s): c4936a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -19
app.py CHANGED
@@ -2,7 +2,7 @@ from __future__ import print_function
2
  from flask import Flask, render_template,request,flash , json, url_for,g , redirect , jsonify , send_file ,make_response
3
  import os
4
  import json
5
- import fitz
6
  from PIL import Image
7
  import cv2
8
  import numpy as np
@@ -151,7 +151,7 @@ def getfromdropboxImg(jsdata):
151
  data = res.content
152
  doc = fitz.open("pdf",data)
153
  page=doc[0]
154
- pix = page.get_pixmap(dpi=300) # render page to an image
155
  pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
156
  img=np.array(pl)
157
  img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
@@ -219,22 +219,22 @@ def measureproject(result,dataDoc=0,img=0,dxffile=0):
219
  _, buffer = cv2.imencode('.png', image_new1)
220
  arr=[base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(),spreadsheet_url , spreadsheetId,colorsUsed,list1.to_dict(), pdflink, areas_Perimeters, namepathArr]
221
  ################################# -3.2- #################################
222
- elif result[5][2].startswith('3.2'): #section value - 3.2 floor finishes
223
- print('IN HEREEEE 3.2')
224
- dxfpath=dxffile.read()
225
- with tempfile.NamedTemporaryFile(suffix='.dxf', delete=False) as temp_file:
226
- temp_file.write(dxfpath)
227
- temp_filename = temp_file.name
228
- print(temp_filename)
229
- doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=dxf__omar3_2.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] , pdfpath,result[0])
230
- dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
231
- pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
232
-
233
- _, buffer = cv2.imencode('.png', outputimg)
234
- arr=[ base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(), spreadsheet_url,spreadsheetId,[],list1.to_dict(),pdflink,hatched_areas,namepathArr]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
235
- ################################# -2.8- #################################
236
- elif result[5][2].startswith('3.3'): #section value - 3.2 floor finishes
237
- print('IN HEREEEE 3.3')
238
  dxfpath=dxffile.read()
239
  with tempfile.NamedTemporaryFile(suffix='.dxf', delete=False) as temp_file:
240
  temp_file.write(dxfpath)
@@ -722,7 +722,6 @@ def cvtSummarytoXML(jsdata):
722
  return jsonify(xmllink)
723
 
724
 
725
-
726
  #_________________________________________________________________________________________________________________________
727
  #_________________________________________________________________________________________________________________________
728
 
 
2
  from flask import Flask, render_template,request,flash , json, url_for,g , redirect , jsonify , send_file ,make_response
3
  import os
4
  import json
5
+ import fitz
6
  from PIL import Image
7
  import cv2
8
  import numpy as np
 
151
  data = res.content
152
  doc = fitz.open("pdf",data)
153
  page=doc[0]
154
+ pix = page.get_pixmap() # render page to an image
155
  pl=Image.frombytes('RGB', [pix.width,pix.height],pix.samples)
156
  img=np.array(pl)
157
  img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
 
219
  _, buffer = cv2.imencode('.png', image_new1)
220
  arr=[base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(),spreadsheet_url , spreadsheetId,colorsUsed,list1.to_dict(), pdflink, areas_Perimeters, namepathArr]
221
  ################################# -3.2- #################################
222
+ # elif result[5][2].startswith('3.2'): #section value - 3.2 floor finishes
223
+ # print('IN HEREEEE 3.2')
224
+ # dxfpath=dxffile.read()
225
+ # with tempfile.NamedTemporaryFile(suffix='.dxf', delete=False) as temp_file:
226
+ # temp_file.write(dxfpath)
227
+ # temp_filename = temp_file.name
228
+ # print(temp_filename)
229
+ # doc,outputimg, SimilarAreaDictionary ,spreadsheetId, spreadsheet_url , namepathArr , list1,hatched_areas=dxf__omar3_2.mainFunctionDrawImgPdf(dataDoc,temp_filename,result[4] , pdfpath,result[0])
230
+ # dbPath='/TSA JOBS/ADR Test'+pdfpath+'Measured Plan/'
231
+ # pdflink= tsadropboxretrieval.uploadanyFile(doc=doc,path=dbPath,pdfname=result[0]) #doc=doc,pdfname=path,pdfpath=pdfpath+'Measured Plan/'
232
+
233
+ # _, buffer = cv2.imencode('.png', outputimg)
234
+ # arr=[ base64.b64encode(buffer).decode('utf-8'),SimilarAreaDictionary.to_dict(), spreadsheet_url,spreadsheetId,[],list1.to_dict(),pdflink,hatched_areas,namepathArr]# , spreadsheetId, spreadsheet_url , list1.to_dict()]
235
+ ################################# -3.3 or 3.2- #################################
236
+ elif result[5][2].startswith('3.3') or result[5][2].startswith('3.2'): #section value - 3.2 floor finishes
237
+ print('code of 3.3 and 3.2')
238
  dxfpath=dxffile.read()
239
  with tempfile.NamedTemporaryFile(suffix='.dxf', delete=False) as temp_file:
240
  temp_file.write(dxfpath)
 
722
  return jsonify(xmllink)
723
 
724
 
 
725
  #_________________________________________________________________________________________________________________________
726
  #_________________________________________________________________________________________________________________________
727