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
e50f93e3
Commit
e50f93e3
authored
Feb 26, 2018
by
广宏伟
Browse files
Options
Browse Files
Download
Plain Diff
Merged in test (pull request #20)
Test
parents
b1637632
d59cbf38
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
6 deletions
+15
-6
app.py
coco/app.py
+2
-2
interactive.py
coco/interactive.py
+1
-1
recorder.py
coco/recorder.py
+11
-2
requirements.txt
requirements/requirements.txt
+1
-1
No files found.
coco/app.py
View file @
e50f93e3
...
@@ -228,10 +228,10 @@ class Coco:
...
@@ -228,10 +228,10 @@ class Coco:
def
add_session
(
self
,
session
):
def
add_session
(
self
,
session
):
with
self
.
lock
:
with
self
.
lock
:
self
.
sessions
.
append
(
session
)
self
.
sessions
.
append
(
session
)
self
.
heartbeat_async
(
)
self
.
service
.
create_session
(
session
.
to_json
()
)
def
remove_session
(
self
,
session
):
def
remove_session
(
self
,
session
):
with
self
.
lock
:
with
self
.
lock
:
logger
.
info
(
"Remove session: {}"
.
format
(
session
))
logger
.
info
(
"Remove session: {}"
.
format
(
session
))
self
.
sessions
.
remove
(
session
)
self
.
sessions
.
remove
(
session
)
self
.
heartbeat_async
(
)
self
.
service
.
finish_session
(
session
.
id
)
coco/interactive.py
View file @
e50f93e3
...
@@ -201,7 +201,7 @@ class InteractiveServer:
...
@@ -201,7 +201,7 @@ class InteractiveServer:
def
display_group_assets
(
self
,
_id
):
def
display_group_assets
(
self
,
_id
):
if
_id
>
len
(
self
.
asset_groups
)
or
_id
<=
0
:
if
_id
>
len
(
self
.
asset_groups
)
or
_id
<=
0
:
self
.
client
.
send
(
wr
(
warning
(
"No
t match
group, select again"
)))
self
.
client
.
send
(
wr
(
warning
(
"No
matched
group, select again"
)))
self
.
display_asset_groups
()
self
.
display_asset_groups
()
return
return
...
...
coco/recorder.py
View file @
e50f93e3
...
@@ -243,14 +243,23 @@ class S3ReplayRecorder(ServerReplayRecorder):
...
@@ -243,14 +243,23 @@ class S3ReplayRecorder(ServerReplayRecorder):
def
__init__
(
self
,
app
):
def
__init__
(
self
,
app
):
super
()
.
__init__
(
app
)
super
()
.
__init__
(
app
)
self
.
bucket
=
app
.
config
[
"REPLAY_STORAGE"
]
.
get
(
"BUCKET"
,
"jumpserver"
)
self
.
bucket
=
app
.
config
[
"REPLAY_STORAGE"
]
.
get
(
"BUCKET"
,
"jumpserver"
)
self
.
s3
=
boto3
.
client
(
's3'
)
self
.
REGION
=
app
.
config
[
"REPLAY_STORAGE"
]
.
get
(
"REGION"
,
None
)
self
.
ACCESS_KEY
=
app
.
config
[
"REPLAY_STORAGE"
]
.
get
(
"ACCESS_KEY"
,
None
)
self
.
SECRET_KEY
=
app
.
config
[
"REPLAY_STORAGE"
]
.
get
(
"SECRET_KEY"
,
None
)
if
self
.
ACCESS_KEY
and
self
.
REGION
and
self
.
SECRET_KEY
:
self
.
s3
=
boto3
.
client
(
's3'
,
region_name
=
self
.
REGION
,
aws_access_key_id
=
self
.
ACCESS_KEY
,
aws_secret_access_key
=
self
.
SECRET_KEY
)
else
:
self
.
s3
=
boto3
.
client
(
's3'
)
def
push_to_server
(
self
,
session_id
):
def
push_to_server
(
self
,
session_id
):
try
:
try
:
self
.
s3
.
upload_file
(
self
.
s3
.
upload_file
(
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay.gz'
),
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay.gz'
),
self
.
bucket
,
self
.
bucket
,
time
.
strftime
(
'
%
Y-
%
m-
%
d'
,
time
.
localtime
(
self
.
app
.
config
.
get
(
"NAME"
,
"coco"
)
+
time
.
strftime
(
'
%
Y-
%
m-
%
d'
,
time
.
localtime
(
self
.
starttime
))
+
'/'
+
session_id
+
'.replay.gz'
)
self
.
starttime
))
+
'/'
+
session_id
+
'.replay.gz'
)
except
:
except
:
return
self
.
app
.
service
.
push_session_replay
(
return
self
.
app
.
service
.
push_session_replay
(
...
...
requirements/requirements.txt
View file @
e50f93e3
...
@@ -30,5 +30,5 @@ tornado==4.5.2
...
@@ -30,5 +30,5 @@ tornado==4.5.2
urllib3==1.22
urllib3==1.22
wcwidth==0.1.7
wcwidth==0.1.7
werkzeug==0.12.2
werkzeug==0.12.2
jumpserver-python-sdk==0.0.
28
jumpserver-python-sdk==0.0.
30
jms-es-sdk
jms-es-sdk
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