AnsweredAssumed Answered

IOError trying to change PICTURE_ELEMENT sourceImage

Question asked by lscharen on Jun 19, 2014
Latest reply on Jun 20, 2014 by lscharen
This question is cross-posted here.

I recently ran into this issue after I published a Geoprocessing Task to a production server.

My geoprocessing python code is an enhanced Web Map Print service that loads a map via the arcpy.mapping.ConvertWebMapToMapDocument function and either sets the sourceImage of a PICTURE_ELEMENT or moves it off of the page. The published GP Service works correctly on a development server, but returns the following error when running on the production server.

Unable to complete operation. Error executing tool.:   Traceback (most recent call last):     File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\", line 643, in <module> main()    File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\", line 634, in main (message, output_file, image_files) = execute(web_map_json, output_format, layout_template, layout_template2, georef_info, quality)    File "<ags_folder>\PythonWebPrint.GPServer\extracted\v101\my_toolboxes\", line 482, in execute staticLegend.sourceImage = legendPath    File "c:\program files\arcgis\server\arcpy\arcpy\arcobjects\", line 87, in _set return setattr(self._arc_object, attr_name, cval(val))   IOError: Cannot set path based on current settings.   Failed to execute (PythonWebPrint). Failed to execute (Python Web Print).

Here is the relevant python code:

            elements = arcpy.mapping.ListLayoutElements(mxd, 'PICTURE_ELEMENT', "StaticLegend")             if len(elements) > 0:                 # Get the picture                 staticLegend = elements[0]                  if web_map_object.has_key("staticLegend"):                     legendPath = os.path.join(template_path, "legends", web_map_object["staticLegend"])                     staticLegend.sourceImage = legendPath                 else:                     # Cannot actually delete things, so just move it off the page                     staticLegend.elementPositionX = -100

I have verified that the correct file path is being used, and that the file exists and that the folder and file permissions are identical to the MXD files being loaded by the arcpy.mapping.ConvertWebMapToMapDocument function.

Any ideas as to the source of or how to fix this issue, or other diagnostics that I can perform?