Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
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
captainwong
douban-api-proxy
Commits
4578af7a
Commit
4578af7a
authored
Jan 02, 2021
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix export of logfiles (#1794)
parent
9e1cdd8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
debug_info.py
cps/debug_info.py
+10
-4
No files found.
cps/debug_info.py
View file @
4578af7a
...
@@ -21,7 +21,12 @@ import shutil
...
@@ -21,7 +21,12 @@ import shutil
import
glob
import
glob
import
zipfile
import
zipfile
import
json
import
json
import
io
from
io
import
BytesIO
try
:
from
StringIO
import
StringIO
except
ImportError
:
from
io
import
StringIO
import
os
import
os
from
flask
import
send_file
from
flask
import
send_file
...
@@ -32,11 +37,12 @@ from .about import collect_stats
...
@@ -32,11 +37,12 @@ from .about import collect_stats
log
=
logger
.
create
()
log
=
logger
.
create
()
def
assemble_logfiles
(
file_name
):
def
assemble_logfiles
(
file_name
):
log_list
=
glob
.
glob
(
file_name
+
'*'
)
log_list
=
sorted
(
glob
.
glob
(
file_name
+
'*'
),
reverse
=
True
)
wfd
=
io
.
StringIO
()
wfd
=
StringIO
()
for
f
in
log_list
:
for
f
in
log_list
:
with
open
(
f
,
'r'
)
as
fd
:
with
open
(
f
,
'r'
)
as
fd
:
shutil
.
copyfileobj
(
fd
,
wfd
)
shutil
.
copyfileobj
(
fd
,
wfd
)
wfd
.
seek
(
0
)
return
send_file
(
wfd
,
return
send_file
(
wfd
,
as_attachment
=
True
,
as_attachment
=
True
,
attachment_filename
=
os
.
path
.
basename
(
file_name
))
attachment_filename
=
os
.
path
.
basename
(
file_name
))
...
@@ -47,7 +53,7 @@ def send_debug():
...
@@ -47,7 +53,7 @@ def send_debug():
for
element
in
[
logger
.
LOG_TO_STDOUT
,
logger
.
LOG_TO_STDERR
]:
for
element
in
[
logger
.
LOG_TO_STDOUT
,
logger
.
LOG_TO_STDERR
]:
if
element
in
file_list
:
if
element
in
file_list
:
file_list
.
remove
(
element
)
file_list
.
remove
(
element
)
memory_zip
=
io
.
BytesIO
()
memory_zip
=
BytesIO
()
with
zipfile
.
ZipFile
(
memory_zip
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zf
:
with
zipfile
.
ZipFile
(
memory_zip
,
'w'
,
compression
=
zipfile
.
ZIP_DEFLATED
)
as
zf
:
zf
.
writestr
(
'settings.txt'
,
json
.
dumps
(
config
.
toDict
()))
zf
.
writestr
(
'settings.txt'
,
json
.
dumps
(
config
.
toDict
()))
zf
.
writestr
(
'libs.txt'
,
json
.
dumps
(
collect_stats
()))
zf
.
writestr
(
'libs.txt'
,
json
.
dumps
(
collect_stats
()))
...
...
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