Error When Running a Python Script via Task Scheduler on Server

6537
13
Jump to solution
01-27-2014 03:31 PM
GeorgeHaskett
Occasional Contributor III
I previously built a model using Model Builder to process some data.  The model runs fine when manually started.  However, I would like to automate the process via the task scheduler on our GIS server.  The model in question is part of a longer python script.  The script routinely failed while trying to run the model.  I therefore rewrote the script and replaced the model with python code.  Again, it runs flawlessly when I manually start it, however it now snags on the arcpy.mapping.ExportReport() portion of the code.  Below is the error message I am receiving:

[INDENT]/n/nPYTHON ERRORS:
Traceback Info:
  File "C:\arcgisserver\gisData\services\eqMap\toolsNscripts\runEQAnalysis.py", line 402, in <module>
    arcpy.mapping.ExportReport(lyr,rlfPath,pdfPathTemp)

Error Info:
     <type 'exceptions.AttributeError'>: This functionality is not supported on server.
/n/n[/INDENT]

Why would it run flawlessly when manually triggered, but crash when triggered by the Task Scheduler?

The entire script is quite long, however below is the section its stopping at:

reportFolder = "C:/inetpub/wwwroot/flexviewers/_supportDocs/reports/" pdfPathTemp = reportFolder+"earthquakeReportTemp.pdf" rlfPath = "C:/arcgisserver/gisData/services/eqMap/toolsNscripts/agentReport.rlf" eq = policyList[0] whereClause = "EPICENTER = '"+eq+"'" lyr.definitionQuery = whereClause  arcpy.mapping.ExportReport(lyr,rlfPath,pdfPathTemp)


The policyList[0] is populated using the arcpy.da.SearchCursor() and appending the list as it reads through the attribute table.

I am using ArcGIS Server 10.2, Windows Server 2008 R2 Standard w/ SP1 and 64-bit OS.

Thanks for any guidance you can give.

Haskett
Tags (2)
0 Kudos
13 Replies
GeorgeHaskett
Occasional Contributor III
/c is an option of cmd. You need to put cmd in front of it, i.e run the cmd command in the command window, as confusing as that sounds. So in the command window, type:

cmd /c python C:\script.py


Okay, well I'm one step closer.  I can get it to run in the CMD window using your example.  So why am I having issues with the Task Manager?
0 Kudos
curtvprice
MVP Esteemed Contributor
Okay, well I'm one step closer.  I can get it to run in the CMD window using your example.  So why am I having issues with the Task Manager?


Instead of messing with your global file associations, env variables and paths (which could easily break other things) you should explicitly give the python path of the version you want to run, i.e. in your bat file:

:: run my awesome batch process
cmd /c C:\Python27\ArcGIS10.1\python.exe myscript.py
0 Kudos
DanielaPalacios
New Contributor II

Hello, I have seen this post and I have a couple of question myself and was wondering if you could help me please.

I have created 2 scripts.

first one: General_EjecutarReporte_Consola.py is the script that is published a geoprocessing service and call the CMD to execute the second python script that has the EXPORTReport called: General_ReporteCriteriosValoracion.py.

I have published my first script and I have run in in the REST and it seems to work, but it does not creates my report in the destinated file. see picture.

I am using Arcgid 10.2.2.

Thank you very much,

0 Kudos
GeorgeHaskett
Occasional Contributor III
Okay, well I'm one step closer.  I can get it to run in the CMD window using your example.  So why am I having issues with the Task Manager?


Brad, oddly enough after a few days off it seems to work....

Thanks.
0 Kudos