Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
e463ae37
Commit
e463ae37
authored
6 years ago
by
广宏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merged in dev (pull request #115)
[Update] 优化代码结构
parents
0e93727f
881cfea8
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
14 additions
and
25 deletions
+14
-25
__init__.py
coco/__init__.py
+1
-0
app.py
coco/app.py
+1
-7
connection.py
coco/connection.py
+1
-1
ctx.py
coco/ctx.py
+0
-6
auth.py
coco/httpd/auth.py
+1
-1
base.py
coco/httpd/base.py
+1
-1
ws.py
coco/httpd/ws.py
+1
-1
interactive.py
coco/interactive.py
+1
-1
interface.py
coco/interface.py
+1
-1
logger.py
coco/logger.py
+1
-1
proxy.py
coco/proxy.py
+1
-1
recorder.py
coco/recorder.py
+1
-1
session.py
coco/session.py
+1
-1
sftp.py
coco/sftp.py
+1
-1
tasks.py
coco/tasks.py
+1
-1
No files found.
coco/__init__.py
View file @
e463ae37
...
@@ -2,4 +2,5 @@
...
@@ -2,4 +2,5 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
#
from
.
import
logger
from
.app
import
Coco
from
.app
import
Coco
This diff is collapsed.
Click to expand it.
coco/app.py
View file @
e463ae37
...
@@ -12,10 +12,9 @@ import signal
...
@@ -12,10 +12,9 @@ import signal
from
.config
import
config
from
.config
import
config
from
.sshd
import
SSHServer
from
.sshd
import
SSHServer
from
.httpd
import
HttpServer
from
.httpd
import
HttpServer
from
.logger
import
create_logger
from
.tasks
import
TaskHandler
from
.tasks
import
TaskHandler
from
.utils
import
get_logger
,
ugettext
as
_
,
ignore_error
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
.recorder
import
get_replay_recorder
from
.session
import
Session
from
.session
import
Session
from
.models
import
Connection
from
.models
import
Connection
...
@@ -56,9 +55,6 @@ class Coco:
...
@@ -56,9 +55,6 @@ class Coco:
self
.
_task_handler
=
TaskHandler
()
self
.
_task_handler
=
TaskHandler
()
return
self
.
_task_handler
return
self
.
_task_handler
def
make_logger
(
self
):
create_logger
()
@staticmethod
@staticmethod
def
load_extra_conf_from_server
():
def
load_extra_conf_from_server
():
configs
=
app_service
.
load_config_from_server
()
configs
=
app_service
.
load_config_from_server
()
...
@@ -68,8 +64,6 @@ class Coco:
...
@@ -68,8 +64,6 @@ class Coco:
config
.
update
(
configs
)
config
.
update
(
configs
)
def
bootstrap
(
self
):
def
bootstrap
(
self
):
self
.
make_logger
()
# app_service.initial()
self
.
load_extra_conf_from_server
()
self
.
load_extra_conf_from_server
()
self
.
keep_heartbeat
()
self
.
keep_heartbeat
()
self
.
monitor_sessions
()
self
.
monitor_sessions
()
...
...
This diff is collapsed.
Click to expand it.
coco/connection.py
View file @
e463ae37
...
@@ -10,7 +10,7 @@ import telnetlib
...
@@ -10,7 +10,7 @@ import telnetlib
import
paramiko
import
paramiko
from
paramiko.ssh_exception
import
SSHException
from
paramiko.ssh_exception
import
SSHException
from
.
ctx
import
app_service
from
.
service
import
app_service
from
.config
import
config
from
.config
import
config
from
.utils
import
get_logger
,
get_private_key_fingerprint
from
.utils
import
get_logger
,
get_private_key_fingerprint
...
...
This diff is collapsed.
Click to expand it.
coco/ctx.py
View file @
e463ae37
...
@@ -4,9 +4,6 @@
...
@@ -4,9 +4,6 @@
from
werkzeug.local
import
LocalProxy
from
werkzeug.local
import
LocalProxy
from
functools
import
partial
from
functools
import
partial
from
.config
import
config
from
jms.service
import
AppService
stack
=
{}
stack
=
{}
__db_sessions
=
[]
__db_sessions
=
[]
...
@@ -18,7 +15,4 @@ def _find(name):
...
@@ -18,7 +15,4 @@ def _find(name):
raise
ValueError
(
"Not found in stack: {}"
.
format
(
name
))
raise
ValueError
(
"Not found in stack: {}"
.
format
(
name
))
app_service
=
AppService
(
config
)
app_service
.
initial
()
current_app
=
LocalProxy
(
partial
(
_find
,
'current_app'
))
current_app
=
LocalProxy
(
partial
(
_find
,
'current_app'
))
# app_service = LocalProxy(partial(_find, 'app_service'))
This diff is collapsed.
Click to expand it.
coco/httpd/auth.py
View file @
e463ae37
...
@@ -4,7 +4,7 @@ from functools import wraps
...
@@ -4,7 +4,7 @@ from functools import wraps
from
flask
import
request
,
abort
,
redirect
from
flask
import
request
,
abort
,
redirect
from
..
ctx
import
app_service
from
..
service
import
app_service
def
login_required
(
func
):
def
login_required
(
func
):
...
...
This diff is collapsed.
Click to expand it.
coco/httpd/base.py
View file @
e463ae37
...
@@ -9,7 +9,7 @@ from flask import Flask, request
...
@@ -9,7 +9,7 @@ from flask import Flask, request
from
..models
import
Connection
,
WSProxy
from
..models
import
Connection
,
WSProxy
from
..proxy
import
ProxyServer
from
..proxy
import
ProxyServer
from
..utils
import
get_logger
from
..utils
import
get_logger
from
..
ctx
import
app_service
from
..
service
import
app_service
from
..config
import
config
from
..config
import
config
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
BASE_DIR
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
__file__
))
...
...
This diff is collapsed.
Click to expand it.
coco/httpd/ws.py
View file @
e463ae37
...
@@ -9,7 +9,7 @@ from flask import request
...
@@ -9,7 +9,7 @@ from flask import request
from
..models
import
Connection
,
WSProxy
from
..models
import
Connection
,
WSProxy
from
..proxy
import
ProxyServer
from
..proxy
import
ProxyServer
from
..utils
import
get_logger
from
..utils
import
get_logger
from
..
ctx
import
app_service
from
..
service
import
app_service
from
.base
import
BaseNamespace
from
.base
import
BaseNamespace
from
.utils
import
get_cached_volume
from
.utils
import
get_cached_volume
...
...
This diff is collapsed.
Click to expand it.
coco/interactive.py
View file @
e463ae37
...
@@ -12,7 +12,7 @@ from .utils import wrap_with_line_feed as wr, wrap_with_title as title, \
...
@@ -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
,
\
wrap_with_warning
as
warning
,
is_obj_attr_has
,
is_obj_attr_eq
,
\
sort_assets
,
ugettext
as
_
,
get_logger
,
net_input
,
format_with_zh
,
\
sort_assets
,
ugettext
as
_
,
get_logger
,
net_input
,
format_with_zh
,
\
item_max_length
,
size_of_str_with_zh
,
switch_lang
item_max_length
,
size_of_str_with_zh
,
switch_lang
from
.
ctx
import
app_service
from
.
service
import
app_service
from
.proxy
import
ProxyServer
from
.proxy
import
ProxyServer
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
...
...
This diff is collapsed.
Click to expand it.
coco/interface.py
View file @
e463ae37
...
@@ -8,7 +8,7 @@ from collections import Iterable
...
@@ -8,7 +8,7 @@ from collections import Iterable
from
.utils
import
get_logger
from
.utils
import
get_logger
from
.config
import
config
from
.config
import
config
from
.
ctx
import
app_service
from
.
service
import
app_service
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
...
...
This diff is collapsed.
Click to expand it.
coco/logger.py
View file @
e463ae37
...
@@ -57,9 +57,9 @@ def create_logger():
...
@@ -57,9 +57,9 @@ def create_logger():
# 'engineio': main_setting,
# 'engineio': main_setting,
}
}
)
)
dictConfig
(
config
)
dictConfig
(
config
)
logger
=
logging
.
getLogger
()
logger
=
logging
.
getLogger
()
return
logger
return
logger
create_logger
()
This diff is collapsed.
Click to expand it.
coco/proxy.py
View file @
e463ae37
...
@@ -8,7 +8,7 @@ import time
...
@@ -8,7 +8,7 @@ import time
from
.session
import
Session
from
.session
import
Session
from
.models
import
Server
,
TelnetServer
from
.models
import
Server
,
TelnetServer
from
.connection
import
SSHConnection
,
TelnetConnection
from
.connection
import
SSHConnection
,
TelnetConnection
from
.
ctx
import
app_service
from
.
service
import
app_service
from
.config
import
config
from
.config
import
config
from
.utils
import
wrap_with_line_feed
as
wr
,
wrap_with_warning
as
warning
,
\
from
.utils
import
wrap_with_line_feed
as
wr
,
wrap_with_warning
as
warning
,
\
get_logger
,
net_input
,
ugettext
as
_
get_logger
,
net_input
,
ugettext
as
_
...
...
This diff is collapsed.
Click to expand it.
coco/recorder.py
View file @
e463ae37
...
@@ -15,7 +15,7 @@ import jms_storage
...
@@ -15,7 +15,7 @@ import jms_storage
from
.config
import
config
from
.config
import
config
from
.utils
import
get_logger
,
Singleton
from
.utils
import
get_logger
,
Singleton
from
.struct
import
MemoryQueue
from
.struct
import
MemoryQueue
from
.
ctx
import
app_service
from
.
service
import
app_service
logger
=
get_logger
(
__file__
)
logger
=
get_logger
(
__file__
)
BUF_SIZE
=
1024
BUF_SIZE
=
1024
...
...
This diff is collapsed.
Click to expand it.
coco/session.py
View file @
e463ae37
...
@@ -8,7 +8,7 @@ import time
...
@@ -8,7 +8,7 @@ import time
from
.utils
import
get_logger
,
wrap_with_warning
as
warn
,
\
from
.utils
import
get_logger
,
wrap_with_warning
as
warn
,
\
wrap_with_line_feed
as
wr
,
ugettext
as
_
,
ignore_error
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
.struct
import
SelectEvent
from
.recorder
import
get_recorder
from
.recorder
import
get_recorder
...
...
This diff is collapsed.
Click to expand it.
coco/sftp.py
View file @
e463ae37
...
@@ -9,7 +9,7 @@ from paramiko.sftp import SFTP_PERMISSION_DENIED, SFTP_NO_SUCH_FILE, \
...
@@ -9,7 +9,7 @@ from paramiko.sftp import SFTP_PERMISSION_DENIED, SFTP_NO_SUCH_FILE, \
from
coco.utils
import
get_logger
from
coco.utils
import
get_logger
from
.config
import
config
from
.config
import
config
from
.
ctx
import
app_service
from
.
service
import
app_service
from
.connection
import
SSHConnection
from
.connection
import
SSHConnection
CURRENT_DIR
=
os
.
path
.
dirname
(
__file__
)
CURRENT_DIR
=
os
.
path
.
dirname
(
__file__
)
...
...
This diff is collapsed.
Click to expand it.
coco/tasks.py
View file @
e463ae37
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
#
#
from
.
ctx
import
app_service
from
.
service
import
app_service
from
.utils
import
get_logger
from
.utils
import
get_logger
from
.session
import
Session
from
.session
import
Session
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment