3

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?

-1

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

| improve this answer | |
  • 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 '19 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 '19 at 12:58

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.