kyleboy7

arcpy Script works as standalone, but not when published to arcgis server

Discussion created by kyleboy7 on Jan 12, 2012
Latest reply on Jan 31, 2012 by kreuzrsk
I am writing an arcpy script to export metadata from my arcsde. When I run it as a publish it to my arcgis server the scrip runs but does not export any metadata.


import os
import shutil
import arcpy
import arcpy.mapping
import arcgisscripting
from arcpy import env

dir = arcpy.GetInstallInfo("desktop")["InstallDir"]
xslt = dir + "Metadata/Stylesheets/ArcGIS.xsl"
translator = dir +  "Metadata/Translator/ESRI_ISO2ISO19139.xml"

#service = arcpy.GetParameterAsText(0)
service = "grace"
workDir = r"c:/temp/"+service
if not os.path.exists(workDir):
 os.makedirs(workDir)
else:
 shutil.rmtree(workDir)
 os.makedirs(workDir)
env.workspace = workDir
mxd = arcpy.mapping.MapDocument(r"D:\\arcGisSupportFiles\\ServerMaps\\"+service+".mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
 try:
  if(lyr.datasetName.split(".")[0] == "sde"):
   arcpy.XSLTransform_conversion(lyr, xslt, lyr.name+".html", "#")
   #arcpy.ESRITranslator_conversion (lyr, translator, lyr.name+".html", "#")
   print "sde layer, metadata created"
  else:
   print "non-sde layer, no metadata to create"
 except:
  print "folder layer"
metaDir = "\\\\gisv\\kyle\\metadata\\"+service
if os.path.exists(metaDir):
 shutil.rmtree(metaDir)

Outcomes