Select to view content in your preferred language

Model Runs But Not When Exported to Python

1619
13
03-13-2013 09:08 AM
MarkYoung
Regular Contributor
Hi,
I have a model which runs fine - tested OK. I wish to run this model once a week out of hours as a scheduled task on the server so I exported the model as a python script and added this script in as a scheduled task. For some reason it does not run giving me an error saying the table already exists. That is correct the table does exist and I wish to overwrite which the model does OK but the scheduled task fails.
Any ideas would be appreciated.
Thanks
Mark
0 Kudos
13 Replies
MichaelVolz
Esteemed Contributor
Brett:

What kind of logging do you have in place to trap the error?

Are you sending e.Message via an E-mail alert or printing out e.Message to a log file?  I am using an E-mail alert that conatins e.Message in the BODY of the E-mail alert.
0 Kudos
MarkYoung
Regular Contributor
Mark,

If you run the model using the following syntax, do you get the same error?

import arcpy
arcpy.ImportToolbox(�??c:/mytools/geometrytools.tbx�?�, �??mytools�?�)
arcpy.CreateRegularPolygons_mytools(parameter1, parameter2)

Best,
Melanie S.


Hi,
Still trying to get this working.. Do I simply add this code at the start of the script (changing "c:/mytools/geometrytools.tbx�?� �??mytools�?� to my own configuration..

Thanks
Mark
0 Kudos
MarkYoung
Regular Contributor
Hi all,
I have trawled numerous threads on the various issues calling a python script from a scheduled task.
To re-cap I have built a model, exported to python and can double click that python script to execute and all works OK - checked the feature class in ArcMap and the table has been updated as expected.

However I cannot for the life of me get a scheduled task to work. I have tried calling the python direct from the scheduled task and creating a .bat file to call the python script

What I have done thus far..
Created the geo-processing model in ArcMap Model Builder 10.0
Created a new task within task scheduler (Windows server 2008 R2)
Checked run whether user is logged in or out
Checked run with highest privileges
Under the actions tab I have selected start a program and the path to that program is "E:\PythonScripts\pytest.py" (Also tried swapping this for "C:\Python26\ArcGIS10.0"
Under Add Arguments I entered "E:\PythonScripts\pytest.py"
Start in Optional is blank

I have tried moving the toolbox and model to the C:\ in case there were any unforseen permission issues - no difference

Also had a look at http://forums.arcgis.com/threads/49702-Modelbuilder-to-Python-Glitch but that confused me a bit with the additional runtool.py script

Has anyone got a scheduled task to call a python script?
If so, are you calling the exported python script direct or have you made a .bat file to call the python script - if so would you be kind enough to supply the code?

Thanks
Mark
0 Kudos
MarkYoung
Regular Contributor
Hi,
I eventually solved this! (on win 2008 server)
When you are testing the scheduled task on the server and running the task on demand rather than a trigger click the radio button which says "Run only when the user is logged on"  Python script is executed and feature class updated. Click the radio button which says "Run whether the user is logged in or not" and add a trigger for a few minutes ahead (or whenever) then log off the server. Log back onto server to see a nice (0x0) task run successfully message.
http://social.technet.microsoft.com/Forums/windows/en-US/c03d6691-b058-4f8d-961c-e8eba25bbaed/task-s...
0 Kudos