Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import json
- from rich.status import Console
- from DreamersDiscoveries.infrastructure.services.result import Result
- class Helpers:
- def __init__(self):
- self.file_path = ""
- self.console = Console()
- def check_infrastructure_setup(self):
- src_path = 'src'
- sub_path = os.path.join(src_path, 'DreamersDiscoveries')
- infrastructure_path = os.path.join(sub_path, 'infrastructure')
- setup_path = os.path.join(infrastructure_path, 'setup')
- self.file_path = os.path.join(setup_path, 'settings.json')
- if not os.path.exists(setup_path):
- os.makedirs(setup_path)
- setup_file_check = self.create_setup_file()
- if not setup_file_check.is_success:
- return Result.fail(setup_file_check.message)
- return Result.ok("Setup File Create Successfully")
- return Result.ok("Setup File Already Exists")
- def create_setup_file(self):
- if not os.path.exists(self.file_path):
- try:
- with open(self.file_path, 'w') as file:
- data = {"setup": False}
- json.dump(data, file, indent=4)
- return Result.ok("Setup File Created Successfully")
- except Exception as e:
- return Result.fail(e)
- return Result.ok("Setup File Created Successfully")
- def build_database_path(self):
- src_path = 'src'
- sub_path = os.path.join(src_path, 'DreamersDiscoveries')
- infrastructure_path = os.path.join(sub_path, 'infrastructure')
- db_path = os.path.join(infrastructure_path, "database")
- file_path = os.path.join(db_path, 'main.db')
- return file_path
Advertisement
Add Comment
Please, Sign In to add comment