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
e4eab175
Commit
e4eab175
authored
May 24, 2020
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix version detect of binaries on windows
parent
cf10244f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
config_sql.py
cps/config_sql.py
+4
-2
helper.py
cps/helper.py
+3
-2
subproc_wrapper.py
cps/subproc_wrapper.py
+4
-3
No files found.
cps/config_sql.py
View file @
e4eab175
...
@@ -362,8 +362,10 @@ def _migrate_table(session, orm_class):
...
@@ -362,8 +362,10 @@ def _migrate_table(session, orm_class):
def
autodetect_calibre_binary
():
def
autodetect_calibre_binary
():
if
sys
.
platform
==
"win32"
:
if
sys
.
platform
==
"win32"
:
calibre_path
=
[
"C:
\\
program files
\
calibre
\
calibre-convert.exe"
,
calibre_path
=
[
"C:
\\
program files
\
calibre
\
ebook-convert.exe"
,
"C:
\\
program files(x86)
\
calibre
\
calibre-convert.exe"
]
"C:
\\
program files(x86)
\
calibre
\
ebook-convert.exe"
,
"C:
\\
program files(x86)
\
calibre2
\
ebook-convert.exe"
,
"C:
\\
program files
\
calibre2
\
ebook-convert.exe"
]
else
:
else
:
calibre_path
=
[
"/opt/calibre/ebook-convert"
]
calibre_path
=
[
"/opt/calibre/ebook-convert"
]
for
element
in
calibre_path
:
for
element
in
calibre_path
:
...
...
cps/helper.py
View file @
e4eab175
...
@@ -634,11 +634,12 @@ def check_unrar(unrarLocation):
...
@@ -634,11 +634,12 @@ def check_unrar(unrarLocation):
unrarLocation
=
unrarLocation
.
encode
(
sys
.
getfilesystemencoding
())
unrarLocation
=
unrarLocation
.
encode
(
sys
.
getfilesystemencoding
())
unrarLocation
=
[
unrarLocation
]
unrarLocation
=
[
unrarLocation
]
for
lines
in
process_wait
(
unrarLocation
):
for
lines
in
process_wait
(
unrarLocation
):
value
=
re
.
search
(
'UNRAR (.*) freeware'
,
lines
)
value
=
re
.
search
(
'UNRAR (.*) freeware'
,
lines
,
re
.
IGNORECASE
)
if
value
:
if
value
:
version
=
value
.
group
(
1
)
version
=
value
.
group
(
1
)
log
.
debug
(
"unrar version
%
s"
,
version
)
log
.
debug
(
"unrar version
%
s"
,
version
)
except
OSError
as
err
:
break
except
(
OSError
,
UnicodeDecodeError
)
as
err
:
log
.
exception
(
err
)
log
.
exception
(
err
)
return
_
(
'Error excecuting UnRar'
)
return
_
(
'Error excecuting UnRar'
)
...
...
cps/subproc_wrapper.py
View file @
e4eab175
...
@@ -22,7 +22,7 @@ import os
...
@@ -22,7 +22,7 @@ import os
import
subprocess
import
subprocess
def
process_open
(
command
,
quotes
=
(),
env
=
None
,
sout
=
subprocess
.
PIPE
,
serr
=
subprocess
.
PIPE
):
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
# Linux py2.7 encode as list without quotes no empty element for parameters
# linux py3.x no encode and as list without quotes no empty element for parameters
# linux py3.x no encode and as list without quotes no empty element for parameters
# windows py2.7 encode as string with quotes empty element for parameters is okay
# windows py2.7 encode as string with quotes empty element for parameters is okay
...
@@ -41,12 +41,13 @@ def process_open(command, quotes=(), env=None, sout=subprocess.PIPE, serr=subpro
...
@@ -41,12 +41,13 @@ def process_open(command, quotes=(), env=None, sout=subprocess.PIPE, serr=subpro
else
:
else
:
exc_command
=
[
x
for
x
in
command
]
exc_command
=
[
x
for
x
in
command
]
return
subprocess
.
Popen
(
exc_command
,
shell
=
False
,
stdout
=
sout
,
stderr
=
serr
,
universal_newlines
=
True
,
env
=
env
)
return
subprocess
.
Popen
(
exc_command
,
shell
=
False
,
stdout
=
sout
,
stderr
=
serr
,
universal_newlines
=
newlines
,
env
=
env
)
def
process_wait
(
command
,
serr
=
subprocess
.
PIPE
):
def
process_wait
(
command
,
serr
=
subprocess
.
PIPE
):
# Run command, wait for process to terminate, and return an iterator over lines of its output.
# Run command, wait for process to terminate, and return an iterator over lines of its output.
p
=
process_open
(
command
,
serr
=
serr
)
newlines
=
os
.
name
!=
'nt'
p
=
process_open
(
command
,
serr
=
serr
,
newlines
=
newlines
)
p
.
wait
()
p
.
wait
()
for
line
in
p
.
stdout
.
readlines
():
for
line
in
p
.
stdout
.
readlines
():
if
isinstance
(
line
,
bytes
):
if
isinstance
(
line
,
bytes
):
...
...
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