1

I have added a shutdown Python script to my FME workbench to publish the TIFFs written as a service.

import fme
import arcpy
AGSconnection = "W:\\Entity\\ABZ\\myfolderpath\\gbepabz-file.name.ags"
print fme.featuresWritten

layerlist = []
mxd = arcpy.mapping.MapDocument("\\\\gbepabz-aqgis02\\OWProcessing\\temptest\\TEMPLATE.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
sr = arcpy.SpatialReference(23031)
df.SpatialReference = sr
mxd.activeDataFrame.spatialReference = sr

for tiff in fme.featuresWritten:
    filepath = "\\\\gbepabz-apgis01\\ArcGisServer_data\\Vendor\\Sentinel\\"+tiff+".tif"
    tifflayer = arcpy.MakeRasterLayer_management(filepath, tiff)
    #addlayer = arcpy.mapping.Layer(tifflayer)
    #layerlist.append(tifflayer)
    layerfile = "\\\\gbepabz-apgis01\\ArcGisServer_data\\Vendor\\Sentinel\\"+tiff+".lyr"
    arcpy.SaveToLayerFile_management (tifflayer, layerfile)
    addlayer = arcpy.mapping.Layer(layerfile)
    arcpy.mapping.AddLayer(df,addlayer)
    print filepath
mxdpath = "\\\\gbepabz-apgis01\\ArcGisServer_data\\Vendor\\Sentinel\\temp3.mxd"
print mxdpath
mxd.saveACopy(mxdpath)
df.SpatialReference = sr
mxd.activeDataFrame.spatialReference = sr
mxd.save()
sddraftpath = "\\\\gbepabz-apgis01\\ArcGisServer_data\\Vendor\\Sentinel\\sentinel.sddraft"
SDpath = "\\\\gbepabz-aPgis01\\ArcGisServer_data\\Vendor\\Sentinel\\sentinel.sd"
service = "Sentinel"
arcpy.mapping.CreateMapSDDraft(mxd, sddraftpath, service, "ARCGIS_SERVER", AGSconnection, "FALSE", "GENERAL")
arcpy.mapping.AnalyzeForSD(sddraftpath)
arcpy.StageService_server(sddraftpath, SDpath)
arcpy.UploadServiceDefinition_server(SDpath, AGSconnection, in_startupType="STARTED")

When this runs at the end of my workbench I get an error on the analyser.

Python Exception : ERROR 001272: Analyzer errors were encountered (codes = 179, 179, 179, 179). Failed to execute (StageService).

Online I've found that this error code means that the data is not registered with the server. It is on the server and registered with the server. It is in the same directory as other data that have been successfully published.

If I then open temp3.mxd and run the following

mxd = arcpy.mapping.MapDocument("CURRENT")
AGSconnection = "W:\\Entity\\ABZ\\myfolderpath\\gbepabz-file.name.ags"
sddraftpath = "\\\\gbepabz-apgis01\\ArcGisServer_data\\Vendor\\Sentinel\\sentinel.sddraft"
SDpath = "\\\\gbepabz-aPgis01\\ArcGisServer_data\\Vendor\\Sentinel\\sentinel.sd"
service = "Sentinel"
arcpy.mapping.CreateMapSDDraft(mxd, sddraftpath, service, "ARCGIS_SERVER", AGSconnection, "FALSE", "GENERAL")
arcpy.mapping.AnalyzeForSD(sddraftpath)
arcpy.StageService_server(sddraftpath, SDpath)
arcpy.UploadServiceDefinition_server(SDpath, AGSconnection, in_startupType="STARTED")

It will sucessfully publish the service. The Analyze for SD step gives warnings but no errors.

The whole point of the process is to work without any manual intervention so I need to get this workiing from FME. Is it a difference in the Python interpretation, or is ArcGIS Server easier to work with from ArcMap?

0

This is more a visual comment than answer (apologies)

I think that you need to add the interpreter to the FME Server side of things

enter image description here

When uploading (publishing) the workspace you can set the resources to upload the python it requires

(not an expert on python)

enter image description here

  • Good info! But as I understand correctly he is currently still trying to get it to work on his desktop, not on server. – nielsgerrits May 29 at 8:46
  • this should work for desktop as well, as FME Workbench is the authoring source. I not a python expert so the other option the user has is to run fme.exe in batch mode knowledge.safe.com/articles/1384/… which can be scheduled in task scheduler. – Mapperz May 29 at 12:58
0

We get this error when we try to publish from test environment to the prod ags, which is a different environment and does not have access to the files on the test environment.

Is it possible that the user running the process does not have access to the data? Is the connection file accessible by the process? Do you run it on FME Desktop or on FME Server?

Please exclude user rights issues before anything else.

  • At the moment I'm running everything on my pc with my windows account so the permissions should be exactly the same in both cases. – whatahitson May 28 at 9:13
  • Do you get anything else done with the connectionfile from FME? Just to be sure that part is not causing issues? – nielsgerrits May 28 at 9:16
  • Not at the moment - I'll try and test it. Is there any simple test you'd recommend? – whatahitson May 28 at 9:22
  • Unfortunately both my python- and Esri-fu are way behind things I can do with FME, so you probably should not rely on me... But I do quite a bit of chaining toolings so I learned to strip down the parts and check in small steps to discover what is bugging the proces. – nielsgerrits May 28 at 9:29
  • And how about setting the current workspace? arcpy.env.workspace = path – nielsgerrits May 28 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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