[Bugfix] 修复获取common settings时数据库问题

pull/2013/head
ibuler 2018-11-07 11:26:39 +08:00
parent b8874e1855
commit 2e4e5503cc
2 changed files with 8 additions and 3 deletions

View File

@ -392,7 +392,10 @@ def get_command_storage_or_create_default_storage():
from common.models import common_settings, Setting from common.models import common_settings, Setting
name = 'TERMINAL_COMMAND_STORAGE' name = 'TERMINAL_COMMAND_STORAGE'
default = {'default': {'TYPE': 'server'}} default = {'default': {'TYPE': 'server'}}
command_storage = common_settings.TERMINAL_COMMAND_STORAGE try:
command_storage = common_settings.TERMINAL_COMMAND_STORAGE
except Exception:
return default
if command_storage is None: if command_storage is None:
obj = Setting() obj = Setting()
obj.name = name obj.name = name
@ -413,7 +416,10 @@ def get_replay_storage_or_create_default_storage():
from common.models import common_settings, Setting from common.models import common_settings, Setting
name = 'TERMINAL_REPLAY_STORAGE' name = 'TERMINAL_REPLAY_STORAGE'
default = {'default': {'TYPE': 'server'}} default = {'default': {'TYPE': 'server'}}
replay_storage = common_settings.TERMINAL_REPLAY_STORAGE try:
replay_storage = common_settings.TERMINAL_REPLAY_STORAGE
except Exception:
return default
if replay_storage is None: if replay_storage is None:
obj = Setting() obj = Setting()
obj.name = name obj.name = name

View File

@ -3,7 +3,6 @@ from django.conf import settings
from .command.serializers import SessionCommandSerializer from .command.serializers import SessionCommandSerializer
from common import utils from common import utils
from common.models import common_settings, Setting
TYPE_ENGINE_MAPPING = { TYPE_ENGINE_MAPPING = {
'elasticsearch': 'terminal.backends.command.es', 'elasticsearch': 'terminal.backends.command.es',