From af72dd1f3520e488ec02a6d0d3edac7de795ecbd Mon Sep 17 00:00:00 2001 From: McCloudS <64094529+McCloudS@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:22:43 -0700 Subject: [PATCH] Create launcher.py --- launcher.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 launcher.py diff --git a/launcher.py b/launcher.py new file mode 100644 index 0000000..f4f25cf --- /dev/null +++ b/launcher.py @@ -0,0 +1,34 @@ +import os +import requests + +def convert_to_bool(in_bool): + if isinstance(in_bool, bool): + return in_bool + else: + value = str(in_bool).lower() + return value not in ('false', 'off', '0', 0) + +def download_from_github(url, output_file): + response = requests.get(url) + if response.status_code == 200: + with open(output_file, 'wb') as f: + f.write(response.content) + print(f"File downloaded successfully to {output_file}") + else: + print(f"Failed to download file from {url}") + +def main(): + github_url = "https://raw.githubusercontent.com/McCloudS/subgen/main/subgen/subgen.py" + output_file = "subgen.py" + + # Check if the environment variable is set + github_download_enabled = convert_to_bool(os.getenv("UPDATE", False)) + + if github_download_enabled: + print("Downloading subgen.py from GitHub...") + download_from_github(github_url, output_file) + else: + print("Environment variable UPDATE is not set or set to False, skipping download.") + +if __name__ == "__main__": + main()