mirror of https://github.com/tp4a/teleport
temp: config class.
parent
cb9ecebbce
commit
28ca556551
|
@ -27,6 +27,10 @@ class ConfigFile(AttrDict):
|
|||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
import builtins
|
||||
if '__web_config__' in builtins.__dict__:
|
||||
raise RuntimeError('WebConfig object exists, you can not create more than one instance.')
|
||||
|
||||
self['core'] = AttrDict()
|
||||
self['core']['detected'] = False
|
||||
# self['core']['ssh'] = AttrDict()
|
||||
|
@ -135,13 +139,26 @@ class ConfigFile(AttrDict):
|
|||
return True
|
||||
|
||||
|
||||
_g_cfg = ConfigFile()
|
||||
del ConfigFile
|
||||
class WebConfig:
|
||||
def __init__(self):
|
||||
import builtins
|
||||
if '__web_config__' in builtins.__dict__:
|
||||
raise RuntimeError('WebConfig object exists, you can not create more than one instance.')
|
||||
|
||||
self.cfg = {}
|
||||
|
||||
self.default_cfg = {}
|
||||
|
||||
@property
|
||||
def server_ip(self):
|
||||
return self.cfg['ip']
|
||||
|
||||
|
||||
def app_cfg():
|
||||
global _g_cfg
|
||||
return _g_cfg
|
||||
import builtins
|
||||
if '__web_config__' not in builtins.__dict__:
|
||||
builtins.__dict__['__web_config__'] = ConfigFile()
|
||||
return builtins.__dict__['__web_config__']
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -51,7 +51,14 @@ class InfoHandler(TPBaseAdminAuthHandler):
|
|||
|
||||
class DatabaseHandler(TPBaseAdminAuthHandler):
|
||||
def get(self):
|
||||
param = {'core_server': cfg.core}
|
||||
_db = get_db()
|
||||
# database = '未知'
|
||||
# if _db.db_source['type'] == _db.DB_TYPE_SQLITE:
|
||||
# database = 'SQLite({})'.format(_db.db_source['file'])
|
||||
# elif _db.db_source['type'] == _db.DB_TYPE_MYSQL:
|
||||
# database = 'MySQL'
|
||||
|
||||
param = {'db': _db.db_source}
|
||||
self.render('set/database.mako', page_param=json.dumps(param))
|
||||
|
||||
# def _restart_func():
|
||||
|
|
Loading…
Reference in New Issue