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
0848852e
Unverified
Commit
0848852e
authored
Feb 08, 2018
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: s3 with access_key and secret_key and bucket
parent
a21d562b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
recorder.py
coco/recorder.py
+11
-2
No files found.
coco/recorder.py
View file @
0848852e
...
...
@@ -243,14 +243,23 @@ class S3ReplayRecorder(ServerReplayRecorder):
def
__init__
(
self
,
app
):
super
()
.
__init__
(
app
)
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
):
try
:
self
.
s3
.
upload_file
(
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay.gz'
),
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'
)
except
:
return
self
.
app
.
service
.
push_session_replay
(
...
...
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