From ba9393ba319e3dfc5ed597439ac4fe828afc6810 Mon Sep 17 00:00:00 2001 From: Etienne Pallier Date: Thu, 13 Jun 2019 17:56:32 +0200 Subject: [PATCH] Restructuration du projet - phase 1 : src/ => pyros_django/ --- .pydevproject | 4 ++-- devices_channel/README.md | 6 +++--- devices_channel/client/devices_abstract/device_controller_abstract.py | 2 +- devices_channel/client/devices_abstract/plc_controller_abstract.py | 2 +- devices_channel/client/devices_abstract/telescope_controller_abstract.py | 2 +- pyros.py | 22 +++++++++++----------- pyros_django/agent/Agent.py | 4 ++-- pyros_django/monitoring/AgentM.py | 6 +++--- pyros_django/monitoring/tasks.py | 2 +- start_agent.py | 10 +++++----- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.pydevproject b/.pydevproject index 48f131b..113d54b 100644 --- a/.pydevproject +++ b/.pydevproject @@ -19,7 +19,7 @@ - /${PROJECT_DIR_NAME}/src + /${PROJECT_DIR_NAME}/pyros_django /${PROJECT_DIR_NAME}/simulators @@ -41,7 +41,7 @@ - src/manage.py + pyros_django/manage.py diff --git a/devices_channel/README.md b/devices_channel/README.md index 01731f3..f7ab4ea 100644 --- a/devices_channel/README.md +++ b/devices_channel/README.md @@ -1,11 +1,11 @@ -VERSION: 0.30.2 +VERSION: 0.30.3 -Date: 11/06/2019 +Date: 13/06/2019 By: epallier@irap.omp.eu - +Comment : Restructuration du projet - phase 1 : src/ => pyros_django/ diff --git a/devices_channel/client/devices_abstract/device_controller_abstract.py b/devices_channel/client/devices_abstract/device_controller_abstract.py index f625b11..7d204aa 100755 --- a/devices_channel/client/devices_abstract/device_controller_abstract.py +++ b/devices_channel/client/devices_abstract/device_controller_abstract.py @@ -22,7 +22,7 @@ import time sys.path.append("..") # from src_socket/client/ sys.path.append("../../..") -import src.utils.celme as celme +import pyros_django.utils.celme as celme from devices_channel.client.logs import * diff --git a/devices_channel/client/devices_abstract/plc_controller_abstract.py b/devices_channel/client/devices_abstract/plc_controller_abstract.py index 3dc714d..964de59 100755 --- a/devices_channel/client/devices_abstract/plc_controller_abstract.py +++ b/devices_channel/client/devices_abstract/plc_controller_abstract.py @@ -20,7 +20,7 @@ import time sys.path.append("..") # from src_socket/client/ sys.path.append("../../..") -import src.utils.celme as celme +import pyros_django.utils.celme as celme # Local application imports diff --git a/devices_channel/client/devices_abstract/telescope_controller_abstract.py b/devices_channel/client/devices_abstract/telescope_controller_abstract.py index 8bf414e..f20b50c 100755 --- a/devices_channel/client/devices_abstract/telescope_controller_abstract.py +++ b/devices_channel/client/devices_abstract/telescope_controller_abstract.py @@ -20,7 +20,7 @@ import time sys.path.append("..") # from src_socket/client/ sys.path.append("../../..") -import src.utils.celme as celme +import pyros_django.utils.celme as celme # Local application imports diff --git a/pyros.py b/pyros.py index 2613f5a..e51422b 100755 --- a/pyros.py +++ b/pyros.py @@ -259,7 +259,7 @@ def shell(): print() print("Type 'exit()' to quit") print() - os.chdir("src/") + os.chdir("pyros_django/") # execProcess("python install.py install") if not test_mode(): execProcessFromVenv("manage.py shell") # Go back to the initial dir @@ -276,7 +276,7 @@ def dbshell(): print("Type 'exit' to quit") print() # execProcess("python install.py install") - if not test_mode(): execProcessFromVenv("src/manage.py dbshell") + if not test_mode(): execProcessFromVenv("pyros_django/manage.py dbshell") # Go back to the initial dir return True @@ -307,7 +307,7 @@ def test(): apps = ['common', 'scheduler', 'routine_manager', 'user_manager', 'alert_manager.tests.TestStrategyChange'] for app in apps: _loaddata() or die() - change_dir("src") + change_dir("pyros_django") execProcessFromVenv('manage.py test ' + app) or die() change_dir("..") # execProcess("python install.py install") @@ -315,7 +315,7 @@ def test(): @pyros_launcher.command(help="Run ALL tests") def testall(): - change_dir("src") + change_dir("pyros_django") execProcessFromVenvAsync("manage.py test") change_dir("..") return True @@ -425,11 +425,11 @@ def start(agent:str, configfile:str): # Agent "webserver" if agent_name == "webserver": cmd = "manage.py runserver" - os.chdir("src") + os.chdir("pyros_django") #if not test_mode(): execProcessFromVenv("start_agent.py " + agent_name + " " + configfile) elif agent_name == "agentM": - os.chdir("src/monitoring/") + os.chdir("pyros_django/monitoring/") cmd = f"Agent{agent_name[5:]}.py" if test_mode(): cmd += " -t" if configfile: cmd += " {configfile}" @@ -438,7 +438,7 @@ def start(agent:str, configfile:str): elif agent_name.startswith("agent"): # Run agent without actual commands sent to devices (FOR_REAL=False) ##agentX.run(FOR_REAL=True) - os.chdir("src/agent/") + os.chdir("pyros_django/agent/") #cmd = "-m AgentX" #cmd = f" Agent{agent_name[5:]}.py {configfile}" cmd = f"Agent{agent_name[5:]}.py" @@ -507,14 +507,14 @@ def _update_python_packages_from_requirements(): def _update_plantuml_diags(): res = False - for dirpath, dirnames, files in os.walk('src'): + for dirpath, dirnames, files in os.walk('pyros_django'): if os.path.basename(dirpath) == "doc": diagrams = glob.glob(dirpath+os.sep+"*.pu") for diag in diagrams: res = execProcessFromVenv("-m plantuml "+diag) return res def _migrate(): - change_dir("src") + change_dir("pyros_django") # Migrate only migrations for the app "common" #res = execProcessFromVenv("manage.py migrate common") # Migrate all migrations for ALL apps @@ -523,7 +523,7 @@ def _migrate(): return res def _makemigrations(): - change_dir("src") + change_dir("pyros_django") #execProcessFromVenv(self.venv_bin + " manage.py makemigrations") #res = execProcessFromVenv("manage.py makemigrations common") res = execProcessFromVenv("manage.py makemigrations") @@ -532,7 +532,7 @@ def _makemigrations(): #TODO: mettre la fixture en date naive (sans time zone) def _loaddata(): - change_dir("src") + change_dir("pyros_django") #execProcessFromVenv(self.venv_bin + " manage.py loaddata misc" + os.sep + "fixtures" + os.sep + self.INIT_FIXTURE) res = execProcessFromVenv("manage.py loaddata misc" + os.sep + "fixtures" + os.sep + INIT_FIXTURE) change_dir("..") diff --git a/pyros_django/agent/Agent.py b/pyros_django/agent/Agent.py index 11ed9f8..b2cd272 100755 --- a/pyros_django/agent/Agent.py +++ b/pyros_django/agent/Agent.py @@ -56,7 +56,7 @@ print("Starting with this sys.path", sys.path) ##os.chdir("src") print("Current directory : " + str(os.getcwd())) -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.pyros.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pyros_django.pyros.settings") # os.environ['SECRET_KEY'] = 'abc' # os.environ['ENVIRONMENT'] = 'production' import django @@ -377,7 +377,7 @@ class Agent: config_filename = os.path.abspath(self.CONFIG_DIR + os.sep + config_filename) # Remove "src/agent_name/" from abs dir : # (1) Remove "src/" - config_filename = config_filename.replace(os.sep+"src"+os.sep,os.sep) + config_filename = config_filename.replace(os.sep+"pyros_django"+os.sep,os.sep) # (2) Remove "agent_name/" #TODO: bidouille, faire plus propre config_filename = config_filename.replace(os.sep+"agent"+os.sep,os.sep) diff --git a/pyros_django/monitoring/AgentM.py b/pyros_django/monitoring/AgentM.py index eca5ed7..2776aa8 100755 --- a/pyros_django/monitoring/AgentM.py +++ b/pyros_django/monitoring/AgentM.py @@ -10,11 +10,11 @@ import sys sys.path.append("..") sys.path.append("../..") -from src.agent.Agent import Agent, extract_parameters +from pyros_django.agent.Agent import Agent, extract_parameters # PM 20190416 recycle code -from src.devices.PLC import PLCController -from src.monitoring.plc_checker import PlcChecker +from pyros_django.devices.PLC import PLCController +from pyros_django.monitoring.plc_checker import PlcChecker from common.models import * ##log = L.setupLogger("AgentXTaskLogger", "AgentX") diff --git a/pyros_django/monitoring/tasks.py b/pyros_django/monitoring/tasks.py index 2e2c453..5ceadd6 100644 --- a/pyros_django/monitoring/tasks.py +++ b/pyros_django/monitoring/tasks.py @@ -2,7 +2,7 @@ from __future__ import absolute_import from django.conf import settings from common.models import * -from src.monitoring.plc_checker import PlcChecker +from pyros_django.monitoring.plc_checker import PlcChecker from devices.PLC import PLCController from utils.JDManipulator import * import json diff --git a/start_agent.py b/start_agent.py index 96fc0d6..30facdd 100755 --- a/start_agent.py +++ b/start_agent.py @@ -85,24 +85,24 @@ if agent_name not in AGENTS: sys.exit(1) if agent_name == "majordome": - from src.majordome.tasks import Majordome + from pyros_django.majordome.tasks import Majordome Majordome().run(FOR_REAL=True) sys.exit(0) if agent_name == "monitoring": - from src.monitoring.tasks import Monitoring + from pyros_django.monitoring.tasks import Monitoring Monitoring().run() sys.exit(0) if agent_name == "agentA": - from src.agent.AgentA import AgentA + from pyros_django.agent.AgentA import AgentA agentA = AgentA(name="agentA", config_filename=configfile) # Run agent without actual commands sent to devices (FOR_REAL=False) agentA.run(FOR_REAL=True) sys.exit(0) if agent_name == "agentM": - from src.monitoring.AgentM import AgentM + from pyros_django.monitoring.AgentM import AgentM agentM = AgentM(name="agentM", config_filename=configfile) # Run agent without actual commands sent to devices (FOR_REAL=False) agentM.run(FOR_REAL=True) @@ -116,7 +116,7 @@ agent.run(FOR_REAL=True) # Default agent is AgentX -from src.agent.AgentX import AgentX +from pyros_django.agent.AgentX import AgentX # AgentX().run(FOR_REAL=False) agentX = AgentX(name="agentX", config_filename=configfile) -- libgit2 0.21.2