Skip to content

Instantly share code, notes, and snippets.

@yurtaev
Last active October 22, 2020 21:15
Show Gist options
  • Save yurtaev/692d7ff64587ae838039 to your computer and use it in GitHub Desktop.
Save yurtaev/692d7ff64587ae838039 to your computer and use it in GitHub Desktop.
"""
requirements:
- requests http://docs.python-requests.org/en/latest/
- requests-toolbelt https://toolbelt.readthedocs.org/en/latest/
pip install requests requests-toolbelt
"""
import requests
from requests.auth import HTTPBasicAuth
from requests_toolbelt import MultipartEncoder
host = 'omaha-server-dev.elasticbeanstalk.com'
username = 'username'
password = 'password'
#
# Upload Symbols file
#
file_path = 'BreakpadTestApp.sym'
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/symbols/'
files = dict(file=open(file_path, 'rb'))
r = requests.post(url, files=files, auth=HTTPBasicAuth(username, password))
print r.text
#
# Version List
#
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/omaha/version/'
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
#
# Upload New Version
#
path_to_new_version_file = '/data/chromium.exe'
data = MultipartEncoder(
fields=dict(
app='{8A76FC95-0086-4BCE-9517-DC09DDB5652F}',
channel='1',
platform='1',
version='1.2.3.4',
file=(file_path, open(path_to_new_version_file, 'rb'), 'text/plain'),
)
)
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/omaha/version/'
r = requests.post(
url, data=data, auth=HTTPBasicAuth(username, password), headers={'Content-Type': data.content_type})
print r.text
#
# Add Action for Omaha Version
#
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/action/'
data = dict(
version=11,
event=1
)
r = requests.post(url, data=data, auth=HTTPBasicAuth(username, password))
print r.text
#
# Sparkle Version List
#
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/omaha/version/'
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
#
# Upload New Sparkle Version
#
path_to_new_version_file = '/data/chromium.dmg'
data = MultipartEncoder(
fields=dict(
app='{8A76FC95-0086-4BCE-9517-DC09DDB5652F}',
channel='1',
version='3.4',
short_version='1.2.3.4',
dsa_signature='MCwCFFjHuSSd/QKCuIJsl7T2GDQd1NeZAhRqnZqXoFdpbfzyaE772N0TISwFzQ==',
file=('BreakpadTestApp.sym', open(path_to_new_version_file, 'rb'), 'text/plain'),
)
)
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/sparkle/version/'
r = requests.post(
url, data=data, auth=HTTPBasicAuth(username, password), headers={'Content-Type': data.content_type})
print r.text
#
# Overall Statistics: users (by months)
#
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/statistics/months/'
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
#
# Statistics for app: users (by months)
#
app_name = 'Chromium'
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/statistics/months/%s/' % app_name
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
#
# Statistics for app: users (by versions)
#
app_name = 'Chromium'
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/statistics/versions/%s/' % app_name
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
#
# Statistics for app: users (by channels)
#
app_name = 'Chromium'
url = 'http://omaha-server-dev.elasticbeanstalk.com/api/statistics/channels/%s/' % app_name
r = requests.get(url, auth=HTTPBasicAuth(username, password))
print r.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment