Skip to content

Commit

Permalink
grouping log files in a single directory (workspace/log)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzanka authored and Michal Szczerba committed Aug 26, 2017
1 parent e02ebcd commit b8c0b28
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions mcpartools/scheduler/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ def __init__(self, scheduler_options):
self.options_args = ""
logger.debug("No scheduler options")
elif os.path.exists(scheduler_options):
opt_fd = open(scheduler_options, 'r')
options_file_content = opt_fd.read()
opt_fd.close()
self.options_header = options_file_content
with open(scheduler_options, 'r') as f:
options_file_content = f.read()
self.options_header = options_file_content
logger.debug("Scheduler options file:" + options_file_content)
self.options_args = ""
logger.debug("Scheduler options file:" + options_file_content)
else:
self.options_header = "# no user options provided"
self.options_args = scheduler_options[1:-1]
Expand Down Expand Up @@ -51,10 +50,9 @@ def main_run_script_body(self, jobs_no, workspace_dir):
return self.main_run_script

def write_submit_script(self, script_path, jobs_no, workspace_dir):
fd = open(script_path, 'w')
abs_path_workspace = os.path.abspath(workspace_dir)
fd.write(self.submit_script_body(jobs_no, abs_path_workspace))
fd.close()
with open(script_path, 'w') as f:
f.write(self.submit_script_body(jobs_no, abs_path_workspace))
os.chmod(script_path, 0o750)
logger.debug("Saved submit script: " + script_path)
logger.debug("Jobs no " + str(jobs_no))
Expand All @@ -63,9 +61,8 @@ def write_submit_script(self, script_path, jobs_no, workspace_dir):
def write_main_run_script(self, jobs_no, output_dir):
output_dir_abspath = os.path.abspath(output_dir)
out_file_path = os.path.join(output_dir_abspath, self.main_run_script)
fd = open(out_file_path, 'w')
fd.write(self.main_run_script_body(jobs_no=jobs_no, workspace_dir=output_dir_abspath))
fd.close()
with open(out_file_path, 'w') as f:
f.write(self.main_run_script_body(jobs_no=jobs_no, workspace_dir=output_dir_abspath))
os.chmod(out_file_path, 0o750)
logger.debug("Saved main run script: " + out_file_path)
logger.debug("Output dir " + output_dir)

0 comments on commit b8c0b28

Please sign in to comment.