start_agent_majordome.py 1.07 KB
#!/usr/bin/env python

import os
import sys
from django.conf import settings as djangosettings

FOR_REAL = True
if len(sys.argv) == 2 and sys.argv[1] == "test":
    FOR_REAL = False
print("FOR_REAL is", FOR_REAL)

# To avoid a "ModuleNotFoundError: No module named 'dashboard'"... (not even 1 app found) :
sys.path.insert(0, os.path.abspath(".."))
# To avoid a "ModuleNotFoundError: No module named 'src'"
sys.path.append("..")
print("Starting with this sys.path", sys.path)

# DJANGO setup
# print("file is", __file__)
# mypath = os.getcwd()
# Go into src/
os.chdir("..")
# print("Current directory : " + str(os.getcwd()))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "src.pyros.settings")
# os.environ['SECRET_KEY'] = 'abc'
# os.environ['ENVIRONMENT'] = 'production'
import django

django.setup()

print("DB2 used is:", djangosettings.DATABASES["default"]["NAME"])


# MONITORING AGENT setup
agent = "majordome"

if agent == "majordome":
    from majordome.tasks import Majordome

    # Run agent Majordome without actual commands sent to devices (FOR_REAL=False)
    Majordome().run(FOR_REAL)