diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/isp-maintenance.iml b/.idea/isp-maintenance.iml new file mode 100644 index 0000000..0484bec --- /dev/null +++ b/.idea/isp-maintenance.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bbd0c57 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..b72fb8a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/isp_maintenance/db/base.py b/isp_maintenance/db/base.py index e69de29..4bbc39b 100644 --- a/isp_maintenance/db/base.py +++ b/isp_maintenance/db/base.py @@ -0,0 +1,6 @@ +class UnknownField(object): + def __init__(self, *_, **__): pass + +class BaseModel(Model): + class Meta: + database = db diff --git a/isp_maintenance/db/vm6/models.py b/isp_maintenance/db/vm6/models.py index 4b4e889..6f5ade4 100644 --- a/isp_maintenance/db/vm6/models.py +++ b/isp_maintenance/db/vm6/models.py @@ -1,43 +1,5 @@ -import os -import json +from peewee import Model, MySQLDatabase, CharField, IntegerField -from peewee import Model, MySQLDatabase, CharField - -CLIENT_HOST = os.environ.get("CLIENT_HOST", "replace_to_client_host") -PLATFORM = os.environ.get("PLATFORM", "vm") # or dci - -DB_ENGINE = os.environ.get("DB_ENGINE", "mysql") -DB_HOST = os.environ.get("DB_HOST", "mysql") -DB_PORT = os.environ.get("DB_PORT", 3306) -DB_USER = os.environ.get("DB_USER", "root") -DB_PASSWORD = os.environ.get("DB_PASSWORD", None) # not secure!!! -DB_NAME = os.environ.get("DB_NAME", "isp") # or auth for dci - -if DB_PASSWORD is None: - with open('config.json', 'r') as f: - platform_config = json.load(f) - DB_PASSWORD = platform_config.get("MysqlRootPassword") - - -# Подключение к базе данных -db = MySQLDatabase( - DB_NAME, **{ - 'charset': 'utf8', - 'sql_mode': 'PIPES_AS_CONCAT', - 'use_unicode': True, - 'host': DB_HOST, - 'port': DB_PORT, - 'user': DB_USER, - 'password': DB_PASSWORD - } - ) - -class UnknownField(object): - def __init__(self, *_, **__): pass - -class BaseModel(Model): - class Meta: - database = db class AlertSetting(BaseModel): channel = UnknownField(null=True) # json