Skip to content

Instantly share code, notes, and snippets.

@steveoh steveoh/soe.csproj

Last active Dec 17, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.