Migrate all py to rhai woo hoooo

This commit is contained in:
windowsboy111
2022-12-05 19:32:21 +08:00
parent 04a6d0f7f9
commit 741d90a9df
9 changed files with 31 additions and 133 deletions
+3 -5
View File
@@ -1,7 +1,5 @@
let req = new_req("https://api.snapcraft.io/v2/snaps/info/authy");
req.head("Snap-Device-Series", "16");
let obj = json(req.get());
let obj2 = get_json(obj, "channel-map");
let obj3 = get_json(obj2, 0);
rpm.version(string_json(get_json(obj3, "version")));
rpm.source(0, string_json(obj3.get_json("download").get_json("url")));
let obj = json(req.get()) @ "channel-map" @ 0;
rpm.version(str(obj @ "version"));
rpm.source(0, str(obj @ "download" @ "url"));
-38
View File
@@ -1,38 +0,0 @@
import os
import re
from requests import get
NAME = 'discord-canary'
SPEC = f'{NAME}.spec'
REGEX = r'Version:(\s+)([\.\d]+)\n'
REGEX_LINK = r'https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/'
LINK = 'https://discordapp.com/api/download/canary?platform=linux&format=tar.gz'
def run_cmds(*cmds: str):
for cmd in cmds:
print(f"{NAME}: $ {cmd}")
if rc := os.system(cmd):
exit(f"{NAME}: Stopping because {rc=}")
html = get(LINK, allow_redirects=False).text
newver = re.findall(REGEX_LINK, html)
if not any(newver):
exit(f"{NAME}: Failed to parse html!")
newver = newver[0]
f = open(SPEC, 'r')
content = f.read()
found = re.findall(REGEX, content)
try:
assert found
curver = found[0][1]
if newver == curver:
exit(f"{NAME}: Up to date!")
else:
print(f"{NAME}: {curver} -> {newver}")
except IndexError or AssertionError:
exit(f"{NAME}: Failed to read spec!")
run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}')
+3
View File
@@ -0,0 +1,3 @@
let html = get("https://discordapp.com/api/download/canary?platform=linux&format=tar.gz");
let newver = str(find("https://dl-canary\.discordapp\.net/apps/linux/([\.\d]+)/", html, 1) @ 0);
rpm.version(newver);
-38
View File
@@ -1,38 +0,0 @@
import os
import re
from requests import get
NAME = 'discord-ptb'
SPEC = f'{NAME}.spec'
REGEX = r'Version:(\s+)([\.\d]+)\n'
REGEX_LINK = r'https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/'
LINK = 'https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz'
def run_cmds(*cmds: str):
for cmd in cmds:
print(f"{NAME}: $ {cmd}")
if rc := os.system(cmd):
exit(f"{NAME}: Stopping because {rc=}")
html = get(LINK, allow_redirects=False).text
newver = re.findall(REGEX_LINK, html)
if not any(newver):
exit(f"{NAME}: Failed to parse html!")
newver = newver[0]
f = open(SPEC, 'r')
content = f.read()
found = re.findall(REGEX, content)
try:
assert found
curver = found[0][1]
if newver == curver:
exit(f"{NAME}: Up to date!")
else:
print(f"{NAME}: {curver} -> {newver}")
except IndexError or AssertionError:
exit(f"{NAME}: Failed to read spec!")
run_cmds(f'rpmdev-bumpspec -n {newver} {SPEC}')
+3
View File
@@ -0,0 +1,3 @@
let html = get("https://discordapp.com/api/download/ptb?platform=linux&format=tar.gz");
let newver = str(find("https://dl-ptb\.discordapp\.net/apps/linux/([\.\d]+)/", html, 1) @ 0);
rpm.version(newver);
@@ -1,26 +0,0 @@
import requests, re, os
from datetime import datetime
NAME = 'prismlauncher-nightly'
REPO = "PrismLauncher/PrismLauncher"
REGEX_SHA = r'%global commit (.+)'
SPEC = f"{NAME}.spec"
LINK = f'https://api.github.com/repos/{REPO}/commits/HEAD'
sha = requests.get(LINK, headers={'Authorization': 'Bearer ' + os.getenv('GITHUB_TOKEN')}).json()['sha']
f = open(SPEC, 'r')
matches = re.findall(REGEX_SHA, txt:=f.read())
if not len(matches): exit(f"{NAME}: Failed to match regex!")
cur = matches[0]
if sha == cur: exit(f'{NAME}: Up to date!')
print(f'{NAME}: {cur} -> {sha}')
newspec = re.sub(REGEX_SHA, f'%global commit {sha}', txt)
f.close()
f = open(SPEC, 'w')
f.write(newspec)
f.close()
@@ -0,0 +1,11 @@
let req = new_req("https://api.github.com/repos/PrismLauncher/PrismLauncher/commits/HEAD");
req.head("Authorization", `Bearer ${env("GITHUB_TOKEN")}`);
let _sha = json(req.get()) @ "sha";
let sha = _sha.str();
let cur = find("%global commit (.+)", rpm.f, 1);
if sha != cur {
print(`prismlauncher-nightly: ${cur} -> ${sha}`);
rpm.f = sub("%global commit (.+)", `%global commit ${sha}`, rpm.f);
} else {
print("prismlauncher-nightly: Up to date!");
}
@@ -1,26 +0,0 @@
import requests, re, os
from datetime import datetime
NAME = 'prismlauncher-qt5-nightly'
REPO = "PrismLauncher/PrismLauncher"
REGEX_SHA = r'%global commit (.+)'
SPEC = f"{NAME}.spec"
LINK = f'https://api.github.com/repos/{REPO}/commits/HEAD'
sha = requests.get(LINK, headers={'Authorization': 'Bearer ' + os.getenv('GITHUB_TOKEN')}).json()['sha']
f = open(SPEC, 'r')
matches = re.findall(REGEX_SHA, txt:=f.read())
if not len(matches): exit(f"{NAME}: Failed to match regex!")
cur = matches[0]
if sha == cur: exit(f'{NAME}: Up to date!')
print(f'{NAME}: {cur} -> {sha}')
newspec = re.sub(REGEX_SHA, f'%global commit {sha}', txt)
f.close()
f = open(SPEC, 'w')
f.write(newspec)
f.close()
@@ -0,0 +1,11 @@
let req = new_req("https://api.github.com/repos/PrismLauncher/PrismLauncher/commits/HEAD");
req.head("Authorization", `Bearer ${env("GITHUB_TOKEN")}`);
let _sha = json(req.get()) @ "sha";
let sha = _sha.str();
let cur = find("%global commit (.+)", rpm.f, 1);
if sha != cur {
print(`prismlauncher-qt5-nightly: ${cur} -> ${sha}`);
rpm.f = sub("%global commit (.+)", `%global commit ${sha}`, rpm.f);
} else {
print("prismlauncher-qt5-nightly: Up to date!");
}