@@ -753,51 +753,51 @@ def save_dwg(self, dxf_filepath: str, filepath: str = None):
753753 filepath = f"{ self .get_filename ()} .dwg"
754754 odafc .convert (dxf_filepath , filepath )
755755
756- def save (self , paper_size : str = "A4" , orientation : str = "portrait" ):
757- # with tempfile.TemporaryDirectory() as tmpdir:
758- filename = self .get_filename ()
759- dxf_path = os .path .join ("" , f"{ filename } .dxf" )
760- dwg_path = os .path .join ("" , f"{ filename } .dwg" )
761- pdf_path = os .path .join ("" , f"{ filename } .pdf" )
762- zip_path = os .path .join ("" , f"{ filename } .zip" )
763-
764- self .save_dxf (dxf_path )
765- self .save_dwg (dxf_path , dwg_path )
766- self .save_pdf (pdf_path , paper_size = paper_size , orientation = orientation )
767-
768- # Create a ZIP file containing all three formats
769- with zipfile .ZipFile (zip_path , "w" ) as zipf :
770- zipf .write (dxf_path , os .path .basename (dxf_path ))
771- zipf .write (dwg_path , os .path .basename (dwg_path ))
772- zipf .write (pdf_path , os .path .basename (pdf_path ))
773-
774- # url = upload_file(zip_path, folder="survey_plans", file_name=filename)
775- # if url is None:
776- # raise Exception("Upload failed")
777- return "url"
778-
779756 # def save(self, paper_size: str = "A4", orientation: str = "portrait"):
780- # with tempfile.TemporaryDirectory() as tmpdir:
781- # filename = self.get_filename()
782- # dxf_path = os.path.join(tmpdir , f"{filename}.dxf")
783- # dwg_path = os.path.join(tmpdir , f"{filename}.dwg")
784- # pdf_path = os.path.join(tmpdir , f"{filename}.pdf")
785- # zip_path = os.path.join(tmpdir , f"{filename}.zip")
757+ # # with tempfile.TemporaryDirectory() as tmpdir:
758+ # filename = self.get_filename()
759+ # dxf_path = os.path.join("" , f"{filename}.dxf")
760+ # dwg_path = os.path.join("" , f"{filename}.dwg")
761+ # pdf_path = os.path.join("" , f"{filename}.pdf")
762+ # zip_path = os.path.join("" , f"{filename}.zip")
786763 #
787- # self.save_dxf(dxf_path)
788- # self.save_dwg(dxf_path, dwg_path)
789- # self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation)
764+ # self.save_dxf(dxf_path)
765+ # self.save_dwg(dxf_path, dwg_path)
766+ # self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation)
790767 #
791- # # Create a ZIP file containing all three formats
792- # with zipfile.ZipFile(zip_path, "w") as zipf:
793- # zipf.write(dxf_path, os.path.basename(dxf_path))
794- # zipf.write(dwg_path, os.path.basename(dwg_path))
795- # zipf.write(pdf_path, os.path.basename(pdf_path))
768+ # # Create a ZIP file containing all three formats
769+ # with zipfile.ZipFile(zip_path, "w") as zipf:
770+ # zipf.write(dxf_path, os.path.basename(dxf_path))
771+ # zipf.write(dwg_path, os.path.basename(dwg_path))
772+ # zipf.write(pdf_path, os.path.basename(pdf_path))
796773 #
797- # url = upload_file(zip_path, folder="survey_plans", file_name=filename)
798- # if url is None:
799- # raise Exception("Upload failed")
800- # return url
774+ # # url = upload_file(zip_path, folder="survey_plans", file_name=filename)
775+ # # if url is None:
776+ # # raise Exception("Upload failed")
777+ # return "url"
778+
779+ def save (self , paper_size : str = "A4" , orientation : str = "portrait" ):
780+ with tempfile .TemporaryDirectory () as tmpdir :
781+ filename = self .get_filename ()
782+ dxf_path = os .path .join (tmpdir , f"{ filename } .dxf" )
783+ dwg_path = os .path .join (tmpdir , f"{ filename } .dwg" )
784+ pdf_path = os .path .join (tmpdir , f"{ filename } .pdf" )
785+ zip_path = os .path .join (tmpdir , f"{ filename } .zip" )
786+
787+ self .save_dxf (dxf_path )
788+ self .save_dwg (dxf_path , dwg_path )
789+ self .save_pdf (pdf_path , paper_size = paper_size , orientation = orientation )
790+
791+ # Create a ZIP file containing all three formats
792+ with zipfile .ZipFile (zip_path , "w" ) as zipf :
793+ zipf .write (dxf_path , os .path .basename (dxf_path ))
794+ zipf .write (dwg_path , os .path .basename (dwg_path ))
795+ zipf .write (pdf_path , os .path .basename (pdf_path ))
796+
797+ url = upload_file (zip_path , folder = "survey_plans" , file_name = filename )
798+ if url is None :
799+ raise Exception ("Upload failed" )
800+ return url
801801
802802
803803
0 commit comments