From 52d59c7cb43d18c18182893ac90feb971eac7a09 Mon Sep 17 00:00:00 2001 From: JGStew Date: Tue, 25 Jun 2024 10:18:48 -0400 Subject: [PATCH] fix export path for plugin --- examples/export_all_sites.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/examples/export_all_sites.py b/examples/export_all_sites.py index 99e868a..9e37b1c 100644 --- a/examples/export_all_sites.py +++ b/examples/export_all_sites.py @@ -89,7 +89,13 @@ def main(): parser.add_argument("-r", "--rest-url", help="Specify the REST URL", required=False) parser.add_argument("-u", "--user", help="Specify the username", required=False) parser.add_argument("-p", "--password", help="Specify the password", required=False) - parser.add_argument("-d", "--delete", help="delete previous export", required=False, action='store_true') + parser.add_argument( + "-d", + "--delete", + help="delete previous export", + required=False, + action="store_true", + ) # allow unknown args to be parsed instead of throwing an error: args, _unknown = parser.parse_known_args() @@ -164,16 +170,18 @@ def main(): except AttributeError: bes_conn = besapi.besapi.get_bes_conn_using_config_file() + export_folder = os.path.join(invoke_folder, "export") + # if --delete arg used, delete export folder: if args.delete: - shutil.rmtree("export", ignore_errors=True) + shutil.rmtree(export_folder, ignore_errors=True) try: - os.mkdir("export") + os.mkdir(export_folder) except FileExistsError: logging.warning("Folder already exists!") - os.chdir("export") + os.chdir(export_folder) bes_conn.export_all_sites()