#1 Thu 17 January 2019 13:36
- benoit111
- Participant actif
- Date d'inscription: 20 Jan 2008
- Messages: 102
erreur pour stopper service dans arcgis server
bonjour,
j'utilise ce script pour démarrer ou stopper un service
Code:
import urllib, urllib2, json import arcpy def gentoken(server, port, adminUser, adminPass, expiration=60): #Re-usable function to get a token required for Admin changes query_dict = {'username': adminUser, 'password': adminPass, 'expiration': str(expiration), 'client': 'requestip'} query_string = urllib.urlencode(query_dict) url = "http://{}:{}/arcgis/admin/generateToken".format(server, port) token = json.loads(urllib.urlopen(url + "?f=json", query_string).read()) if "token" not in token: arcpy.AddError(token['messages']) quit() else: return token['token'] def stopStartServices(server, port, adminUser, adminPass, stopStart, serviceList, token=None): ''' Function to stop, start or delete a service. Requires Admin user/password, as well as server and port (necessary to construct token if one does not exist). stopStart = Stop|Start|Delete serviceList = List of services. A service must be in the <name>.<type> notation If a token exists, you can pass one in for use. ''' # Get and set the token if token is None: token = gentoken(server, port, adminUser, adminPass) # Getting services from tool validation creates a semicolon delimited list that needs to be broken up services = serviceList.split(';') #modify the services(s) for service in services: service = urllib.quote(service.encode('utf8')) op_service_url = "http://{}:{}/arcgis/admin/services/{}/{}?token={}&f=json".format(server, port, service, stopStart, token) status = urllib2.urlopen(op_service_url, ' ').read() if 'success' in status: arcpy.AddMessage(str(service) + " === " + str(stopStart)) else: arcpy.AddWarning(status) return
et j'ai cet erreur IOError: [Errno socket error] [Errno 11001] getaddrinfo failed et je ne vois pas du tout ce qui cloche??
merci de votre aide
Hors ligne