From 938e9bed87af0ffda762c5338eff166fbcca5751 Mon Sep 17 00:00:00 2001 From: "didierlopes.eth" Date: Mon, 28 Mar 2022 14:57:18 +0100 Subject: [PATCH] Allows to export when using installer (#1568) * fix export for packaged apps * fix filename --- gamestonk_terminal/helper_funcs.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index 99c72465074..d459d21f36d 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -1159,8 +1159,25 @@ def export_data( default_filename = f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}" else: - full_path_dir = dir_path.replace("gamestonk_terminal", "exports") - default_filename = f"{func_name}_{now.strftime('%Y%m%d_%H%M%S')}" + if gtff.PACKAGED_APPLICATION: + default_filename = ( + f"{now.strftime('%Y%m%d_%H%M%S')}_{path_cmd}_{func_name}" + ) + full_path_dir = os.path.join( + os.environ["HOME"], "Desktop", "GST-exports" + ) + + if not os.path.isdir(full_path_dir): + try: + os.makedirs(full_path_dir) + except Exception: + console.print( + f"[red]Couldn't create a folder in {full_path_dir}. Exporting failed.[/red]" + ) + return + else: + default_filename = f"{func_name}_{now.strftime('%Y%m%d_%H%M%S')}" + full_path_dir = dir_path.replace("gamestonk_terminal", "exports") for exp_type in export_type.split(","):