inspect_service_properties

Inspect service properties

In [1]:
from arcgis.gis import *
from getpass import getpass
In [2]:
password = getpass()
gis = GIS("https://esriwebgis.webgistesting.net/portal/",'admin',password)
········
In [3]:
hosting_server = gis.servers[0]
hosting_server.connection.baseurl
Out[3]:
'https://ESRIwebgis.webgistesting.net/server/rest/services'
In [4]:
hosting_server.services.url
Out[4]:
'https://ESRIwebgis.webgistesting.net/server/admin/services'

Get admin properties for a map service

In [4]:
# get the list of folders
hosting_server.services.folders
Out[4]:
['custom_streets', 'Hosted', 'System', 'Utilities', '/']
In [5]:
# set active folder
hosting_server.services.folder = '/'
In [6]:
# get list of services in that folder
service_list = hosting_server.services.services
In [7]:
print(len(service_list))
s1 = service_list[1]
4
In [8]:
s1.url
Out[8]:
'https://ESRIwebgis.webgistesting.net/server/admin/services/Renter_percentage.MapServer'
In [9]:
s1.properties
Out[9]:
{'antialiasingMode': 'None',
 'cacheDir': '/gisdata/arcgisserver/directories/arcgiscache',
 'cacheOnDemand': 'false',
 'clientCachingAllowed': 'true',
 'disableIdentifyRelates': 'false',
 'dynamicDataWorkspaces': '',
 'enableDynamicLayers': 'true',
 'exportTilesAllowed': 'false',
 'filePath': 'Z:\\gisdata\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\Renter_percentage.MapServer\\extracted\\v101\\Renter_percentage.msd',
 'hasStaticData': 'true',
 'ignoreCache': 'false',
 'isCached': 'false',
 'maxBufferCount': '100',
 'maxDomainCodeCount': '25000',
 'maxExportTilesCount': '100000',
 'maxImageHeight': '4096',
 'maxImageWidth': '4096',
 'maxRecordCount': '1000',
 'maxScale': '4513.9887049999998',
 'minScale': '9244648.8686180003',
 'outputDir': '/gisdata/arcgisserver/directories/arcgisoutput',
 'schemaLockingEnabled': 'true',
 'supportedImageReturnTypes': 'URL',
 'textAntialiasingMode': 'Force',
 'useLocalCacheDir': 'true',
 'virtualCacheDir': '/rest/directories/arcgiscache',
 'virtualOutputDir': '/rest/directories/arcgisoutput'}
In [10]:
s1.status
Out[10]:
{'configuredState': 'STARTED', 'realTimeState': 'STARTED'}
In [11]:
s1.iteminfo
Out[11]:
{'accessInformation': '',
 'catalogPath': '',
 'culture': 'en-US',
 'description': 'ratio of renters vs owners',
 'extent': [[-124.579958342708, 32.4162831425432],
  [-113.498062309958, 42.0723284696811]],
 'guid': 'EAEEFB44-ED9A-44F8-B079-FF351370C604',
 'licenseInfo': '',
 'name': 'Renter_percentage',
 'snippet': 'social vulnerability',
 'spatialReference': 'NAD_1983_California_Teale_Albers',
 'summary': 'social vulnerability',
 'tags': ['renters'],
 'thumbnail': 'thumbnail/thumbnail.png',
 'title': 'Renter_percentage',
 'type': 'Map Service',
 'typeKeywords': ['Data', 'Service', 'Map Service', 'ArcGIS Server'],
 'url': ''}
In [12]:
s1.statistics
Out[12]:
{'perMachine': [{'busy': 0,
   'folderName': '/',
   'free': 1,
   'initializing': 0,
   'isStatisticsAvailable': True,
   'machineName': '10.0.0.157',
   'max': 2,
   'notCreated': 1,
   'serviceName': 'Renter_percentage',
   'totalBusyTime': 3150,
   'transactions': 3,
   'type': 'MapServer'}],
 'summary': {'busy': 0,
  'folderName': '/',
  'free': 1,
  'initializing': 0,
  'isStatisticsAvailable': True,
  'max': 2,
  'notCreated': 1,
  'serviceName': 'Renter_percentage',
  'totalBusyTime': 3150,
  'transactions': 3,
  'type': 'MapServer'}}

Modify a service state

In [13]:
s1.stop()
Unknown Error
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-13-b1ff7ba3a5c7> in <module>()
----> 1 s1.stop()

C:\Users\atma6951\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\geonuma_server\lib\site-packages\arcgis\server\admin\_services.py in stop(self)
    757         }
    758         uURL = self._url + "/stop"
--> 759         return self._con.post(path=uURL, postdata=params)
    760     #----------------------------------------------------------------------
    761     def restart(self):

C:\Users\atma6951\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\geonuma_server\lib\site-packages\arcgis\server\_common\_connection.py in post(self, path, postdata, files, ssl, compress, is_retry, use_ordered_dict, add_token, verify_cert, token, **kwargs)
    779                     raise RuntimeError('Invalid token')
    780                 if 'status' in resp_json:
--> 781                     self._handle_json_error(resp_json, errorcode)
    782                 else:
    783                     self._handle_json_error(resp_json['error'], errorcode)

C:\Users\atma6951\AppData\Local\Programs\ArcGIS\Pro\bin\Python\envs\geonuma_server\lib\site-packages\arcgis\server\_common\_connection.py in _handle_json_error(self, error, errorcode)
    806                 errormessage = errormessage + "\n" + errordetail
    807         errormessage = errormessage + "\n(Error Code: " + str(errorcode) +")"
--> 808         raise RuntimeError(errormessage)
    809 ########################################################################
    810 class _StrictURLopener(request.FancyURLopener):

RuntimeError: Unknown Error
(Error Code: 0)
In [14]:
s1.status
Out[14]:
{'configuredState': 'STOPPED', 'realTimeState': 'STOPPED'}
In [ ]:
s1.start()

Inspect service extensions

In [15]:
extns = s1.extensions
len(extns)
Out[15]:
7
In [16]:
extn1 = extns[0]
extn1.enabled
Out[16]:
False
In [17]:
for ex in extns:
    print(ex.typeName + " : " + str(ex.enabled))
NAServer : False
SchematicsServer : False
WCSServer : False
WFSServer : False
WMSServer : False
KmlServer : True
FeatureServer : False
In [18]:
fx_ext = extns[-2]
In [19]:
fx_ext.capabilities
Out[19]:
'SingleImage,SeparateImages,Vectors'
In [ ]: