I have a standalone python script that runs on our ArcGIS 10.7.1 server nightly to regenerate a tile cache. The script runs fine when I use an admin server connection file, but when I switch to a publisher connection I am getting the error 000732:
Input Service: Dataset <path to server connection file>\<service name>.Mapserver does not exist or is not supported
Failed to execute (ManageMapServerCacheTiles).
However, the dataset does exist at the path specified on the server. The publisher connection file uses a user that is a publisher on the server. Connection file was created in ArcMap. When I regenerate the tiles in ArcMap using the same publisher connection all works fine.
Here is the script:
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="keyword token">import</SPAN> os<SPAN class="punctuation token">,</SPAN> sys<SPAN class="punctuation token">,</SPAN> time<SPAN class="punctuation token">,</SPAN> datetime<SPAN class="punctuation token">,</SPAN> traceback<SPAN class="punctuation token">,</SPAN> string
<SPAN class="comment token"># Set environment settings</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:/data"</SPAN>
<SPAN class="comment token"># List of input variables for map service properties</SPAN>
connectionPath <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"<drive letter>:\Scripts\ManageMapServerCacheTiles"</SPAN>
server <SPAN class="operator token">=</SPAN> <SPAN class="string token">"<publisher connection file name>.ags"</SPAN>
serviceName <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"<service name>.MapServer"</SPAN>
database <SPAN class="operator token">=</SPAN> <SPAN class="string token">"<sde connection file>.sde"</SPAN>
featureClass <SPAN class="operator token">=</SPAN> <SPAN class="string token">"<feature class name>"</SPAN>
inputService <SPAN class="operator token">=</SPAN> connectionPath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> server <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> serviceName
scales <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="operator token"><</SPAN>list of scales<SPAN class="operator token">></SPAN><SPAN class="punctuation token">]</SPAN>
numOfCachingServiceInstances <SPAN class="operator token">=</SPAN> <SPAN class="number token">3</SPAN>
updateMode <SPAN class="operator token">=</SPAN> <SPAN class="string token">"RECREATE_ALL_TILES"</SPAN>
areaOfInterest <SPAN class="operator token">=</SPAN> <SPAN class="string token">""</SPAN>
waitForJobCompletion <SPAN class="operator token">=</SPAN> <SPAN class="string token">"DO_NOT_WAIT"</SPAN>
updateExtents <SPAN class="operator token">=</SPAN> connectionPath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> database <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> featureClass
currentTime <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arg1 <SPAN class="operator token">=</SPAN> currentTime<SPAN class="punctuation token">.</SPAN>strftime<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"%H-%M"</SPAN><SPAN class="punctuation token">)</SPAN>
file <SPAN class="operator token">=</SPAN> connectionPath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\report_%s_<cache name>.txt"</SPAN> <SPAN class="operator token">%</SPAN> arg1
<SPAN class="comment token"># print results of the script to a report</SPAN>
report <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>file<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'w'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
starttime <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>clock<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
result <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ManageMapServerCacheTiles_server<SPAN class="punctuation token">(</SPAN>inputService<SPAN class="punctuation token">,</SPAN> scales<SPAN class="punctuation token">,</SPAN>
updateMode<SPAN class="punctuation token">,</SPAN>
numOfCachingServiceInstances<SPAN class="punctuation token">,</SPAN>
areaOfInterest<SPAN class="punctuation token">,</SPAN> updateExtents<SPAN class="punctuation token">,</SPAN>
waitForJobCompletion<SPAN class="punctuation token">)</SPAN>
finishtime <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>clock<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
elapsedtime<SPAN class="operator token">=</SPAN> finishtime <SPAN class="operator token">-</SPAN> starttime
<SPAN class="comment token">#print messages to a file</SPAN>
<SPAN class="keyword token">while</SPAN> result<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token"><</SPAN> <SPAN class="number token">4</SPAN><SPAN class="punctuation token">:</SPAN>
time<SPAN class="punctuation token">.</SPAN>sleep<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0.2</SPAN><SPAN class="punctuation token">)</SPAN>
resultValue <SPAN class="operator token">=</SPAN> result<SPAN class="punctuation token">.</SPAN>getMessages<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
report<SPAN class="punctuation token">.</SPAN>write <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"completed "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>resultValue<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Created cache tiles for given schema successfully for "</SPAN> <SPAN class="operator token">+</SPAN>\
serviceName <SPAN class="operator token">+</SPAN> <SPAN class="string token">" in "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>elapsedtime<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">" sec on "</SPAN> <SPAN class="operator token">+</SPAN> arg2
<SPAN class="keyword token">except</SPAN> Exception<SPAN class="punctuation token">,</SPAN> e<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># If an error occurred, print line number and error message</SPAN>
tb <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>exc_info<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
report<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Failed at step 1 \n"</SPAN> <SPAN class="string token">"Line %i"</SPAN> <SPAN class="operator token">%</SPAN> tb<SPAN class="punctuation token">.</SPAN>tb_lineno<SPAN class="punctuation token">)</SPAN>
report<SPAN class="punctuation token">.</SPAN>write<SPAN class="punctuation token">(</SPAN>e<SPAN class="punctuation token">.</SPAN>message<SPAN class="punctuation token">)</SPAN>
report<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Created Map server Cache Tiles "</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>The error occurs on line 36.
What would be the reason that the script will run with an admin connection but not a publisher connection, and using the same publisher connection in Desktop I can regenerate all tiles?
Thanks