get_settings
This commit is contained in:
parent
65132e1017
commit
651c16558c
27
main_func.py
27
main_func.py
|
|
@ -1,5 +1,5 @@
|
||||||
from settings.logger import log_function_call, logger
|
from settings.logger import log_function_call, logger
|
||||||
from utils import sql_insert
|
from utils import sql_insert, sql_select
|
||||||
|
|
||||||
|
|
||||||
class MAIN_FUNC:
|
class MAIN_FUNC:
|
||||||
|
|
@ -16,7 +16,30 @@ class MAIN_FUNC:
|
||||||
except SystemError as e:
|
except SystemError as e:
|
||||||
print(e)
|
print(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@log_function_call
|
||||||
|
def get_settings(self):
|
||||||
|
t = 'SELECT * FROM main_settings'
|
||||||
|
try:
|
||||||
|
res = sql_select(t)
|
||||||
|
return res
|
||||||
|
except SystemError as e:
|
||||||
|
print(e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
@log_function_call
|
||||||
|
def get_setting(self, name):
|
||||||
|
id = -1
|
||||||
|
if isinstance(name, (int)):
|
||||||
|
id = int(name)
|
||||||
|
t = 'SELECT * FROM main_settings WHERE name = %s OR id = %s'
|
||||||
|
v = (name, id)
|
||||||
|
try:
|
||||||
|
res = sql_select(t, v)
|
||||||
|
return res[0][2]
|
||||||
|
except SystemError as e:
|
||||||
|
print(e)
|
||||||
|
return False
|
||||||
|
|
||||||
logger.info('START | 3/4 | Load main_func')
|
logger.info('START | 3/4 | Load main_func')
|
||||||
main_func = MAIN_FUNC()
|
main_func = MAIN_FUNC()
|
||||||
|
|
|
||||||
15
start.py
15
start.py
|
|
@ -1,5 +1,6 @@
|
||||||
from utils import *
|
from utils import *
|
||||||
from main_func import main_func
|
from main_func import main_func
|
||||||
|
import time
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'page': 'testing',
|
'page': 'testing',
|
||||||
|
|
@ -7,4 +8,16 @@ data = {
|
||||||
'data': (1, 23, 'vok1no', (1, 2, 3))
|
'data': (1, 23, 'vok1no', (1, 2, 3))
|
||||||
}
|
}
|
||||||
r = main_func.create_log(data)
|
r = main_func.create_log(data)
|
||||||
print(r)
|
d = main_func.get_settings()
|
||||||
|
print(d)
|
||||||
|
print(r)
|
||||||
|
c = main_func.get_setting('debug_log_type')
|
||||||
|
print(c)
|
||||||
|
if c == 1:
|
||||||
|
logger.info(f'DEBUG_LOG_TYPE -> {c} | Включение режима!')
|
||||||
|
interval = 2 # интервал в секундах
|
||||||
|
while True:
|
||||||
|
print(f"DEBUG_LOG: Сейчас {time.ctime()}")
|
||||||
|
time.sleep(2)
|
||||||
|
else:
|
||||||
|
logger.info(f'DEBUG_LOG_TYPE -> {c} | Без включения!')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue