I created a Python script, run by a toolbox. I am using Python shapefile to generate a point shapefile. If I run the tool locally (i.e. on the desktop) it works great. Shp, shx and dbf all writen out as expected and the points are valid.

Once I share the geoprocessing script as a service, and then run the tool via an ArcGIS server connection on a remote PC, the only file that writes out is the .shp file. And of course without the .shx and .dbf the .shp file can't be used.

Any ideas on why once the geoprocessing script runs server side, all the files aren't generating for Python library Shapefile?

Any other ideas on how to simply write out a point shapefile using Python?

I know typically a code snippet, is desired, but the code runs locally it's only server side where there is an issue writing the files to a client via, ArcCatalog.


1 Answer 1


I ended up zipping up the files and then outputting them. this worked like a charm. I think that was happening is that on output the only file being sent from server, was the .shp file. Once they are zipped up then the .zip gets sent but that has all the files compressed. My conclusion is that zipping is the only way to do server side geoprocessing with file out as a parameter.

So in my geoprocessing script I added in this code:

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

try: zip = zipfile.ZipFile(outzip, 'w', zipfile.ZIP_DEFLATED) zipws(unicode(folder), zip, "CONTENTS_ONLY") zip.close() except RuntimeError: # Delete zip file if exists if os.path.exists(outzip): os.unlink(outzip) zip = zipfile.ZipFile(outzip, '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))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.