From b8643efe295a520e84bad016f7f2ebde7e9621a3 Mon Sep 17 00:00:00 2001 From: Ben Puls Date: Thu, 29 Aug 2024 18:56:28 +0500 Subject: [PATCH] Refactor code and sorting imports --- utility/update_version.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utility/update_version.py b/utility/update_version.py index 4148cbb..e3fb4bb 100644 --- a/utility/update_version.py +++ b/utility/update_version.py @@ -4,6 +4,7 @@ import json import os import shutil import tempfile + import requests YM_VERSIONS_URL = "https://music-desktop-application.s3.yandex.net/stable/download.json" @@ -13,17 +14,21 @@ ELECTRON_DOWNLOAD_URL = "https://github.com/electron/electron/releases/download/ script_dir = os.path.dirname(os.path.realpath(__file__)) tempdir = tempfile.mkdtemp() + def clear(): shutil.rmtree(tempdir) + atexit.register(clear) + def assert_dependency(dependency): if shutil.which(dependency): return print(f"{dependency} not installed.") exit(1) + # loading versions json versions_obj = requests.get(YM_VERSIONS_URL).json() exe_link = versions_obj["windows"] @@ -74,4 +79,4 @@ version_file = os.path.join(script_dir, "version_info.json") with open(version_file, "w") as f: f.write(json.dumps(version_info, indent=4)) -print(f"Version info written to {version_file}") \ No newline at end of file +print(f"Version info written to {version_file}")