Skip to content

Instantly share code, notes, and snippets.

@XavierTolza
Created July 2, 2019 15:11
Show Gist options
  • Save XavierTolza/04c6d29957728d5c8c859ea81bb8c5d0 to your computer and use it in GitHub Desktop.
Save XavierTolza/04c6d29957728d5c8c859ea81bb8c5d0 to your computer and use it in GitHub Desktop.
Python script to automatically update rambox from deb
#!python3
import urllib3
import json
import re
import os
user_agent = {'user-agent': 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'}
http = urllib3.PoolManager(10, headers=user_agent)
url = "https://api.github.com/repos/ramboxapp/community-edition/releases"
data = json.loads(http.request('GET', url).data.decode("utf-8"))
assets = data[0]["assets"]
r = re.compile(".+(x86_64|amd64).deb")
valid_assets = [i for i in assets if r.fullmatch(i["name"])]
valid_urls = [i["browser_download_url"] for i in valid_assets]
deb_content = http.request("GET",valid_urls[0]).data
with open("/tmp/rambox.deb","wb") as f:
f.write(deb_content)
os.system("gdebi -n /tmp/rambox.deb")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment