def _setup_script_dir(self, email_list):
"""
setup the directory in the log_dir to hold all of the shell scripts we
will generate. Also write the epilogue script to this directory
:param email_list: we need the list of email addresses (usually a
single address) when generating the epilogue script from the
template
"""
script_dir = os.path.join(self.log_dir, _SHELL_SCRIPT_DIR)
try:
os.makedirs(script_dir)
os.chmod(script_dir, stat.S_IRWXU)
if self.need_to_write_epilogue:
with open(self.epilogue_filename, "w") as epilogue_file:
epilogue_file.write(self.generate_epilogue(email_list))
os.chmod(self.epilogue_filename, stat.S_IRWXU)
self.need_to_write_epilogue = False
except OSError as exception:
if exception.errno != errno.EEXIST:
print('Error while creating directory ' + script_dir, file=sys.stderr)
raise
评论列表
文章目录