Create launcher.py
This commit is contained in:
34
launcher.py
Normal file
34
launcher.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user