Skip to content

Commit

Permalink
Merge pull request #90 from AxFoundation/dispatcher_log_commit
Browse files Browse the repository at this point in the history
Adds commit to startup message
  • Loading branch information
darrylmasson committed Mar 9, 2022
2 parents 5c428de + 7b1501e commit d680f44
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions dispatcher/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

def setup():
# Parse command line
err = None
try:
commit = subprocess.run('git log -n 1 --pretty=oneline'.split(),
capture_output=True
).stdout.decode().split(' ')[0]
except Exception as e:
err = f'Couldn\'t get commit hash: {type(e)}, {e}'
commit = 'unknown'

parser = argparse.ArgumentParser(description='Manage the DAQ')
parser.add_argument('--config', type=str, help='Path to your configuration file',
default='config.ini')
Expand All @@ -27,8 +36,10 @@ def setup():
daq_config = json.loads(config['MasterDAQConfig'])
control_mc = daqnt.get_client('daq')
runs_mc = daqnt.get_client('runs')
logger = daqnt.get_daq_logger(config['LogName'], level=args.log, mc=control_mc)
logger = daqnt.get_daq_logger(config['LogName'], level=args.log, mc=control_mc, opening_message=f'Commit {commit}')
vme_config = json.loads(config['VMEConfig'])
if err is not None:
logger.error(err)

SlackBot = daqnt.DaqntBot(os.environ['SLACK_KEY'])
while True:
Expand Down Expand Up @@ -71,15 +82,6 @@ def main(config, control_mc, logger, daq_config, vme_config, SlackBot, runs_mc,

sleep_period = int(config['PollFrequency'])

try:
commit = subprocess.run('git log -n 1 --pretty=oneline'.split(),
capture_output=True
).stdout.decode().split(' ')[0]
except Exception as e:
logger.debug(f'Couldn\'t get commit hash: {type(e)}, {e}')
commit = 'unknown'
logger.info(f'Dispatcher starting on commit: {commit}')

last_loop_dt = 0

while sh.event.is_set() == False:
Expand Down

0 comments on commit d680f44

Please sign in to comment.