Skip to content

Commit

Permalink
Change user variable naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mjaehn committed Sep 20, 2023
1 parent 2199b88 commit e8f781e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions run_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class Config():

def __init__(self, casename):
# Global attributes (initialized with default values)
self.casename = casename
self.user = os.environ['USER']
self.user_name = os.environ['USER']
self.set_email()
self.casename = casename

self.chain_src_dir = os.getcwd()
self.path = os.path.join(self.chain_src_dir, self.casename)
Expand Down Expand Up @@ -149,7 +149,7 @@ def load_config_file(self, casename):
return self

def set_account(self):
if self.user == 'jenkins':
if self.user_name == 'jenkins':
# g110 account for Jenkins testing
self.compute_account = 'g110'
elif os.path.exists(os.environ['HOME'] + '/.acct'):
Expand Down Expand Up @@ -179,13 +179,13 @@ def set_node_info(self):
return self

def set_email(self):
if self.user == 'jenkins':
self.mail_address = None
if self.user_name == 'jenkins':
self.user_mail = None
elif os.path.exists(os.environ['HOME'] + '/.forward'):
with open(os.environ['HOME'] + '/.forward', 'r') as file:
self.mail_address = file.read().rstrip()
self.user_mail = file.read().rstrip()
else:
self.mail_address = None
self.user_mail = None

return self

Expand Down Expand Up @@ -501,24 +501,24 @@ def run_chain(work_root, model_cfg, cfg, start_time, hstart, hstop, job_names,
subject = "ERROR or TIMEOUT in job '%s' for chain '%s'" % (
job, job_id)
logging.exception(subject)
if cfg.mail_address:
if cfg.user_mail:
message = tools.prepare_message(
os.path.join(log_working_dir, job))
logging.info('Sending log file to %s' %
cfg.mail_address)
tools.send_mail(cfg.mail_address, subject, message)
cfg.user_mail)
tools.send_mail(cfg.user_mail, subject, message)
if try_count == 0:
raise RuntimeError(subject)

if exitcode != 0 or not os.path.exists(
os.path.join(log_finished_dir, job)):
subject = "ERROR or TIMEOUT in job '%s' for chain '%s'" % (
job, job_id)
if cfg.mail_address:
if cfg.user_mail:
message = tools.prepare_message(
os.path.join(log_working_dir, job))
logging.info('Sending log file to %s' % cfg.mail_address)
tools.send_mail(cfg.mail_address, subject, message)
logging.info('Sending log file to %s' % cfg.user_mail)
tools.send_mail(cfg.user_mail, subject, message)
raise RuntimeError(subject)


Expand Down

0 comments on commit e8f781e

Please sign in to comment.