I have encountered something kind of odd and I'm not sure what's causing it. I have published a geoprocessing service and it's duplicating the SDE connection file during publishing. The code is very simple, all it's doing is checking that a database connection can be made and then unzipping the uploaded file. The service works, but I'd like to understand why it's duplicating the SDE connection file.
The python code:
import arcpy, zipfile db_con = r'Database Connections\HbMonitoringTest_nbcidb_HabitatTestWriter.sde' arcpy.AddMessage(db_con) if arcpy.Exists(db_con): arcpy.AddMessage("your db connection worked") else: arcpy.AddMessage("your db connection sucks") try: myZipFile = arcpy.GetParameterAsText(0) arcpy.AddMessage(myZipFile) scratch = arcpy.env.scratchFolder arcpy.AddMessage(scratch) zip_ref = zipfile.ZipFile(myZipFile, 'r') zip_ref.extractall(scratch) zip_ref.close() arcpy.AddMessage("success") except: arcpy.AddMessage("fail")
When I publish this as a geoprocessing service it does this in the /extracted/v101 directory: