Commit c8bceb1c4827c731437055222099d4e4d539cdf4
Exists in
dev
Merge branch 'dev' of https://gitlab.irap.omp.eu/pyros-irap/pyros into dev
Showing
6 changed files
with
155 additions
and
149 deletions
Show diff stats
docker/docker-compose.yml
pyros.py
@@ -115,10 +115,7 @@ try: | @@ -115,10 +115,7 @@ try: | ||
115 | except KeyError: | 115 | except KeyError: |
116 | WITH_DOCKER = False | 116 | WITH_DOCKER = False |
117 | 117 | ||
118 | -if type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$", WITH_DOCKER.rstrip()) != None: | ||
119 | - WITH_DOCKER = True | ||
120 | -else: | ||
121 | - WITH_DOCKER = False | 118 | +WITH_DOCKER = type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$", WITH_DOCKER.rstrip()) != None |
122 | 119 | ||
123 | my_abs_path = os.path.dirname(os.path.realpath(__file__)) | 120 | my_abs_path = os.path.dirname(os.path.realpath(__file__)) |
124 | # VENV_ROOT = "private" | 121 | # VENV_ROOT = "private" |
@@ -568,8 +565,7 @@ def update(): | @@ -568,8 +565,7 @@ def update(): | ||
568 | def install(packages_only, database_only): | 565 | def install(packages_only, database_only): |
569 | with_packages = not database_only | 566 | with_packages = not database_only |
570 | with_database = not packages_only | 567 | with_database = not packages_only |
571 | - _install_or_update(UPDATE=False, with_packages=with_packages, | ||
572 | - with_database=with_database) | 568 | + _install_or_update(UPDATE=False, with_packages=with_packages, with_database=with_database) |
573 | # install_or_update(UPDATE=False, with_packages=packages_only, with_database=database_only) | 569 | # install_or_update(UPDATE=False, with_packages=packages_only, with_database=database_only) |
574 | # install_or_update(UPDATE=False, packages_only=packages_only, database_only=database_only) | 570 | # install_or_update(UPDATE=False, packages_only=packages_only, database_only=database_only) |
575 | 571 | ||
@@ -587,9 +583,7 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | @@ -587,9 +583,7 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | ||
587 | # if WITH_DOCKER: only install the DB (with_database = True) | 583 | # if WITH_DOCKER: only install the DB (with_database = True) |
588 | if WITH_DOCKER: | 584 | if WITH_DOCKER: |
589 | with_packages = False | 585 | with_packages = False |
590 | - | ||
591 | # if not with_packages and not with_database: with_packages = with_database = True | 586 | # if not with_packages and not with_database: with_packages = with_database = True |
592 | - | ||
593 | print("- with_packages:", with_packages) | 587 | print("- with_packages:", with_packages) |
594 | print("- with_database:", with_database) | 588 | print("- with_database:", with_database) |
595 | 589 | ||
@@ -600,13 +594,14 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | @@ -600,13 +594,14 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | ||
600 | num = 0 | 594 | num = 0 |
601 | 595 | ||
602 | if UPDATE: | 596 | if UPDATE: |
603 | - # Update source code (git pull) | 597 | + # 1) Update source code (git pull) |
604 | num += 1 | 598 | num += 1 |
605 | printFullTerm(Colors.BLUE, f"{num}) UPDATING SOURCE CODE: Running git pull") | 599 | printFullTerm(Colors.BLUE, f"{num}) UPDATING SOURCE CODE: Running git pull") |
606 | if not WITH_DOCKER: | 600 | if not WITH_DOCKER: |
607 | _gitpull() or die() | 601 | _gitpull() or die() |
608 | 602 | ||
609 | if with_packages: | 603 | if with_packages: |
604 | + # 2) Install venv and packages in it | ||
610 | # Update python packages (pip upgrade AND pip install requirements) | 605 | # Update python packages (pip upgrade AND pip install requirements) |
611 | num += 1 | 606 | num += 1 |
612 | printFullTerm(Colors.BLUE, f"{num}) {ACTION} PYTHON PACKAGES") | 607 | printFullTerm(Colors.BLUE, f"{num}) {ACTION} PYTHON PACKAGES") |
@@ -617,7 +612,7 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | @@ -617,7 +612,7 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | ||
617 | if UPDATE: | 612 | if UPDATE: |
618 | print("Running UPDATE command") | 613 | print("Running UPDATE command") |
619 | else: | 614 | else: |
620 | - # Install GitPython package for git support inside python | 615 | + # 3) Install GitPython package for git support inside python |
621 | print("Running INSTALL command") | 616 | print("Running INSTALL command") |
622 | try: | 617 | try: |
623 | from git import Repo | 618 | from git import Repo |
@@ -644,59 +639,58 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | @@ -644,59 +639,58 @@ def _install_or_update(UPDATE: bool = False, with_packages: bool = True, with_da | ||
644 | change_dir("PREVIOUS") | 639 | change_dir("PREVIOUS") |
645 | ''' | 640 | ''' |
646 | 641 | ||
647 | - # | ||
648 | - # Guitastro | ||
649 | - # | ||
650 | - GUITASTRO_PATH = os.path.join(os.getcwd(), "./vendor/guitastro") | ||
651 | - if with_packages: # and not WITH_DOCKER: | ||
652 | - #GUITASTRO_PATH = os.path.join(os.getcwd(), "../vendor/guitastro") | ||
653 | - change_dir("..") | 642 | + # 4) Install GUITASTRO + its requirements |
643 | + # (ONLY FOR NON DOCKER INSTALL) | ||
654 | print(os.getcwd()) | 644 | print(os.getcwd()) |
655 | - # 1) clone repo if not yet done | ||
656 | - if not WITH_DOCKER and not os.path.exists(GUITASTRO_PATH): | ||
657 | - print("Guitastro : Cloning repository") | ||
658 | - cloned_repo = Repo.clone_from( | ||
659 | - "https://gitlab.irap.omp.eu/guitastrolib/guitastro.git", GUITASTRO_PATH) | ||
660 | - print("Cloned successfully: ", cloned_repo.__class__ is Repo) | ||
661 | - if UPDATE and os.path.exists(GUITASTRO_PATH) and and not WITH_DOCKER: | ||
662 | - gitpull_guitastro() | ||
663 | - change_dir("PREVIOUS") | ||
664 | - # 2) install/update requirements & generate API doc | ||
665 | - if not WITH_DOCKER and os.path.exists(GUITASTRO_PATH): | ||
666 | - # TODO: update guitastro (git pull from vendor/guitastro/) | ||
667 | - print("\nGuitastro : Installing/Updating python package dependencies\n") | ||
668 | - # Upgrade pip if new version available | ||
669 | - os.system(VENV_PYTHON + ' -m pip install --upgrade pip') | ||
670 | - # TODO: faire les apt-get intall aussi (indi, ...) | ||
671 | - venv_pip_install2(GUITASTRO_PATH + '/install/requirements.txt', '-r') | ||
672 | - #venv_pip_install2(GUITASTRO_PATH + '/install/requirements_linux.txt', '-r') | ||
673 | - venv_pip_install2(GUITASTRO_PATH + '/install/requirements_dev.txt', '-r') | ||
674 | - ''' | ||
675 | - print("Guitastro : Generating (updating) API documentation (using Sphinx)") | ||
676 | - # Make html doc from RST | ||
677 | - # cd doc/sourcedoc/ | ||
678 | - change_dir(GUITASTRO_PATH + '/doc_rst/') | ||
679 | - # ./MAKE_DOC.sh | ||
680 | - res = execProcess('/bin/bash MAKE_DOC.sh') | ||
681 | - # Come back to where we were before | ||
682 | - # cd - | ||
683 | - change_dir("PREVIOUS") | ||
684 | - ''' | ||
685 | - | ||
686 | - | ||
687 | - # 3) Update PlantUML diagrams | 645 | + if not WITH_DOCKER: |
646 | + GUITASTRO_PATH = os.path.join(os.getcwd(), "./vendor/guitastro") | ||
647 | + if with_packages: | ||
648 | + change_dir("..") | ||
649 | + print(os.getcwd()) | ||
650 | + if not os.path.exists(GUITASTRO_PATH): | ||
651 | + # a) clone repo if not yet done | ||
652 | + print("Guitastro : Cloning repository") | ||
653 | + cloned_repo = Repo.clone_from( | ||
654 | + "https://gitlab.irap.omp.eu/guitastrolib/guitastro.git", GUITASTRO_PATH) | ||
655 | + print("Cloned successfully: ", cloned_repo.__class__ is Repo) | ||
656 | + if os.path.exists(GUITASTRO_PATH): | ||
657 | + if UPDATE: | ||
658 | + gitpull_guitastro() | ||
659 | + change_dir("PREVIOUS") | ||
660 | + # b) install/update requirements & generate API doc | ||
661 | + # TODO: update guitastro (git pull from vendor/guitastro/) | ||
662 | + print("\nGuitastro : Installing/Updating python package dependencies\n") | ||
663 | + # Upgrade pip if new version available | ||
664 | + os.system(VENV_PYTHON + ' -m pip install --upgrade pip') | ||
665 | + # TODO: faire les apt-get intall aussi (indi, ...) | ||
666 | + _venv_pip_install2(GUITASTRO_PATH + '/install/requirements.txt', '-r') | ||
667 | + #venv_pip_install2(GUITASTRO_PATH + '/install/requirements_linux.txt', '-r') | ||
668 | + _venv_pip_install2(GUITASTRO_PATH + '/install/requirements_dev.txt', '-r') | ||
669 | + ''' | ||
670 | + print("Guitastro : Generating (updating) API documentation (using Sphinx)") | ||
671 | + # Make html doc from RST | ||
672 | + # cd doc/sourcedoc/ | ||
673 | + change_dir(GUITASTRO_PATH + '/doc_rst/') | ||
674 | + # ./MAKE_DOC.sh | ||
675 | + res = execProcess('/bin/bash MAKE_DOC.sh') | ||
676 | + # Come back to where we were before | ||
677 | + # cd - | ||
678 | + change_dir("PREVIOUS") | ||
679 | + ''' | ||
680 | + | ||
681 | + # 5) Update PlantUML diagrams (in UPDATE or INSTALL mode) | ||
688 | num += 1 | 682 | num += 1 |
689 | printFullTerm(Colors.BLUE, f"{num}) UPDATING UML DIAGRAMS") | 683 | printFullTerm(Colors.BLUE, f"{num}) UPDATING UML DIAGRAMS") |
690 | _update_plantuml_diags() or die() | 684 | _update_plantuml_diags() or die() |
691 | print(os.getcwd()) | 685 | print(os.getcwd()) |
692 | 686 | ||
693 | - # 4) Update Sphinx API doc | 687 | + # 6) Update Sphinx API doc (Non Windows only) (in UPDATE or INSTALL mode) |
694 | num += 1 | 688 | num += 1 |
695 | printFullTerm(Colors.BLUE, f"{num}) UPDATING API DOC (with Sphinx)") | 689 | printFullTerm(Colors.BLUE, f"{num}) UPDATING API DOC (with Sphinx)") |
696 | if not IS_WINDOWS: | 690 | if not IS_WINDOWS: |
697 | _update_api_doc() or die() | 691 | _update_api_doc() or die() |
698 | 692 | ||
699 | - # 5) Install/Update database structure (make migrations + migrate) | 693 | + # 7) Install/Update database structure (make migrations + migrate) |
700 | if with_database: | 694 | if with_database: |
701 | num += 1 | 695 | num += 1 |
702 | printFullTerm(Colors.BLUE, f"{num}) {ACTION} DATABASE") | 696 | printFullTerm(Colors.BLUE, f"{num}) {ACTION} DATABASE") |
@@ -727,8 +721,7 @@ def test(module, function): | @@ -727,8 +721,7 @@ def test(module, function): | ||
727 | if module is None: | 721 | if module is None: |
728 | # apps = ['obs_config','scp_mgmt','common', 'scheduling', 'seq_submit', 'user_mgmt', 'alert_mgmt.tests.TestStrategyChange'] | 722 | # apps = ['obs_config','scp_mgmt','common', 'scheduling', 'seq_submit', 'user_mgmt', 'alert_mgmt.tests.TestStrategyChange'] |
729 | # Removing alert_mgmt, scheduler from tests | 723 | # Removing alert_mgmt, scheduler from tests |
730 | - apps = ['obs_config', "scp_mgmt", | ||
731 | - 'dashboard', 'user_mgmt', 'seq_submit','api'] | 724 | + apps = ['obs_config', "scp_mgmt", 'dashboard', 'user_mgmt', 'seq_submit', 'api'] |
732 | else: | 725 | else: |
733 | os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath( | 726 | os.environ["PATH_TO_OBSCONF_FILE"] = os.path.join(os.path.abspath( |
734 | PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/observatory_configuration_ok_simple.yml") | 727 | PYROS_DJANGO_BASE_DIR), "obs_config/fixtures/observatory_configuration_ok_simple.yml") |
@@ -760,7 +753,7 @@ def test(module, function): | @@ -760,7 +753,7 @@ def test(module, function): | ||
760 | # execProcessFromVenv('manage.py test ' + app) or die() | 753 | # execProcessFromVenv('manage.py test ' + app) or die() |
761 | # KEEP test_pyros database after tests | 754 | # KEEP test_pyros database after tests |
762 | # execProcessFromVenv('manage.py test --keep ' + app) or die() | 755 | # execProcessFromVenv('manage.py test --keep ' + app) or die() |
763 | - execProcessFromVenv('manage.py test --keep --noinput ' + app,foreground=True) or die() | 756 | + execProcessFromVenv('manage.py test --keep --noinput ' + app, foreground=True) or die() |
764 | change_dir("PREVIOUS") | 757 | change_dir("PREVIOUS") |
765 | # execProcess("python install.py install") | 758 | # execProcess("python install.py install") |
766 | return True | 759 | return True |
@@ -1126,8 +1119,7 @@ def new_start(configfile: str, observatory: str, unit: str, computer_hostname: s | @@ -1126,8 +1119,7 @@ def new_start(configfile: str, observatory: str, unit: str, computer_hostname: s | ||
1126 | # pip = "pip" if platform.system() == "Windows" else "pip3" | 1119 | # pip = "pip" if platform.system() == "Windows" else "pip3" |
1127 | # TODO: "python -m pip" au lieu de "pip" | 1120 | # TODO: "python -m pip" au lieu de "pip" |
1128 | pip = "pip" if IS_WINDOWS else "pip3" | 1121 | pip = "pip" if IS_WINDOWS else "pip3" |
1129 | - process = subprocess.Popen( | ||
1130 | - pip + " install --user --upgrade pykwalify", shell=True) | 1122 | + process = subprocess.Popen(pip + " install --user --upgrade pykwalify", shell=True) |
1131 | process.wait() | 1123 | process.wait() |
1132 | if process.returncode == 0: | 1124 | if process.returncode == 0: |
1133 | # self.addExecuted(self.current_command, command) | 1125 | # self.addExecuted(self.current_command, command) |
@@ -1308,12 +1300,9 @@ def _update_api_doc(): | @@ -1308,12 +1300,9 @@ def _update_api_doc(): | ||
1308 | print(os.getcwd()) | 1300 | print(os.getcwd()) |
1309 | DOC_RST_PATH = "doc/doc_rst/" | 1301 | DOC_RST_PATH = "doc/doc_rst/" |
1310 | # 0) Upgrade pip if new version available | 1302 | # 0) Upgrade pip if new version available |
1311 | - if WITH_DOCKER: | ||
1312 | - os.system(VENV_PYTHON + ' -m pip install --user --upgrade pip') | ||
1313 | - else: | ||
1314 | - os.system(VENV_PYTHON + ' -m pip install --upgrade pip') | 1303 | + _venv_pip_install2('pip', '--upgrade') |
1315 | # 1) install/update Sphinx requirements (only if not yet installed) | 1304 | # 1) install/update Sphinx requirements (only if not yet installed) |
1316 | - venv_pip_install2(DOC_RST_PATH+'requirements.txt', '-r') | 1305 | + _venv_pip_install2(DOC_RST_PATH+'requirements.txt', '-r') |
1317 | # 2) make html doc from RST doc | 1306 | # 2) make html doc from RST doc |
1318 | # cd doc/sourcedoc/ | 1307 | # cd doc/sourcedoc/ |
1319 | change_dir(DOC_RST_PATH) | 1308 | change_dir(DOC_RST_PATH) |
@@ -1485,20 +1474,24 @@ def notused_install_required(): | @@ -1485,20 +1474,24 @@ def notused_install_required(): | ||
1485 | exit(1) | 1474 | exit(1) |
1486 | 1475 | ||
1487 | 1476 | ||
1488 | -def venv_pip_install(package_name: str, options: str = ''): | ||
1489 | - if WITH_DOCKER: | ||
1490 | - os.system(VENV_PIP + ' install --user ' + options + ' ' + package_name) | ||
1491 | - else: | ||
1492 | - os.system(VENV_PIP + ' install ' + options + ' ' + package_name) | 1477 | +def _venv_pip_install_from_venv(PIP_MODULE: bool, package_name: str, options: str = ''): |
1478 | + ''' | ||
1479 | + pip install package_name with options | ||
1480 | + If PIP_MODULE install with 'python -m pip' else install with 'pip' | ||
1481 | + If WITH_DOCKER => install in user mode (with --user option) | ||
1482 | + ''' | ||
1483 | + #_pip_install(options + ' ' + package_name) | ||
1484 | + pip_cmd = VENV_PYTHON+' -m pip' if PIP_MODULE else VENV_PIP | ||
1485 | + usermode = '--user' if WITH_DOCKER else '' | ||
1486 | + os.system(f'{pip_cmd} install {usermode} {options} {package_name}') | ||
1493 | 1487 | ||
1494 | 1488 | ||
1495 | -def venv_pip_install2(package_name: str, options: str = ''): | ||
1496 | - if WITH_DOCKER: | ||
1497 | - os.system(VENV_PYTHON + ' -m pip install --user ' | ||
1498 | - + options + ' ' + package_name) | ||
1499 | - else: | ||
1500 | - os.system(VENV_PYTHON + ' -m pip install ' | ||
1501 | - + options + ' ' + package_name) | 1489 | +def _venv_pip_install(package_name: str, options: str = ''): |
1490 | + _venv_pip_install_from_venv(False, package_name, options) | ||
1491 | + | ||
1492 | + | ||
1493 | +def _venv_pip_install2(package_name: str, options: str = ''): | ||
1494 | + _venv_pip_install_from_venv(True, package_name, options) | ||
1502 | 1495 | ||
1503 | 1496 | ||
1504 | def install_venv(EVEN_IF_ALREADY_EXISTS: bool = False): | 1497 | def install_venv(EVEN_IF_ALREADY_EXISTS: bool = False): |
@@ -1570,10 +1563,7 @@ def install_packages(): | @@ -1570,10 +1563,7 @@ def install_packages(): | ||
1570 | print(Colors.LOG_BLUE + "-----------------------------Upgrade pip, wheel, and setuptools" + | 1563 | print(Colors.LOG_BLUE + "-----------------------------Upgrade pip, wheel, and setuptools" + |
1571 | "-----------------------------"+END_OF_LINE + Colors.END) | 1564 | "-----------------------------"+END_OF_LINE + Colors.END) |
1572 | # Upgrade pip | 1565 | # Upgrade pip |
1573 | - if WITH_DOCKER: | ||
1574 | - os.system(VENV_PYTHON + ' -m pip install --user --upgrade pip') | ||
1575 | - else: | ||
1576 | - os.system(VENV_PYTHON + ' -m pip install --upgrade pip') | 1566 | + _venv_pip_install2('pip', '--upgrade') |
1577 | ''' | 1567 | ''' |
1578 | if (platform.system() == "Windows"): | 1568 | if (platform.system() == "Windows"): |
1579 | os.system(venv + '\Scripts\python -m pip install --upgrade pip') | 1569 | os.system(venv + '\Scripts\python -m pip install --upgrade pip') |
@@ -1582,27 +1572,24 @@ def install_packages(): | @@ -1582,27 +1572,24 @@ def install_packages(): | ||
1582 | ''' | 1572 | ''' |
1583 | 1573 | ||
1584 | # Pip upgrade wheel and setuptools | 1574 | # Pip upgrade wheel and setuptools |
1585 | - venv_pip_install('wheel', '--upgrade') | 1575 | + _venv_pip_install('wheel', '--upgrade') |
1586 | # os.system(VENV_PIP+' install --upgrade wheel') | 1576 | # os.system(VENV_PIP+' install --upgrade wheel') |
1587 | # Not working with python 3.8 (on 17/02/2022) | 1577 | # Not working with python 3.8 (on 17/02/2022) |
1588 | # venv_pip_install('setuptools', '--upgrade') | 1578 | # venv_pip_install('setuptools', '--upgrade') |
1589 | - if WITH_DOCKER: | ||
1590 | - os.system(VENV_PIP+' install --user setuptools==58') | ||
1591 | - else: | ||
1592 | - os.system(VENV_PIP+' install setuptools==58') | 1579 | + _venv_pip_install('setuptools==58') |
1593 | 1580 | ||
1594 | # Pip install required packages from REQUIREMENTS file | 1581 | # Pip install required packages from REQUIREMENTS file |
1595 | print() | 1582 | print() |
1596 | 1583 | ||
1597 | # General normal packages | 1584 | # General normal packages |
1598 | print(Colors.LOG_BLUE + "-----------------------------Installing python packages via pip-----------------------------" + Colors.END) | 1585 | print(Colors.LOG_BLUE + "-----------------------------Installing python packages via pip-----------------------------" + Colors.END) |
1599 | - venv_pip_install('../install/'+REQUIREMENTS, '-r') | 1586 | + _venv_pip_install('../install/'+REQUIREMENTS, '-r') |
1600 | # os.system(VENV_PIP+' install -r ../install' + os.sep + REQUIREMENTS) | 1587 | # os.system(VENV_PIP+' install -r ../install' + os.sep + REQUIREMENTS) |
1601 | 1588 | ||
1602 | # DEV only packages | 1589 | # DEV only packages |
1603 | if DEV: | 1590 | if DEV: |
1604 | print(Colors.LOG_BLUE + "-----------------------------Installing DEV python packages via pip-----------------------------" + Colors.END) | 1591 | print(Colors.LOG_BLUE + "-----------------------------Installing DEV python packages via pip-----------------------------" + Colors.END) |
1605 | - venv_pip_install('../install/'+REQUIREMENTS_DEV, '-r') | 1592 | + _venv_pip_install('../install/'+REQUIREMENTS_DEV, '-r') |
1606 | print("FIN INSTALL PACKAGES") | 1593 | print("FIN INSTALL PACKAGES") |
1607 | return None | 1594 | return None |
1608 | 1595 | ||
@@ -1659,12 +1646,9 @@ def install_observatory(observatory): | @@ -1659,12 +1646,9 @@ def install_observatory(observatory): | ||
1659 | from git import Repo, GitError | 1646 | from git import Repo, GitError |
1660 | except: | 1647 | except: |
1661 | pip = "pip" if IS_WINDOWS else "pip3" | 1648 | pip = "pip" if IS_WINDOWS else "pip3" |
1662 | - if WITH_DOCKER: | ||
1663 | - process = subprocess.Popen( | ||
1664 | - pip + " install --user --upgrade GitPython", shell=True) | ||
1665 | - else: | ||
1666 | - process = subprocess.Popen( | ||
1667 | - pip + " install --upgrade GitPython", shell=True) | 1649 | + |
1650 | + usermode = '--user' if WITH_DOCKER else '' | ||
1651 | + process = subprocess.Popen(pip + f" install {usermode} --upgrade GitPython", shell=True) | ||
1668 | process.wait() | 1652 | process.wait() |
1669 | if process.returncode == 0: | 1653 | if process.returncode == 0: |
1670 | # self.addExecuted(self.current_command, command) | 1654 | # self.addExecuted(self.current_command, command) |
src/core/pyros_django/majordome/agent/AgentBasic.py renamed to src/core/pyros_django/majordome/agent/A_Basic.py
1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
2 | 2 | ||
3 | 3 | ||
4 | -import time | ||
5 | -import sys, argparse | 4 | +#import time |
5 | +import sys | ||
6 | +import argparse | ||
7 | +import os | ||
6 | 8 | ||
7 | ##import utils.Logger as L | 9 | ##import utils.Logger as L |
8 | 10 | ||
9 | ##from .Agent import Agent | 11 | ##from .Agent import Agent |
10 | ##sys.path.append("..") | 12 | ##sys.path.append("..") |
11 | ###from agent.Agent import Agent, build_agent | 13 | ###from agent.Agent import Agent, build_agent |
12 | -sys.path.append("../../../..") | 14 | + |
15 | +###sys.path.append("../../../..") | ||
16 | + | ||
17 | +# pwd = PYROS/ | ||
18 | +pwd = os.environ['PROJECT_ROOT_PATH'] | ||
19 | +if pwd not in sys.path: | ||
20 | + sys.path.append(pwd) | ||
21 | + | ||
22 | +# Add paths PYROS/src and PYROS/src/core/pyros_django | ||
23 | +short_paths = ['src', 'src/core/pyros_django'] | ||
24 | +for short_path in short_paths: | ||
25 | + path = os.path.join(pwd, short_path) | ||
26 | + # ou plutot ? | ||
27 | + #path = os.path.abspath(os.path.join(pwd, short_path)) | ||
28 | + if path not in sys.path: | ||
29 | + sys.path.insert(0, path) | ||
30 | + | ||
13 | #from src.core.pyros_django.common.models import AgentCmd | 31 | #from src.core.pyros_django.common.models import AgentCmd |
14 | -from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent | 32 | +#from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent |
33 | +from majordome.agent.Agent import Agent, build_agent | ||
34 | + | ||
15 | #from src.core.pyros_django.common.models import AgentCmd | 35 | #from src.core.pyros_django.common.models import AgentCmd |
16 | 36 | ||
17 | from typing import List, Tuple, Union, Any | 37 | from typing import List, Tuple, Union, Any |
@@ -20,16 +40,16 @@ from typing import List, Tuple, Union, Any | @@ -20,16 +40,16 @@ from typing import List, Tuple, Union, Any | ||
20 | 40 | ||
21 | 41 | ||
22 | 42 | ||
23 | -class AgentBasic(Agent): | 43 | +class A_Basic(Agent): |
24 | 44 | ||
25 | # FOR TEST ONLY | 45 | # FOR TEST ONLY |
26 | - # Run this agent in simulator mode | 46 | + # - Run this agent in simulator mode |
27 | TEST_MODE = False | 47 | TEST_MODE = False |
28 | - # Run the assertion tests at the end | 48 | + # - Run the assertion tests at the end |
29 | TEST_WITH_FINAL_TEST = False | 49 | TEST_WITH_FINAL_TEST = False |
30 | #TEST_MAX_DURATION_SEC = None | 50 | #TEST_MAX_DURATION_SEC = None |
31 | TEST_MAX_DURATION_SEC = 400 | 51 | TEST_MAX_DURATION_SEC = 400 |
32 | - # Who should I send commands to ? | 52 | + # - Who should I send commands to ? |
33 | TEST_COMMANDS_DEST = "myself" | 53 | TEST_COMMANDS_DEST = "myself" |
34 | #TEST_COMMANDS_DEST = "AgentB" | 54 | #TEST_COMMANDS_DEST = "AgentB" |
35 | # Scenario to be executed | 55 | # Scenario to be executed |
@@ -459,7 +479,7 @@ if __name__ == "__main__": | @@ -459,7 +479,7 @@ if __name__ == "__main__": | ||
459 | parser.add_argument("--computer",dest="computer",help='Launch agent with simulated computer hostname',action="store") | 479 | parser.add_argument("--computer",dest="computer",help='Launch agent with simulated computer hostname',action="store") |
460 | parser.add_argument("-t", action="store_true") | 480 | parser.add_argument("-t", action="store_true") |
461 | args = vars(parser.parse_args()) | 481 | args = vars(parser.parse_args()) |
462 | - agent = build_agent(AgentBasic,param_constr=args) | 482 | + agent = build_agent(A_Basic, param_constr=args) |
463 | 483 | ||
464 | ''' | 484 | ''' |
465 | TEST_MODE, configfile = extract_parameters() | 485 | TEST_MODE, configfile = extract_parameters() |
src/core/pyros_django/majordome/agent/Agent.py
@@ -160,6 +160,7 @@ from vendor.guitastro.src.guitastro import Ephemeris | @@ -160,6 +160,7 @@ from vendor.guitastro.src.guitastro import Ephemeris | ||
160 | import pickle | 160 | import pickle |
161 | 161 | ||
162 | 162 | ||
163 | +# Aliases for Cmd exceptions | ||
163 | CmdException = AgentCmd.CmdException | 164 | CmdException = AgentCmd.CmdException |
164 | CmdExceptionUnknown = AgentCmd.CmdExceptionUnknown | 165 | CmdExceptionUnknown = AgentCmd.CmdExceptionUnknown |
165 | CmdExceptionUnimplemented = AgentCmd.CmdExceptionUnimplemented | 166 | CmdExceptionUnimplemented = AgentCmd.CmdExceptionUnimplemented |
@@ -218,7 +219,7 @@ class Colors: | @@ -218,7 +219,7 @@ class Colors: | ||
218 | BOLD = "\033[1m" | 219 | BOLD = "\033[1m" |
219 | UNDERLINE = "\033[4m" | 220 | UNDERLINE = "\033[4m" |
220 | 221 | ||
221 | -def printColor(color: Colors, message, file=sys.stdout, eol=os.linesep, forced=False): | 222 | +def print_colored(color: Colors, message, file=sys.stdout, eol=os.linesep, forced=False): |
222 | #system = platform.system() | 223 | #system = platform.system() |
223 | """ | 224 | """ |
224 | if (self.disp == False and forced == False): | 225 | if (self.disp == False and forced == False): |
@@ -237,10 +238,10 @@ def printFullTerm(color: Colors, string: str): | @@ -237,10 +238,10 @@ def printFullTerm(color: Colors, string: str): | ||
237 | row = 1000 | 238 | row = 1000 |
238 | disp = True | 239 | disp = True |
239 | value = int(columns / 2 - len(string) / 2) | 240 | value = int(columns / 2 - len(string) / 2) |
240 | - printColor(color, "-" * value, eol="") | ||
241 | - printColor(color, string, eol="") | 241 | + print_colored(color, "-" * value, eol="") |
242 | + print_colored(color, string, eol="") | ||
242 | value += len(string) | 243 | value += len(string) |
243 | - printColor(color, "-" * (columns - value)) | 244 | + print_colored(color, "-" * (columns - value)) |
244 | return 0 | 245 | return 0 |
245 | 246 | ||
246 | 247 | ||
@@ -301,23 +302,22 @@ class Agent: | @@ -301,23 +302,22 @@ class Agent: | ||
301 | # --- - INSTANCE attributes are accessible via agent.__dict__ | 302 | # --- - INSTANCE attributes are accessible via agent.__dict__ |
302 | # --- | 303 | # --- |
303 | 304 | ||
304 | - | ||
305 | class EXEC_MODE(Enum): | 305 | class EXEC_MODE(Enum): |
306 | SEQUENTIAL = 0 | 306 | SEQUENTIAL = 0 |
307 | THREAD = 1 | 307 | THREAD = 1 |
308 | PROCESS = 2 | 308 | PROCESS = 2 |
309 | 309 | ||
310 | # Default modes | 310 | # Default modes |
311 | - DEBUG_MODE:bool = False | 311 | + DEBUG_MODE: bool = False |
312 | #TEST_MODE = False | 312 | #TEST_MODE = False |
313 | 313 | ||
314 | # By default, a command is valid during 5s (and then perempted) | 314 | # By default, a command is valid during 5s (and then perempted) |
315 | - DEFAULT_CMD_VALIDITY_DURATION:int = 5 | 315 | + DEFAULT_CMD_VALIDITY_DURATION: int = 5 |
316 | 316 | ||
317 | # Wait a fixed number of seconds before each loop ? | 317 | # Wait a fixed number of seconds before each loop ? |
318 | #WITH_RANDOM_WAIT = False | 318 | #WITH_RANDOM_WAIT = False |
319 | # 1 sec by default | 319 | # 1 sec by default |
320 | - __DELAY_NB_SEC:int = 1 | 320 | + __DELAY_NB_SEC: int = 1 |
321 | # - YES if TEST mode (in init()) | 321 | # - YES if TEST mode (in init()) |
322 | 322 | ||
323 | # Default LOG level is INFO | 323 | # Default LOG level is INFO |
@@ -332,7 +332,7 @@ class Agent: | @@ -332,7 +332,7 @@ class Agent: | ||
332 | - exec_mode (EXEC_MODE) : EXEC_MODE.SEQUENTIAL, EXEC_MODE.THREAD, or EXEC_MODE.PROCESS | 332 | - exec_mode (EXEC_MODE) : EXEC_MODE.SEQUENTIAL, EXEC_MODE.THREAD, or EXEC_MODE.PROCESS |
333 | - tooltip : description text (displayed on clic) | 333 | - tooltip : description text (displayed on clic) |
334 | ''' | 334 | ''' |
335 | - _AGENT_SPECIFIC_COMMANDS: Dict [ str, Tuple[int, EXEC_MODE, str] ] = { | 335 | + _AGENT_SPECIFIC_COMMANDS: Dict[str, Tuple[int, EXEC_MODE, str]] = { |
336 | # Format : โcmd_nameโ : (timeout, exec_mode, tooltip) | 336 | # Format : โcmd_nameโ : (timeout, exec_mode, tooltip) |
337 | 337 | ||
338 | #"do_specific1" : (10, EXEC_MODE.SEQUENTIAL, ''), | 338 | #"do_specific1" : (10, EXEC_MODE.SEQUENTIAL, ''), |
@@ -352,14 +352,15 @@ class Agent: | @@ -352,14 +352,15 @@ class Agent: | ||
352 | # Maximum duration of this agent (only for SIMULATION mode) | 352 | # Maximum duration of this agent (only for SIMULATION mode) |
353 | # If set to 0, it will never exit except if asked (or CTRL-C) | 353 | # If set to 0, it will never exit except if asked (or CTRL-C) |
354 | # If set to 20, it will exit after 20s | 354 | # If set to 20, it will exit after 20s |
355 | - TEST_MAX_DURATION_SEC :int=0 | 355 | + TEST_MAX_DURATION_SEC: int = 0 |
356 | #TEST_MAX_DURATION_SEC = 30 | 356 | #TEST_MAX_DURATION_SEC = 30 |
357 | # Run this agent in simulator mode | 357 | # Run this agent in simulator mode |
358 | #TEST_MODE = True | 358 | #TEST_MODE = True |
359 | - WITH_SIMULATOR:bool = False | 359 | + WITH_SIMULATOR: bool = False |
360 | # Run the assertion tests at the end | 360 | # Run the assertion tests at the end |
361 | - TEST_WITH_FINAL_TEST:bool = False | 361 | + TEST_WITH_FINAL_TEST: bool = False |
362 | 362 | ||
363 | + # Aliases | ||
363 | CMD_STATUS = AgentCmd.CMD_STATUS_CODES | 364 | CMD_STATUS = AgentCmd.CMD_STATUS_CODES |
364 | AGT_STATUS = AgentSurvey.STATUS_CHOICES | 365 | AGT_STATUS = AgentSurvey.STATUS_CHOICES |
365 | 366 | ||
@@ -393,8 +394,8 @@ class Agent: | @@ -393,8 +394,8 @@ class Agent: | ||
393 | ##_TEST_COMMANDS_LIST: List[ Tuple[ bool, str, int, Optional[str], AgentCmd.CMD_STATUS_CODES ] ] = [ | 394 | ##_TEST_COMMANDS_LIST: List[ Tuple[ bool, str, int, Optional[str], AgentCmd.CMD_STATUS_CODES ] ] = [ |
394 | 395 | ||
395 | # Alias type for _TEST_COMMANDS_LIST (for more readability) | 396 | # Alias type for _TEST_COMMANDS_LIST (for more readability) |
396 | - TestCommand = Tuple[ bool, str, Optional[int], Optional[str], Optional[int]] | ||
397 | - _TEST_COMMANDS_LIST: List[ TestCommand ] = [ | 397 | + TestCommand = Tuple[bool, str, Optional[int], Optional[str], Optional[int]] |
398 | + _TEST_COMMANDS_LIST: List[TestCommand] = [ | ||
398 | # Format : (DO_IT, "self cmd_name cmd_args", validity, "expected_result", expected_status), | 399 | # Format : (DO_IT, "self cmd_name cmd_args", validity, "expected_result", expected_status), |
399 | 400 | ||
400 | #("self do_stop now", 200, '15.5', None), | 401 | #("self do_stop now", 200, '15.5', None), |
@@ -591,8 +592,8 @@ class Agent: | @@ -591,8 +592,8 @@ class Agent: | ||
591 | ##_cmdts: AgentCmd = None | 592 | ##_cmdts: AgentCmd = None |
592 | ##_next_cmdts = None | 593 | ##_next_cmdts = None |
593 | 594 | ||
594 | - __agent_survey:AgentSurvey = None | ||
595 | - __pending_commands:QuerySet = None # [] | 595 | + __agent_survey: AgentSurvey = None |
596 | + __pending_commands: QuerySet = None # [] | ||
596 | 597 | ||
597 | # List of agents I will send commands to | 598 | # List of agents I will send commands to |
598 | _my_client_agents_aliases = [] | 599 | _my_client_agents_aliases = [] |
@@ -610,28 +611,28 @@ class Agent: | @@ -610,28 +611,28 @@ class Agent: | ||
610 | 611 | ||
611 | # new obsconfig init for agent: | 612 | # new obsconfig init for agent: |
612 | ##def __init__(self, RUN_IN_THREAD=True): | 613 | ##def __init__(self, RUN_IN_THREAD=True): |
613 | - def __init__(self,simulated_computer=None): | 614 | + def __init__(self, simulated_computer=None): |
614 | 615 | ||
615 | # Instance attributes declaration (with default values, or None) | 616 | # Instance attributes declaration (with default values, or None) |
616 | - self.__UP_SINCE : Final = datetime.now(tz=timezone.utc) | 617 | + self.__UP_SINCE: Final = datetime.now(tz=timezone.utc) |
617 | #self.UP_SINCE = datetime.utcnow() | 618 | #self.UP_SINCE = datetime.utcnow() |
618 | - self.__ROUTINE_ITER_START_IS_RUNNING:bool = False | ||
619 | - self.__ROUTINE_ITER_END_IS_RUNNING:bool = False | ||
620 | - self.__test_cmd_received_num:int = 0 # only for tests | 619 | + self.__ROUTINE_ITER_START_IS_RUNNING: bool = False |
620 | + self.__ROUTINE_ITER_END_IS_RUNNING: bool = False | ||
621 | + self.__test_cmd_received_num: int = 0 # only for tests | ||
621 | # Current Command running | 622 | # Current Command running |
622 | - self.__CC :Optional[AgentCmd] #= None | ||
623 | - self.__CC_thread :Union[StoppableThreadEvenWhenSleeping, multiprocessing.Process] #= None | 623 | + self.__CC: Optional[AgentCmd] # = None |
624 | + self.__CC_thread: Union[StoppableThreadEvenWhenSleeping, multiprocessing.Process] #= None | ||
624 | # Previous Command running | 625 | # Previous Command running |
625 | ##self.__CC_prev :Optional[AgentCmd] = None | 626 | ##self.__CC_prev :Optional[AgentCmd] = None |
626 | # Current Command exception (if occurs) | 627 | # Current Command exception (if occurs) |
627 | - self.__CCE :Optional[Exception] #= None | 628 | + self.__CCE: Optional[Exception] #= None |
628 | self.name = "Generic Agent" | 629 | self.name = "Generic Agent" |
629 | - self.__status :str #= None | ||
630 | - self.__mode :str #= None | ||
631 | - self.unit :str #= None | 630 | + self.__status: str # = None |
631 | + self.__mode: str # = None | ||
632 | + self.unit: str # = None | ||
632 | #self.TEST_COMMANDS :List #= None | 633 | #self.TEST_COMMANDS :List #= None |
633 | - self.TEST_COMMANDS :Iterable[Agent.TestCommand] #= None | ||
634 | - self.__iter_num :int = 0 | 634 | + self.TEST_COMMANDS: Iterable[Agent.TestCommand] # = None |
635 | + self.__iter_num: int = 0 | ||
635 | #print(AgentSurvey.MODE_CHOICES.IDLE) | 636 | #print(AgentSurvey.MODE_CHOICES.IDLE) |
636 | #sys.exit() | 637 | #sys.exit() |
637 | 638 | ||
@@ -639,18 +640,21 @@ class Agent: | @@ -639,18 +640,21 @@ class Agent: | ||
639 | #self.__mode = self.MODE_ATTENTIVE | 640 | #self.__mode = self.MODE_ATTENTIVE |
640 | self.set_mode_attentive() | 641 | self.set_mode_attentive() |
641 | #self._set_mode(MODES.) | 642 | #self._set_mode(MODES.) |
643 | + | ||
644 | + # Set Obs config | ||
642 | obs_config_file_path = os.environ["PATH_TO_OBSCONF_FILE"] | 645 | obs_config_file_path = os.environ["PATH_TO_OBSCONF_FILE"] |
643 | path_to_obs_config_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] | 646 | path_to_obs_config_folder = os.environ["PATH_TO_OBSCONF_FOLDER"] |
644 | unit = os.environ["unit_name"] | 647 | unit = os.environ["unit_name"] |
645 | - oc = OBSConfig(obs_config_file_path,unit) | 648 | + oc = OBSConfig(obs_config_file_path, unit) |
646 | pyros_yaml_path = os.environ["pyros_config_file"] | 649 | pyros_yaml_path = os.environ["pyros_config_file"] |
647 | pyros_config = ConfigPyros(pyros_yaml_path) | 650 | pyros_config = ConfigPyros(pyros_yaml_path) |
648 | self.set_config(oc, obs_config_file_path, path_to_obs_config_folder, unit, pyros_config, pyros_yaml_path) | 651 | self.set_config(oc, obs_config_file_path, path_to_obs_config_folder, unit, pyros_config, pyros_yaml_path) |
652 | + | ||
653 | + # Agent name | ||
649 | agent_name_from_config = self.get_config().get_agent_name_from_config(self.__class__.__name__,simulated_computer) | 654 | agent_name_from_config = self.get_config().get_agent_name_from_config(self.__class__.__name__,simulated_computer) |
650 | - if agent_name_from_config: | ||
651 | - self.name = agent_name_from_config | ||
652 | - else: | ||
653 | - self.name = self.__class__.__name__ | 655 | + self.name = agent_name_from_config if agent_name_from_config else self.__class__.__name__ |
656 | + | ||
657 | + # LOG | ||
654 | log.addHandler(handler_filebyagent(logging.INFO, self.name)) | 658 | log.addHandler(handler_filebyagent(logging.INFO, self.name)) |
655 | #log.addHandler(handler_filebyagent(logging.INFO, self.name)) | 659 | #log.addHandler(handler_filebyagent(logging.INFO, self.name)) |
656 | log.debug("start Agent init") | 660 | log.debug("start Agent init") |
@@ -670,10 +674,11 @@ class Agent: | @@ -670,10 +674,11 @@ class Agent: | ||
670 | 674 | ||
671 | self.TEST_COMMANDS = iter(self._TEST_COMMANDS_LIST) | 675 | self.TEST_COMMANDS = iter(self._TEST_COMMANDS_LIST) |
672 | ##self.RUN_IN_THREAD = RUN_IN_THREAD | 676 | ##self.RUN_IN_THREAD = RUN_IN_THREAD |
677 | + | ||
673 | self.__set_status(self.AGT_STATUS.LAUNCHED) | 678 | self.__set_status(self.AGT_STATUS.LAUNCHED) |
674 | ####self._set_idle() | 679 | ####self._set_idle() |
675 | 680 | ||
676 | - # Create 1st survey if none | 681 | + # Get survey or create 1st one if none |
677 | #tmp = AgentSurvey.objects.filter(name=self.name) | 682 | #tmp = AgentSurvey.objects.filter(name=self.name) |
678 | #if len(tmp) == 0: | 683 | #if len(tmp) == 0: |
679 | #nb_agents = AgentSurvey.objects.filter(name=self.name).count() | 684 | #nb_agents = AgentSurvey.objects.filter(name=self.name).count() |
@@ -857,18 +862,16 @@ class Agent: | @@ -857,18 +862,16 @@ class Agent: | ||
857 | @property | 862 | @property |
858 | def ROUTINE_ITER_START_IS_RUNNING(self): | 863 | def ROUTINE_ITER_START_IS_RUNNING(self): |
859 | return self.__ROUTINE_ITER_START_IS_RUNNING | 864 | return self.__ROUTINE_ITER_START_IS_RUNNING |
865 | + | ||
860 | @property | 866 | @property |
861 | def ROUTINE_ITER_END_IS_RUNNING(self): | 867 | def ROUTINE_ITER_END_IS_RUNNING(self): |
862 | return self.__ROUTINE_ITER_END_IS_RUNNING | 868 | return self.__ROUTINE_ITER_END_IS_RUNNING |
863 | 869 | ||
864 | - | ||
865 | - | ||
866 | - | ||
867 | def set_config(self, oc: OBSConfig, obs_config_file_path: str, path_to_obs_config_folder: str, unit: str, pyros_config: str, pyros_yaml_path: str): | 870 | def set_config(self, oc: OBSConfig, obs_config_file_path: str, path_to_obs_config_folder: str, unit: str, pyros_config: str, pyros_yaml_path: str): |
868 | self._oc = { | 871 | self._oc = { |
869 | - 'config' : oc, | ||
870 | - 'pyros_config' : pyros_config, | ||
871 | - 'env' : [ | 872 | + 'config': oc, |
873 | + 'pyros_config': pyros_config, | ||
874 | + 'env': [ | ||
872 | obs_config_file_path, | 875 | obs_config_file_path, |
873 | path_to_obs_config_folder, | 876 | path_to_obs_config_folder, |
874 | unit, | 877 | unit, |
@@ -962,10 +965,6 @@ class Agent: | @@ -962,10 +965,6 @@ class Agent: | ||
962 | print("\n") | 965 | print("\n") |
963 | 966 | ||
964 | 967 | ||
965 | - | ||
966 | - | ||
967 | - | ||
968 | - | ||
969 | def get_config_filename(self, config_filename: str): | 968 | def get_config_filename(self, config_filename: str): |
970 | if not config_filename: | 969 | if not config_filename: |
971 | #config_filename = self.DEFAULT_CONFIG_FILE_NAME | 970 | #config_filename = self.DEFAULT_CONFIG_FILE_NAME |
@@ -1013,7 +1012,7 @@ class Agent: | @@ -1013,7 +1012,7 @@ class Agent: | ||
1013 | 1012 | ||
1014 | 1013 | ||
1015 | 1014 | ||
1016 | - def _get_real_agent_name(self, agent_alias_name:str)->str: | 1015 | + def _get_real_agent_name(self, agent_alias_name: str) -> str: |
1017 | #self.printd("key is", agent_alias_name) | 1016 | #self.printd("key is", agent_alias_name) |
1018 | ''' | 1017 | ''' |
1019 | if not self._my_client_agents: return agent_alias_name | 1018 | if not self._my_client_agents: return agent_alias_name |
@@ -1023,7 +1022,7 @@ class Agent: | @@ -1023,7 +1022,7 @@ class Agent: | ||
1023 | 1022 | ||
1024 | 1023 | ||
1025 | 1024 | ||
1026 | - def run(self, nb_iter:int=None, FOR_REAL:bool=True): | 1025 | + def run(self, nb_iter: int = None, FOR_REAL: bool = True): |
1027 | """ | 1026 | """ |
1028 | FOR_REAL: set to False if you don't want Agent to send commands to devices but just print messages without really doing anything | 1027 | FOR_REAL: set to False if you don't want Agent to send commands to devices but just print messages without really doing anything |
1029 | """ | 1028 | """ |
src/core/pyros_django/scheduling/A_Scheduler.py
@@ -29,6 +29,7 @@ import argparse | @@ -29,6 +29,7 @@ import argparse | ||
29 | import os | 29 | import os |
30 | import pickle | 30 | import pickle |
31 | import socket | 31 | import socket |
32 | + | ||
32 | pwd = os.environ['PROJECT_ROOT_PATH'] | 33 | pwd = os.environ['PROJECT_ROOT_PATH'] |
33 | if pwd not in sys.path: | 34 | if pwd not in sys.path: |
34 | sys.path.append(pwd) | 35 | sys.path.append(pwd) |
@@ -39,7 +40,8 @@ for short_path in short_paths: | @@ -39,7 +40,8 @@ for short_path in short_paths: | ||
39 | if path not in sys.path: | 40 | if path not in sys.path: |
40 | sys.path.insert(0, path) | 41 | sys.path.insert(0, path) |
41 | 42 | ||
42 | -from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent, log, parse_args | 43 | +#from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent, log, parse_args |
44 | +from majordome.agent.Agent import Agent, build_agent, log, parse_args | ||
43 | from seq_submit.models import Sequence | 45 | from seq_submit.models import Sequence |
44 | from user_mgmt.models import Period, ScientificProgram, SP_Period | 46 | from user_mgmt.models import Period, ScientificProgram, SP_Period |
45 | from scheduling.models import PredictiveSchedule, EffectiveSchedule | 47 | from scheduling.models import PredictiveSchedule, EffectiveSchedule |
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
@@ -277,7 +277,7 @@ if __name__ == "__main__": | @@ -277,7 +277,7 @@ if __name__ == "__main__": | ||
277 | print("ARGV OF AGENT SP :",sys.argv) | 277 | print("ARGV OF AGENT SP :",sys.argv) |
278 | if len(sys.argv) > 1 and sys.argv[1] == "test": | 278 | if len(sys.argv) > 1 and sys.argv[1] == "test": |
279 | print("i'm in test") | 279 | print("i'm in test") |
280 | - agentSP = AgentSP(use_db_test=True) | 280 | + agentSP = A_SCP_Manager(use_db_test=True) |
281 | agentSP.run() | 281 | agentSP.run() |
282 | #agent = build_agent(agentSP, RUN_IN_THREAD=True) | 282 | #agent = build_agent(agentSP, RUN_IN_THREAD=True) |
283 | else: | 283 | else: |