Sync to trunk.

This commit is contained in:
John Schember 2010-01-03 11:17:08 -05:00
commit afe1fccbdb
3 changed files with 24 additions and 16 deletions

View File

@ -455,29 +455,22 @@ class Device(DeviceConfig, DevicePlugin):
usb_dir = None
def test(val, attr):
q = getattr(self, attr)
if q is None: return True
return q == val or val in q
q = getattr(self.detected_device, attr)
return q == val
for x, isfile in walk('/sys/devices'):
if isfile and x.endswith('idVendor'):
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):
usb_dir = None
continue
e = lambda q : raw2num(open(j(usb_dir, q)).read())
ven, prod = map(e, ('idVendor', 'idProduct'))
if not (test(ven, 'VENDOR_ID') and test(prod, 'PRODUCT_ID')):
ven, prod, bcd = map(e, ('idVendor', 'idProduct', 'bcdDevice'))
if not (test(ven, 'idVendor') and test(prod, 'idProduct') and
test(bcd, 'bcdDevice')):
usb_dir = None
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:
break

View File

@ -11,8 +11,15 @@ from threading import Thread
from calibre.constants import iswindows
ADDRESS = r'\\.\pipe\CalibreGUI' if iswindows else \
os.path.expanduser('~/.calibre-gui.socket')
if iswindows:
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):

View File

@ -806,7 +806,7 @@ class BasicNewsRecipe(Recipe):
return index
def download_cover(self):
def _download_cover(self):
self.cover_path = None
try:
cu = self.get_cover_url()
@ -839,6 +839,14 @@ class BasicNewsRecipe(Recipe):
f.write(mi.cover_data[1])
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):
'''