Hello all,
I am trying to build a PythonCaller that replicates the Windows command of “Send to Compressed (zipped) folder”
The goal is to prepare a fileGDB dataset for transfer by ftp by zipping it
I want to give the PythonCaller a filePath such as D:\2024\03\project\data.gdb
Which then creates a zip file D:\2024\03\project\data.gdb.zip (that is, the zip file is sitting in the same folder as the data.gdb)
And, when the end user opens the zip file they see the folder data.gdb which they can then extract
I am trying using this code
def input(self, feature):
import os, shutil
folder = feature.getAttribute('folder')
fileGDB = feature.getAttribute('fileGDB')
zip_file = feature.getAttribute('zip_file')
if os.path.exists(fileGDB):
print('fileGDB exists')
if os.path.exists(zip_file):
os.remove(zip_file)
else:
print('zip file DOES NOT exist')
shutil.make_archive(fileGDB, 'zip', folder)
else:
print('fileGDB DOES NOT exist')
self.pyoutput(feature)
But! the zip file contains itself! Which is wrong