mekasu0124

Untitled

May 5th, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. import threading
  2. import time
  3.  
  4. from .infrastructure.services.result import Result
  5. from .infrastructure.database.create_database import CreateDatabase
  6. from .infrastructure.database.query_database import QueryDatabase
  7. from .infrastructure.services.helpers import Helpers
  8.  
  9. from rich.progress import Progress
  10. from rich.status import Console
  11.  
  12. def start_program():
  13.     helpers = Helpers()
  14.     database_create = CreateDatabase(helpers)
  15.     database_query = QueryDatabase(helpers)
  16.  
  17.     with Progress() as progress:
  18.         threads = [
  19.             threading.Thread(target=helpers.check_infrastructure_setup),
  20.             threading.Thread(target=database_create.check_for_db_file),
  21.             threading.Thread(target=database_query.check_for_existing_users)
  22.         ]
  23.  
  24.         task = progress.add_task("Checking Project Setup. . .", total=100)
  25.  
  26.         for t in threads:
  27.             t.start()
  28.  
  29.         setup_file_check = helpers.check_infrastructure_setup()
  30.  
  31.         if not setup_file_check.is_success:
  32.             return Result.fail(setup_file_check.message)
  33.  
  34.         database_file_check = database_create.check_for_db_file()
  35.  
  36.         if not database_file_check.is_success:
  37.             return Result.fail(database_file_check.message)
  38.        
  39.         any_existing_users = database_query.check_for_existing_users()
  40.  
  41.         if not any_existing_users.is_success:
  42.             return Result.fail(any_existing_users.message)
  43.        
  44.         for _ in range(100):
  45.             time.sleep(0.1)
  46.             progress.advance(task)
  47.    
  48.         if len(any_existing_users.value) >= 2:
  49.             print("launching login screen")
  50.         elif len(any_existing_users.value) >= 1:
  51.             print("launching create new user screen")
  52.        
  53.         print("="*30)
  54.         print("END")
  55.  
  56. start_program()
  57.  
Advertisement
Add Comment
Please, Sign In to add comment