mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Sync to trunk.
This commit is contained in:
commit
afe1fccbdb
@ -455,29 +455,22 @@ class Device(DeviceConfig, DevicePlugin):
|
|||||||
usb_dir = None
|
usb_dir = None
|
||||||
|
|
||||||
def test(val, attr):
|
def test(val, attr):
|
||||||
q = getattr(self, attr)
|
q = getattr(self.detected_device, attr)
|
||||||
if q is None: return True
|
return q == val
|
||||||
return q == val or val in q
|
|
||||||
|
|
||||||
for x, isfile in walk('/sys/devices'):
|
for x, isfile in walk('/sys/devices'):
|
||||||
if isfile and x.endswith('idVendor'):
|
if isfile and x.endswith('idVendor'):
|
||||||
usb_dir = d(x)
|
usb_dir = d(x)
|
||||||
for y in ('idProduct',):
|
for y in ('idProduct', 'idVendor', 'bcdDevice'):
|
||||||
if not os.access(j(usb_dir, y), os.R_OK):
|
if not os.access(j(usb_dir, y), os.R_OK):
|
||||||
usb_dir = None
|
usb_dir = None
|
||||||
continue
|
continue
|
||||||
e = lambda q : raw2num(open(j(usb_dir, q)).read())
|
e = lambda q : raw2num(open(j(usb_dir, q)).read())
|
||||||
ven, prod = map(e, ('idVendor', 'idProduct'))
|
ven, prod, bcd = map(e, ('idVendor', 'idProduct', 'bcdDevice'))
|
||||||
if not (test(ven, 'VENDOR_ID') and test(prod, 'PRODUCT_ID')):
|
if not (test(ven, 'idVendor') and test(prod, 'idProduct') and
|
||||||
|
test(bcd, 'bcdDevice')):
|
||||||
usb_dir = None
|
usb_dir = None
|
||||||
continue
|
continue
|
||||||
if self.BCD is not None:
|
|
||||||
if not os.access(j(usb_dir, 'bcdDevice'), os.R_OK) or \
|
|
||||||
not test(e('bcdDevice'), 'BCD'):
|
|
||||||
usb_dir = None
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -11,8 +11,15 @@ from threading import Thread
|
|||||||
|
|
||||||
from calibre.constants import iswindows
|
from calibre.constants import iswindows
|
||||||
|
|
||||||
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
|
if iswindows:
|
||||||
os.path.expanduser('~/.calibre-gui.socket')
|
ADDRESS = r'\\.\pipe\CalibreGUI'
|
||||||
|
else:
|
||||||
|
from tempfile import gettempdir
|
||||||
|
tmp = gettempdir()
|
||||||
|
user = os.environ.get('USER', '')
|
||||||
|
if not user:
|
||||||
|
user = os.path.basename(os.path.expanduser('~'))
|
||||||
|
ADDRESS = os.path.join(tmp, user+'-calibre-gui.socket')
|
||||||
|
|
||||||
class RC(Thread):
|
class RC(Thread):
|
||||||
|
|
||||||
|
@ -806,7 +806,7 @@ class BasicNewsRecipe(Recipe):
|
|||||||
|
|
||||||
return index
|
return index
|
||||||
|
|
||||||
def download_cover(self):
|
def _download_cover(self):
|
||||||
self.cover_path = None
|
self.cover_path = None
|
||||||
try:
|
try:
|
||||||
cu = self.get_cover_url()
|
cu = self.get_cover_url()
|
||||||
@ -839,6 +839,14 @@ class BasicNewsRecipe(Recipe):
|
|||||||
f.write(mi.cover_data[1])
|
f.write(mi.cover_data[1])
|
||||||
self.cover_path = cpath
|
self.cover_path = cpath
|
||||||
|
|
||||||
|
def download_cover(self):
|
||||||
|
try:
|
||||||
|
self._download_cover()
|
||||||
|
except:
|
||||||
|
self.log.exception('Failed to download cover')
|
||||||
|
self.cover_path = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def default_cover(self, cover_file):
|
def default_cover(self, cover_file):
|
||||||
'''
|
'''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user