Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import threading
- import time
- from .infrastructure.services.result import Result
- from .infrastructure.database.create_database import CreateDatabase
- from .infrastructure.database.query_database import QueryDatabase
- from .infrastructure.services.helpers import Helpers
- from rich.progress import Progress
- from rich.status import Console
- def start_program():
- helpers = Helpers()
- database_create = CreateDatabase(helpers)
- database_query = QueryDatabase(helpers)
- with Progress() as progress:
- threads = [
- threading.Thread(target=helpers.check_infrastructure_setup),
- threading.Thread(target=database_create.check_for_db_file),
- threading.Thread(target=database_query.check_for_existing_users)
- ]
- task = progress.add_task("Checking Project Setup. . .", total=100)
- for t in threads:
- t.start()
- setup_file_check = helpers.check_infrastructure_setup()
- if not setup_file_check.is_success:
- return Result.fail(setup_file_check.message)
- database_file_check = database_create.check_for_db_file()
- if not database_file_check.is_success:
- return Result.fail(database_file_check.message)
- any_existing_users = database_query.check_for_existing_users()
- if not any_existing_users.is_success:
- return Result.fail(any_existing_users.message)
- for _ in range(100):
- time.sleep(0.1)
- progress.advance(task)
- if len(any_existing_users.value) >= 2:
- print("launching login screen")
- elif len(any_existing_users.value) >= 1:
- print("launching create new user screen")
- print("="*30)
- print("END")
- start_program()
Advertisement
Add Comment
Please, Sign In to add comment