AnsweredAssumed Answered

arcpy.CreateMobileCache_mobile forcing system's %errorlevel% variable to -2146234327

Question asked by dom426 on Feb 18, 2015

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))

Outcomes