Skip to content

Commit 6133cc9

Browse files
committed
feat(updater): get download url
Signed-off-by: Me0wo <[email protected]>
1 parent 89eebbc commit 6133cc9

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Updater/main.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import json
22
import time
3+
from pathlib import Path
34

45
from Updater.config.yml_loader import get_config
6+
from Updater.updater.assets.name import get_package_name_from_current_machine
57
from Updater.updater.runner.process import find_processes_by_path, try_terminate
68
from Updater.updater.tag.reader import read
7-
from Updater.updater.tag.writer import write
89
from fetch.github_release_api import fetch_latest_release
910
from proxy.http import get_proxies
1011

1112
OWNER = "Sn0wo2"
1213
REPO = "QuickNote"
1314
INTERVAL = 5.0
1415

16+
1517
def main():
1618
result = fetch_latest_release(OWNER, REPO, get_proxies())
1719
print(json.dumps(
@@ -24,16 +26,28 @@ def main():
2426
print("=" * 80)
2527
print(f"New tag: {tag}")
2628

27-
procs = find_processes_by_path(get_config().path.processPath)
29+
procs = find_processes_by_path(Path(get_config().path.workPath, get_config().path.processName))
2830
if not procs:
2931
print("No matching processes found.")
3032
for proc in procs:
3133
try_terminate(proc)
3234

33-
write(tag)
35+
download_url = None
36+
37+
for asset in result.get("assets"):
38+
if asset.get("name") == get_package_name_from_current_machine():
39+
download_url = asset.get("browser_download_url")
40+
break
41+
42+
if download_url is None:
43+
print(f"Could not find asset for {get_package_name_from_current_machine()}")
44+
return
45+
46+
print(download_url)
3447

3548
print("=" * 80)
3649
time.sleep(INTERVAL)
3750

51+
3852
if __name__ == "__main__":
3953
main()

0 commit comments

Comments
 (0)