Don't print out error messages when no cache is present on a device

This commit is contained in:
Kovid Goyal 2010-05-17 12:46:14 -06:00
parent 78bb3a2753
commit 38b1f35ff7

View File

@ -277,18 +277,22 @@ class USBMS(CLI, Device):
bl = [] bl = []
js = [] js = []
need_sync = False need_sync = False
try: cache_file = cls.normalize_path(os.path.join(prefix, name))
with open(cls.normalize_path(os.path.join(prefix, name)), 'rb') as f: if os.access(cache_file, os.R_OK):
js = json.load(f, encoding='utf-8') try:
for item in js: with open(cache_file, 'rb') as f:
book = cls.book_class(prefix, item.get('lpath', None)) js = json.load(f, encoding='utf-8')
for key in item.keys(): for item in js:
setattr(book, key, item[key]) book = cls.book_class(prefix, item.get('lpath', None))
bl.append(book) for key in item.keys():
except: setattr(book, key, item[key])
import traceback bl.append(book)
traceback.print_exc() except:
bl = [] import traceback
traceback.print_exc()
bl = []
need_sync = True
else:
need_sync = True need_sync = True
return bl, need_sync return bl, need_sync