Skip to content

Instantly share code, notes, and snippets.

@steveoh
Last active December 17, 2015 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steveoh/5671680 to your computer and use it in GitHub Desktop.
Save steveoh/5671680 to your computer and use it in GitHub Desktop.
automated soe updating
<Project DefaultTargets="UpdateSOE" ...>
<Target Name="UpdateSOE" DependsOnTargets="Build">
<!-- Python needs to be in the path -->
<Exec Command="python $(MSBuildProjectDirectory)\PostBuildEvents\Runner.py"/>
</Target>
</Project>
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