def set_windows_env_variables(config): import winpath config.set('DEFAULT', 'common_app_data_folder', winpath.get_common_appdata()) config.set('DEFAULT', 'win_local_appdata', winpath.get_local_appdata()) config.set('DEFAULT', 'win_appdata', winpath.get_appdata()) config.set('DEFAULT', 'win_desktop', winpath.get_desktop()) config.set('DEFAULT', 'win_programs', winpath.get_programs()) config.set('DEFAULT', 'win_common_admin_tools', winpath.get_common_admin_tools()) config.set('DEFAULT', 'win_common_documents', winpath.get_common_documents()) config.set('DEFAULT', 'win_cookies', winpath.get_cookies()) config.set('DEFAULT', 'win_history', winpath.get_history()) config.set('DEFAULT', 'win_internet_cache', winpath.get_internet_cache()) config.set('DEFAULT', 'win_my_pictures', winpath.get_my_pictures()) config.set('DEFAULT', 'win_personal', winpath.get_personal()) config.set('DEFAULT', 'win_my_documents', winpath.get_my_documents()) config.set('DEFAULT', 'win_program_files', winpath.get_program_files()) config.set('DEFAULT', 'win_program_files_common', winpath.get_program_files_common()) config.set('DEFAULT', 'win_system', winpath.get_system()) config.set('DEFAULT', 'win_windows', winpath.get_windows()) config.set('DEFAULT', 'win_startup', winpath.get_startup()) config.set('DEFAULT', 'win_recent', winpath.get_recent())
def populate_with_defaults(self): self.config['DATABASE'] = { 'host': '127.0.0.1', 'port': '3050', 'database': 'C:\\FAKT95', 'user': '******', 'password': '******', 'charset': 'UTF8' } self.config['other'] = { 'splits': str([180, 90, 60, 30, 0]), 'output_file': path.join(winpath.get_desktop(), 'Zestawienie'), 'id_firmy': '1', 'to_date': '', 'open_file': '1', }
def get_windows_desktop_path() -> str: return winpath.get_desktop()
def get_save_folder(): """ Obtains the save folder Lets the user pick between automatic save retrieving/copying or a custom save folder Arguments: None Returns: Returns the save folder path Exception: None """ AstroLogging.logPrint("Which folder would you like to work with ?") AstroLogging.logPrint( "\t1) Automatically detect and copy my save folder (Please close Astroneer first)" ) AstroLogging.logPrint("\t2) Chose a custom folder") folder_type = input() while folder_type not in ('1', '2'): AstroLogging.logPrint(f'\nPlease choose 1 or 2') folder_type = input() AstroLogging.logPrint(f'folder_type {folder_type}', 'debug') if folder_type == '1': microsoft_save_folders = get_microsoft_save_folder() if len(microsoft_save_folders) != 1: AstroLogging.logPrint( f'\nToo many save folders found ! Please use custom folder mode.' ) AstroLogging.logPrint('\nPress any key to exit') input() exit(-1) AstroLogging.logPrint( 'Where would you like to copy your save folder ?') AstroLogging.logPrint('\t1) New folder on my desktop') AstroLogging.logPrint("\t2) New folder in a custom path") copy_choice = input() while copy_choice not in ('1', '2'): AstroLogging.logPrint(f'\nPlease choose 1 or 2') copy_choice = input() AstroLogging.logPrint(f'copy_choice {copy_choice}', 'debug') # Using date and time to create a unique folder name now = datetime.now().strftime('%Y.%m.%d-%H.%M') astrosave_folder_name = f'AstroSaveFolder_{now}' if copy_choice == '1': # Winpath is needed here because Windows user can have a custom Desktop location astrosave_folder_path = winpath.get_desktop() elif copy_choice == '2': AstroLogging.logPrint(f'\nEnter your custom folder path:') astrosave_folder_path = input() AstroLogging.logPrint( f'astrosave_folder_path {astrosave_folder_path}', 'debug') save_folder_path = os.path.join(astrosave_folder_path, astrosave_folder_name) AstroLogging.logPrint( f'Microsoft folder path: {microsoft_save_folders[0]}', 'debug') AstroLogging.logPrint(f'Save files copied to: {save_folder_path}') # Creating the new folder and copying the saves and container into it if os.path.isdir(save_folder_path): shutil.rmtree(save_folder_path) shutil.copytree(microsoft_save_folders[0], save_folder_path) elif folder_type == '2': AstroLogging.logPrint(f'\nEnter your custom folder path:') save_folder_path = input() AstroLogging.logPrint(f'save_folder_path {save_folder_path}', 'debug') while not os.path.isdir(save_folder_path): AstroLogging.logPrint( f'\nWrong path for save folder, please enter a valid path : ') save_folder_path = input() AstroLogging.logPrint(f'save_folder_path {save_folder_path}', 'debug') return save_folder_path
def test_desktop(): path = Path(winpath.get_desktop()) os_path = Path(_system_path("Desktop")) assert path == os_path