mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
pep8: fix bare except
ruff 'E722'
This commit is contained in:
parent
0cac76f515
commit
730ac72ee8
@ -37,7 +37,7 @@ quote-style = 'single'
|
||||
[tool.ruff.lint]
|
||||
explicit-preview-rules = true
|
||||
ignore = [
|
||||
'E402', 'E722', 'E741',
|
||||
'E402', 'E741',
|
||||
'UP012', 'UP030', 'UP038', 'C413', 'C420', 'PIE790', 'ISC003',
|
||||
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF100',
|
||||
'RUF059', # unused unpacked variable
|
||||
|
@ -92,7 +92,7 @@ class AlMonitor(BasicNewsRecipe):
|
||||
try:
|
||||
self._p('process section ' + section + ', url: ' + url)
|
||||
soup = self.index_to_soup(url)
|
||||
except:
|
||||
except Exception:
|
||||
self._p('Unable to spider section')
|
||||
return []
|
||||
|
||||
@ -175,7 +175,7 @@ class AlMonitor(BasicNewsRecipe):
|
||||
try:
|
||||
# eg: Posted September 17, 2014
|
||||
dt = datetime.datetime.strptime(datestring, 'Posted %B %d, %Y')
|
||||
except:
|
||||
except Exception:
|
||||
dt = None
|
||||
|
||||
if dt:
|
||||
|
@ -69,7 +69,7 @@ class AM730(BasicNewsRecipe):
|
||||
if articles.index({'title':title,'url':href})>=0:
|
||||
# print('already added')
|
||||
continue # already added
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
articles.append({'title':title,'url':href})
|
||||
|
@ -71,7 +71,7 @@ class AdvancedUserRecipe1306097511(BasicNewsRecipe):
|
||||
try:
|
||||
br.open_novisit(cov)
|
||||
cover_url = cov
|
||||
except:
|
||||
except Exception:
|
||||
cover_url = 'http://s.birminghammail.co.uk/skins/birminghammail/gfx/follow-media.jpg'
|
||||
|
||||
return cover_url
|
||||
|
@ -66,7 +66,7 @@ class BostonGlobePrint(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self, verify_ssl_certificates=False)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
index = 'https://en.kiosko.net/us/np/boston_globe.html'
|
||||
soup = self.index_to_soup(index)
|
||||
for image in soup.findAll('img', src=True):
|
||||
|
@ -151,14 +151,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -295,7 +295,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -118,7 +118,7 @@ class CaravanMagazine(BasicNewsRecipe):
|
||||
res = json.loads(res)
|
||||
self.log(safe_dict(res[0], 'result', 'data', 'json', 'message'))
|
||||
self.logged = True
|
||||
except:
|
||||
except Exception:
|
||||
self.log.warn('\n**Login failed, check your username and password\n')
|
||||
return br
|
||||
return br
|
||||
|
@ -71,7 +71,7 @@ class CNN(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(masthead)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
masthead = None
|
||||
return masthead
|
||||
|
@ -92,7 +92,7 @@ class AdvancedUserRecipe1306061239(BasicNewsRecipe):
|
||||
try:
|
||||
br.open_novisit(cov2)
|
||||
cover_url = cov2
|
||||
except:
|
||||
except Exception:
|
||||
cover_url = 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/373019_6149699161_1710984811_n.jpg'
|
||||
|
||||
return cover_url
|
||||
|
@ -151,14 +151,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -295,7 +295,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -118,7 +118,7 @@ div.a_md_a {text-align: center; text-transform: uppercase; font-size: .8rem;}
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
cover = None
|
||||
return cover
|
||||
|
@ -88,7 +88,7 @@ class ElMundo(BasicNewsRecipe):
|
||||
cover = 'http://img.kiosko.net/' + '/'.join([year, month, day]) + '/es/elmundo.750.jpg'
|
||||
try:
|
||||
self.browser.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nPortada no disponible')
|
||||
return cover
|
||||
|
||||
@ -101,7 +101,7 @@ class ElMundo(BasicNewsRecipe):
|
||||
response = self.browser.open(url)
|
||||
html = response.read()
|
||||
count = tries
|
||||
except:
|
||||
except Exception:
|
||||
print('Retrying download...')
|
||||
count += 1
|
||||
if html is not None:
|
||||
|
@ -114,7 +114,7 @@ class Esensja(BasicNewsRecipe):
|
||||
nr = r.findAll(attrs={'class': 'tn-link'})[-1]
|
||||
try:
|
||||
nr = int(nr.a.string)
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
baseurl = soup.find(attrs={'property': 'og:url'})[
|
||||
'content'] + '&strona={0}'
|
||||
|
@ -62,7 +62,7 @@ class EsensjaRSS(BasicNewsRecipe):
|
||||
nr = r.findAll(attrs={'class': 'tn-link'})[-1]
|
||||
try:
|
||||
nr = int(nr.a.string)
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
baseurl = soup.find(attrs={'property': 'og:url'})[
|
||||
'content'] + '&strona={0}'
|
||||
|
@ -112,7 +112,7 @@ class expansion_spanish(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nPortada no disponible')
|
||||
cover = 'http://www.aproahp.org/enlaces/images/diario_expansion.gif'
|
||||
return cover
|
||||
|
@ -75,7 +75,7 @@ class gw_krakow(BasicNewsRecipe):
|
||||
try:
|
||||
baseurl = soup.find(name='meta', attrs={
|
||||
'property': 'og:url'})['content']
|
||||
except:
|
||||
except Exception:
|
||||
return 1
|
||||
link = tag.findAll('a')[-1]
|
||||
while link:
|
||||
|
@ -74,7 +74,7 @@ class gw_wawa(BasicNewsRecipe):
|
||||
try:
|
||||
baseurl = soup.find(name='meta', attrs={
|
||||
'property': 'og:url'})['content']
|
||||
except:
|
||||
except Exception:
|
||||
return 1
|
||||
link = tag.findAll('a')[-1]
|
||||
while link:
|
||||
|
@ -38,7 +38,7 @@ class GryOnlinePl(BasicNewsRecipe):
|
||||
try:
|
||||
soup2 = self.index_to_soup(finalurl)
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
print('retrying in 0.5s')
|
||||
time.sleep(0.5)
|
||||
pagetext = soup2.find(attrs={'class': 'gc660'})
|
||||
@ -73,7 +73,7 @@ class GryOnlinePl(BasicNewsRecipe):
|
||||
try:
|
||||
soup2 = self.index_to_soup(finalurl)
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
print('retrying in 0.5s')
|
||||
time.sleep(0.5)
|
||||
tag = soup2.find('div', attrs={'class': 'S018stronyr'})
|
||||
|
@ -49,7 +49,7 @@ class IlMessaggero(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
cover = 'http://www.ilmessaggero.it/img_tst/logomsgr.gif'
|
||||
|
||||
|
@ -41,7 +41,7 @@ class IncMagazineRecipe(BasicNewsRecipe):
|
||||
def has_login_name(form):
|
||||
try:
|
||||
form.find_control(name='email')
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
@ -16,7 +16,7 @@ class BasicUserRecipe1318619728(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(masthead)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
masthead = None
|
||||
return masthead
|
||||
|
@ -49,7 +49,7 @@ class LaRepubblica(BasicNewsRecipe):
|
||||
response = self.browser.open(url)
|
||||
html = response.read()
|
||||
count = 10
|
||||
except:
|
||||
except Exception:
|
||||
print('Retrying download...')
|
||||
count += 1
|
||||
self.temp_files.append(PersistentTemporaryFile('_fa.html'))
|
||||
|
@ -105,7 +105,7 @@ class LATimes(BasicNewsRecipe):
|
||||
self.log('Pattern: ', pattern)
|
||||
try:
|
||||
soup = self.index_to_soup(index)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('Failed to download ', index)
|
||||
return []
|
||||
if soup.main is not None:
|
||||
|
@ -59,12 +59,12 @@ class LeggoIT(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
cover = 'http://www.leggo.it/' + year + month + day + '/jpeg/LEGGO_ROMA_3.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
cover = 'http://www.leggo.it/img/logo-leggo2.gif'
|
||||
return cover
|
||||
|
@ -70,7 +70,7 @@ class lepoint(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(masthead)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
masthead = None
|
||||
return masthead
|
||||
|
@ -72,7 +72,7 @@ class lepoint(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(masthead)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
masthead = None
|
||||
return masthead
|
||||
|
@ -151,14 +151,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -295,7 +295,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -57,7 +57,7 @@ class Nature(BasicNewsRecipe):
|
||||
)['src']
|
||||
try:
|
||||
self.cover_url = re.sub(r'\bw\d+\b', 'w1000', self.cover_url) # enlarge cover size resolution
|
||||
except:
|
||||
except Exception:
|
||||
'''
|
||||
failed, img src might have changed, use default width 200
|
||||
'''
|
||||
|
@ -236,7 +236,7 @@ fragment ArticlePageFields on Article {
|
||||
)
|
||||
img['src'] = img_src
|
||||
del img['data-serialized']
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return f'''<html>
|
||||
|
@ -100,6 +100,6 @@ class NikkeiNet_paper_subscription(BasicNewsRecipe):
|
||||
[self.tag_to_string(elm).strip() for elm in elms])
|
||||
elm_text = unicodedata.normalize('NFKC', elm_text)
|
||||
article.summary = article.text_summary = elm_text
|
||||
except:
|
||||
except Exception:
|
||||
self.log('Error: Failed to get article summary.')
|
||||
return
|
||||
|
@ -144,7 +144,7 @@ class Guardian(BasicNewsRecipe):
|
||||
for title, href in self.find_sections():
|
||||
feeds.append((title, list(self.find_articles(href))))
|
||||
return feeds
|
||||
except:
|
||||
except Exception:
|
||||
raise NotImplementedError
|
||||
|
||||
def postprocess_html(self, soup, first):
|
||||
|
@ -151,14 +151,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -295,7 +295,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -110,7 +110,7 @@ class Pagina12(BasicNewsRecipe):
|
||||
tfile.close()
|
||||
self.temp_files.append(tfile)
|
||||
result = tfile.name
|
||||
except:
|
||||
except Exception:
|
||||
self.info('Retrying download...')
|
||||
count += 1
|
||||
return result
|
||||
|
@ -133,7 +133,7 @@ class AdvancedUserRecipe1277129332(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable: ' + cover)
|
||||
cover = None
|
||||
return cover
|
||||
|
@ -161,7 +161,7 @@ class Pocket(BasicNewsRecipe):
|
||||
img_data = calibre_cover2(title, date, time)
|
||||
cover_file.write(img_data)
|
||||
cover_file.flush()
|
||||
except:
|
||||
except Exception:
|
||||
self.log.exception('Failed to generate default cover')
|
||||
return False
|
||||
return True
|
||||
|
@ -110,14 +110,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
|
@ -145,7 +145,7 @@ class respektRecipe(BasicNewsRecipe):
|
||||
t = root.xpath("//span[@class='post-author-name']")[0]
|
||||
t.text = ('Autor: ' + t.text + ' ')
|
||||
root.xpath("//div[@class='authorship-names']")[0].append(E.span(article_length))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
# Make images visible
|
||||
pictures = root.xpath('//picture')
|
||||
@ -169,6 +169,6 @@ class respektRecipe(BasicNewsRecipe):
|
||||
e = E.h2({'class':'post-subtitle'})
|
||||
e.text = o.text
|
||||
o.getparent().replace(o,e)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return BeautifulSoup(lxml.etree.tostring(root,encoding='unicode'))
|
||||
|
@ -110,14 +110,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
|
@ -61,7 +61,7 @@ class AdvancedUserRecipe1325006965(BasicNewsRecipe):
|
||||
try:
|
||||
br.open_novisit(
|
||||
'http://www.thepaperboy.com/frontpages/current/The_Sun_newspaper_front_page.jpg')
|
||||
except:
|
||||
except Exception:
|
||||
cover_url = random.choice([
|
||||
'http://img.thesun.co.uk/multimedia/archive/00905/errorpage6_677961a_905507a.jpg', 'http://img.thesun.co.uk/multimedia/archive/00905/errorpage7_677962a_905505a.jpg', 'http://img.thesun.co.uk/multimedia/archive/00905/errorpage5_677960a_905512a.jpg', 'http://img.thesun.co.uk/multimedia/archive/00905/errorpage2_677957a_905502a.jpg', 'http://img.thesun.co.uk/multimedia/archive/00905/errorpage3_677958a_905503a.jpg' # noqa: E501
|
||||
])
|
||||
|
@ -39,7 +39,7 @@ class TheEconomicTimes(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
cover = None
|
||||
return cover
|
||||
|
@ -111,7 +111,7 @@ class TheNewCriterion(BasicNewsRecipe):
|
||||
tfile.close()
|
||||
self.temp_files.append(tfile)
|
||||
result = tfile.name
|
||||
except:
|
||||
except Exception:
|
||||
print('Retrying download...')
|
||||
count += 1
|
||||
return result
|
||||
|
@ -151,14 +151,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -308,7 +308,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -152,14 +152,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -296,7 +296,7 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
print('Section: ' + key + ': ' + self.url_prefix + keyurl)
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + keyurl)
|
||||
except:
|
||||
except Exception:
|
||||
print('Section: ' + key + ' NOT FOUND')
|
||||
return
|
||||
ans.append(key)
|
||||
|
@ -114,14 +114,14 @@ class TimesColonist(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
@ -235,7 +235,7 @@ class TimesColonist(BasicNewsRecipe):
|
||||
print('Add section url=' + self.url_prefix + '/' + securl + '\n\r')
|
||||
try:
|
||||
soup = self.index_to_soup(self.url_prefix + '/' + securl)
|
||||
except:
|
||||
except Exception:
|
||||
return ans
|
||||
mainsoup = soup.find(
|
||||
'div', attrs={'class': re.compile(r'main.content')})
|
||||
|
@ -110,14 +110,14 @@ class CanWestPaper(BasicNewsRecipe):
|
||||
daysback = 1
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
while daysback < 7:
|
||||
cover = 'http://webmedia.newseum.org/newseum-multimedia/dfp/jpg' + \
|
||||
str((date.today() - timedelta(days=daysback)).day) + '/lg/' + self.fp_tag + '.jpg'
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(cover)
|
||||
except:
|
||||
except Exception:
|
||||
daysback = daysback + 1
|
||||
continue
|
||||
break
|
||||
|
@ -61,7 +61,7 @@ class zdnet(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self)
|
||||
try:
|
||||
br.open(masthead)
|
||||
except:
|
||||
except Exception:
|
||||
self.log('\nCover unavailable')
|
||||
masthead = None
|
||||
return masthead
|
||||
|
@ -285,13 +285,13 @@ class ZeitEPUBAbo(BasicNewsRecipe):
|
||||
save_cover_data_to(cdata, cpath)
|
||||
cover_url = cpath
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
self.log.warning('Trying low-res cover')
|
||||
try:
|
||||
inhalt = self.index_to_soup('http://www.zeit.de/inhalt')
|
||||
cover_url = inhalt.find('div', attrs={'class': 'singlearchive clearfix'}).img[
|
||||
'src'].replace('icon_', '')
|
||||
except:
|
||||
except Exception:
|
||||
self.log.warning('Using static old low-res cover')
|
||||
cover_url = 'http://images.zeit.de/bilder/titelseiten_zeit/1946/001_001.jpg'
|
||||
return cover_url
|
||||
|
@ -615,7 +615,7 @@ class Build(Command):
|
||||
'''
|
||||
try:
|
||||
subprocess.check_call(*args, **kwargs)
|
||||
except:
|
||||
except Exception:
|
||||
cmdline = ' '.join([f'"{arg}"' if ' ' in arg else arg for arg in args[0]])
|
||||
print(f'Error while executing: {cmdline}\n')
|
||||
raise
|
||||
|
@ -85,7 +85,7 @@ def run_pkgconfig(name, envvar, default, flag, prefix):
|
||||
stdout=subprocess.PIPE).stdout.read().decode('utf-8')
|
||||
ans = [x.strip() for x in raw.split(prefix)]
|
||||
ans = [x for x in ans if x and (prefix=='-l' or os.path.exists(x))]
|
||||
except:
|
||||
except Exception:
|
||||
print('Failed to run pkg-config:', PKGCONFIG, 'for:', name)
|
||||
|
||||
return ans or ([default] if default else [])
|
||||
|
@ -47,7 +47,7 @@ class Bug:
|
||||
raw = urllib.request.urlopen(LAUNCHPAD_BUG.format(bug)).read()
|
||||
h1 = html.fromstring(raw).xpath('//h1[@id="edit-title"]')[0]
|
||||
summary = html.tostring(h1, method='text', encoding=str).strip()
|
||||
except:
|
||||
except Exception:
|
||||
summary = 'Private bug'
|
||||
else:
|
||||
summary = json.loads(urllib.request.urlopen(GITHUB_BUG.format(bug)).read())['title']
|
||||
|
@ -118,7 +118,7 @@ class SourceForge(Base): # {{{
|
||||
])
|
||||
except KeyboardInterrupt:
|
||||
raise SystemExit(1)
|
||||
except:
|
||||
except Exception:
|
||||
print('\nUpload failed, trying again in 30 seconds')
|
||||
time.sleep(30)
|
||||
else:
|
||||
@ -421,7 +421,7 @@ def upload_to_servers(files, version): # {{{
|
||||
# f'root@{server}:{rdir}'])
|
||||
# except KeyboardInterrupt:
|
||||
# raise SystemExit(1)
|
||||
# except:
|
||||
# except Exception:
|
||||
# print('\nUpload failed, trying again in 30 seconds')
|
||||
# time.sleep(30)
|
||||
# else:
|
||||
|
@ -187,7 +187,7 @@ class Resources(Command): # {{{
|
||||
lambda x: inspect.ismethod(x) and x.__name__ == 'evaluate')
|
||||
try:
|
||||
lines = [l[4:] for l in inspect.getsourcelines(eval_func[0][1])[0]]
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
lines = ''.join(lines)
|
||||
function_dict[obj.name] = lines
|
||||
|
@ -281,7 +281,7 @@ class UploadInstallers(Command): # {{{
|
||||
while True:
|
||||
try:
|
||||
send_data(tdir)
|
||||
except:
|
||||
except Exception:
|
||||
print('\nUpload to staging failed, retrying in a minute')
|
||||
time.sleep(60)
|
||||
else:
|
||||
@ -290,7 +290,7 @@ class UploadInstallers(Command): # {{{
|
||||
while True:
|
||||
try:
|
||||
send_to_backup(tdir)
|
||||
except:
|
||||
except Exception:
|
||||
print('\nUpload to backup failed, retrying in a minute')
|
||||
time.sleep(60)
|
||||
else:
|
||||
|
@ -273,7 +273,7 @@ def get_parsed_proxy(typ='http', debug=True):
|
||||
}
|
||||
if ans['port']:
|
||||
ans['port'] = int(ans['port'])
|
||||
except:
|
||||
except Exception:
|
||||
if debug:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
@ -54,7 +54,7 @@ TOC_DIALOG_APP_UID = 'com.calibre-ebook.toc-editor'
|
||||
try:
|
||||
preferred_encoding = locale.getpreferredencoding()
|
||||
codecs.lookup(preferred_encoding)
|
||||
except:
|
||||
except Exception:
|
||||
preferred_encoding = 'utf-8'
|
||||
|
||||
dark_link_color = '#6cb4ee'
|
||||
@ -391,7 +391,7 @@ else:
|
||||
config_dir = os.path.join(bdir, 'calibre')
|
||||
try:
|
||||
os.makedirs(config_dir, mode=CONFIG_DIR_MODE)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if not os.path.exists(config_dir) or \
|
||||
not os.access(config_dir, os.W_OK) or not \
|
||||
@ -405,7 +405,7 @@ else:
|
||||
try:
|
||||
import shutil
|
||||
shutil.rmtree(config_dir)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
atexit.register(cleanup_cdir)
|
||||
# }}}
|
||||
|
@ -623,7 +623,7 @@ class CatalogPlugin(Plugin): # {{{
|
||||
for file in files_to_copy:
|
||||
try:
|
||||
resources.extract(file, self.resources_path)
|
||||
except:
|
||||
except Exception:
|
||||
print(f' customize:__init__.initialize(): {file} not found in {os.path.basename(self.plugin_path)}')
|
||||
continue
|
||||
resources.close()
|
||||
|
@ -144,7 +144,7 @@ class ComicMetadataReader(MetadataReaderPlugin):
|
||||
series_index = 'volume'
|
||||
try:
|
||||
mi.smart_update(get_comic_metadata(stream, ftype, series_index=series_index))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if ret is not None:
|
||||
path, data = ret
|
||||
|
@ -231,7 +231,7 @@ class InputFormatPlugin(Plugin):
|
||||
log(f'InputFormatPlugin: {self.name} running')
|
||||
if hasattr(stream, 'name'):
|
||||
log('on', stream.name)
|
||||
except:
|
||||
except Exception:
|
||||
# In case stdout is broken
|
||||
pass
|
||||
|
||||
|
@ -212,7 +212,7 @@ def _run_filetype_plugins(path_to_file, ft=None, occasion='preprocess'):
|
||||
pass
|
||||
try:
|
||||
nfp = plugin.run(nfp) or nfp
|
||||
except:
|
||||
except Exception:
|
||||
print(f'Running file type plugin {plugin.name} failed with traceback:', file=oe)
|
||||
traceback.print_exc(file=oe)
|
||||
sys.stdout, sys.stderr = oo, oe
|
||||
@ -495,7 +495,7 @@ def get_file_type_metadata(stream, ftype):
|
||||
stream.seek(0)
|
||||
mi = plugin.get_metadata(stream, ftype.lower().strip())
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
continue
|
||||
return mi
|
||||
@ -514,7 +514,7 @@ def set_file_type_metadata(stream, mi, ftype, report_error=None):
|
||||
plugin.site_customization = customization.get(plugin.name, '')
|
||||
plugin.set_metadata(stream, mi, ftype.lower().strip())
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
if report_error is None:
|
||||
from calibre import prints
|
||||
prints('Failed to set metadata for the', ftype.upper(), 'format of:', getattr(mi, 'title', ''), file=sys.stderr)
|
||||
@ -569,7 +569,7 @@ def remove_plugin(plugin_or_name):
|
||||
zfp = plugins[name]
|
||||
if os.path.exists(zfp):
|
||||
os.remove(zfp)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
plugins.pop(name)
|
||||
config['plugins'] = plugins
|
||||
@ -829,7 +829,7 @@ def initialize_plugins(perf=False):
|
||||
if perf:
|
||||
times[plugin.name] = time.time() - st
|
||||
_initialized_plugins.append(plugin)
|
||||
except:
|
||||
except Exception:
|
||||
print('Failed to initialize plugin:', repr(zfp), file=sys.stderr)
|
||||
if DEBUG:
|
||||
traceback.print_exc()
|
||||
|
@ -44,7 +44,7 @@ def get_resources(zfp, name_or_list_of_names, print_tracebacks_for_missing_resou
|
||||
for name in names:
|
||||
try:
|
||||
ans[name] = zf.read(name)
|
||||
except:
|
||||
except Exception:
|
||||
if print_tracebacks_for_missing_resources:
|
||||
print('Failed to load resource:', repr(name), 'from the plugin zip file:', zfp, file=sys.stderr)
|
||||
import traceback
|
||||
@ -331,7 +331,7 @@ class CalibrePluginFinder:
|
||||
f'The plugin at {as_unicode(path_to_zip_file)} cannot be used on {platform}')
|
||||
|
||||
return ans
|
||||
except:
|
||||
except Exception:
|
||||
with self._lock:
|
||||
del self.loaded_plugins[plugin_name]
|
||||
raise
|
||||
|
@ -63,7 +63,7 @@ def _get_series_values(val):
|
||||
try:
|
||||
idx = float(idx)
|
||||
return match.group(1).strip(), idx
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return val, None
|
||||
|
||||
|
@ -113,7 +113,7 @@ class DBPrefs(dict): # {{{
|
||||
for key, val in self.db.conn.get('SELECT key,val FROM preferences'):
|
||||
try:
|
||||
val = self.raw_to_object(val)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to read value for:', key, 'from db')
|
||||
continue
|
||||
dict.__setitem__(self, key, val)
|
||||
@ -185,7 +185,7 @@ class DBPrefs(dict): # {{{
|
||||
data = data.encode('utf-8')
|
||||
with open(to_filename, 'wb') as f:
|
||||
f.write(data)
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
@ -204,12 +204,12 @@ def pynocase(one, two, encoding='utf-8'):
|
||||
if isbytestring(one):
|
||||
try:
|
||||
one = one.decode(encoding, 'replace')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if isbytestring(two):
|
||||
try:
|
||||
two = two.decode(encoding, 'replace')
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return cmp(one.lower(), two.lower())
|
||||
|
||||
@ -648,7 +648,7 @@ class DB:
|
||||
rules = migrate_old_rule(self.field_metadata, templ)
|
||||
for templ in rules:
|
||||
old_rules.append((col, templ))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if old_rules:
|
||||
self.prefs['column_color_rules'] += old_rules
|
||||
@ -673,7 +673,7 @@ class DB:
|
||||
for t in ogst:
|
||||
ngst[icu_lower(t)] = ogst[t]
|
||||
self.prefs.set('grouped_search_terms', ngst)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# migrate the gui_restriction preference to a virtual library
|
||||
@ -1467,7 +1467,7 @@ class DB:
|
||||
cur.execute('BEGIN EXCLUSIVE TRANSACTION')
|
||||
try:
|
||||
cur.execute(metadata_sqlite)
|
||||
except:
|
||||
except Exception:
|
||||
cur.execute('ROLLBACK')
|
||||
raise
|
||||
else:
|
||||
@ -1597,7 +1597,7 @@ class DB:
|
||||
for table in itervalues(self.tables):
|
||||
try:
|
||||
table.read(self)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to read table:', table.name)
|
||||
import pprint
|
||||
pprint.pprint(table.metadata)
|
||||
@ -1756,7 +1756,7 @@ class DB:
|
||||
try:
|
||||
hardlink_file(path, dest)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
with open(dest, 'wb') as d:
|
||||
shutil.copyfileobj(f, d)
|
||||
@ -1848,7 +1848,7 @@ class DB:
|
||||
try:
|
||||
if path != dest:
|
||||
os.rename(path, dest)
|
||||
except:
|
||||
except Exception:
|
||||
pass # Nothing too catastrophic happened, the cases mismatch, that's all
|
||||
else:
|
||||
windows_atomic_move.copy_path_to(path, dest)
|
||||
@ -1875,7 +1875,7 @@ class DB:
|
||||
try:
|
||||
hardlink_file(path, dest)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
with open(path, 'rb') as f, open(make_long_path_useable(dest), 'wb') as d:
|
||||
shutil.copyfileobj(f, d)
|
||||
@ -2386,7 +2386,7 @@ class DB:
|
||||
def safe_load(val):
|
||||
try:
|
||||
return json.loads(val, object_hook=from_json)
|
||||
except:
|
||||
except Exception:
|
||||
return default
|
||||
|
||||
if len(book_ids) == 1:
|
||||
|
@ -77,7 +77,7 @@ class MetadataBackup(Thread):
|
||||
return
|
||||
except Abort:
|
||||
raise
|
||||
except:
|
||||
except Exception:
|
||||
# Happens during interpreter shutdown
|
||||
return
|
||||
|
||||
@ -85,13 +85,13 @@ class MetadataBackup(Thread):
|
||||
|
||||
try:
|
||||
mi, sequence = self.db.get_metadata_for_dump(book_id)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to get backup metadata for id:', book_id, 'once')
|
||||
traceback.print_exc()
|
||||
self.wait(self.interval)
|
||||
try:
|
||||
mi, sequence = self.db.get_metadata_for_dump(book_id)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to get backup metadata for id:', book_id, 'again, giving up')
|
||||
traceback.print_exc()
|
||||
return
|
||||
@ -107,7 +107,7 @@ class MetadataBackup(Thread):
|
||||
|
||||
try:
|
||||
raw = metadata_to_opf(mi)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to convert to opf for id:', book_id)
|
||||
traceback.print_exc()
|
||||
self.db.clear_dirtied(book_id, sequence)
|
||||
@ -117,13 +117,13 @@ class MetadataBackup(Thread):
|
||||
|
||||
try:
|
||||
self.db.write_backup(book_id, raw)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to write backup metadata for id:', book_id, 'once')
|
||||
traceback.print_exc()
|
||||
self.wait(self.interval)
|
||||
try:
|
||||
self.db.write_backup(book_id, raw)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to write backup metadata for id:', book_id, 'again, giving up')
|
||||
traceback.print_exc()
|
||||
return
|
||||
|
@ -127,7 +127,7 @@ def _add_default_custom_column_values(mi, fm):
|
||||
if dt == 'datetime' and icu_lower(dv) == 'now':
|
||||
dv = nowf()
|
||||
mi.set(cc, dv)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@ -1003,7 +1003,7 @@ class Cache:
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
raise NoSuchFormat(f'Record {book_id} has no fmt: {fmt}')
|
||||
return self.backend.format_hash(book_id, fmt, name, path)
|
||||
|
||||
@ -1033,7 +1033,7 @@ class Cache:
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
ans = {}
|
||||
@ -1256,7 +1256,7 @@ class Cache:
|
||||
fmt = (fmt or '').upper()
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
if path:
|
||||
if fmt == '__COVER_INTERNAL__':
|
||||
@ -1264,7 +1264,7 @@ class Cache:
|
||||
else:
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
if name:
|
||||
return self.backend.format_abspath(book_id, fmt, name, path)
|
||||
@ -1276,7 +1276,7 @@ class Cache:
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
return self.backend.has_format(book_id, fmt, name, path)
|
||||
|
||||
@ -1324,13 +1324,13 @@ class Cache:
|
||||
if verify_formats and ans:
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return ()
|
||||
|
||||
def verify(fmt):
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
return self.backend.has_format(book_id, fmt, name, path)
|
||||
|
||||
@ -1361,7 +1361,7 @@ class Cache:
|
||||
with self.safe_read_lock:
|
||||
try:
|
||||
fname = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
fname += ext
|
||||
|
||||
@ -1369,7 +1369,7 @@ class Cache:
|
||||
d = os.path.join(bd, 'format_abspath')
|
||||
try:
|
||||
os.makedirs(d)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
ret = os.path.join(d, fname)
|
||||
try:
|
||||
@ -1387,7 +1387,7 @@ class Cache:
|
||||
with self.safe_read_lock:
|
||||
try:
|
||||
fname = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
fname += ext
|
||||
|
||||
@ -1703,7 +1703,7 @@ class Cache:
|
||||
# try to write the opf, because it will go to the wrong folder.
|
||||
if self._field_for('path', book_id):
|
||||
mi = self._metadata_as_object_for_dump(book_id)
|
||||
except:
|
||||
except Exception:
|
||||
# This almost certainly means that the book has been deleted while
|
||||
# the backup operation sat in the queue.
|
||||
traceback.print_exc()
|
||||
@ -1723,7 +1723,7 @@ class Cache:
|
||||
def write_backup(self, book_id, raw):
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
|
||||
self.backend.write_backup(path, raw)
|
||||
@ -1738,7 +1738,7 @@ class Cache:
|
||||
if no such backup exists. '''
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return
|
||||
|
||||
try:
|
||||
@ -1774,7 +1774,7 @@ class Cache:
|
||||
self._write_backup(book_id, raw)
|
||||
if remove_from_dirtied:
|
||||
self._clear_dirtied(book_id, sequence)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if callback is not None:
|
||||
callback(book_id, mi, True)
|
||||
@ -1856,7 +1856,7 @@ class Cache:
|
||||
def protected_set_field(name, val):
|
||||
try:
|
||||
set_field(name, val)
|
||||
except:
|
||||
except Exception:
|
||||
if ignore_errors:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
@ -1870,7 +1870,7 @@ class Cache:
|
||||
cdata = f.read() or None
|
||||
if cdata is not None:
|
||||
self._set_cover({book_id: cdata})
|
||||
except:
|
||||
except Exception:
|
||||
if ignore_errors:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
@ -1925,7 +1925,7 @@ class Cache:
|
||||
extra = mi.get_extra(key)
|
||||
if extra is not None or force_changes:
|
||||
protected_set_field(idx, extra)
|
||||
except:
|
||||
except Exception:
|
||||
# sqlite will rollback the entire transaction, thanks to the with
|
||||
# statement, so we have to re-read everything form the db to ensure
|
||||
# the db and Cache are in sync
|
||||
@ -2035,12 +2035,12 @@ class Cache:
|
||||
for book_id, fmts in iteritems(formats_map):
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
for fmt in fmts:
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if name and path:
|
||||
removes[book_id].add((fmt, name, path))
|
||||
@ -2725,7 +2725,7 @@ class Cache:
|
||||
return identical_book_ids
|
||||
try:
|
||||
book_ids = self._search(query, restriction=search_restriction, book_ids=book_ids)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return identical_book_ids
|
||||
if qauthors and book_ids:
|
||||
@ -3061,14 +3061,14 @@ class Cache:
|
||||
mi.cover_data = ('jpeg', cdata)
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
for fmt in fmts:
|
||||
if only_fmts is not None and fmt.lower() not in only_fmts:
|
||||
continue
|
||||
try:
|
||||
name = self.fields['formats'].format_fname(book_id, fmt)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if name and path:
|
||||
try:
|
||||
@ -3333,7 +3333,7 @@ class Cache:
|
||||
def are_paths_inside_book_dir(self, book_id, paths, sub_path=''):
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except:
|
||||
except Exception:
|
||||
return set()
|
||||
return {x for x in paths if self.backend.is_path_inside_book_dir(x, path, sub_path)}
|
||||
|
||||
|
@ -133,7 +133,7 @@ def clean_user_categories(dbcache):
|
||||
try:
|
||||
if new_cats != user_cats:
|
||||
dbcache.set_pref('user_categories', new_cats)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return new_cats
|
||||
|
||||
|
@ -127,7 +127,7 @@ def main(opts, args, dbctx):
|
||||
try:
|
||||
int(x)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if len(args) < 1 or not verify_int(args[0]):
|
||||
|
@ -86,7 +86,7 @@ class FormatMetadata(MutableBase, MutableMapping):
|
||||
for f in self._formats:
|
||||
try:
|
||||
self._values[f] = db.format_metadata(self._id, f)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -316,7 +316,7 @@ class LibraryDatabase:
|
||||
for listener in self.listeners:
|
||||
try:
|
||||
listener(event, ids)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
continue
|
||||
|
||||
|
@ -154,7 +154,7 @@ class Restore(Thread):
|
||||
if self.successes == 0 and len(self.dirs) > 0:
|
||||
raise Exception('Something bad happened')
|
||||
self.replace_db()
|
||||
except:
|
||||
except Exception:
|
||||
self.tb = traceback.format_exc()
|
||||
if self.failed_dirs:
|
||||
for x in self.failed_dirs:
|
||||
@ -183,7 +183,7 @@ class Restore(Thread):
|
||||
return True
|
||||
self.progress_callback(_('Finished restoring preferences'), 1)
|
||||
return False
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
self.progress_callback(None, 1)
|
||||
self.progress_callback(_('Restoring preferences and column metadata failed'), 0)
|
||||
|
@ -30,7 +30,7 @@ class SchemaUpgrade:
|
||||
prints(f'Upgrading database to version {uv + 1}...')
|
||||
meth()
|
||||
self.db.execute(f'pragma user_version={uv + 1}')
|
||||
except:
|
||||
except Exception:
|
||||
self.db.execute('ROLLBACK')
|
||||
raise
|
||||
else:
|
||||
|
@ -196,13 +196,13 @@ class DateSearch: # {{{
|
||||
num = query[:-len(m.group(1))]
|
||||
try:
|
||||
qd = now() - timedelta(int(num))
|
||||
except:
|
||||
except Exception:
|
||||
raise ParseException(_('Number conversion error: {0}').format(num))
|
||||
field_count = 3
|
||||
else:
|
||||
try:
|
||||
qd = parse_date(query, as_utc=False)
|
||||
except:
|
||||
except Exception:
|
||||
raise ParseException(_('Date conversion error: {0}').format(query))
|
||||
if '-' in query:
|
||||
field_count = query.count('-') + 1
|
||||
@ -588,7 +588,7 @@ class Parser(SearchQueryParser): # {{{
|
||||
c -= m
|
||||
if len(c) == 0:
|
||||
break
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return matches
|
||||
|
||||
@ -662,7 +662,7 @@ class Parser(SearchQueryParser): # {{{
|
||||
sep = sep.lower()
|
||||
else:
|
||||
sep = 't'
|
||||
except:
|
||||
except Exception:
|
||||
if DEBUG:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
@ -720,17 +720,17 @@ class Parser(SearchQueryParser): # {{{
|
||||
|
||||
try:
|
||||
rating_query = int(float(query)) * 2
|
||||
except:
|
||||
except Exception:
|
||||
rating_query = None
|
||||
|
||||
try:
|
||||
int_query = int(float(query))
|
||||
except:
|
||||
except Exception:
|
||||
int_query = None
|
||||
|
||||
try:
|
||||
float_query = float(query)
|
||||
except:
|
||||
except Exception:
|
||||
float_query = None
|
||||
|
||||
for location in locations:
|
||||
|
@ -31,7 +31,7 @@ def c_parse(val):
|
||||
return datetime(int(val), 1, 3, tzinfo=utc_tz)
|
||||
if val is None:
|
||||
return UNDEFINED_DATE
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
|
@ -628,7 +628,7 @@ class ReadingTest(BaseTest):
|
||||
def f(x):
|
||||
try:
|
||||
x.pop('rec_index', None)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return x
|
||||
if field not in {'#series_index'}:
|
||||
|
@ -35,7 +35,7 @@ def force_to_bool(val):
|
||||
val = False
|
||||
else:
|
||||
val = bool(int(val))
|
||||
except:
|
||||
except Exception:
|
||||
val = None
|
||||
return val
|
||||
|
||||
|
@ -47,7 +47,7 @@ def get_series_values(val):
|
||||
try:
|
||||
idx = float(idx)
|
||||
return match.group(1).strip(), idx
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return val, None
|
||||
|
||||
|
@ -174,7 +174,7 @@ def print_basic_debug_info(out=None):
|
||||
out('OSX:', platform.mac_ver())
|
||||
else:
|
||||
out('Linux:', platform.linux_distribution())
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
out('Interface language:', str(set_translators.lang))
|
||||
out('EXE path:', sys.executable)
|
||||
|
@ -52,7 +52,7 @@ def get_connected_device():
|
||||
for det, d in connected_devices:
|
||||
try:
|
||||
d.open(det, None)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
else:
|
||||
dev = d
|
||||
@ -89,7 +89,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
for d in devplugins:
|
||||
try:
|
||||
d.startup()
|
||||
except:
|
||||
except Exception:
|
||||
out(f'Startup failed for device plugin: {d}')
|
||||
|
||||
if disabled_plugins is None:
|
||||
@ -165,7 +165,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
dev.reset(detected_device=det)
|
||||
dev.open(det, None)
|
||||
out('OK')
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
errors[dev] = traceback.format_exc()
|
||||
out('failed')
|
||||
@ -203,7 +203,7 @@ def debug(ioreg_to_tmp=False, buf=None, plugins=None,
|
||||
for d in devplugins:
|
||||
try:
|
||||
d.shutdown()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
|
@ -313,7 +313,7 @@ class ANDROID(USBMS):
|
||||
def windows_sort_drives(self, drives):
|
||||
try:
|
||||
vid, pid, bcd = self.device_being_opened[:3]
|
||||
except:
|
||||
except Exception:
|
||||
vid, pid, bcd = -1, -1, -1
|
||||
if (vid, pid, bcd) == (0x0e79, 0x1408, 0x0222):
|
||||
letter_a = drives.get('carda', None)
|
||||
|
@ -175,7 +175,7 @@ def shutdown_plugins():
|
||||
for d in device_plugins():
|
||||
try:
|
||||
d.shutdown()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
@ -207,7 +207,7 @@ def main():
|
||||
for d in device_plugins():
|
||||
try:
|
||||
d.startup()
|
||||
except:
|
||||
except Exception:
|
||||
print(f'Startup failed for device plugin: {d}')
|
||||
if d.MANAGES_DEVICE_PRESENCE:
|
||||
cd = d.detect_managed_devices(scanner.devices)
|
||||
@ -230,7 +230,7 @@ def main():
|
||||
for det, d in connected_devices:
|
||||
try:
|
||||
d.open(det, None)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
else:
|
||||
dev = d
|
||||
|
@ -44,11 +44,11 @@ class HANLINV3(USBMS):
|
||||
|
||||
try:
|
||||
main_num = int(re.findall(r'\d+', main)[0]) if main else None
|
||||
except:
|
||||
except Exception:
|
||||
main_num = None
|
||||
try:
|
||||
card_num = int(re.findall(r'\d+', card)[0]) if card else None
|
||||
except:
|
||||
except Exception:
|
||||
card_num = None
|
||||
|
||||
if card_num is not None and main_num is not None and card_num > main_num:
|
||||
|
@ -142,7 +142,7 @@ class ALEX(N516):
|
||||
cpath = self.alex_cpath(path)
|
||||
if os.path.exists(cpath):
|
||||
os.remove(cpath)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.report_progress(1.0, _('Removing books from device...'))
|
||||
|
||||
|
@ -27,7 +27,7 @@ class Bookmark: # {{{
|
||||
self.get_book_length()
|
||||
try:
|
||||
self.percent_read = min(float(100*self.last_read / self.book_length),100)
|
||||
except:
|
||||
except Exception:
|
||||
self.percent_read = 0
|
||||
|
||||
def record(self, n):
|
||||
@ -167,7 +167,7 @@ class Bookmark: # {{{
|
||||
text += line.strip()
|
||||
else:
|
||||
raise Exception('error')
|
||||
except:
|
||||
except Exception:
|
||||
text = '(Unable to extract highlight text from My Clippings.txt)'
|
||||
return text
|
||||
|
||||
@ -288,7 +288,7 @@ class Bookmark: # {{{
|
||||
self.nrecs, = unpack('>H', self.data[76:78])
|
||||
record0 = self.record(0)
|
||||
self.book_length = int(unpack('>I', record0[0x04:0x08])[0])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
elif self.bookmark_extension == 'tan':
|
||||
# Read bookLength from metadata
|
||||
@ -297,7 +297,7 @@ class Bookmark: # {{{
|
||||
with open(book_fs,'rb') as f:
|
||||
mu = MetadataUpdater(f)
|
||||
self.book_length = mu.book_length
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
print(f'unsupported bookmark_extension: {self.bookmark_extension}')
|
||||
|
@ -463,7 +463,7 @@ class KINDLE2(KINDLE):
|
||||
if os.access(collections, os.R_OK):
|
||||
try:
|
||||
self.kindle_update_booklist(bl, collections)
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return bl
|
||||
@ -513,7 +513,7 @@ class KINDLE2(KINDLE):
|
||||
# Upload the cover thumbnail
|
||||
try:
|
||||
self.upload_kindle_thumbnail(metadata, filepath)
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
# Upload the apnx file
|
||||
@ -621,7 +621,7 @@ class KINDLE2(KINDLE):
|
||||
if cust_col_name:
|
||||
try:
|
||||
custom_page_count = int(metadata.get(cust_col_name, 0))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
apnx_path = f'{os.path.join(path, filename)}.apnx'
|
||||
@ -638,10 +638,10 @@ class KINDLE2(KINDLE):
|
||||
method = temp
|
||||
else:
|
||||
print(f'Invalid method choice for this book ({temp!r}), ignoring.')
|
||||
except:
|
||||
except Exception:
|
||||
print('Could not retrieve override method choice, using default.')
|
||||
apnx_builder.write_apnx(filepath, apnx_path, method=method, page_count=custom_page_count)
|
||||
except:
|
||||
except Exception:
|
||||
print('Failed to generate APNX')
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
@ -67,7 +67,7 @@ class Bookmark: # {{{
|
||||
'chapter_index': chapter_row['VolumeIndex']
|
||||
}
|
||||
debug_print(f'Kobo::Bookmark::get_bookmark_data - getting kepub chapter: kepub chapters={kepub_chapters}')
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('Kobo::Bookmark::get_bookmark_data - No chapters found')
|
||||
|
||||
cursor.execute(bookmark_query, book_query_values)
|
||||
|
@ -46,20 +46,20 @@ class Book(Book_):
|
||||
if ContentType == '6' and date is not None:
|
||||
try:
|
||||
self.datetime = time.strptime(date, '%Y-%m-%dT%H:%M:%S.%f')
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
self.datetime = time.strptime(date.split('+')[0], '%Y-%m-%dT%H:%M:%S')
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
self.datetime = time.strptime(date.split('+')[0], '%Y-%m-%d')
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
self.datetime = parse_date(date,
|
||||
assume_utc=True).timetuple()
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
self.datetime = time.gmtime(os.path.getctime(self.path))
|
||||
except:
|
||||
except Exception:
|
||||
self.datetime = time.gmtime()
|
||||
|
||||
self.kobo_metadata = Metadata(title, self.authors)
|
||||
|
@ -332,7 +332,7 @@ class KOBO(USBMS):
|
||||
title = 'FILE MISSING: ' + title
|
||||
book = self.book_class(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=1048576)
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('prefix: ', prefix, 'lpath: ', lpath, 'title: ', title, 'authors: ', authors,
|
||||
'mime: ', mime, 'date: ', date, 'ContentType: ', ContentType, 'ImageID: ', ImageID)
|
||||
raise
|
||||
@ -342,7 +342,7 @@ class KOBO(USBMS):
|
||||
|
||||
if bl.add_book(book, replace_metadata=False):
|
||||
changed = True
|
||||
except: # Probably a path encoding error
|
||||
except Exception: # Probably a path encoding error
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return changed
|
||||
@ -809,7 +809,7 @@ class KOBO(USBMS):
|
||||
|
||||
try:
|
||||
cursor.execute(query)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(' Database Exception: Unable to reset ReadStatus list')
|
||||
raise
|
||||
finally:
|
||||
@ -839,7 +839,7 @@ class KOBO(USBMS):
|
||||
try:
|
||||
debug_print(f'Kobo::set_readstatus - Making change - ContentID={ContentID}, ReadStatus={ReadStatus}, DateLastRead={datelastread}')
|
||||
cursor.execute("update content set ReadStatus=?,FirstTimeReading='false',DateLastRead=? where BookID is Null and ContentID = ?", t)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(' Database Exception: Unable to update ReadStatus')
|
||||
raise
|
||||
|
||||
@ -1038,7 +1038,7 @@ class KOBO(USBMS):
|
||||
debug_print('KOBO: uploading cover')
|
||||
try:
|
||||
self._upload_cover(path, filename, metadata, filepath, uploadgrayscale)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('FAILED to upload cover', filepath)
|
||||
|
||||
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale):
|
||||
@ -1248,13 +1248,13 @@ class KOBO(USBMS):
|
||||
if bookmark.last_read is not None:
|
||||
try:
|
||||
last_read = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(calendar.timegm(time.strptime(bookmark.last_read, '%Y-%m-%dT%H:%M:%S'))))
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
last_read = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(calendar.timegm(time.strptime(bookmark.last_read, '%Y-%m-%dT%H:%M:%S.%f'))))
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
last_read = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(calendar.timegm(time.strptime(bookmark.last_read, '%Y-%m-%dT%H:%M:%SZ'))))
|
||||
except:
|
||||
except Exception:
|
||||
last_read = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime())
|
||||
else:
|
||||
# self.datetime = time.gmtime()
|
||||
@ -1846,10 +1846,10 @@ class KOBOTOUCH(KOBO):
|
||||
if DateCreated is not None:
|
||||
try:
|
||||
kobo_metadata.pubdate = parse_date(DateCreated, assume_utc=True)
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
kobo_metadata.pubdate = datetime.strptime(DateCreated, '%Y-%m-%dT%H:%M:%S.%fZ')
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(f"KoboTouch:update_booklist - Cannot convert date - DateCreated='{DateCreated}'")
|
||||
|
||||
idx = bl_cache.get(lpath, None)
|
||||
@ -1966,7 +1966,7 @@ class KOBOTOUCH(KOBO):
|
||||
if show_debug:
|
||||
debug_print(' book.device_collections', book.device_collections)
|
||||
debug_print(' book.title', book.title)
|
||||
except: # Probably a path encoding error
|
||||
except Exception: # Probably a path encoding error
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return changed
|
||||
@ -3338,7 +3338,7 @@ class KOBOTOUCH(KOBO):
|
||||
if book.kobo_series_number is not None:
|
||||
try:
|
||||
kobo_series_number = float(book.kobo_series_number)
|
||||
except:
|
||||
except Exception:
|
||||
kobo_series_number = None
|
||||
if kobo_series_number == book.series_index:
|
||||
if show_debug:
|
||||
@ -3359,7 +3359,7 @@ class KOBOTOUCH(KOBO):
|
||||
debug_print('KoboTouch:set_series - about to set - parameters:', update_values)
|
||||
cursor.execute(update_query, update_values)
|
||||
self.series_set += 1
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(' Database Exception: Unable to set series info')
|
||||
raise
|
||||
finally:
|
||||
@ -3435,7 +3435,7 @@ class KOBOTOUCH(KOBO):
|
||||
self.series_index_template, newmi, 'Kobo series number template', newmi)
|
||||
else:
|
||||
new_series_number = f'{newmi.series_index:g}'
|
||||
except:
|
||||
except Exception:
|
||||
new_series_number = None
|
||||
else:
|
||||
new_series = None
|
||||
@ -3590,7 +3590,7 @@ class KOBOTOUCH(KOBO):
|
||||
debug_print('KoboTouch:set_core_metadata - about to set - update_query:', update_query)
|
||||
cursor.execute(update_query, update_values)
|
||||
self.core_metadata_set += 1
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(' Database Exception: Unable to set the core metadata')
|
||||
debug_print(f' Query was: {update_query}')
|
||||
debug_print(f' Values were: {update_values}')
|
||||
@ -3623,7 +3623,7 @@ class KOBOTOUCH(KOBO):
|
||||
cls.opts = cls.settings()
|
||||
try:
|
||||
return getattr(cls.opts, key)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('KoboTouch::get_prefs - probably an extra_customization:', key)
|
||||
return None
|
||||
|
||||
@ -4342,7 +4342,7 @@ class KOBOTOUCH(KOBO):
|
||||
self.debugging_title = self.get_debugging_title()
|
||||
try:
|
||||
is_debugging = (len(self.debugging_title) > 0 and title.lower().find(self.debugging_title.lower()) >= 0) or len(title) == 0
|
||||
except:
|
||||
except Exception:
|
||||
debug_print(f"KoboTouch::is_debugging_title - Exception checking debugging title for title '{title}'.")
|
||||
is_debugging = False
|
||||
|
||||
|
@ -51,7 +51,7 @@ class DeviceDefaults:
|
||||
if m is not None:
|
||||
try:
|
||||
vid, pid = int(m.group(1), 16), int(m.group(2), 16)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
else:
|
||||
vid, pid = device.vendor_id, device.product_id
|
||||
|
@ -228,7 +228,7 @@ class MTP_DEVICE(BASE):
|
||||
try:
|
||||
stream = self.get_mtp_file(f)
|
||||
dinfo = json.load(stream, object_hook=from_json)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to load existing driveinfo.calibre file, with error:')
|
||||
traceback.print_exc()
|
||||
dinfo = {}
|
||||
@ -304,7 +304,7 @@ class MTP_DEVICE(BASE):
|
||||
try:
|
||||
stream = self.get_mtp_file(cache)
|
||||
json_codec.decode_from_file(stream, bl, Book, sid)
|
||||
except:
|
||||
except Exception:
|
||||
need_sync = True
|
||||
|
||||
relpath_cache = {b.mtp_relpath:i for i, b in enumerate(bl)}
|
||||
@ -333,7 +333,7 @@ class MTP_DEVICE(BASE):
|
||||
try:
|
||||
book.smart_update(self.read_file_metadata(mtp_file))
|
||||
debug('Read metadata for', '/'.join(mtp_file.full_path))
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to read metadata from',
|
||||
'/'.join(mtp_file.full_path))
|
||||
traceback.print_exc()
|
||||
@ -723,7 +723,7 @@ class MTP_DEVICE(BASE):
|
||||
if parent.empty and parent.can_delete and not parent.is_system:
|
||||
try:
|
||||
self.recursive_delete(parent)
|
||||
except:
|
||||
except Exception:
|
||||
prints('Failed to delete parent: {}, ignoring'.format('/'.join(parent.full_path)))
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
|
@ -159,7 +159,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
except BlacklistedDevice:
|
||||
p('This device has been blacklisted by the user')
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
p('Opening device failed:')
|
||||
p(traceback.format_exc())
|
||||
return False
|
||||
|
@ -116,7 +116,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
self.last_refresh_devices_time = time.time()
|
||||
try:
|
||||
pnp_ids = frozenset(self.wpd.enumerate_devices())
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
self.detected_devices = {dev:self.detected_devices.get(dev, None)
|
||||
@ -168,7 +168,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
return False
|
||||
try:
|
||||
pnp_ids = frozenset(self.wpd.enumerate_devices())
|
||||
except:
|
||||
except Exception:
|
||||
p('Failed to get list of PNP ids on system')
|
||||
p(traceback.format_exc())
|
||||
return False
|
||||
@ -183,7 +183,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
for pnp_id in pnp_ids:
|
||||
try:
|
||||
data = self.wpd.device_info(pnp_id)
|
||||
except:
|
||||
except Exception:
|
||||
p('Failed to get data for device:', pnp_id)
|
||||
p(traceback.format_exc())
|
||||
continue
|
||||
@ -201,7 +201,7 @@ class MTP_DEVICE(MTPDeviceBase):
|
||||
except BlacklistedDevice:
|
||||
p('This device has been blacklisted by the user')
|
||||
continue
|
||||
except:
|
||||
except Exception:
|
||||
p('Open failed:')
|
||||
p(traceback.format_exc())
|
||||
continue
|
||||
|
@ -132,7 +132,7 @@ class PRS505(USBMS):
|
||||
if not os.path.exists(dname):
|
||||
try:
|
||||
os.makedirs(dname, mode=0o777)
|
||||
except:
|
||||
except Exception:
|
||||
time.sleep(5)
|
||||
os.makedirs(dname, mode=0o777)
|
||||
with open(cachep, 'wb') as f:
|
||||
@ -142,7 +142,7 @@ class PRS505(USBMS):
|
||||
''')
|
||||
fsync(f)
|
||||
return True
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
@ -237,7 +237,7 @@ class PRS505(USBMS):
|
||||
self._upload_cover(os.path.dirname(p),
|
||||
os.path.splitext(os.path.basename(p))[0],
|
||||
book, p)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('FAILED to upload cover',
|
||||
prefix, book.lpath)
|
||||
else:
|
||||
@ -266,7 +266,7 @@ class PRS505(USBMS):
|
||||
debug_print('PRS505: uploading cover')
|
||||
try:
|
||||
self._upload_cover(path, filename, metadata, filepath)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('FAILED to upload cover', filepath)
|
||||
|
||||
def _upload_cover(self, path, filename, metadata, filepath):
|
||||
|
@ -72,7 +72,7 @@ def strptime(src):
|
||||
def strftime(epoch, zone=time.localtime):
|
||||
try:
|
||||
src = time.strftime('%w, %d %m %Y %H:%M:%S GMT', zone(epoch)).split()
|
||||
except:
|
||||
except Exception:
|
||||
src = time.strftime('%w, %d %m %Y %H:%M:%S GMT', zone()).split()
|
||||
|
||||
src[0] = INVERSE_DAY_MAP[int(src[0][:-1])]+','
|
||||
@ -127,7 +127,7 @@ class XMLCache:
|
||||
with open(path, 'wb') as f:
|
||||
f.write(EMPTY_EXT_CACHE)
|
||||
fsync(f)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if os.access(path, os.W_OK):
|
||||
try:
|
||||
@ -136,7 +136,7 @@ class XMLCache:
|
||||
xml_to_unicode(f.read(), strip_encoding_pats=True, assume_utf8=True, verbose=DEBUG)[0]
|
||||
)
|
||||
self.ext_paths[source_id] = path
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# }}}
|
||||
@ -286,7 +286,7 @@ class XMLCache:
|
||||
id_ = x.get('id')
|
||||
try:
|
||||
id_ = int(id_)
|
||||
except:
|
||||
except Exception:
|
||||
x.set('id', '-1')
|
||||
idmap[id_] = '-1'
|
||||
|
||||
@ -471,7 +471,7 @@ class XMLCache:
|
||||
if not name:
|
||||
try:
|
||||
name = [t for t in book.tags if t != _('News')][0]
|
||||
except:
|
||||
except Exception:
|
||||
name = None
|
||||
|
||||
if not name:
|
||||
@ -483,7 +483,7 @@ class XMLCache:
|
||||
pubdate = strftime(book.pubdate.utctimetuple(),
|
||||
zone=lambda x: x)
|
||||
record.set('publicationDate', pubdate)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def rebuild_collections(self, booklist, bl_index):
|
||||
@ -616,7 +616,7 @@ class XMLCache:
|
||||
# matches. Use localtime if the case of a tie, and hope it is right.
|
||||
try:
|
||||
timestamp = os.path.getmtime(path)
|
||||
except:
|
||||
except Exception:
|
||||
debug_print('Failed to get timestamp for:', path)
|
||||
timestamp = time.time()
|
||||
rec_date = record.get('date', None)
|
||||
@ -630,7 +630,7 @@ class XMLCache:
|
||||
def record_set(k, v):
|
||||
try:
|
||||
record.set(k, clean(v))
|
||||
except:
|
||||
except Exception:
|
||||
# v is not suitable for XML, ignore
|
||||
pass
|
||||
|
||||
@ -656,7 +656,7 @@ class XMLCache:
|
||||
record.set('date', clean(date))
|
||||
try:
|
||||
record.set('size', clean(str(os.stat(path).st_size)))
|
||||
except:
|
||||
except Exception:
|
||||
record.set('size', '0')
|
||||
title = book.title if book.title else _('Unknown')
|
||||
record_set('title', title)
|
||||
@ -731,7 +731,7 @@ class XMLCache:
|
||||
try:
|
||||
raw = etree.tostring(self.ext_roots[i], encoding='UTF-8',
|
||||
xml_declaration=True)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
raw = raw.replace(b"<?xml version='1.0' encoding='UTF-8'?>",
|
||||
b'<?xml version="1.0" encoding="UTF-8"?>')
|
||||
@ -768,7 +768,7 @@ class XMLCache:
|
||||
num = int(id_)
|
||||
if num > ans:
|
||||
ans = num
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
return ans
|
||||
|
||||
|
@ -470,7 +470,7 @@ class PRST1(USBMS):
|
||||
author = newmi.authors[0]
|
||||
else:
|
||||
author = authors_to_string(newmi.authors)
|
||||
except:
|
||||
except Exception:
|
||||
author = _('Unknown')
|
||||
title = newmi.title or _('Unknown')
|
||||
|
||||
@ -796,7 +796,7 @@ class PRST1(USBMS):
|
||||
if not name:
|
||||
try:
|
||||
name = [t for t in book.tags if t != _('News')][0]
|
||||
except:
|
||||
except Exception:
|
||||
name = None
|
||||
|
||||
if not name:
|
||||
@ -805,7 +805,7 @@ class PRST1(USBMS):
|
||||
pubdate = None
|
||||
try:
|
||||
pubdate = int(time.mktime(book.pubdate.timetuple()) * 1000)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cursor = connection.cursor()
|
||||
|
@ -74,7 +74,7 @@ class ConnectionListener(Thread):
|
||||
def _close_socket(self, the_socket):
|
||||
try:
|
||||
the_socket.shutdown(socket.SHUT_RDWR)
|
||||
except:
|
||||
except Exception:
|
||||
# the shutdown can fail if the socket isn't fully connected. Ignore it
|
||||
pass
|
||||
the_socket.close()
|
||||
@ -86,7 +86,7 @@ class ConnectionListener(Thread):
|
||||
while self.keep_running:
|
||||
try:
|
||||
time.sleep(1)
|
||||
except:
|
||||
except Exception:
|
||||
# Happens during interpreter shutdown
|
||||
break
|
||||
|
||||
@ -131,7 +131,7 @@ class ConnectionListener(Thread):
|
||||
',' + str(self.driver.port)).encode('utf-8')
|
||||
self.driver._debug('received broadcast', packet, message)
|
||||
self.driver.broadcast_socket.sendto(message, remote)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
break
|
||||
@ -415,7 +415,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
prints('', printable, end='')
|
||||
else:
|
||||
prints('', a, end='')
|
||||
except:
|
||||
except Exception:
|
||||
prints('', 'value too long', end='')
|
||||
print()
|
||||
self.debug_time = time.time()
|
||||
@ -461,7 +461,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
# Fall back to the ch if the UUID doesn't exist.
|
||||
if self.client_wants_uuid_file_names and mdata.uuid:
|
||||
return (mdata.uuid + ext)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
dotless_ext = ext[1:] if len(ext) > 0 else ext
|
||||
@ -481,7 +481,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
p = mdata.pubdate
|
||||
date = (p.year, p.month, p.day)
|
||||
except:
|
||||
except Exception:
|
||||
today = time.localtime()
|
||||
date = (today[0], today[1], today[2])
|
||||
template = f'{{title}}_{date[0]}-{date[1]}-{date[2]}'
|
||||
@ -572,7 +572,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
v = self.device_socket.recv(length)
|
||||
return v
|
||||
except:
|
||||
except Exception:
|
||||
self._close_device_socket()
|
||||
raise
|
||||
|
||||
@ -621,7 +621,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self._close_device_socket()
|
||||
raise
|
||||
time.sleep(0.1) # lets not hammer the OS too hard
|
||||
except:
|
||||
except Exception:
|
||||
self._close_device_socket()
|
||||
raise
|
||||
|
||||
@ -656,7 +656,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self._debug('device went away')
|
||||
self._close_device_socket()
|
||||
raise ControlError(desc='Device closed the network connection')
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('other exception')
|
||||
traceback.print_exc()
|
||||
self._close_device_socket()
|
||||
@ -684,7 +684,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self._debug('device went away')
|
||||
self._close_device_socket()
|
||||
raise ControlError(desc='Device closed the network connection')
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('other exception')
|
||||
traceback.print_exc()
|
||||
self._close_device_socket()
|
||||
@ -745,7 +745,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if key in self.device_book_cache and self.device_book_cache[key]['book'].last_modified == lastmod:
|
||||
self.device_book_cache[key]['last_used'] = now()
|
||||
return self.device_book_cache[key]['book'].deepcopy(lambda: SDBook('', ''))
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
@ -763,7 +763,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if bool(v_thumb) != bool(b_thumb):
|
||||
return False
|
||||
return not v_thumb or v_thumb[1] == b_thumb[1]
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
@ -775,7 +775,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
continue
|
||||
if metadata.get('lpath', '').endswith(ext):
|
||||
return metadata
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
@ -788,7 +788,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
'_metadata_cache.pickle')
|
||||
if os.path.exists(old_cache_file_name):
|
||||
os.remove(old_cache_file_name)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
@ -797,7 +797,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
'_metadata_cache.json')
|
||||
if os.path.exists(old_cache_file_name):
|
||||
os.remove(old_cache_file_name)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cache_file_name = os.path.join(cache_dir(),
|
||||
@ -825,14 +825,14 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self.known_metadata[lpath] = metadata
|
||||
count += 1
|
||||
self._debug('loaded', count, 'cache items')
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
self.device_book_cache = defaultdict(dict)
|
||||
self.known_metadata = {}
|
||||
try:
|
||||
if os.path.exists(cache_file_name):
|
||||
os.remove(cache_file_name)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
def _write_metadata_cache(self):
|
||||
@ -862,7 +862,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
|
||||
from calibre.utils.filenames import atomic_rename
|
||||
atomic_rename(fd.name, prefix + '.json')
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
def _make_metadata_cache_key(self, uuid, lpath_or_ext):
|
||||
@ -904,7 +904,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
def _close_socket(self, the_socket):
|
||||
try:
|
||||
the_socket.shutdown(socket.SHUT_RDWR)
|
||||
except:
|
||||
except Exception:
|
||||
# the shutdown can fail if the socket isn't fully connected. Ignore it
|
||||
pass
|
||||
the_socket.close()
|
||||
@ -913,7 +913,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if self.device_socket is not None:
|
||||
try:
|
||||
self._close_socket(self.device_socket)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self.device_socket = None
|
||||
self._write_metadata_cache()
|
||||
@ -930,7 +930,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
except OSError:
|
||||
self._debug('socket error on port', port)
|
||||
port = 0
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('Unknown exception while attaching port to socket')
|
||||
traceback.print_exc()
|
||||
raise
|
||||
@ -972,7 +972,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
# protocol, this can only be a disconnect notification. Fall
|
||||
# through and actually try to talk to the client.
|
||||
# This will usually toss an exception if the socket is gone.
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if (self.settings().extra_customization[self.OPT_AUTODISCONNECT] and
|
||||
self.noop_counter > self.DISCONNECT_AFTER_N_SECONDS):
|
||||
@ -983,7 +983,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
if self._call_client('NOOP', {})[0] is None:
|
||||
self._close_device_socket()
|
||||
except:
|
||||
except Exception:
|
||||
self._close_device_socket()
|
||||
return self if self.is_connected else None
|
||||
|
||||
@ -1003,7 +1003,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self.connection_attempts[peer] = attempts + 1
|
||||
except InitialConnectionError:
|
||||
raise
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
except queue.Empty:
|
||||
self.is_connected = False
|
||||
@ -1136,7 +1136,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self._call_client('DISPLAY_MESSAGE',
|
||||
{'messageKind': self.MESSAGE_UPDATE_NEEDED,
|
||||
'lastestKnownAppVersion': self.CURRENT_CC_VERSION})
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self.max_book_packet_len = result.get('maxBookContentPacketLen',
|
||||
@ -1190,7 +1190,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
{'messageKind': self.MESSAGE_PASSWORD_ERROR,
|
||||
'currentLibraryName': self.current_library_name,
|
||||
'currentLibraryUUID': library_uuid})
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._close_device_socket()
|
||||
# Don't bother with a message. The user will be informed on
|
||||
@ -1199,7 +1199,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
peer = self.device_socket.getpeername()[0]
|
||||
self.connection_attempts[peer] = 0
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return True
|
||||
@ -1342,7 +1342,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
self.device_book_cache.pop(key, None)
|
||||
self.known_metadata.pop(lpath, None)
|
||||
count_of_cache_items_deleted += 1
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('Exception while deleting book from caches', lpath)
|
||||
traceback.print_exc()
|
||||
self._debug('removed', count_of_cache_items_deleted, 'books from caches')
|
||||
@ -1374,7 +1374,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
book.set('_new_book_', True)
|
||||
else:
|
||||
self._set_known_metadata(book)
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('exception retrieving metadata for book', result.get('title', 'Unknown'))
|
||||
traceback.print_exc()
|
||||
else:
|
||||
@ -1446,7 +1446,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
if bool(self.is_read_sync_col):
|
||||
book.set('_is_read_', book.get(self.is_read_sync_col, None))
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('failed to set local copy of _is_read_')
|
||||
traceback.print_exc()
|
||||
|
||||
@ -1454,7 +1454,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if bool(self.is_read_date_sync_col):
|
||||
book.set('_last_read_date_',
|
||||
book.get(self.is_read_date_sync_col, None))
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('failed to set local copy of _last_read_date_')
|
||||
traceback.print_exc()
|
||||
# Write the cache here so that if we are interrupted on disconnect then the
|
||||
@ -1655,7 +1655,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if cc_mtime < calibre_mtime:
|
||||
book.set('_format_mtime_', isoformat(self.now))
|
||||
return posixpath.basename(book.lpath), False
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('exception checking if must send format', book.title)
|
||||
traceback.print_exc()
|
||||
return None, False
|
||||
@ -1770,7 +1770,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
book.get('title', 'huh?'), 'to', calibre_val)
|
||||
book.set('_force_send_metadata_', True)
|
||||
force_return_changed_books = True
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('exception special syncing is_read', self.is_read_sync_col)
|
||||
traceback.print_exc()
|
||||
|
||||
@ -1793,7 +1793,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
book.get('title', 'huh?'), 'to', calibre_val)
|
||||
book.set('_force_send_metadata_', True)
|
||||
force_return_changed_books = True
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('exception special syncing is_read_date',
|
||||
self.is_read_sync_col)
|
||||
traceback.print_exc()
|
||||
@ -1816,7 +1816,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
{id_: is_read})
|
||||
if self.set_temp_mark_when_syncing_read:
|
||||
db.data.toggle_marked_ids({id_})
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('exception standard syncing is_read', self.is_read_sync_col)
|
||||
traceback.print_exc()
|
||||
|
||||
@ -1833,7 +1833,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
{id_: is_read_date})
|
||||
if self.set_temp_mark_when_syncing_read:
|
||||
db.data.toggle_marked_ids({id_})
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('Exception standard syncing is_read_date',
|
||||
self.is_read_date_sync_col)
|
||||
traceback.print_exc()
|
||||
@ -1892,7 +1892,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
compression_quality_ok = False
|
||||
else:
|
||||
self.THUMBNAIL_COMPRESSION_QUALITY = cq
|
||||
except:
|
||||
except Exception:
|
||||
compression_quality_ok = False
|
||||
if not compression_quality_ok:
|
||||
self.THUMBNAIL_COMPRESSION_QUALITY = 70
|
||||
@ -1905,7 +1905,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
set_socket_inherit(self.listen_socket, False)
|
||||
except:
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
message = 'creation of listen socket failed'
|
||||
self._debug(message)
|
||||
@ -1916,7 +1916,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
if self.settings().extra_customization[self.OPT_USE_PORT]:
|
||||
try:
|
||||
opt_port = int(self.settings().extra_customization[self.OPT_PORT_NUMBER])
|
||||
except:
|
||||
except Exception:
|
||||
message = _('Invalid port in options: %s')% \
|
||||
self.settings().extra_customization[self.OPT_PORT_NUMBER]
|
||||
self._debug(message)
|
||||
@ -1944,7 +1944,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
|
||||
try:
|
||||
self.listen_socket.listen(1)
|
||||
except:
|
||||
except Exception:
|
||||
message = f'listen on port {port} failed'
|
||||
self._debug(message)
|
||||
self._close_listen_socket()
|
||||
@ -1955,7 +1955,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
publish_zeroconf('calibre smart device client',
|
||||
'_calibresmartdeviceapp._tcp', port, {},
|
||||
use_ip_address=ip_addr, strict=False)
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('registration with bonjour failed')
|
||||
traceback.print_exc()
|
||||
|
||||
@ -1967,7 +1967,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
self.broadcast_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
set_socket_inherit(self.broadcast_socket, False)
|
||||
except:
|
||||
except Exception:
|
||||
message = 'creation of broadcast socket failed. This is not fatal.'
|
||||
self._debug(message)
|
||||
self.broadcast_socket = None
|
||||
@ -2001,7 +2001,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
unpublish_zeroconf('calibre smart device client',
|
||||
'_calibresmartdeviceapp._tcp', self.port, {})
|
||||
except:
|
||||
except Exception:
|
||||
self._debug('deregistration with bonjour failed')
|
||||
traceback.print_exc()
|
||||
self._close_listen_socket()
|
||||
|
@ -67,7 +67,7 @@ class Book(Metadata):
|
||||
self.size = size # will be set later if None
|
||||
try:
|
||||
self.datetime = time.gmtime(os.path.getctime(self.path))
|
||||
except:
|
||||
except Exception:
|
||||
self.datetime = time.gmtime()
|
||||
if other:
|
||||
self.smart_update(other)
|
||||
|
@ -550,7 +550,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
ok[node] = True
|
||||
else:
|
||||
ok[node] = False
|
||||
except:
|
||||
except Exception:
|
||||
ok[node] = False
|
||||
if is_debugging() and not ok[node]:
|
||||
print(f'\nIgnoring the node: {node} as could not read size from: {sz}')
|
||||
@ -580,7 +580,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
with open(sz, 'rb') as szf:
|
||||
sz = int(szf.read().decode('utf-8'))
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if sz > 0:
|
||||
nodes.append((x.split('/')[-1], sz))
|
||||
@ -602,7 +602,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
from calibre.devices.udisks import mount
|
||||
mount(node)
|
||||
return 0
|
||||
except:
|
||||
except Exception:
|
||||
print('Udisks mount call failed:')
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
@ -658,12 +658,12 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
try:
|
||||
with open(path, 'wb'):
|
||||
ro = False
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
os.remove(path)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if is_debugging() and ro:
|
||||
print('\nThe mountpoint', mp, 'is readonly, ignoring it')
|
||||
@ -889,7 +889,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
if x is not None:
|
||||
try:
|
||||
subprocess.Popen(self.OSX_EJECT_COMMAND + [x])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def eject_linux(self):
|
||||
@ -898,7 +898,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
for d in drives:
|
||||
try:
|
||||
umount(d)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
for d in drives:
|
||||
try:
|
||||
@ -918,22 +918,22 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
if islinux:
|
||||
try:
|
||||
self.eject_linux()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if isfreebsd:
|
||||
try:
|
||||
self.eject_freebsd()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if iswindows:
|
||||
try:
|
||||
self.eject_windows()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if ismacos:
|
||||
try:
|
||||
self.eject_osx()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._main_prefix = self._card_a_prefix = self._card_b_prefix = None
|
||||
self.on_device_close()
|
||||
@ -945,7 +945,7 @@ class Device(DeviceConfig, DevicePlugin):
|
||||
if islinux:
|
||||
try:
|
||||
self.linux_post_yank()
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self._main_prefix = self._card_a_prefix = self._card_b_prefix = None
|
||||
|
@ -115,7 +115,7 @@ class USBMS(CLI, Device):
|
||||
with open(os.path.join(prefix, self.DRIVEINFO), 'rb') as f:
|
||||
try:
|
||||
driveinfo = json.loads(f.read(), object_hook=from_json)
|
||||
except:
|
||||
except Exception:
|
||||
driveinfo = None
|
||||
driveinfo = self._update_driveinfo_record(driveinfo, prefix,
|
||||
location_code, name)
|
||||
@ -252,7 +252,7 @@ class USBMS(CLI, Device):
|
||||
if bl.add_book(self.book_from_path(prefix, lpath),
|
||||
replace_metadata=False):
|
||||
changed = True
|
||||
except: # Probably a filename encoding error
|
||||
except Exception: # Probably a filename encoding error
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return changed
|
||||
@ -333,7 +333,7 @@ class USBMS(CLI, Device):
|
||||
self.upload_cover(os.path.dirname(filepath),
|
||||
os.path.splitext(os.path.basename(filepath))[0],
|
||||
mdata, filepath)
|
||||
except: # Failure to upload cover is not catastrophic
|
||||
except Exception: # Failure to upload cover is not catastrophic
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
@ -413,7 +413,7 @@ class USBMS(CLI, Device):
|
||||
if self.SUPPORTS_SUB_DIRS:
|
||||
try:
|
||||
os.removedirs(os.path.dirname(path))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
@ -504,7 +504,7 @@ class USBMS(CLI, Device):
|
||||
try:
|
||||
with open(cache_file, 'rb') as f:
|
||||
json_codec.decode_from_file(f, bl, cls.book_class, prefix)
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
bl = []
|
||||
|
@ -106,7 +106,7 @@ class USER_DEFINED(USBMS):
|
||||
self.WINDOWS_CARD_A_MEM = e[self.OPT_USB_WINDOWS_CA_ID] + '&'
|
||||
self.EBOOK_DIR_MAIN = e[self.OPT_MAIN_MEM_FOLDER]
|
||||
self.EBOOK_DIR_CARD_A = e[self.OPT_CARD_A_FOLDER]
|
||||
except:
|
||||
except Exception:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
self.plugin_needs_delayed_initialization = False
|
||||
|
@ -59,7 +59,7 @@ def build_template_regexp(template):
|
||||
try:
|
||||
template = template.rpartition('/')[2]
|
||||
return re.compile(re.sub(r'{([^}]*)}', f, template) + r'([_\d]*$)')
|
||||
except:
|
||||
except Exception:
|
||||
prints(f'Failed to parse template: {template!r}')
|
||||
template = '{title} - {authors}'
|
||||
return re.compile(re.sub(r'{([^}]*)}', f, template) + r'([_\d]*$)')
|
||||
@ -88,7 +88,7 @@ def create_upload_path(mdata, fname, template, sanitize,
|
||||
try:
|
||||
p = mdata.pubdate
|
||||
date = (p.year, p.month, p.day)
|
||||
except:
|
||||
except Exception:
|
||||
today = time.localtime()
|
||||
date = (today[0], today[1], today[2])
|
||||
template = f'{{title}}_{date[0]}-{date[1]}-{date[2]}'
|
||||
|
@ -81,7 +81,7 @@ def _get_comments(soup):
|
||||
# and pages often comes as '(\d+ pages)'
|
||||
pages = re.search(r'\d+', pages).group(0)
|
||||
return f'Published {date}, {pages} pages.'
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
@ -108,7 +108,7 @@ def _get_cover(soup, rdr):
|
||||
# interestingly, occasionally the only image without height
|
||||
# or width attrs is the cover...
|
||||
r[0] = img['src']
|
||||
except:
|
||||
except Exception:
|
||||
# Probably invalid width, height aattributes, ignore
|
||||
continue
|
||||
if r:
|
||||
@ -118,11 +118,11 @@ def _get_cover(soup, rdr):
|
||||
if ans is not None:
|
||||
try:
|
||||
ans = rdr.GetFile(ans)
|
||||
except:
|
||||
except Exception:
|
||||
ans = rdr.root + '/' + ans
|
||||
try:
|
||||
ans = rdr.GetFile(ans)
|
||||
except:
|
||||
except Exception:
|
||||
ans = None
|
||||
if ans is not None:
|
||||
import io
|
||||
@ -132,7 +132,7 @@ def _get_cover(soup, rdr):
|
||||
try:
|
||||
Image.open(io.BytesIO(ans)).convert('RGB').save(buf, 'JPEG')
|
||||
ans = buf.getvalue()
|
||||
except:
|
||||
except Exception:
|
||||
ans = None
|
||||
return ans
|
||||
|
||||
@ -147,7 +147,7 @@ def get_metadata_from_reader(rdr):
|
||||
x = rdr.GetEncoding()
|
||||
codecs.lookup(x)
|
||||
enc = x
|
||||
except:
|
||||
except Exception:
|
||||
enc = 'cp1252'
|
||||
title = force_unicode(title, enc)
|
||||
authors = _get_authors(home)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user