Update check app version script
This commit is contained in:
parent
6f5fce61e0
commit
33827f72d5
|
@ -2,38 +2,26 @@
|
|||
import requests
|
||||
from tabulate import tabulate
|
||||
import json
|
||||
import re
|
||||
|
||||
apps = [{"name": "bitcoin/bitcoin", "current_version": "v0.20.1"},
|
||||
{"name": "lightningnetwork/lnd", "current_version": "v0.11.1-beta"},
|
||||
{"name": "lightninglabs/loop", "current_version": "v0.9.0-beta"},
|
||||
{"name": "romanz/electrs", "current_version": "v0.8.5"},
|
||||
{"name": "Ride-The-Lightning/RTL", "current_version": "v0.9.3"},
|
||||
{"name": "janoside/btc-rpc-explorer", "current_version": "v2.0.2"},
|
||||
{"name": "BlueWallet/LndHub", "current_version": "v1.2.0"},
|
||||
{"name": "btcpayserver/btcpayserver", "current_version": "v1.0.5.9"},
|
||||
{"name": "unchained-capital/caravan", "current_version": "v0.3.3"},
|
||||
{"name": "cryptoadvance/specter-desktop", "current_version": "v0.9.2"},
|
||||
{"name": "lnbits/lnbits", "current_version": "6cf4881"},
|
||||
{"name": "apotdevin/thunderhub", "current_version": "v0.10.1"}
|
||||
]
|
||||
apps = [{"name": "bitcoin/bitcoin", "current_version_variable": "BTC_VERSION"},
|
||||
{"name": "lightningnetwork/lnd", "current_version_variable": "LND_VERSION"},
|
||||
{"name": "lightninglabs/loop", "current_version_variable": "LOOP_VERSION"},
|
||||
{"name": "lightninglabs/pool", "current_version_variable": "POOL_VERSION"},
|
||||
{"name": "romanz/electrs", "current_version": "v0.8.5"},
|
||||
{"name": "romanz/electrs", "current_version": "v0.8.6"},
|
||||
{"name": "Ride-The-Lightning/RTL", "current_version_variable": "RTL_VERSION"},
|
||||
{"name": "janoside/btc-rpc-explorer", "current_version_variable": "BTCRPCEXPLORER_VERSION"},
|
||||
{"name": "BlueWallet/LndHub", "current_version_variable": "LNDHUB_VERSION"},
|
||||
{"name": "btcpayserver/btcpayserver", "current_version": "v1.0.5.9"},
|
||||
{"name": "btcpayserver/btcpayserver", "current_version": "v1.0.6.2"},
|
||||
{"name": "unchained-capital/caravan", "current_version_variable": "CARAVAN_VERSION"},
|
||||
{"name": "cryptoadvance/specter-desktop", "current_version_variable": "SPECTER_VERSION"},
|
||||
{"name": "lnbits/lnbits", "current_version": "6cf4881"},
|
||||
{"name": "apotdevin/thunderhub", "current_version_variable": "THUNDERHUB_VERSION"}
|
||||
{"name": "apotdevin/thunderhub", "current_version_variable": "THUNDERHUB_VERSION"},
|
||||
{"name": "whirlpool/whirlpool-client-cli", "current_version": "v0.10.9"},
|
||||
{"name": "dojo/samourai-dojo", "current_version": "v1.8.0"}
|
||||
]
|
||||
|
||||
# Apps that don't work or are not on GitHub
|
||||
# - Samourai Whirlpool
|
||||
# - Samourai Dojo
|
||||
# -
|
||||
|
||||
def needs_update(current, latest):
|
||||
|
@ -58,6 +46,54 @@ def get_current_version_from_variable(version_variable):
|
|||
return "UNKNOWN FAIL"
|
||||
return "UNKNOWN " + version_variable
|
||||
|
||||
def get_app_version_data(app_name, current_version):
|
||||
success = False
|
||||
github_url = "https://api.github.com/repos/" + app_name + "/releases/latest"
|
||||
github_tag_url = "https://api.github.com/repos/" + app_name + "/tags"
|
||||
row=[app_name, current_version, "FAILED", "?"]
|
||||
|
||||
# Try GitHub Releases
|
||||
try:
|
||||
r = requests.get(github_url)
|
||||
j = r.json()
|
||||
latest_version = j["tag_name"]
|
||||
need_update = needs_update(current_version, latest_version)
|
||||
row = [app_name, current_version, latest_version, need_update]
|
||||
success = True
|
||||
except:
|
||||
pass
|
||||
|
||||
# Try GitHub Tags
|
||||
if not success:
|
||||
try:
|
||||
r = requests.get(github_tag_url)
|
||||
j = r.json()
|
||||
latest_version = j[0]["name"]
|
||||
need_update = needs_update(current_version, latest_version)
|
||||
row=[app_name, current_version, latest_version, need_update]
|
||||
success = True
|
||||
except Exception as e:
|
||||
pass
|
||||
#print(str(e))
|
||||
#print(r.content)
|
||||
|
||||
# Try Samourai Whirlpool CLI
|
||||
if (not success and ("whirlpool" in app_name or "dojo" in app_name)):
|
||||
try:
|
||||
samourai_url = "https://code.samourai.io/"+app_name+"/-/tags?format=atom"
|
||||
r = requests.get(samourai_url)
|
||||
matches = re.search( r'/-/tags/(.*?)</id>', str(r.content), re.M)
|
||||
latest_version = matches.group(1)
|
||||
need_update = needs_update(current_version, latest_version)
|
||||
row=[app_name, current_version, latest_version, need_update]
|
||||
success = True
|
||||
except Exception as e:
|
||||
#print(str(e))
|
||||
pass
|
||||
|
||||
|
||||
return row
|
||||
|
||||
def check_app_versions():
|
||||
data=[]
|
||||
for app in apps:
|
||||
|
@ -69,28 +105,7 @@ def check_app_versions():
|
|||
current_version = app["current_version"]
|
||||
|
||||
# Get data from github
|
||||
github_url = "https://api.github.com/repos/" + app["name"] + "/releases/latest"
|
||||
github_tag_url = "https://api.github.com/repos/" + app["name"] + "/tags"
|
||||
row=[]
|
||||
try:
|
||||
r = requests.get(github_url)
|
||||
j = r.json()
|
||||
latest_version = j["tag_name"]
|
||||
need_update = needs_update(current_version, latest_version)
|
||||
row = [app["name"], current_version, latest_version, need_update]
|
||||
except:
|
||||
#print(str(e))
|
||||
#print(r.content)
|
||||
try:
|
||||
r = requests.get(github_tag_url)
|
||||
j = r.json()
|
||||
latest_version = j[0]["name"]
|
||||
need_update = needs_update(current_version, latest_version)
|
||||
row=[app["name"], current_version, latest_version, need_update]
|
||||
except Exception as e:
|
||||
row=[app["name"], current_version, "FAILED", "?"]
|
||||
#print(str(e))
|
||||
#print(r.content)
|
||||
row = get_app_version_data(app["name"], current_version)
|
||||
data.append(row)
|
||||
|
||||
table = tabulate(data, headers=['App', 'myNode Version', 'Latest Version', 'Needs Update'], tablefmt='pretty')
|
||||
|
|
Loading…
Reference in New Issue
Block a user