mccarthp 0 Newbie Poster

Alright, I think my previous post about this subject was very confusing so I will try again. First off I appreciate all the responses to my prior post (Setting a Variable to the Exit Code).

It is my understanding that when a script completes it returns an exit code. I want to capture this exit code in order to pass it to a CF page. So my questions are:

1) Is there an exit code returned when a script completes?

2) Is the value of the exit code stored somewhere? If so where?

3) Can I assign the value of the exit code to a variable?
i.e. errorlevel = exit code

4) Can I include the variable in my URL?
i.e. ('http://cob/gis/GISAutoProcess_Action.cfm?ProcessID=000&ErrorCode=%s' % (errorlevel))

5) Can this be added to the end of the process or does it need to be run separately?

6) If I need to run it separately is there a way to set a ‘global’ variable that can be called in the other process?

Thank you everybody for your patience and understanding as I stumble my way through my first Python experience.

mccarthp 0 Newbie Poster

Hello, I am new to Python and I am just starting to figure things out but this one has me stumped.

I need to capture the exit code of my processes in order to track them in a database. I have all the other components working except this. In DOS I use:

Echo %errorlevel%

then post the value of %errorlevel% to the SQL table by calling a CF page and passing the value in the URL.

Is there a way to calculate %errorlevel% with the exit code of the process in Python? I need Python to set %errorlevel% equal to the exit code. I’m pretty sure that ‘%’ is not the proper syntax in Python to designate a variable but, as I said, I’m new. Below is the Python code that I am using to open the CF page that inserts the data to SQL.

opener = urllib.FancyURLopener({})
n_url = opener.open('http://cob/gis/GISAutoProcess_Action.cfm?ProcessID=000&ErrorCode=%errorlevel%')
for line in n_url.readlines():
print line

Thanks in advance for your help.

mccarthp 0 Newbie Poster

Hello, I am very new to Python and have, what I think, is a rather simple question.

First, I am running Python 2.1 on Win XP. What I want to do is open a CF page after my process has run and pass the processID, that I will set, and the exit code value to it. The CF page will then insert the values to a SQL table. I have tried to just get Python to open a URL using the URLLIB but have been unsuccessful. Here is a sample what I have tried:

import urllib
url = ‘http://www.google.com
page = urllib.urlopen(url)
pagedata = page.read()

Any help would be greatly appreciated. Thanks.

Also, if there is a way for Python to post to a SQL table directly without using an intermediate CF page I would be interested in learning how. Thanks again.

mccarthp 0 Newbie Poster

I have a script that is called by a batch file. Whether or not the script completes successfully the batch file continues. I need to know the results of the script. Is there a way to open an IE session, and call a CF page that I can pass an exit code to in the URL? Also, how would I generate an exit code to pass? Thanks

mccarthp 0 Newbie Poster

You need to post an example code of one of your typical scripts, otherwise I am lost!

Sure here you go.

# ---------------------------------------------------------------------------
# LMARKS_UPDATE.py
# Created on: Tue May 24 2005 08:27:58 AM
# (generated by ArcGIS/ModelBuilder)
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, win32com.client

# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

# Set the necessary product code
gp.SetProduct("ArcInfo")

# Load required toolboxes...
gp.AddToolbox("H:/Patrick/P_Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx")


