Commit dc832011 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Changed default directory for job logs.

parent a6a6ecbb
......@@ -61,6 +61,18 @@ def silentremove(filename):
raise # re-raise exception if a different error occured
def silentmkdir(path_dir_file):
# type: (str) -> None
while not os.path.isdir(os.path.dirname(path_dir_file)):
try:
os.makedirs(os.path.dirname(path_dir_file))
except OSError as e:
if e.errno != 17:
raise
else:
pass
def gzipfile(iname, oname, compression_level=1, blocksize=None):
blocksize = blocksize if blocksize else 1 << 16 # 64kB
with open(iname, 'rb') as f_in:
......
......@@ -46,17 +46,12 @@ class GMS_logger(logging.Logger):
self.formatter_ConsoleH = logging.Formatter('%(asctime)s' + (' [%s]' % fmt_suffix if fmt_suffix else '') +
': %(message)s', datefmt='%Y/%m/%d %H:%M:%S')
from ..misc.helper_functions import silentmkdir
# set fileHandler
if path_logfile:
# create output directory
while not os.path.isdir(os.path.dirname(path_logfile)):
try:
os.makedirs(os.path.dirname(path_logfile))
except OSError as e:
if e.errno != 17:
raise
else:
pass
silentmkdir(path_logfile)
# create FileHandler
fileHandler = logging.FileHandler(path_logfile, mode='a' if append else 'w')
......@@ -67,9 +62,13 @@ class GMS_logger(logging.Logger):
# set fileHandler for job logfile
if log_to_joblog:
job_logfile = os.path.join(CFG.path_job_logs, '%s.log' % CFG.ID)
# create output directory
silentmkdir(job_logfile)
# create FileHandler
joblog_fileHandler = logging.FileHandler(os.path.join(CFG.path_job_logs, '%s.log' % CFG.ID),
mode='a' if append else 'w')
joblog_fileHandler = logging.FileHandler(job_logfile, mode='a' if append else 'w')
joblog_fileHandler.setFormatter(self.formatter_fileH)
joblog_fileHandler.setLevel(log_level)
else:
......
......@@ -279,7 +279,7 @@ class JobConfig(object):
self.path_job_logs = \
gp('path_job_logs', json_paths['path_job_logs'],
fallback=self.absP(self.DB_config_table['path_job_logs']))
fallback=self.joinP(self.path_fileserver, self.DB_config_table['foldername_job_logs']))
else:
# software test mode, the repository should be self-contained -> use only relative paths
......@@ -289,7 +289,7 @@ class JobConfig(object):
self.path_procdata_MGRS = self.joinP(path_gmslib, '..', 'tests', 'data', 'output_mgrs_tiles')
self.path_ECMWF_db = self.joinP(path_gmslib, '..', 'tests', 'data', 'processed_ECMWF')
self.path_benchmarks = self.joinP(path_gmslib, '..', 'tests', 'data', 'benchmarks')
self.path_job_logs = self.joinP(path_gmslib, 'logs', 'job_logs')
self.path_job_logs = self.joinP(path_gmslib, '..', 'tests', 'data', 'job_logs')
###########################
# processor configuration #
......
......@@ -31,7 +31,8 @@
"benchmark_global": false /*enable/disable benchmark of the whole processing pipeline*/
},
"paths": {
"paths": { /*Set individual paths if you don't want to use the system defaults.*/
"path_fileserver": "",
"path_archive": "", /*input path where downloaded data are stored*/
"path_procdata_scenes": "", /*output path to store processed scenes*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment