From 1988b1e16fa862d4864ae916814574561636ba30 Mon Sep 17 00:00:00 2001 From: Alexandre Pron Date: Wed, 4 Dec 2024 14:11:10 +0100 Subject: [PATCH 1/4] [ENH]: put log files in a dedicated log dir --- shanoir_downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shanoir_downloader.py b/shanoir_downloader.py index b0452a7..755b65f 100644 --- a/shanoir_downloader.py +++ b/shanoir_downloader.py @@ -44,7 +44,7 @@ def add_configuration_arguments(parser): parser.add_argument('-ca', '--certificate', default='', required=False, help='Path to the CA bundle to use.') parser.add_argument('-v', '--verbose', default=False, action='store_true', help='Print log messages.') parser.add_argument('-t', '--timeout', type=float, default=60*4, help='The request timeout.') - parser.add_argument('-lf', '--log_file', type=str, help="Path to the log file. Default is output_folder/downloads.log", default=None) + parser.add_argument('-lf', '--log_file', type=str, help="Path to the log file. Default is output_folder/shanoir_downloader_logs/downloads.log", default=None) return parser def add_ids_arguments(parser): @@ -58,7 +58,7 @@ def init_logging(args): verbose = args.verbose - logfile = Path(args.log_file) if args.log_file else Path(args.output_folder) / f'downloads{datetime.datetime.now().strftime("%Y-%m-%d_%Hh%Mm%S")}.log' + logfile = Path(args.log_file) if args.log_file else Path(args.output_folder, "shanoir_downloader_logs", f'downloads{datetime.datetime.now().strftime("%Y-%m-%d_%Hh%Mm%S")}.log') logfile.parent.mkdir(exist_ok=True, parents=True) logging.basicConfig( From b6305e569afa71587efc20e598550c30e74f2aa5 Mon Sep 17 00:00:00 2001 From: Alexandre Pron Date: Wed, 4 Dec 2024 14:23:24 +0100 Subject: [PATCH 2/4] Revert "[ENH]: put log files in a dedicated log dir" This reverts commit 1988b1e16fa862d4864ae916814574561636ba30. --- shanoir_downloader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shanoir_downloader.py b/shanoir_downloader.py index 755b65f..b0452a7 100644 --- a/shanoir_downloader.py +++ b/shanoir_downloader.py @@ -44,7 +44,7 @@ def add_configuration_arguments(parser): parser.add_argument('-ca', '--certificate', default='', required=False, help='Path to the CA bundle to use.') parser.add_argument('-v', '--verbose', default=False, action='store_true', help='Print log messages.') parser.add_argument('-t', '--timeout', type=float, default=60*4, help='The request timeout.') - parser.add_argument('-lf', '--log_file', type=str, help="Path to the log file. Default is output_folder/shanoir_downloader_logs/downloads.log", default=None) + parser.add_argument('-lf', '--log_file', type=str, help="Path to the log file. Default is output_folder/downloads.log", default=None) return parser def add_ids_arguments(parser): @@ -58,7 +58,7 @@ def init_logging(args): verbose = args.verbose - logfile = Path(args.log_file) if args.log_file else Path(args.output_folder, "shanoir_downloader_logs", f'downloads{datetime.datetime.now().strftime("%Y-%m-%d_%Hh%Mm%S")}.log') + logfile = Path(args.log_file) if args.log_file else Path(args.output_folder) / f'downloads{datetime.datetime.now().strftime("%Y-%m-%d_%Hh%Mm%S")}.log' logfile.parent.mkdir(exist_ok=True, parents=True) logging.basicConfig( From 82e70fbae647ad6d38b18de7173b0c98ea4c316f Mon Sep 17 00:00:00 2001 From: Alexandre Pron Date: Wed, 4 Dec 2024 14:26:16 +0100 Subject: [PATCH 3/4] [ENH]: put log files in a dedicated log dir (shanoir2bids) --- shanoir2bids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shanoir2bids.py b/shanoir2bids.py index bdaf86d..b21f679 100755 --- a/shanoir2bids.py +++ b/shanoir2bids.py @@ -383,7 +383,7 @@ def set_log_filename(self): curr_time.minute, curr_time.second, ) - self.log_fn = opj(self.dl_dir, basename) + self.log_fn = opj(self.dl_dir, 'shanoir_downloader_logs', basename) def toggle_longitudinal_version(self): self.longitudinal = True From c5ed7803128fda9e8fe8dfac8484317cb754eeff Mon Sep 17 00:00:00 2001 From: Alexandre Pron Date: Wed, 4 Dec 2024 14:49:52 +0100 Subject: [PATCH 4/4] [ENH]: put log files in a dedicated log dir (shanoir2bids) --- shanoir2bids.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shanoir2bids.py b/shanoir2bids.py index b21f679..f3bf813 100755 --- a/shanoir2bids.py +++ b/shanoir2bids.py @@ -383,6 +383,9 @@ def set_log_filename(self): curr_time.minute, curr_time.second, ) + dir_log = opj(self.dl_dir, 'shanoir_downloader_logs') + if not ope(dir_log): + Path(dir_log).mkdir(parents=True, exist_ok=True) self.log_fn = opj(self.dl_dir, 'shanoir_downloader_logs', basename) def toggle_longitudinal_version(self):