I couldn’t figure out if there are a tool or a way to count the number of allocated max\min instances for all published services. See below
Best Regards,
Rawan
Good Morning Rawan,
Check and download the attached python file and try to run it.
No need to spend time on format this code.
https://community.esri.com/docs/DOC-9922-arcgis-server-map-service-properties
You can look into writing a python script to get the "minInstancesPerNode" and "maxInstancesPerNode" properties from the Admin API:
https://<server>.<domain>.com:6443/arcgis/admin/services/SampleWorldCities.MapServer?f=pjson
Dear Jonthan,
Thanks for you reply,I need this to be applied on all services.
How could I add a python script to get the "minInstancesPerNode" and "maxInstancesPerNode" properties from the Admin API:?
I opened this link, and logins as admin but I couldn’t made any changes, maybe I misunderstand this point.
You're at the Rest API, not the Admin API:
The bolded section is the URL to the Admin API. Log in with administrative credentials to make changes.
I would start with looking at the overview of scripting administration of your Server, and the specific examples of editing service properties and checking a folder for stopped services for pieces of code you can use.
Dear Jonathan,
Hi
Please try below link code and generate one output file with all details about services.
From this file you can calculate total instance assigned from one ArcGIS server.
Dear Avinash Kumar Patel,
Thanks for your reply,
Actually, I’m not sure where should I apply this code to get the required information.
Can you please tell me the path in Admin API where I could run this code?
Best,
Hi Rawan,
You need to copy the code in notepad and make the extension as .py like(avinash.py).
After that you need to double click it
Give inputs like:
Enter user name: avinashEnter password:Enter server name: avinashOutput File: \avinash.csvYou can get the output file on you save location.
Make sure system have python installed on it like where ArcGIS server or desktop installed on it.
Dear Avinash,
Thank you for your answer.
I tried to do what you are mention, but it doesn’t work for me.
When I double click on the “file py” it’s not open like the screenshot you provide.
And I make sure the python is installed. attached
What might be the issue here?
Try like thisIn Start menu>search python >select python GUI>then in GUI file>new file>past your code & save >run it
Are you able to execute this.
Thank you for your answer and prompt help.
I tried to follow the steps that you mentioned above, I’m able to run the model but it gives me the following error. Should I enhance on the code to make it work fine?
Thanks a lot for your effort, it’s working fine with me.
But I still need to enhance this code to sum the min/max instances automatically, is that possible?
Hello Rawan,
Good to know its working !
In code its not possible but in out put file you can calculate its not take more that 1 min in out put file.
If you have any idea how its possible Please share with me so i can also try to enhance code.
Thanks,
Avinash patel
Many thanks for your answer.
Kindly find the following screenshots.
The variables on line 6, 7, and 8 are simply place holders. Replace them with the appropriate information for your Server.
I got the same error even though I entered the specific variable
If you can reach what you entered for the baseURL in a browser on the machine you're running the script, there shouldn't be a reason why you see the getaddrinfo error in Python. That error simply means the host can't be found.
Jonathan Quinn script.
Find the out put like
Total minimum instances: ****---countTotal maximum instances: ***--count
https://community.esri.com/docs/DOC-9922/edit?draftID=328241
Jonathan_Avinash.zip
Are you able to execute this?
Thanks for your effort, actually I couldn’t access the above link. Attached
Dear Aviniesh,
The py file doesn’t catch the services published in the system folder (attached), what might be issue here?
Hi Rawan Saleh,
Need to check
But in my new project don't get enough time to do testing and rectifying.
update you soon.
Thanks
I could manage to do this, kindly find the below it works fine with me.
# Reads the following properties <SPAN class="keyword token">from</SPAN> services and writes them to a comma<SPAN class="operator token">-</SPAN>delimited file<SPAN class="punctuation token">:</SPAN> # ServiceName<SPAN class="punctuation token">,</SPAN> Folder<SPAN class="punctuation token">,</SPAN> Type<SPAN class="punctuation token">,</SPAN> Status<SPAN class="punctuation token">,</SPAN> Min Instances<SPAN class="punctuation token">,</SPAN> Max Instances<SPAN class="punctuation token">,</SPAN> KML<SPAN class="punctuation token">,</SPAN> # WMS<SPAN class="punctuation token">,</SPAN> Max Records<SPAN class="punctuation token">,</SPAN> Cluster<SPAN class="punctuation token">,</SPAN> Cache Directory<SPAN class="punctuation token">,</SPAN> Jobs Directory<SPAN class="punctuation token">,</SPAN> Output Directory # For HTTP calls <SPAN class="keyword token">import</SPAN> httplib<SPAN class="punctuation token">,</SPAN> urllib<SPAN class="punctuation token">,</SPAN> json # For system tools <SPAN class="keyword token">import</SPAN> sys # For reading passwords without echoing <SPAN class="keyword token">import</SPAN> getpass def <SPAN class="token function">main</SPAN><SPAN class="punctuation token">(</SPAN>argv<SPAN class="operator token">=</SPAN>None<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> # Ask <SPAN class="keyword token">for</SPAN> admin<SPAN class="operator token">/</SPAN>publisher user name and password username <SPAN class="operator token">=</SPAN> <SPAN class="token function">raw_input</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Enter user name: "</SPAN><SPAN class="punctuation token">)</SPAN> password <SPAN class="operator token">=</SPAN> getpass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getpass</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Enter password: "</SPAN><SPAN class="punctuation token">)</SPAN> # Ask <SPAN class="keyword token">for</SPAN> server name <SPAN class="operator token">&</SPAN> port serverName <SPAN class="operator token">=</SPAN> <SPAN class="token function">raw_input</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Enter server name: "</SPAN><SPAN class="punctuation token">)</SPAN> serverPort <SPAN class="operator token">=</SPAN> <SPAN class="number token">6080</SPAN> # Get the location and the name <SPAN class="keyword token">of</SPAN> the file to be created resultFile <SPAN class="operator token">=</SPAN> <SPAN class="token function">raw_input</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Output File: "</SPAN><SPAN class="punctuation token">)</SPAN> # Get a token token <SPAN class="operator token">=</SPAN> <SPAN class="token function">getToken</SPAN><SPAN class="punctuation token">(</SPAN>username<SPAN class="punctuation token">,</SPAN> password<SPAN class="punctuation token">,</SPAN> serverName<SPAN class="punctuation token">,</SPAN> serverPort<SPAN class="punctuation token">)</SPAN> # Get the root info serverURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/"</SPAN> # This request only needs the token and the response formatting parameter params <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">urlencode</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">:</SPAN> token<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> headers <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Content-type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"application/x-www-form-urlencoded"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Accept"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"text/plain"</SPAN><SPAN class="punctuation token">}</SPAN> # Connect to URL and post parameters httpConn <SPAN class="operator token">=</SPAN> httplib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">HTTPConnection</SPAN><SPAN class="punctuation token">(</SPAN>serverName<SPAN class="punctuation token">,</SPAN> serverPort<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> serverURL<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Read response response <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token">!=</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> print <SPAN class="string token">"Could not read folder information."</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> data <SPAN class="operator token">=</SPAN> response<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Check that data returned is not an error object <SPAN class="keyword token">if</SPAN> not <SPAN class="token function">assertJsonSuccess</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> print <SPAN class="string token">"Error when reading server information. "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> print <SPAN class="string token">"Processed server information successfully. Now processing folders..."</SPAN> # Deserialize response into Python object dataObj <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> #Store the Folders <SPAN class="keyword token">in</SPAN> a list to loop on folders <SPAN class="operator token">=</SPAN> dataObj<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"folders"</SPAN><SPAN class="punctuation token">]</SPAN> #Remove the System and Utilities folders folders<SPAN class="punctuation token">.</SPAN><SPAN class="token function">remove</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"System"</SPAN><SPAN class="punctuation token">)</SPAN> # folders<SPAN class="punctuation token">.</SPAN><SPAN class="token function">remove</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Utilities"</SPAN><SPAN class="punctuation token">)</SPAN> #Add an entry <SPAN class="keyword token">for</SPAN> the root folder folders<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN> folders<SPAN class="punctuation token">.</SPAN><SPAN class="token function">append</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"System"</SPAN><SPAN class="punctuation token">)</SPAN> #Create the summary file <SPAN class="keyword token">of</SPAN> services serviceResultFile <SPAN class="operator token">=</SPAN> <SPAN class="token function">open</SPAN><SPAN class="punctuation token">(</SPAN>resultFile<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'w'</SPAN><SPAN class="punctuation token">)</SPAN> serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"ServiceName,Folder,Type,Status,Min Instances,Max Instances,FeatureService,kml,wms,Max Records,Cluster,Cache Directory,Jobs Directory,Output Directory"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN><SPAN class="punctuation token">)</SPAN> #Loop on the found folders and discover the services and write the service information <SPAN class="keyword token">for</SPAN> folder <SPAN class="keyword token">in</SPAN> folders<SPAN class="punctuation token">:</SPAN> # Determine <SPAN class="keyword token">if</SPAN> the loop is working on the root folder or not <SPAN class="keyword token">if</SPAN> folder <SPAN class="operator token">!=</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">:</SPAN> folder <SPAN class="operator token">+</SPAN><SPAN class="operator token">=</SPAN> <SPAN class="string token">"/"</SPAN> # Build the URL <SPAN class="keyword token">for</SPAN> the current folder folderURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/"</SPAN> <SPAN class="operator token">+</SPAN> folder params <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">urlencode</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">:</SPAN> token<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> headers <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Content-type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"application/x-www-form-urlencoded"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Accept"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"text/plain"</SPAN><SPAN class="punctuation token">}</SPAN> # Connect to URL and post parameters httpConn <SPAN class="operator token">=</SPAN> httplib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">HTTPConnection</SPAN><SPAN class="punctuation token">(</SPAN>serverName<SPAN class="punctuation token">,</SPAN> serverPort<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> folderURL<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Read response response <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token">!=</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> print <SPAN class="string token">"Could not read folder information."</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> data <SPAN class="operator token">=</SPAN> response<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Check that data returned is not an error object <SPAN class="keyword token">if</SPAN> not <SPAN class="token function">assertJsonSuccess</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> print <SPAN class="string token">"Error when reading folder information. "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> print <SPAN class="string token">"Processed folder information successfully. Now processing services..."</SPAN> # Deserialize response into Python object dataObj <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Loop through each service <SPAN class="keyword token">in</SPAN> the folder <SPAN class="keyword token">for</SPAN> item <SPAN class="keyword token">in</SPAN> dataObj<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'services'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GeometryServer"</SPAN><SPAN class="punctuation token">:</SPAN># and folder <SPAN class="operator token">==</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the Service URL to test the running status # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Obtain the data <SPAN class="keyword token">from</SPAN> the response readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"SearchServer"</SPAN><SPAN class="punctuation token">:</SPAN># and folder <SPAN class="operator token">==</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"jobsDirectory"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ImageServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the Service URL to test the running status <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Extract the WMS properties <SPAN class="keyword token">from</SPAN> the response wmsProps <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>imageWMS <SPAN class="keyword token">for</SPAN> imageWMS <SPAN class="keyword token">in</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"extensions"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> imageWMS<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"typeName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'WMSServer'</SPAN><SPAN class="punctuation token">]</SPAN>#<SPAN class="punctuation token">.</SPAN><SPAN class="token function">items</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'WMSServer'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="token function">len</SPAN><SPAN class="punctuation token">(</SPAN>wmsProps<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> wmsStatus <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>wmsProps<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"enabled"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> wmsStatus <SPAN class="operator token">=</SPAN> <SPAN class="string token">"NA"</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> wmsStatus <SPAN class="operator token">+</SPAN><SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"cacheDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA,"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GlobeServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> #Build the Service URL to test the running status <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxRecordCount"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"cacheDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GPServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the Service URL to test the running status <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"jobsDirectory"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GeocodeServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"GeoDataServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxRecordCount"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> elif item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"MapServer"</SPAN><SPAN class="punctuation token">:</SPAN> # Build the Service URL <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> sUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> sUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJ <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Build the Service URL to test the running status <SPAN class="keyword token">if</SPAN> folder<SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>folder<SPAN class="punctuation token">,</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> statusUrl <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/services/%s.%s/status"</SPAN> <SPAN class="operator token">%</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> # Submit the request to the server httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> statusUrl<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Get the response servStatusResponse <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> readData <SPAN class="operator token">=</SPAN> servStatusResponse<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> jsonOBJStatus <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>readData<SPAN class="punctuation token">)</SPAN> # Check <SPAN class="keyword token">for</SPAN> Map Cache isCached <SPAN class="operator token">=</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"isCached"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> isCached <SPAN class="operator token">==</SPAN> <SPAN class="string token">"true"</SPAN><SPAN class="punctuation token">:</SPAN> cacheDir <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"cacheDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> cacheDir <SPAN class="operator token">=</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"isCached"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="token function">len</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"extensions"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> # Build the line to write to the output file ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"FeatServHolder"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Disabled"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Disabled"</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxRecordCount"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> cacheDir <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> # Extract the KML properties <SPAN class="keyword token">from</SPAN> the response kmlProps <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>mapKML <SPAN class="keyword token">for</SPAN> mapKML <SPAN class="keyword token">in</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"extensions"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> mapKML<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"typeName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'KmlServer'</SPAN><SPAN class="punctuation token">]</SPAN>#<SPAN class="punctuation token">.</SPAN><SPAN class="token function">items</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'KmlServer'</SPAN><SPAN class="punctuation token">]</SPAN> # Extract the WMS properties <SPAN class="keyword token">from</SPAN> the response wmsProps <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>mapWMS <SPAN class="keyword token">for</SPAN> mapWMS <SPAN class="keyword token">in</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"extensions"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> mapWMS<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"typeName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'WMSServer'</SPAN><SPAN class="punctuation token">]</SPAN>#<SPAN class="punctuation token">.</SPAN><SPAN class="token function">items</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'WMSServer'</SPAN><SPAN class="punctuation token">]</SPAN> # Extract the FeatureService properties <SPAN class="keyword token">from</SPAN> the response featServProps <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>featServ <SPAN class="keyword token">for</SPAN> featServ <SPAN class="keyword token">in</SPAN> jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"extensions"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> featServ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"typeName"</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'FeatureServer'</SPAN><SPAN class="punctuation token">]</SPAN>#<SPAN class="punctuation token">.</SPAN><SPAN class="token function">items</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">'FeatureServer'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="token function">len</SPAN><SPAN class="punctuation token">(</SPAN>featServProps<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> featureStatus <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>featServProps<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"enabled"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> featureStatus <SPAN class="operator token">=</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="token function">len</SPAN><SPAN class="punctuation token">(</SPAN>kmlProps<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> kmlStatus <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>kmlProps<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"enabled"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> kmlStatus <SPAN class="operator token">=</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="token function">len</SPAN><SPAN class="punctuation token">(</SPAN>wmsProps<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN> wmsStatus <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>wmsProps<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"enabled"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> wmsStatus <SPAN class="operator token">=</SPAN> <SPAN class="string token">"NA"</SPAN> ln <SPAN class="operator token">=</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"serviceName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> folder <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"type"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> jsonOBJStatus<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'realTimeState'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"minInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxInstancesPerNode"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> featureStatus <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> kmlStatus <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> wmsStatus <SPAN class="operator token">+</SPAN><SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"maxRecordCount"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"clusterName"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> cacheDir <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"NA"</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">","</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>jsonOBJ<SPAN class="punctuation token">[</SPAN><SPAN class="string token">"properties"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"outputDir"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN><SPAN class="string token">"\n"</SPAN> # Write the results to the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">write</SPAN><SPAN class="punctuation token">(</SPAN>ln<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> # Close the connection to the current service httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Close the file serviceResultFile<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> def <SPAN class="token function">getToken</SPAN><SPAN class="punctuation token">(</SPAN>username<SPAN class="punctuation token">,</SPAN> password<SPAN class="punctuation token">,</SPAN> serverName<SPAN class="punctuation token">,</SPAN> serverPort<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> # Token URL is typically http<SPAN class="punctuation token">:</SPAN><SPAN class="operator token">/</SPAN><SPAN class="operator token">/</SPAN>server<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN>port<SPAN class="punctuation token">]</SPAN><SPAN class="operator token">/</SPAN>arcgis<SPAN class="operator token">/</SPAN>admin<SPAN class="operator token">/</SPAN>generateToken tokenURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">"/arcgis/admin/generateToken"</SPAN> params <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">urlencode</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'username'</SPAN><SPAN class="punctuation token">:</SPAN> username<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'password'</SPAN><SPAN class="punctuation token">:</SPAN> password<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'client'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'requestip'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'json'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN> headers <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Content-type"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"application/x-www-form-urlencoded"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Accept"</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"text/plain"</SPAN><SPAN class="punctuation token">}</SPAN> # Connect to URL and post parameters httpConn <SPAN class="operator token">=</SPAN> httplib<SPAN class="punctuation token">.</SPAN><SPAN class="token function">HTTPConnection</SPAN><SPAN class="punctuation token">(</SPAN>serverName<SPAN class="punctuation token">,</SPAN> serverPort<SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">request</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POST"</SPAN><SPAN class="punctuation token">,</SPAN> tokenURL<SPAN class="punctuation token">,</SPAN> params<SPAN class="punctuation token">,</SPAN> headers<SPAN class="punctuation token">)</SPAN> # Read response response <SPAN class="operator token">=</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getresponse</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>status <SPAN class="operator token">!=</SPAN> <SPAN class="number token">200</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> print <SPAN class="string token">"Error while fetching tokens from admin URL. Please check the URL and try again."</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> data <SPAN class="operator token">=</SPAN> response<SPAN class="punctuation token">.</SPAN><SPAN class="token function">read</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> httpConn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">close</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> # Check that data returned is not an error object <SPAN class="keyword token">if</SPAN> not <SPAN class="token function">assertJsonSuccess</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> # Extract the token <SPAN class="keyword token">from</SPAN> it token <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> token<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'token'</SPAN><SPAN class="punctuation token">]</SPAN> # A <SPAN class="keyword token">function</SPAN> that checks that the input JSON object # is not an error object<SPAN class="punctuation token">.</SPAN> def <SPAN class="token function">assertJsonSuccess</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> obj <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN><SPAN class="token function">loads</SPAN><SPAN class="punctuation token">(</SPAN>data<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'status'</SPAN> <SPAN class="keyword token">in</SPAN> obj and obj<SPAN class="punctuation token">[</SPAN><SPAN class="string token">'status'</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="string token">"error"</SPAN><SPAN class="punctuation token">:</SPAN> print <SPAN class="string token">"Error: JSON object returns an error. "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="token function">str</SPAN><SPAN class="punctuation token">(</SPAN>obj<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">return</SPAN> False <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">return</SPAN> True <SPAN class="keyword token">if</SPAN> __name__ <SPAN class="operator token">==</SPAN> <SPAN class="string token">"__main__"</SPAN><SPAN class="punctuation token">:</SPAN> sys<SPAN class="punctuation token">.</SPAN><SPAN class="token function">exit</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="token function">main</SPAN><SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>argv<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</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></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><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></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><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></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><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></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>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.