ArcGIS 10.2 Python-addin Zipfile locked

المشرف العام

Administrator
طاقم الإدارة
I made a Python-Addin-Button with the function to create a zip. Everything works fine, but after creating the zip-file, the zipfile is locked, when the mxd-Project is open. Any suggestions why I can't open or delete the zipfile? Here my script:

import sys, os, arcpy, zipfile, traceback, pythonaddins from arcpy import * class CreateZIP(object): """Implementation for Python_Addins_addin.button (Button)""" def __init__(self): self.enabled = True self.checked = False def onClick(self): arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument('current') mxdpath = mxd.filePath inWorkspace = os.path.dirname(mxdpath) outWorkspace = inWorkspace arcpy.env.workspace = inWorkspace outzip = zipfile.ZipFile(outWorkspace+"\Arch_Data.zip","a",zipfile.ZIP_DEFLATED) infolder = os.path.join(inWorkspace,"DATA") path = os.path.normpath(infolder) for (dirpath, dirnames, filenames) in os.walk(path): for file in filenames: if not file.endswith(".lock"): outzip.write(os.path.join(dirpath, file),os.path.join(os.path.basename(path), os.path.join(dirpath, file)[len(path)+len(os.sep):])) outzip.close() z = zipfile.ZipFile("Arch_Data.zip","a") z.write("README.txt") outzip.close()Thank you for help.



أكثر...
 
أعلى