Commit 6c81456d90ddbd4b94244b172ccae307b36463df

Authored by Etienne Pallier
1 parent c7318a4a
Exists in dev

Nouvelle méthode command.get_updated_result()

Démonstration d'utilisation dans "pyros shell" page 127
Showing 3 changed files with 9 additions and 5 deletions   Show diff stats
@@ -71,7 +71,7 @@ Date: 22/03/2019 @@ -71,7 +71,7 @@ Date: 22/03/2019
71 71
72 Author: E. Pallier 72 Author: E. Pallier
73 73
74 -VERSION: 0.20.25 74 +VERSION: 0.20.26
75 75
76 Comment: mode "test" (-t) géré (= mode simulateur) 76 Comment: mode "test" (-t) géré (= mode simulateur)
77 77
src/agent/Agent.py
@@ -704,7 +704,7 @@ class Agent: @@ -704,7 +704,7 @@ class Agent:
704 if param['section']=="assembly" and param['key']=="alias": 704 if param['section']=="assembly" and param['key']=="alias":
705 assembled_aliases.append(param['value']) 705 assembled_aliases.append(param['value'])
706 #print(f"Unit {unit_alias} is the assembly of {assembled_aliases}") 706 #print(f"Unit {unit_alias} is the assembly of {assembled_aliases}")
707 - 707 +
708 print("--------- Components of the unit -----------") 708 print("--------- Components of the unit -----------")
709 print("Configuration file is {}".format(self.config.get_configfile())) 709 print("Configuration file is {}".format(self.config.get_configfile()))
710 alias = self.config.get_aliases('unit')[0] 710 alias = self.config.get_aliases('unit')[0]
@@ -722,15 +722,15 @@ class Agent: @@ -722,15 +722,15 @@ class Agent:
722 assembled_mount_aliases.append(alias) 722 assembled_mount_aliases.append(alias)
723 elif unit_subtag=="channel": 723 elif unit_subtag=="channel":
724 assembled_channel_aliases.append(alias) 724 assembled_channel_aliases.append(alias)
725 - 725 +
726 print("--------- Assembly of the unit -----------") 726 print("--------- Assembly of the unit -----------")
727 print(f"Assembled mount aliases: {assembled_mount_aliases}") 727 print(f"Assembled mount aliases: {assembled_mount_aliases}")
728 print(f"Assembled channel aliases: {assembled_channel_aliases}") 728 print(f"Assembled channel aliases: {assembled_channel_aliases}")
729 - 729 +
730 # --- Get the home of the mount[0] 730 # --- Get the home of the mount[0]
731 mount_alias = assembled_mount_aliases[0] 731 mount_alias = assembled_mount_aliases[0]
732 home = self.config.get_param(mount_alias,'MountPointing','home') 732 home = self.config.get_param(mount_alias,'MountPointing','home')
733 - 733 +
734 print("------------------------------------------") 734 print("------------------------------------------")
735 hostname = socket.gethostname() 735 hostname = socket.gethostname()
736 self._computer_alias = '' 736 self._computer_alias = ''
src/common/models.py
@@ -482,6 +482,10 @@ class Command(models.Model): @@ -482,6 +482,10 @@ class Command(models.Model):
482 def get_result(self): 482 def get_result(self):
483 return self.result 483 return self.result
484 484
  485 + def get_updated_result(self):
  486 + self.refresh_from_db()
  487 + return self.result
  488 +
485 def set_result(self, result:str): 489 def set_result(self, result:str):
486 self.result = result 490 self.result = result
487 self.save() 491 self.save()