Skip to content

Commit

Permalink
Force python version and start graceful user shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Sep 6, 2024
1 parent 7cec387 commit c46988c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
14 changes: 9 additions & 5 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,15 @@ def __init__(self, screens, img_host, config):
self.img_host = img_host.lower()
tmdb.API_KEY = config['DEFAULT']['tmdb_api']

async def prompt_user_for_confirmation(self, message):
response = input(f"{message} (Y/n): ").strip().lower()
if response == '' or response == 'y':
return True
return False
async def prompt_user_for_confirmation(self, message: str) -> bool:
try:
response = input(f"{message} (Y/n): ").strip().lower()
if response in ["y", "yes", ""]:
return True
return False
except EOFError:
console.print("[bold red]Input was interrupted.")
return False

async def check_images_concurrently(self, imagelist):
async def check_and_collect(image_dict):
Expand Down
18 changes: 8 additions & 10 deletions upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,11 @@ def get_missing(meta):

if __name__ == '__main__':
pyver = platform.python_version_tuple()
if int(pyver[0]) != 3:
console.print("[bold red]Python2 Detected, please use python3")
exit()
else:
if int(pyver[1]) <= 6:
console.print("[bold red]Python <= 3.6 Detected, please use Python >=3.7")
loop = asyncio.get_event_loop()
loop.run_until_complete(do_the_thing(base_dir))
else:
asyncio.run(do_the_thing(base_dir))
if int(pyver[0]) != 3 or int(pyver[1]) < 12:
console.print("[bold red]Python version is too low. Please use Python 3.12 or higher.")
sys.exit(1)

try:
asyncio.run(do_the_thing(base_dir)) # Pass the correct base_dir value here
except (KeyboardInterrupt, SystemExit):
console.print("[bold red]Program interrupted. Exiting.")

0 comments on commit c46988c

Please sign in to comment.