Commit e463ae37 authored by 广宏伟's avatar 广宏伟

Merged in dev (pull request #115)

[Update] 优化代码结构
parents 0e93727f 881cfea8
......@@ -2,4 +2,5 @@
# -*- coding: utf-8 -*-
#
from . import logger
from .app import Coco
......@@ -12,10 +12,9 @@ import signal
from .config import config
from .sshd import SSHServer
from .httpd import HttpServer
from .logger import create_logger
from .tasks import TaskHandler
from .utils import get_logger, ugettext as _, ignore_error
from .ctx import app_service
from .service import app_service
from .recorder import get_replay_recorder
from .session import Session
from .models import Connection
......@@ -56,9 +55,6 @@ class Coco:
self._task_handler = TaskHandler()
return self._task_handler
def make_logger(self):
create_logger()
@staticmethod
def load_extra_conf_from_server():
configs = app_service.load_config_from_server()
......@@ -68,8 +64,6 @@ class Coco:
config.update(configs)
def bootstrap(self):
self.make_logger()
# app_service.initial()
self.load_extra_conf_from_server()
self.keep_heartbeat()
self.monitor_sessions()
......
......@@ -10,7 +10,7 @@ import telnetlib
import paramiko
from paramiko.ssh_exception import SSHException
from .ctx import app_service
from .service import app_service
from .config import config
from .utils import get_logger, get_private_key_fingerprint
......
......@@ -4,9 +4,6 @@
from werkzeug.local import LocalProxy
from functools import partial
from .config import config
from jms.service import AppService
stack = {}
__db_sessions = []
......@@ -18,7 +15,4 @@ def _find(name):
raise ValueError("Not found in stack: {}".format(name))
app_service = AppService(config)
app_service.initial()
current_app = LocalProxy(partial(_find, 'current_app'))
# app_service = LocalProxy(partial(_find, 'app_service'))
......@@ -4,7 +4,7 @@ from functools import wraps
from flask import request, abort, redirect
from ..ctx import app_service
from ..service import app_service
def login_required(func):
......
......@@ -9,7 +9,7 @@ from flask import Flask, request
from ..models import Connection, WSProxy
from ..proxy import ProxyServer
from ..utils import get_logger
from ..ctx import app_service
from ..service import app_service
from ..config import config
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
......
......@@ -9,7 +9,7 @@ from flask import request
from ..models import Connection, WSProxy
from ..proxy import ProxyServer
from ..utils import get_logger
from ..ctx import app_service
from ..service import app_service
from .base import BaseNamespace
from .utils import get_cached_volume
......
......@@ -12,7 +12,7 @@ from .utils import wrap_with_line_feed as wr, wrap_with_title as title, \
wrap_with_warning as warning, is_obj_attr_has, is_obj_attr_eq, \
sort_assets, ugettext as _, get_logger, net_input, format_with_zh, \
item_max_length, size_of_str_with_zh, switch_lang
from .ctx import app_service
from .service import app_service
from .proxy import ProxyServer
logger = get_logger(__file__)
......
......@@ -8,7 +8,7 @@ from collections import Iterable
from .utils import get_logger
from .config import config
from .ctx import app_service
from .service import app_service
logger = get_logger(__file__)
......
......@@ -57,9 +57,9 @@ def create_logger():
# 'engineio': main_setting,
}
)
dictConfig(config)
logger = logging.getLogger()
return logger
create_logger()
......@@ -8,7 +8,7 @@ import time
from .session import Session
from .models import Server, TelnetServer
from .connection import SSHConnection, TelnetConnection
from .ctx import app_service
from .service import app_service
from .config import config
from .utils import wrap_with_line_feed as wr, wrap_with_warning as warning, \
get_logger, net_input, ugettext as _
......
......@@ -15,7 +15,7 @@ import jms_storage
from .config import config
from .utils import get_logger, Singleton
from .struct import MemoryQueue
from .ctx import app_service
from .service import app_service
logger = get_logger(__file__)
BUF_SIZE = 1024
......
......@@ -8,7 +8,7 @@ import time
from .utils import get_logger, wrap_with_warning as warn, \
wrap_with_line_feed as wr, ugettext as _, ignore_error
from .ctx import app_service
from .service import app_service
from .struct import SelectEvent
from .recorder import get_recorder
......
......@@ -9,7 +9,7 @@ from paramiko.sftp import SFTP_PERMISSION_DENIED, SFTP_NO_SUCH_FILE, \
from coco.utils import get_logger
from .config import config
from .ctx import app_service
from .service import app_service
from .connection import SSHConnection
CURRENT_DIR = os.path.dirname(__file__)
......
......@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
#
from .ctx import app_service
from .service import app_service
from .utils import get_logger
from .session import Session
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment