Use newer form of catching exceptions
autopep8 -i --select=W602 Also some other minor deprecated syntax changes, like "while 1". I did not commit the less obvious changes.
This commit is contained in:
parent
fb1b8bc5b8
commit
a6ad7e83ff
72 changed files with 151 additions and 154 deletions
|
|
@ -301,7 +301,7 @@ class AuMBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapDating, ICapCh
|
|||
children=[],
|
||||
flags=Message.IS_UNREAD)
|
||||
yield thread.root
|
||||
except BrowserUnavailable, e:
|
||||
except BrowserUnavailable as e:
|
||||
self.logger.debug('No messages, browser is unavailable: %s' % e)
|
||||
pass # don't care about waiting
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ class Decoder(object):
|
|||
|
||||
def main(self):
|
||||
try:
|
||||
while 1:
|
||||
while True:
|
||||
self.process()
|
||||
except KeyboardInterrupt:
|
||||
print ''
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class PriorityConnection(Optimization):
|
|||
zipcode= 75001,
|
||||
country= 'fr',
|
||||
godfather= my_id)
|
||||
except AccountRegisterError, e:
|
||||
except AccountRegisterError as e:
|
||||
self.logger.warning('Unable to register account: %s' % e)
|
||||
except CaptchaError:
|
||||
self.logger.warning('Unable to solve captcha... Retrying')
|
||||
|
|
@ -156,12 +156,12 @@ class PriorityConnection(Optimization):
|
|||
fakes = self.storage.get('priority_connection', 'fakes', default={})
|
||||
if len(fakes) == 0:
|
||||
return
|
||||
while 1:
|
||||
while True:
|
||||
name = random.choice(fakes.keys())
|
||||
fake = fakes[name]
|
||||
try:
|
||||
browser = AuMBrowser(fake['username'], fake['password'], proxy=self.browser.proxy)
|
||||
except (AdopteBanned,BrowserIncorrectPassword), e:
|
||||
except (AdopteBanned,BrowserIncorrectPassword) as e:
|
||||
self.logger.warning('Fake %s can\'t login: %s' % (name, e))
|
||||
continue
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class ProfilesWalker(Optimization):
|
|||
# We consider this profil hasn't been [correctly] analysed
|
||||
self.profiles_queue.add(id)
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print e
|
||||
finally:
|
||||
if self.view_cron is not None:
|
||||
|
|
|
|||
|
|
@ -47,6 +47,6 @@ class Visibility(Optimization):
|
|||
try:
|
||||
with self.browser:
|
||||
self.browser.login()
|
||||
except BrowserUnavailable, e:
|
||||
except BrowserUnavailable as e:
|
||||
print str(e)
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class BanquePopulaire(BaseBrowser):
|
|||
account = self.get_account(account.id)
|
||||
self.location('/cyber/internet/ContinueTask.do', urllib.urlencode(account._params))
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
assert self.is_on_page(TransactionsPage)
|
||||
|
||||
for tr in self.page.get_history():
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class LoginPage(BEPage):
|
|||
def login(self, login, password):
|
||||
try:
|
||||
vk = BNPVirtKeyboard(self)
|
||||
except VirtKeyboardError, err:
|
||||
except VirtKeyboardError as err:
|
||||
self.logger.error("Error: %s" % err)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class LoginPage(BasePage):
|
|||
def login(self, login, password):
|
||||
try:
|
||||
vk=BNPVirtKeyboard(self)
|
||||
except VirtKeyboardError, err:
|
||||
except VirtKeyboardError as err:
|
||||
self.logger.error("Error: %s"%err)
|
||||
return False
|
||||
|
||||
|
|
@ -111,7 +111,7 @@ class ChangePasswordPage(BasePage):
|
|||
def change_password(self, current, new):
|
||||
try:
|
||||
vk=BNPVirtKeyboard(self)
|
||||
except VirtKeyboardError, err:
|
||||
except VirtKeyboardError as err:
|
||||
self.logger.error("Error: %s"%err)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class BPBrowser(BaseBrowser):
|
|||
"""
|
||||
ops = self.page.get_history(deferred=True)
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
for tr in ops:
|
||||
yield tr
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class TransferSummary(BasePage):
|
|||
#HACK for deal with bad encoding ...
|
||||
try:
|
||||
text = p.text
|
||||
except UnicodeDecodeError, error:
|
||||
except UnicodeDecodeError as error:
|
||||
text = error.object.strip()
|
||||
|
||||
match = re.search("Votre virement N.+ ([0-9]+) ", text)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ class CaisseEpargne(BaseBrowser):
|
|||
|
||||
self.page.go_history(info)
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
assert self.is_on_page(IndexPage)
|
||||
|
||||
for tr in self.page.get_history():
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class CreditCooperatif(BaseBrowser):
|
|||
def get_history(self, account):
|
||||
self.location('/banque/cpt/cpt/situationcomptes.do?lnkReleveAction=X&numeroExterne='+ account.id)
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
assert self.is_on_page(TransactionsPage)
|
||||
|
||||
for tr in self.page.get_history():
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class CDNBasePage(BasePage):
|
|||
if start < 0:
|
||||
continue
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
if value is None:
|
||||
value = ''
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ class DLFP(BaseBrowser):
|
|||
|
||||
try:
|
||||
self.submit()
|
||||
except BrowserHTTPError, e:
|
||||
except BrowserHTTPError as e:
|
||||
raise CantSendMessage('Unable to send message to %s.%s: %s' % (thread, reply_id, e))
|
||||
|
||||
if self.is_on_page(NodePage):
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class GDCVaultBrowser(BaseBrowser):
|
|||
try:
|
||||
self.open_novisit(url)
|
||||
#headers = req.info()
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
# print e.getcode()
|
||||
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
||||
#print e.hdrs['Location']
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class VideoPage(BasePage):
|
|||
if len(obj) > 0:
|
||||
try:
|
||||
title = unicode(obj[0].text)
|
||||
except UnicodeDecodeError, e:
|
||||
except UnicodeDecodeError as e:
|
||||
title = None
|
||||
|
||||
|
||||
|
|
@ -125,7 +125,7 @@ class VideoPage(BasePage):
|
|||
# FIXME: 1013483 has buggus title (latin1)
|
||||
# for now we just pass it as-is
|
||||
title = obj[0].attrib['content']
|
||||
except UnicodeDecodeError, e:
|
||||
except UnicodeDecodeError as e:
|
||||
# XXX: this doesn't even works!?
|
||||
title = obj[0].attrib['content'].decode('iso-5589-15')
|
||||
|
||||
|
|
@ -172,7 +172,7 @@ class VideoPage(BasePage):
|
|||
|
||||
|
||||
#print req.code
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
#print e.getcode()
|
||||
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
||||
#print e.hdrs['Location']
|
||||
|
|
@ -218,7 +218,7 @@ class VideoPage(BasePage):
|
|||
self.browser.set_handle_redirect(False)
|
||||
try:
|
||||
self.browser.open_novisit(video.url)
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
||||
video.url = unicode(e.hdrs['Location'])
|
||||
self.browser.set_handle_redirect(True)
|
||||
|
|
@ -298,7 +298,7 @@ class VideoPage(BasePage):
|
|||
# 1016634 has "Invalid Date"
|
||||
try:
|
||||
video.date = parse_dt(obj.text)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
video.date = NotAvailable
|
||||
|
||||
obj = self.parser.select(config.getroot(), 'duration', 1)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class LoginPage(BasePage):
|
|||
def login(self, login, password):
|
||||
try:
|
||||
vk=HelloBankVirtKeyboard(self)
|
||||
except VirtKeyboardError,err:
|
||||
except VirtKeyboardError as err:
|
||||
self.logger.error("Error: %s"%err)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ class Ing(BaseBrowser):
|
|||
|
||||
index = 0 # index, we get always the same page, but with more informations
|
||||
hashlist = []
|
||||
while 1:
|
||||
while True:
|
||||
i = index
|
||||
for transaction in self.page.get_transactions(index):
|
||||
while transaction.id in hashlist:
|
||||
|
|
@ -227,7 +227,7 @@ class Ing(BaseBrowser):
|
|||
"transfer_issuer_radio": subscription.id
|
||||
}
|
||||
self.location(self.billpage, urllib.urlencode(data))
|
||||
while 1:
|
||||
while True:
|
||||
for bill in self.page.iter_bills(subscription.id):
|
||||
yield bill
|
||||
if self.page.islast():
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class LoginPage(BasePage):
|
|||
# 2) And now, the virtual Keyboard
|
||||
try:
|
||||
vk = INGVirtKeyboard(self)
|
||||
except VirtKeyboardError, err:
|
||||
except VirtKeyboardError as err:
|
||||
error("Error: %s" % err)
|
||||
return False
|
||||
realpasswd = ""
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class TransferConfirmPage(BasePage):
|
|||
def confirm(self, password):
|
||||
try:
|
||||
vk = INGVirtKeyboard(self)
|
||||
except VirtKeyboardError, err:
|
||||
except VirtKeyboardError as err:
|
||||
error("Error: %s" % err)
|
||||
return
|
||||
realpasswd = ""
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class LoginPage(BasePage):
|
|||
def login(self, login, passwd, agency):
|
||||
try:
|
||||
vk=LCLVirtKeyboard(self)
|
||||
except VirtKeyboardError,err:
|
||||
except VirtKeyboardError as err:
|
||||
error("Error: %s"%err)
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ class OkCBackend(BaseBackend, ICapMessages, ICapContact, ICapMessagesPost):
|
|||
# if m.flags & m.IS_UNREAD:
|
||||
# yield m
|
||||
|
||||
# except BrowserUnavailable, e:
|
||||
# except BrowserUnavailable as e:
|
||||
# self.logger.debug('No messages, browser is unavailable: %s' % e)
|
||||
# pass # don't care about waiting
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class PastebinBrowser(BaseBrowser):
|
|||
urllib.urlencode(data)).decode(self.ENCODING)
|
||||
try:
|
||||
self._validate_api_response(res)
|
||||
except BadAPIRequest, e:
|
||||
except BadAPIRequest as e:
|
||||
if str(e) == 'invalid login':
|
||||
raise BrowserIncorrectPassword()
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class PhpBB(BaseBrowser):
|
|||
assert self.is_on_page(TopicPage)
|
||||
|
||||
parent = 0
|
||||
while 1:
|
||||
while True:
|
||||
for post in self.page.iter_posts():
|
||||
if stop_id and post.id >= stop_id:
|
||||
return
|
||||
|
|
@ -117,7 +117,7 @@ class PhpBB(BaseBrowser):
|
|||
assert self.is_on_page(TopicPage)
|
||||
|
||||
child = None
|
||||
while 1:
|
||||
while True:
|
||||
for post in self.page.riter_posts():
|
||||
if child:
|
||||
child.parent = post.id
|
||||
|
|
|
|||
|
|
@ -38,6 +38,6 @@ class PiratebayTest(BackendTest):
|
|||
assert isinstance(full_torrent.description, basestring)
|
||||
try:
|
||||
assert self.backend.get_torrent_file(torrent.id)
|
||||
except MagnetOnly, e:
|
||||
except MagnetOnly as e:
|
||||
assert e.magnet.startswith('magnet:')
|
||||
assert e.magnet == full_torrent.magnet
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class SeLogerBrowser(BaseBrowser):
|
|||
|
||||
self.location(self.buildurl('http://ws.seloger.com/search.xml', **data))
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
assert self.is_on_page(SearchResultsPage)
|
||||
|
||||
for housing in self.page.iter_housings():
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class AccountHistory(BasePage):
|
|||
# There are no transactions in this kind of account
|
||||
return
|
||||
|
||||
while 1:
|
||||
while True:
|
||||
d = XML(self.browser.readurl(url))
|
||||
try:
|
||||
el = self.parser.select(d, '//dataBody', 1, 'xpath')
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class LoginPage(BasePage):
|
|||
|
||||
try:
|
||||
img.build_tiles()
|
||||
except TileError, err:
|
||||
except TileError as err:
|
||||
error("Error: %s" % err)
|
||||
if err.tile:
|
||||
err.tile.display()
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class LoginPage(SGPEPage):
|
|||
|
||||
try:
|
||||
img.build_tiles()
|
||||
except TileError, err:
|
||||
except TileError as err:
|
||||
error("Error: %s" % err)
|
||||
if err.tile:
|
||||
err.tile.display()
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class VideoPage(BasePage):
|
|||
self.browser.set_handle_redirect(False)
|
||||
try:
|
||||
self.browser.open_novisit(v.url)
|
||||
except HTTPError, e:
|
||||
except HTTPError as e:
|
||||
if e.getcode() == 302 and hasattr(e, 'hdrs'):
|
||||
#print e.hdrs['Location']
|
||||
v.url = unicode(e.hdrs['Location'])
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
|
|||
yt_service.ssl = True
|
||||
try:
|
||||
entry = yt_service.GetYouTubeVideoEntry(video_id=_id)
|
||||
except gdata.service.Error, e:
|
||||
except gdata.service.Error as e:
|
||||
if e.args[0]['status'] == 400:
|
||||
return None
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue