Estoy tratando de obtener una lista de nombres de capas dentro de nuestros servicios de descanso para todos los servicios y carpetas. Tengo dos códigos que estoy tratando de poner juntos y por alguna razón el código de la capa no se ve a trabajar dentro del código de servicio de mapa. Cualquier sugerencia sería genial. Estoy corriendo en un servidor 10.2.
import urllib2, json
server = "hcs084mcgida901"
port = "6080"
baseUrl = "http://gisdev.mcgi.state.mi.us/arcgis/rest/services".format(server, port)
def serviceLayers(URL):
fURL = URL + "/" + "?f=json"
openURL = urllib2.urlopen(fURL, '').read()
outJson = json.loads(openURL)
return outJson["services"]
if __name__ == "__main__":
URL = "http://gisdev.mcgi.state.mi.us/arcgis/rest/services".format(folder)
def getCatalog():
catalog = json.load(urllib2.urlopen(baseUrl + "/" + "?f=json"))
print 'ROOT'
if "error" in catalog: return
services = catalog['services']
for service in services:
response = json.load(urllib2.urlopen(baseUrl + '/' + service['name'] + '/' + service['type'] + "?f=json"))
print ' %s %s (%s)' % (service['name'], service['type'], 'ERROR' if "error" in response else 'SUCCESS')
folders = catalog['folders']
for folderName in folders:
catalog = json.load(urllib2.urlopen(baseUrl + "/" + folderName + "?f=json"))
print folderName
if "error" in catalog: return
services = catalog['services']
for service in services:
response = json.load(urllib2.urlopen(baseUrl + '/' + service['name'] + '/' + service['type'] + "?f=json"))
services = serviceLayers(URL)
for f in services:
print ' %s %s (%s)' % (service['name'], service['type'], 'ERROR' if "error" in response else 'SUCCESS'), "Layer : {}".format(f["name"])
getCatalog()