Using arcpy from the command line on ArcGIS Linux Server 10.1

المشرف العام

Administrator
طاقم الإدارة
We installed ArcGIS SERVER (not Desktop!) 10.1 on a RHEL (Red Hat) machine. ArcGIS Sever is supported for Linux.

However, it appears they don't make it easy to script in python, from the command line, making use of the arcpy module.

There are many things awkward about this. The arcpy library that they use is actually for Windows, with some external patching. In fact, it comes with its own implementation of python. So pathnames look a little weird. You have to be the arcgis user to even get access to python or arcpy. So here is how my code looks:

import arcpy""" From http://resources.arcgis.com/en/help/main/10.1/index.html#//0155000005mm000000The Python libraries installed by an ArcGIS Linux Server installation is Windows 64-bit Python. Therefor, stand-alone Python scripts should always use the Win\dows path separator (\) when accessing data and other Python modules. Also, be aware that there is a Z:\ which is mapped to the Linux systems' /. Within a Pyt\hon script you can access data and other Python modules using Z:\ mapping. For example, data in /myuser/myproject/data can be accessed as z:\myuser\myproject\\data. This does not apply to Python scripts you publish from ArcGIS for Desktop because the publishing process converts all paths to the correct format. """""" I'm using: sudo su arcgis /opt/arcgis/server/tools/python ./arcpytest.py """dataDir=r"z:home\arcpy-tmp"+"\\"print dataDirshp='tgr39105lkA.shp'arcpy.FeatureToLine_management(dataDir+shp, 'temp_links')What I get back is:

$ /opt/arcgis/server/tools/python ./arcpytest-1.pyz:home\arcpy-tmp\Traceback (most recent call last): File "./arcpytest-1.py", line 28, in arcpy.FeatureToLine_management(dataDir+shp, 'temp_links') File "C:\Program Files\ArcGIS\Server\arcpy\arcpy\management.py", line 2343, in FeatureToLine raise earcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.ERROR 000732: Input Features: Dataset z:home\arcpy-tmp\tgr39105lkA.shp does not exist or is not supportedFailed to execute (FeatureToLine).Has anyone tried to use arcpy in this direct way? It's a REALLY powerful server, so we put ArcGIS server on it, but want to use ArcPy for programming.



أكثر...
 
أعلى