# Local variables...
LM_NAC_SELECT_shp = "x:\\_GIS\\WORKSPACE\\LM_NAC_SELECT.shp"
LM_UNION_TEMP_shp = "x:\\_GIS\\WORKSPACE\\LM_UNION_TEMP.shp"
LM_LMARK_PT_IDENT_shp = "x:\\_GIS\\WORKSPACE\\LM_LMARK_PT_IDENT.shp"
T__COB_Places_LMARK_shp_ = "x:\\COB\\Places\\LMARKS"
LM_NAC_SELECT__3_ = "x:\\_GIS\\WORKSPACE\\LM_NAC_SELECT.shp"
LM_PD_DIST_SELECT_DIS_shp__3_ = "x:\\_GIS\\WORKSPACE\\LM_PD_DIST_SELECT_DIS.shp"
LM_PD_DIST_SELECT_DIS_shp__4_ = "x:\\_GIS\\WORKSPACE\\LM_PD_DIST_SELECT_DIS.shp"
LM_NAC_SELECT__4_ = "x:\\_GIS\\WORKSPACE\\LM_NAC_SELECT.shp"
T__IMS_COB_LMARKS_shp_ = "x:\\IMS\\COB\\LMARKS"
LM_LMARK_TEMP_shp__8_ = "x:\\_GIS\\WORKSPACE\\LM_LMARK_TEMP.shp"
LM_PD_DIST_SELECT_shp = "x:\\_GIS\\WORKSPACE\\LM_PD_DIST_SELECT.shp"
LMARKS_shp__2_ = "x:\\COB\\Places\\LMARKS.shp"
LMARKS_shp__3_ = "x:\\IMS\\COB\\LMARKS.shp"
LM_LMARK_SELECT_shp = "x:\\_GIS\\WORKSPACE\\LM_LMARK_SELECT.shp"
LM_NAC_SELECT__2_ = "x:\\_GIS\\WORKSPACE\\LM_NAC_SELECT.shp"
LM_PD_DIST_SELECT_DIS_shp__2_ = "x:\\_GIS\\WORKSPACE\\LM_PD_DIST_SELECT_DIS.shp"
LM_PD_DIST_SELECT_DIS_shp = "x:\\_GIS\\WORKSPACE\\LM_PD_DIST_SELECT_DIS.shp"
nac_shp = "x:\\COB\\Boundary\\nac.shp"
pd_dist_shp = "x:\\COB\\Boundary\\pd_dist.shp"
LMARKS_shp = "x:\\COB\\Places\\LMARKS.shp"
LM_LMARK_PT_shp = "S:\\_GIS\\WORKSPACE\\LM_LMARK_PT.shp"
LM_LMARK_SELECT_Layer = "LM_LMARK_SELECT_Layer"
LM_LMARK_SELECT_Layer_ = "LM_LMARK_SELECT_Layer"
LM_LMARK_SELECT_JOIN_shp = "S:\\_GIS\\WORKSPACE\\LM_LMARK_SELECT_JOIN.shp"
LM_LMARK_TEMP_shp__6_ = "S:\\_GIS\\WORKSPACE\\LM_LMARK_TEMP.shp"
LM_UNION_TEMP_shp__2_ = "S:\\_GIS\\WORKSPACE\\LM_UNION_TEMP.shp"
LM_LMARK_SELECT_JOIN_Layer = "LM_LMARK_SELECT_JOIN_Layer"
LM_LMARK_TEMP_shp = "S:\\_GIS\\WORKSPACE\\LM_LMARK_TEMP.shp"
LM_LMARK_TEMP_shp__2_ = "S:\\_GIS\\WORKSPACE\\LM_LMARK_TEMP.shp"
T__IMS_COB_LMARKS_shp_Delete_succeeded = "false"
T__COB_Places_LMARKS_shp_Delete_succeeded = "false"
Delete_succeeded__7_ = "false"
Delete_succeeded__3_ = "false"
Delete_succeeded__5_ = "false"
Delete_succeeded__6_ = "false"
Delete_succeeded__8_ = "false"
Delete_succeeded__2_ = "false"
Delete_succeeded__9_ = …

mccarthp 0 Newbie Poster

Python Version: 2.1
Platform: HP Windows XP

I am using Python scripts generated by ArcGIS/ModelBuilder in order to automate geoprocesses. Currently I am calling a series of scripts from a batch file that is called by the task scheduler. My problem is if there is an error the process stops, returns to the batch file and the next script starts. What I need to do is pass a result code to the batch file so I can tell if the script executed correctly. The scripts are independent and do not rely on the previous script but I still need to know if one of them failed. Any help would be greatly appreciated. Thanks