Tengo este script basado en una exportación de Model Builder (ArcMap 10.4) que se supone que toma archivos .tif de un directorio y los importa a un servicio existente. El problema es que ImportMapServerCache_server
no se ejecuta después de editar un poco el código llegué a lo siguiente:
import arcpy
import os
entrada:
# Local variables:
connectionFile = "C:\\Users\\carmel.han\\AppData\\Roaming\\ESRI\\Desktop10.4\\ArcCatalog"
server = "arcgis on geoerpdev_6080 (publisher)"
serviceName = "MondayFull3.MapServer"
Input_Service = connectionFile + "\\" + server + "\\" + serviceName
print (Input_Service)
#Input_Service = "http://geoerpdev:6080/arcgis/rest/services/tests/MondayFull2/MapServer"
OutPut_Cache_Location_Path = "C:\\Users\\carmel.han\\Desktop\\Caching\\Output"
Manage_Mode = "RECREATE_ALL_TILES"
# Input_Data_Source = "Ov_i04_L02_R000005F1_C000004567892"
Input_Tiling_Scheme = "IMPORT_SCHEME"
Import_Tiling_Scheme = "C:\\Users\\carmel.han\\Desktop\\tests_monday\\Final.xml"
Scales__Pixel_Size___Estimated_Disk_Space_ = "64000;32000;16000"
#Area_of_Interest = "in_memory\\{3B818E7A-1914-4D00-9C2C-E97C6744D7BC}"
Area_of_Interest = "#"
Maximum_Source_Cell_Size = ""
Minimum_Cached_Scale = "64000"
Maximum_Cached_Scale = "16000"
#Cache_Name = "C:\\Users\\carmel.han\\Desktop\\Wensday\\wensday2"
Source_Tile_Package = ""
Upload_data_to_server = "UPLOAD_DATA"
Scales = "64000;32000;16000"
Number_of_caching_service_instances = "3"
#Area_Of_Interest__Polygon_ = "in_memory\\{8BBC3764-B579-4CCF-847B-E1D1E428CE1C}"
#Area_Of_Interest__Polygon_ = "#"
Area_Of_Interest__Polygon_ = ""
Overwrite_Tiles = "MERGE"
Output_Map_Service_URL = "http://geoerpdev:6080/arcgis/rest/services/System/CachingControllers/GPServer/ImportCache/jobs/j98c38213db434a8da6aec04aacb259c3"
Source_Cache_Dataset = "C:\\Users\\carmel.han\\Desktop\\Wensday\\Wensday1"
directory = "C:\\Users\\carmel.han\\Desktop\\Caching\\Input"
código:
for Input_Data_Source in os.listdir(directory):
if Input_Data_Source.endswith(".tif") or Input_Data_Source.endswith(".ecw"):
Input_Data_Raster = directory + "\\" + Input_Data_Source
print ("Input: " + Input_Data_Raster)
try:
os.stat(OutPut_Cache_Location_Path)
except:
os.mkdir(OutPut_Cache_Location_Path)
print ("Output: "+ OutPut_Cache_Location_Path)
arcpy.ManageTileCache_management(OutPut_Cache_Location_Path, Manage_Mode, os.path.splitext(Input_Data_Source)[0], Input_Data_Raster, Input_Tiling_Scheme, Import_Tiling_Scheme, Scales__Pixel_Size___Estimated_Disk_Space_, Area_of_Interest, Maximum_Source_Cell_Size, Minimum_Cached_Scale, Maximum_Cached_Scale)
Cache_Name = OutPut_Cache_Location_Path + "\\" + os.path.splitext(Input_Data_Source)[0]
print (Cache_Name)
try:
arcpy.ImportMapServerCache_server(Input_Service, "CACHE_DATASET", Cache_Name, Source_Tile_Package, "UPLOAD_DATA", Scales, Number_of_caching_service_instances, Area_Of_Interest__Polygon_, "", Overwrite_Tiles)
except ValueError:
print ("Bad!!")
de salida:
Executing: ManageTileCache C:\Users\carmel.han\Desktop\Caching\Output RECREATE_ALL_TILES Ov_i04_L02_R000005F1_C0000045678921 C:\Users\carmel.han\Desktop\Caching\Input\Ov_i04_L02_R000005F1_C0000045678921.tif IMPORT_SCHEME C:\Users\carmel.han\Desktop\tests_monday\Final.xml 64000;32000;16000 "Feature Set" # 64000 16000
Start Time: Mon May 28 08:48:52 2018
Generating tile cache using 4 parallel instances.
Succeeded at Mon May 28 08:49:02 2018 (Elapsed Time: 9.58 seconds)
Executing: ImportMapServerCache "C:\Users\carmel.han\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\arcgis on geoerpdev_6080 (publisher)\MondayFull3.MapServer" CACHE_DATASET C:\Users\carmel.han\Desktop\Caching\Output\Ov_i04_L02_R000005F1_C0000045678921 # DO_NOT_UPLOAD 64000;32000;16000 3 "Feature Set" "646401.583133334 8292340.10282222 662788.783133334 8308724.10282222" MERGE
Start Time: Mon May 28 08:49:04 2018
Reporting status from http://geoerpdev:6080/arcgis/rest/services/System/CachingControllers/GPServer/ImportCache/jobs/j2b56a4d7497b4eb8a3e914735072d50a
ERROR 001225: Server cannot access target_cache_path.
Failed to execute (ImportCache).
Failed.
The workspace is not connected.
Failed to execute (ImportMapServerCache).
Failed at Mon May 28 08:49:19 2018 (Elapsed Time: 14.41 seconds)
Me he dado cuenta de que en la salida bajo Executing
dice DO_NOT_UPLOAD
a pesar de que entré UPLOAD_DATA
así que lo sustituí por DO_NOT_UPLOAD
pensando que podría haber algún problema con la variable boolian, pero no ayudó. ¿Qué puede causar este problema?