Commit 80192fe90927337651bd2a14e417989e9fbc9a72

Authored by Alain Klotz
1 parent 7a3253ee
Exists in dev

Affichage d'informations de config.xml

config/config_unit_simulunit1.xml
... ... @@ -37,6 +37,7 @@ options : HTML tag <option> contents in case of HTML element <select>
37 37 <date_creation>2018-04-13 00:38:14</date_creation>
38 38 <date_last_modification>2019-02-18 16:38:00</date_last_modification>
39 39 <author_last_modification>Alain Klotz</author_last_modification>
  40 + <param section="unit" key="name" value="Unit of simulation No 1"/>
40 41  
41 42 <!-- Select the unit as one mount and one or more channels -->
42 43 <param section="assembly" key="alias" value="PyROSDatabase" comment="database"/>
... ... @@ -45,6 +46,7 @@ options : HTML tag &lt;option&gt; contents in case of HTML element &lt;select&gt;
45 46  
46 47 <!-- A database definition -->
47 48 <database alias="PyROSDatabase">
  49 + <param section="database" key="name" value="PyROS database"/>
48 50 <!-- Select the type of database (DBMS) -->
49 51 <param section="management" key="system" value="MySQL"/>
50 52 <!-- Access autorizations -->
... ...
config/configpyros.py
... ... @@ -41,6 +41,7 @@ class ConfigPyros:
41 41 _tags_to_scan = None
42 42 # --- XML contents
43 43 _config_contents_valid = False
  44 + _config_contents_changed = False
44 45 _tree = None
45 46 _root = None
46 47 _unit_subtags = None
... ... @@ -419,6 +420,11 @@ class ConfigPyros:
419 420 """ Get the current config file name
420 421 """
421 422 return self._config_filename
  423 +
  424 + def is_config_contents_changed(self):
  425 + response =self._config_contents_changed
  426 + self._config_contents_changed = False
  427 + return response
422 428  
423 429 def load(self, verbose:bool = False, force:bool = False):
424 430 """ To load the config file if necessary
... ... @@ -436,6 +442,7 @@ class ConfigPyros:
436 442 print("Load Error = {}".format(errno))
437 443 return
438 444 if self._config_filename_need_to_be_read == False and force == False:
  445 + self._config_contents_changed = False
439 446 return
440 447  
441 448 # --- Read the configuration file and parse it
... ... @@ -462,6 +469,7 @@ class ConfigPyros:
462 469 # --- Validation step
463 470 if valid == True:
464 471 self._config_filename_mtime = os.path.getmtime(self._config_filename)
  472 + self._config_contents_changed = True
465 473 else:
466 474 # --- Se the current tree and root from '_old'
467 475 self._config_contents_valid = False
... ... @@ -591,6 +599,7 @@ class ConfigPyros:
591 599 self._last_errno = self.NO_ERROR
592 600 self._unit_component_params = []
593 601 self.set_configfile(config_filename)
  602 + self._configfile_changed = False
594 603  
595 604 # =====================================================================
596 605 # =====================================================================
... ...
src/agent/Agent.py
... ... @@ -277,11 +277,23 @@ class Agent:
277 277 raise Exception(f"error {str(self.config.get_last_errno())}: {str(self.config.get_last_errmsg())}")
278 278 # --- display informations
279 279 # --- Get all the assembly of this unit[0] (mount + channels)
280   - unit_alias = self.config.get_aliases('unit')[0]
281   - print("Unit alias is {}".format(unit_alias))
282   - #params = self.config.get_params(unit_alias)
283   - #for param in params:
284   - # print("Unit component is {}".format(param))
  280 + if self.config.is_config_contents_changed():
  281 + print("--------- Components of the unit -----------")
  282 + print("Configuration file is {}".format(self.config.get_configfile()))
  283 + alias = self.config.get_aliases('unit')[0]
  284 + namevalue = self.config.get_paramvalue(alias,'unit','name')
  285 + print("Unit alias is {}. Name is {}".format(alias,namevalue))
  286 + unit_subtags = self.config.get_unit_subtags()
  287 + for unit_subtag in unit_subtags:
  288 + aliases = self.config.get_aliases(unit_subtag)
  289 + for alias in aliases:
  290 + namevalue = self.config.get_paramvalue(alias,unit_subtag,'name')
  291 + print("Unit {} alias is {}. Name is {}".format(unit_subtag,alias,namevalue))
  292 + print("------------------------------------------")
  293 +
  294 + #params = self.config.get_params(unit_alias)
  295 + #for param in params:
  296 + # print("Unit component is {}".format(param))
285 297  
286 298 """
287 299 # self.config = Config.objects.get(pk=1)
... ...