Last active
December 17, 2015 20:59
-
-
Save steveoh/5671680 to your computer and use it in GitHub Desktop.
automated soe updating
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project DefaultTargets="UpdateSOE" ...> | |
<Target Name="UpdateSOE" DependsOnTargets="Build"> | |
<!-- Python needs to be in the path --> | |
<Exec Command="python $(MSBuildProjectDirectory)\PostBuildEvents\Runner.py"/> | |
</Target> | |
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
token_url = "http://localhost:6080/arcgis/admin/generateToken" | |
update_soe_url = "http://localhost:6080/arcgis/admin/services/types/extensions/update" | |
upload_url = "http://localhost:6080/arcgis/admin/uploads/upload?token={}" | |
#: Enhancement: pass in as a build arguement | |
file_name = r'C:\*.soe' | |
data = {'username': "", | |
'password': "", | |
'client': 'requestip', | |
'f': 'json'} | |
r = requests.post(token_url, data=data) | |
print 'got token' | |
files = {'itemFile': open(file_name, 'rb'), 'f': 'json'} | |
data['token'] = token = r.json()['token'] | |
print 'uploading' | |
r = requests.post(upload_url.format(token), files=files) | |
print r.status_code, r.text | |
data['id'] = r.json()["item"]["itemID"] | |
print data['id'] | |
files = {'file': open(file_name, 'rb')} | |
print 'updating' | |
r = requests.post(update_soe_url, params=data) | |
print r.status_code, r.text | |
print 'done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment