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

272
1
01-12-2012 07:55 AM
KyleChouinard
New Contributor
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)
Tags (2)
0 Kudos
1 Reply
RandyKreuziger
Occasional Contributor III
There is a known bug dealing with the XSLTransform_conversion command.  It runs from a model but not when exporting to a script.  Two ESRI DLLs must be installed on each PC that runs the script.  I don't have the bug number handy but can look it up.
0 Kudos