Commit 88767c841703161e2fca50894f006b85e1b1868b
1 parent
fbfe7abb
Exists in
dev
new agent = Agent -- et new script wrapper PYROS multiplateforme
Showing
4 changed files
with
81 additions
and
71 deletions
Show diff stats
src/core/pyros_django/agent/Agent.py
... | ... | @@ -1637,6 +1637,74 @@ if __name__ == "__main__": |
1637 | 1637 | #RUN_IN_THREAD=False |
1638 | 1638 | |
1639 | 1639 | agent = build_agent(Agent, RUN_IN_THREAD=RUN_IN_THREAD) |
1640 | + obs_config_file_path = os.environ["PATH_TO_OBSCONF_FILE"] | |
1641 | + path_to_obs_config_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] | |
1642 | + unit = os.environ["unit_name"] | |
1643 | + print("TOTO") | |
1644 | + agent.printd(obs_config_file_path) | |
1645 | + agent.printd(path_to_obs_config_folder) | |
1646 | + agent.printd(unit) | |
1647 | + from src.core.pyros_django.obsconfig.configpyros import ConfigPyros | |
1648 | + oc = ConfigPyros(obs_config_file_path) | |
1649 | + | |
1650 | + print("\n") | |
1651 | + print("- Observatory:", oc.get_obs_name()) | |
1652 | + | |
1653 | + my_unit_name = oc.get_units_name()[0] | |
1654 | + my_unit = (oc.get_units()[my_unit_name]) | |
1655 | + #print("- Unit description:", my_unit) | |
1656 | + | |
1657 | + print("\n") | |
1658 | + print("- Computers:", oc.get_computers()) | |
1659 | + | |
1660 | + print("\n") | |
1661 | + print("- Active Computers:", oc.get_active_computers()) | |
1662 | + | |
1663 | + print("\n") | |
1664 | + print("- Active Devices:", oc.get_active_devices()) | |
1665 | + | |
1666 | + print("\n") | |
1667 | + print("- Unit:", my_unit_name) | |
1668 | + print(oc.get_unit_by_name(my_unit_name)) | |
1669 | + | |
1670 | + print("\n") | |
1671 | + print("- Unit topology:", oc.get_topology(my_unit_name)) | |
1672 | + | |
1673 | + print("\n") | |
1674 | + print("- Unit active Agents:", oc.get_active_agents(my_unit_name)) | |
1675 | + print(oc.get_agents(my_unit_name)) | |
1676 | + | |
1677 | + print("\n") | |
1678 | + print("- Unit Agents per computer:", oc.get_agents_per_computer(my_unit_name)) | |
1679 | + | |
1680 | + print("\n") | |
1681 | + print("- Unit Agents per device:", oc.get_agents_per_device(my_unit_name)) | |
1682 | + | |
1683 | + print("\n") | |
1684 | + print("- Unit Channel groups:", oc.get_channel_groups(my_unit_name)) | |
1685 | + | |
1686 | + print("\n") | |
1687 | + print("- Unit Channels:", oc.get_channels(my_unit_name)) | |
1688 | + | |
1689 | + print("\n") | |
1690 | + print("- Unit/Channel info:", oc.get_channel_information(my_unit_name, 'OpticalChannel_up')) | |
1691 | + | |
1692 | + print("\n") | |
1693 | + print("- Unit Components agents:", oc.get_components_agents(my_unit_name)) | |
1694 | + | |
1695 | + print("\n") | |
1696 | + print("- Unit database:", oc.get_database_for_unit(my_unit_name)) | |
1697 | + | |
1698 | + print("\n") | |
1699 | + print("- Devices names:", oc.get_devices_names()) | |
1700 | + print("\n") | |
1701 | + print("- Devices names & files:", oc.get_devices_names_and_file()) | |
1702 | + print("\n") | |
1703 | + print("- Devices:", oc.get_devices()) | |
1704 | + | |
1705 | + print("\n") | |
1706 | + | |
1707 | + exit(0) | |
1640 | 1708 | #agent = build_agent(Agent, name="GenericAgent", RUN_IN_THREAD=RUN_IN_THREAD) |
1641 | 1709 | ''' |
1642 | 1710 | TEST_MODE, WITH_SIM, configfile = extract_parameters() | ... | ... |
src/core/pyros_django/agent/Agent2.py renamed to src/core/pyros_django/agent/AgentOld.py
... | ... | @@ -216,7 +216,7 @@ class StoppableThreadEvenWhenSleeping(threading.Thread): |
216 | 216 | ================================================================= |
217 | 217 | """ |
218 | 218 | |
219 | -class Agent2: | |
219 | +class Agent: | |
220 | 220 | """ |
221 | 221 | See Agent_activity_diag.pu for PlantUML activity diagram |
222 | 222 | |
... | ... | @@ -1617,7 +1617,7 @@ def extract_parameters(): |
1617 | 1617 | return DEBUG_MODE, WITH_SIM, TEST_MODE, VERBOSE_MODE, configfile |
1618 | 1618 | |
1619 | 1619 | #def build_agent(Agent_type:Agent, name="GenericAgent", RUN_IN_THREAD=True): |
1620 | -def build_agent(Agent_type:Agent2, RUN_IN_THREAD=True): | |
1620 | +def build_agent(Agent_type:Agent, RUN_IN_THREAD=True): | |
1621 | 1621 | DEBUG_MODE, WITH_SIM, TEST_MODE, VERBOSE_MODE, configfile = extract_parameters() |
1622 | 1622 | #agent = Agent("GenericAgent", configfile, RUN_IN_THREAD=True) |
1623 | 1623 | #agent = Agent_type(configfile, RUN_IN_THREAD, DEBUG_MODE=DEBUG_MODE) |
... | ... | @@ -1636,75 +1636,7 @@ if __name__ == "__main__": |
1636 | 1636 | # with process |
1637 | 1637 | #RUN_IN_THREAD=False |
1638 | 1638 | |
1639 | - agent = build_agent(Agent2, RUN_IN_THREAD=RUN_IN_THREAD) | |
1640 | - obs_config_file_path = os.environ["PATH_TO_OBSCONF_FILE"] | |
1641 | - path_to_obs_config_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] | |
1642 | - unit = os.environ["unit_name"] | |
1643 | - print("TOTO") | |
1644 | - agent.printd(obs_config_file_path) | |
1645 | - agent.printd(path_to_obs_config_folder) | |
1646 | - agent.printd(unit) | |
1647 | - from src.core.pyros_django.obsconfig.configpyros import ConfigPyros | |
1648 | - oc = ConfigPyros(obs_config_file_path) | |
1649 | - | |
1650 | - print("\n") | |
1651 | - print("- Observatory:", oc.get_obs_name()) | |
1652 | - | |
1653 | - my_unit_name = oc.get_units_name()[0] | |
1654 | - my_unit = (oc.get_units()[my_unit_name]) | |
1655 | - #print("- Unit description:", my_unit) | |
1656 | - | |
1657 | - print("\n") | |
1658 | - print("- Computers:", oc.get_computers()) | |
1659 | - | |
1660 | - print("\n") | |
1661 | - print("- Active Computers:", oc.get_active_computers()) | |
1662 | - | |
1663 | - print("\n") | |
1664 | - print("- Active Devices:", oc.get_active_devices()) | |
1665 | - | |
1666 | - print("\n") | |
1667 | - print("- Unit:", my_unit_name) | |
1668 | - print(oc.get_unit_by_name(my_unit_name)) | |
1669 | - | |
1670 | - print("\n") | |
1671 | - print("- Unit topology:", oc.get_topology(my_unit_name)) | |
1672 | - | |
1673 | - print("\n") | |
1674 | - print("- Unit active Agents:", oc.get_active_agents(my_unit_name)) | |
1675 | - print(oc.get_agents(my_unit_name)) | |
1676 | - | |
1677 | - print("\n") | |
1678 | - print("- Unit Agents per computer:", oc.get_agents_per_computer(my_unit_name)) | |
1679 | - | |
1680 | - print("\n") | |
1681 | - print("- Unit Agents per device:", oc.get_agents_per_device(my_unit_name)) | |
1682 | - | |
1683 | - print("\n") | |
1684 | - print("- Unit Channel groups:", oc.get_channel_groups(my_unit_name)) | |
1685 | - | |
1686 | - print("\n") | |
1687 | - print("- Unit Channels:", oc.get_channels(my_unit_name)) | |
1688 | - | |
1689 | - print("\n") | |
1690 | - print("- Unit/Channel info:", oc.get_channel_information(my_unit_name, 'OpticalChannel_up')) | |
1691 | - | |
1692 | - print("\n") | |
1693 | - print("- Unit Components agents:", oc.get_components_agents(my_unit_name)) | |
1694 | - | |
1695 | - print("\n") | |
1696 | - print("- Unit database:", oc.get_database_for_unit(my_unit_name)) | |
1697 | - | |
1698 | - print("\n") | |
1699 | - print("- Devices names:", oc.get_devices_names()) | |
1700 | - print("\n") | |
1701 | - print("- Devices names & files:", oc.get_devices_names_and_file()) | |
1702 | - print("\n") | |
1703 | - print("- Devices:", oc.get_devices()) | |
1704 | - | |
1705 | - print("\n") | |
1706 | - | |
1707 | - exit(0) | |
1639 | + agent = build_agent(Agent, RUN_IN_THREAD=RUN_IN_THREAD) | |
1708 | 1640 | #agent = build_agent(Agent, name="GenericAgent", RUN_IN_THREAD=RUN_IN_THREAD) |
1709 | 1641 | ''' |
1710 | 1642 | TEST_MODE, WITH_SIM, configfile = extract_parameters() | ... | ... |