-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetParity.py
More file actions
35 lines (27 loc) · 980 Bytes
/
getParity.py
File metadata and controls
35 lines (27 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python3
import requests
import os
import hashlib
def get_parity_release():
r = requests.get("https://api.github.com/repos/paritytech/parity-ethereum/releases/latest")
b = r.json()
lines = b['body'].split('\r\n')
pkg_line = [l for l in lines if "x86_64-unknown-linux-gnu" in l][0]
p1 = pkg_line.split("[parity](")[1]
(url, p2) = p1.split(") | `")
checksum = p2.split("`")[0]
return (url.replace("http:", "https:"), checksum)
def download_parity(url, checksum):
print("Downloading parity from: %s" % url)
r = requests.get(url)
bin = r.content
got_checksum = hashlib.sha256(bin).hexdigest()
print("Verifying integrity of package")
assert checksum == got_checksum
print("Sha256 checksum verified")
with open(os.path.expanduser("~/parity.bin"), "wb") as f:
f.write(bin)
print("Saved latest parity release to ~/parity.bin")
if __name__ == "__main__":
(url, checksum) = get_parity_release()
download_parity(url, checksum)