Commit b4525abc32c89d7bc78a47d6cde24fa6f62f869c

Authored by Alexis Koralewski
1 parent 8e3c40f8
Exists in dev

Add get_period method in Agent.py

Showing 1 changed file with 24 additions and 0 deletions   Show diff stats
src/core/pyros_django/majordome/agent/Agent.py
... ... @@ -3517,7 +3517,30 @@ class Agent:
3517 3517 ephem_target = pickle.load(open(eph_file,"rb"))
3518 3518 self._oc['config'].fn.fcontext = fcontext0
3519 3519 return ephem_target
  3520 +
  3521 +
  3522 + def get_period(self) -> dict:
  3523 + """Returns a dictionary of the period in various formats
  3524 +
  3525 + Returns:
  3526 + Dictionay of following items:
3520 3527  
  3528 + * id: integer of the period number
  3529 + * Pxxx: string of the period symbol for file names
  3530 + """
  3531 + period_dict = {}
  3532 + operiod = Period.objects.exploitation_period()
  3533 + if operiod == None:
  3534 + log.info("No period valid in the database")
  3535 + raise Exception
  3536 + period_dict['id'] = int(operiod.id)
  3537 + period_id = str(operiod.id)
  3538 + if len(str(operiod.id)) < 3:
  3539 + while len(period_id) < 3:
  3540 + period_id = "0" + period_id
  3541 + period_id = "P" + period_id
  3542 + period_dict['Pxxx'] = period_id
  3543 + return period_dict
3521 3544 """
3522 3545 =================================================================
3523 3546 MAIN
... ... @@ -3539,6 +3562,7 @@ def parse_args(args):
3539 3562 parser = argparse.ArgumentParser(description='Start an agent.')
3540 3563 parser.add_argument("--computer",dest="computer",help='Launch agent with simulated computer hostname',action="store")
3541 3564 parser.add_argument("-t", action="store_true")
  3565 + parser.add_argument("-d", action="store_true" )
3542 3566 args = vars(parser.parse_args(args))
3543 3567 return args
3544 3568  
... ...