POST
|
I have created a python script that has the purpose of automating the generation of mobile caches which utilizes the CreateMobileCache_mobile function. This python script is required to run from within a batch script which checks the value of %errorlevel% to see whether an error has occurred in the python script (0 = no error, 1 = error). I have found that no matter what I try, the call to the CreateMobileCache_mobile function produces an errorlevel of -2146234327, whether the call itself fails or succeeds, and overrides my own sys.exit call that should be returning a 0 or 1, depending. I should mention, I've tested this on ArcGIS 10.1, 10.2, 10.2.1. Has anyone run into this issue and know a way to 'catch' this or prevent it? I've tried to surround the call with a try/except, but nothing is caught by the except. Here's a code example of the isolated issue: startGenerateCache.bat REM will return error level of 0 since nothing has been done yet
echo %errorlevel%
REM run the python script
C:\Python27\ArcGIS10.2\python.exe generateCache.py
REM will always return the large error level of -2146234327
echo %errorlevel% generateCache.py import arcpy
# Set some variables up as example map document and output folder location
theMXD = "C:\anMXD.mxd"
theOutputFolder = "C:\output"
try:
# Call the Create Mobile Cache tool from arcpy
arcpy.CreateMobileCache(theMXD, theOutputFolder, "", "", "")
except arcpy.ExecuteError:
# Print out any error messages (this never gets triggered...)
print(arcpy.GetMessages(2))
... View more
02-18-2015
11:05 AM
|
0
|
0
|
2955
|
POST
|
I have a Geoprocessing Service that is complicated, but the issue I'm having revolves around a few very simple steps. I'm trying to take in a path to a feature class that sits within SDE, create a temporary feature layer out of it (arcpy.MakeFeatureLayer_management), and then use a search cursor (arcpy.da.SearchCursor) to count the records in the feature class. I am not using ArcMap or anything outside of arcpy for this, the layer is stored in-memory and dumped after being used. The script itself works fine up until the point that new data is added and then the results become inconsistent with the actual data. Here is an example of the issue: Feature Class has 0 records. The Model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and returns a count of "0 records found." (OK) The Geoprocessing Service itself also returns "0 records found." (OK) 1 record is added to the Feature Class through some means in an edit session (programatically, through ArcMap, etc.) The model behind the Geoprocessing Service is run through ArcCatalog/ArcMap and still returns a count of "0 records found." (INCORRECT) The Geoprocessing Service itself also returns "0 records found." (INCORRECT) The only way I've discovered that the model will display the correct record count when run from Desktop is to close/open all ArcGIS Desktop applications and re-run it. Likewise, for the Geoprocessing Service to display the correct record count, I must restart or republish the Geoprocessing Service. I'm hoping this issue has a simple resolution, but I'm scratching my head over it as of right now. If someone needs sample code, I can provide it, but the first paragraph is the script in a nutshell.
... View more
11-05-2014
10:56 AM
|
0
|
1
|
1488
|
POST
|
I am working with multiple workspaces which is why I needed to specify the full path, exactly as you say! After successfully running the DomainToTable function, I am having trouble reading the values (description values) from the table itself. Shouldn't I just be able to do this by using a cursor just like when trying to access data in a feature class, etc? Or would this be different because of the structure of the table object? I want to try and create a python dict from the values in the table (linking "code" fields to their respective "description" fields so that I can reference them in another area of the script). Your help is much appreciated!!
... View more
01-31-2012
07:28 AM
|
0
|
0
|
1845
|
POST
|
Oh, I see now! My issue was with the name of the table itself in the parameters to the function... I did not think that I would need to include the workspace it had to be placed inside, I just assumed it would know this from the workspace parameter. Thanks for all your help!!
... View more
01-30-2012
01:51 PM
|
0
|
0
|
1845
|
POST
|
Okay, so I think I'm just about there now... For some reason the DomainToTable function is not liking the input I am giving it. I find the domain name the way you suggested, csny490, and stick that into the function with the rest of my parameters:
#workspace is a parameter taken as input on the tool (example.gdb would be the workspace, for example)
#domain is a field.domain value: fields are listed using arcpy.ListFields(aFeatureClass) function, iterated through to find the correct field and then that field's domain is placed into a variable called "domain"
#the last 3 inputs are made up names for the table, code and description values respectively
arcpy.DomainToTable_management(workspace, domain, "ExampleTable", "code", "description")
It errors out with: File "...\arcpy\management.py", line... ERROR 999999: Error executing function. Failed to execute (DomainToTable). Any ideas?
... View more
01-30-2012
01:22 PM
|
0
|
0
|
1845
|
POST
|
Thanks, csny490, that actually helped me get started with what I need to accomplish... Is there a built-in function that will help me in finding the domain name of a field using the field's name so that I can use the domain name in the DomainToTable function? Also, russellb, I will definitely keep that in mind! That's good to know info for a future update down the road. 🙂
... View more
01-30-2012
12:27 PM
|
0
|
0
|
1845
|
POST
|
Can anyone from this thread assist me? I am trying to do something similar to the original poster's question; however, my fields are tied to domains and I do not need coded values, but need their description values instead. I have already posted here about this. Any help is appreciated, thanks!! 🙂
... View more
01-27-2012
12:08 PM
|
0
|
0
|
459
|
POST
|
Hello, this is my first time posting on these forums so I apologize if I am doing something wrong beforehand! I am trying to find a way to get a value from a field that has a domain. I noticed that getting a value using the normal approach only gives me the coded value of the field, but not the description value. Is there any way to retrieve the description? The coded value is not needed for what I am trying to accomplish. Here is the function I am using this in:
def getValues(featureClass,FieldName):
desc = arcpy.Describe(featureClass)
cur = arcpy.SearchCursor(featureClass)
row = cur.next()
names = []
while row:
name = str(row.getValue(FieldName)) #would like to get description and not code value on this line...
try:
ind = names.index(name)
except:
names.append(name)
row = cur.next()
return(names)
Thanks!
... View more
01-27-2012
12:06 PM
|
0
|
10
|
9065
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|