AnsweredAssumed Answered

Launching a python script (and a python subscript) with a batch file (troubles with os.spawnv / subprocess.Popen)

Question asked by roelandtn on Oct 6, 2017

Hi,

 

I'm writing a python script to load a big raster directory (552 files, 50 Go) into a mxd file in order to publish it easily with ArcGIS Server.

 

Unfortunately, 300+ files is too much to had in one time, so, with the help of ERSI France, we use a subscript who add 100 files at a time.

 

The scripts are working fine by themself, but my boss want to make easy to use by the IT outsourcing and wants to launch it through a .bat file with all the parameters.

 

When I launch the script I get a read/write error:

  • with os.spawnv()
Traceback (most recent call last):
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in <module>
    __main()
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main
    subscript(pythonPath, pathToFile, author, title, listRaster)
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 35, in subscript
    os.spawnv(os.P_WAIT, pythonPath, parameterList)
OSError: [Errno 13] Permission denied
  • with subprocess.Popen()
Traceback (most recent call last):
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 168, in <module>
    __main()
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 152, in __main
    subscript(pythonPath, pathToFile, author, title, listRaster)
  File "D:\Projets\GEOSERVER\scripts\script_creation_mxd\rasters_folder_in_mxd_1.py", line 36, in subscript
    subprocess.Popen([pythonPath, parameterList])
  File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 390, in __init__
    errread, errwrite)
  File "C:\Python27\ArcGIS10.5\lib\subprocess.py", line 640, in _execute_child
    startupinfo)
WindowsError: [Error 5] Accès refus

 

The mxd file is created by the first py script but it seems that the second one can't access it. It even seems that the second  is not even activated (don't execute a print command).

 

I'm using ArcMap 10.5.1 with python 2.7.13 on a win10 computer.

 

Any ideas how to solve this ?

 

Thanks,

 

Nicolas from France

Outcomes