I resolved myself as below ,Just incase it can be helpful to anyone
import arcgisscripting
import arcpy
import os
import sys
import traceback
import zipfile
import re
import shutil
gp = arcgisscripting.create(9.3)
class LicenseError(Exception):
pass
def setUpCoordSystemEnvironment(coordinateSystem, customCoordSystemFolder):
# get the correct spatial reference and set it into the environment
# so that the data will get projected when clip runs
# if it is a number, assume we have a WKID and set it directly in
# else, find the file in the Coordinate System directory
if coordinateSystem.lower() == "same as input" or coordinateSystem == "":
return "same as input"
if coordinateSystem.strip().isalnum() and customCoordSystemFolder == "":
try:
gp.OutputCoordinateSystem = coordinateSystem.strip()
except:
#Message "Coordinate System WKID %s is not valid. Output Coordinate System will be the same as the input layer's Coordinate System"
gp.AddWarning(get_ID_message(86131) % (coordinateSystem))
coordinateSystem = "same as input"
gp.OutputCoordinateSystem = None
pass
return coordinateSystem
found = False
# Search custom folder if specified
if customCoordSystemFolder != "":
found, coordinateSystemPath = getPRJFile(coordinateSystem, customCoordSystemFolder)
# Search to see if we can find the spatial reference
if not found:
srList = gp.ListSpatialReferences("*/%s" % coordinateSystem)
if srList:
coordinateSystemPath = os.path.join(os.path.join(gp.getinstallinfo()["InstallDir"], "Coordinate Systems"), srList[0]) + ".prj"
found = True
if found:
gp.OutputCoordinateSystem = arcpy.SpatialReference(coordinateSystemPath).factoryCode
return coordinateSystemPath
else:
#Message "Couldn't find the specified projection file %s. Output Coordinate System will be the same as the input layer's Coordinate System."
gp.AddWarning(get_ID_message(86132) % coordinateSystem)
return "same as input"
def getPRJFile(inputCoordSysString, prjDir):
inputCoordSysString += ".prj"
# walk through the dirs to find the prj file
if os.path.exists(prjDir):
for x in os.walk(prjDir):
if inputCoordSysString in x[2]:
return True, os.path.join(x[0], inputCoordSysString)
else:
return False, ""
# if we got to here then it didn't find the prj file
return False, ""
def zipUpFolder(folder, outZipFile):
# zip the data
try:
zip = zipfile.ZipFile(outZipFile, 'w', zipfile.ZIP_DEFLATED)
zipws(folder, zip, "CONTENTS_ONLY")
zip.close()
except RuntimeError:
# Delete zip file if exists
if os.path.exists(outZipFile):
os.unlink(outZipFile)
zip = zipfile.ZipFile(outZipFile, 'w', zipfile.ZIP_STORED)
zipws(unicode(folder), zip, "CONTENTS_ONLY")
zip.close()
#Message" Unable to compress zip file contents."
gp.AddWarning(get_ID_message(86133))
def zipws(path, zip, keep):
path = os.path.normpath(path)
# os.walk visits every subdirectory, returning a 3-tuple
# of directory name, subdirectories in it, and filenames
# in it.
for (dirpath, dirnames, filenames) in os.walk(path):
# Iterate over every filename
for file in filenames:
# Ignore .lock files
if not file.endswith('.lock'):
#gp.AddMessage("Adding %s..." % os.path.join(path, dirpath, file))
try:
if keep:
zip.write(os.path.join(dirpath, file),
os.path.join(os.path.basename(path), os.path.join(dirpath, file)[len(path)+len(os.sep):]))
else:
zip.write(os.path.join(dirpath, file),
os.path.join(dirpath[len(path):], file))
except Exception as e:
#Message " Error adding %s: %s"
gp.AddWarning(get_ID_message(86134) % (file, e[0]))
return None
def createFolderInScratch(folderName):
# create the folders necessary for the job
folderPath = gp.CreateUniqueName(folderName, gp.scratchworkspace)
gp.CreateFolder_management(gp.scratchworkspace, os.path.basename(folderPath))
return folderPath
def getTempLocationPath(folderPath, format):
# make sure there is a location to write to for gdb and mdb
if format == "mdb":
MDBPath = os.path.join(folderPath, "data.mdb")
if not gp.exists(MDBPath):
gp.CreatePersonalGDB_management(folderPath, "data")
return MDBPath
elif format == "gdb":
GDBPath = os.path.join(folderPath, "data.gdb")
if not gp.exists(GDBPath):
gp.CreateFileGDB_management(folderPath, "data")
return GDBPath
else:
return folderPath
def get_ID_message(ID):
return re.sub("%1|%2", "%s", gp.GetIDMessage(ID))
if __name__ == '__main__':
try:
zipFolder, scratchFolder = None, None
# Get the Parameters
zipFolder = gp.getparameterastext(0)
#inputGDBFolder = gp.getparameterastext(6)
outputZipFile = gp.getparameterastext(1).replace("\\",os.sep)
zipUpFolder(zipFolder, outputZipFile)
except:
e = sys.exc_info()[1]
arcpy.AddError(e.args[0])
sys.exit(1)
finally:
if zipFolder:
shutil.rmtree(zipFolder, ignore_errors=True)
if scratchFolder:
shutil.rmtree(scratchFolder, ignore_errors=True)