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
f8de7e75
Commit
f8de7e75
authored
Jul 11, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error unclosed IO on external binary version query
parent
87f07003
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
converter.py
cps/converter.py
+1
-3
helper.py
cps/helper.py
+5
-6
subproc_wrapper.py
cps/subproc_wrapper.py
+9
-3
No files found.
cps/converter.py
View file @
f8de7e75
...
...
@@ -39,9 +39,7 @@ def _get_command_version(path, pattern, argument=None):
if
argument
:
command
.
append
(
argument
)
try
:
for
line
in
process_wait
(
command
):
if
re
.
search
(
pattern
,
line
):
return
line
return
process_wait
(
command
,
pattern
=
pattern
)
.
string
except
Exception
as
ex
:
log
.
warning
(
"
%
s:
%
s"
,
path
,
ex
)
return
_EXECUTION_ERROR
...
...
cps/helper.py
View file @
f8de7e75
...
...
@@ -711,12 +711,11 @@ def check_unrar(unrarLocation):
if
sys
.
version_info
<
(
3
,
0
):
unrarLocation
=
unrarLocation
.
encode
(
sys
.
getfilesystemencoding
())
unrarLocation
=
[
unrarLocation
]
for
lines
in
process_wait
(
unrarLocation
):
value
=
re
.
search
(
'UNRAR (.*) freeware'
,
lines
,
re
.
IGNORECASE
)
if
value
:
version
=
value
.
group
(
1
)
log
.
debug
(
"unrar version
%
s"
,
version
)
break
value
=
process_wait
(
unrarLocation
,
pattern
=
'UNRAR (.*) freeware'
)
if
value
:
version
=
value
.
group
(
1
)
log
.
debug
(
"unrar version
%
s"
,
version
)
except
(
OSError
,
UnicodeDecodeError
)
as
err
:
log
.
debug_or_exception
(
err
)
return
_
(
'Error excecuting UnRar'
)
...
...
cps/subproc_wrapper.py
View file @
f8de7e75
...
...
@@ -20,7 +20,7 @@ from __future__ import division, print_function, unicode_literals
import
sys
import
os
import
subprocess
import
re
def
process_open
(
command
,
quotes
=
(),
env
=
None
,
sout
=
subprocess
.
PIPE
,
serr
=
subprocess
.
PIPE
,
newlines
=
True
):
# Linux py2.7 encode as list without quotes no empty element for parameters
...
...
@@ -44,12 +44,18 @@ def process_open(command, quotes=(), env=None, sout=subprocess.PIPE, serr=subpro
return
subprocess
.
Popen
(
exc_command
,
shell
=
False
,
stdout
=
sout
,
stderr
=
serr
,
universal_newlines
=
newlines
,
env
=
env
)
# nosec
def
process_wait
(
command
,
serr
=
subprocess
.
PIPE
):
def
process_wait
(
command
,
serr
=
subprocess
.
PIPE
,
pattern
=
""
):
# Run command, wait for process to terminate, and return an iterator over lines of its output.
newlines
=
os
.
name
!=
'nt'
ret_val
=
""
p
=
process_open
(
command
,
serr
=
serr
,
newlines
=
newlines
)
p
.
wait
()
for
line
in
p
.
stdout
.
readlines
():
if
isinstance
(
line
,
bytes
):
line
=
line
.
decode
(
'utf-8'
)
yield
line
match
=
re
.
search
(
pattern
,
line
,
re
.
IGNORECASE
)
if
match
and
ret_val
==
""
:
ret_val
=
match
p
.
stdout
.
close
()
p
.
stderr
.
close
()
return
ret_val
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