mirror of
https://github.com/RicterZ/nhentai.git
synced 2025-04-19 18:31:24 +02:00
fix exceptions
This commit is contained in:
parent
79fbce348b
commit
ff7d566aae
@ -40,5 +40,5 @@ if __name__ == '__main__':
|
||||
test.show()
|
||||
try:
|
||||
test.download()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print 'Exception: %s' % str(e)
|
@ -34,20 +34,20 @@ class Downloader(object):
|
||||
else:
|
||||
for chunk in response.iter_content(2048):
|
||||
f.write(chunk)
|
||||
except (os.error, IOError), e:
|
||||
except requests.HTTPError as e:
|
||||
if not retried:
|
||||
logger.error('Error: %s, retrying' % str(e))
|
||||
return self._download(url=url, folder=folder, filename=filename, retried=True)
|
||||
else:
|
||||
return None
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.critical('CRITICAL: %s' % str(e))
|
||||
raise e
|
||||
return None
|
||||
return url
|
||||
|
||||
def _download_callback(self, request, result):
|
||||
if not result:
|
||||
logger.critical('Too many network errors occurred, please check your connection.')
|
||||
logger.critical('Too many errors occurred, quit.')
|
||||
raise SystemExit
|
||||
logger.log(15, '%s download successfully' % result)
|
||||
|
||||
@ -62,7 +62,7 @@ class Downloader(object):
|
||||
logger.warn('Path \'%s\' not exist.' % folder)
|
||||
try:
|
||||
os.mkdir(folder)
|
||||
except os.error, e:
|
||||
except EnvironmentError as e:
|
||||
logger.critical('Error: %s' % str(e))
|
||||
raise SystemExit
|
||||
else:
|
||||
|
@ -75,7 +75,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
||||
if fd is not None:
|
||||
fd = fd()
|
||||
|
||||
if fd in (1, 2): # stdout or stderr
|
||||
if fd in (1, 2): # stdout or stderr
|
||||
h = ctypes.windll.kernel32.GetStdHandle(-10 - fd)
|
||||
|
||||
while parts:
|
||||
@ -97,11 +97,11 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
||||
elif 30 <= p <= 37:
|
||||
color |= self.nt_color_map[p - 30]
|
||||
elif p == 1:
|
||||
color |= 0x08 # foreground intensity on
|
||||
elif p == 0: # reset to default color
|
||||
color |= 0x08 # foreground intensity on
|
||||
elif p == 0: # reset to default color
|
||||
color = 0x07
|
||||
else:
|
||||
pass # error condition ignored
|
||||
pass # error condition ignored
|
||||
|
||||
ctypes.windll.kernel32.SetConsoleTextAttribute(h, color)
|
||||
|
||||
@ -127,7 +127,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
|
||||
prefix = ""
|
||||
|
||||
message = "%s%s" % (prefix, ''.join((self.csi, ';'.join(params),
|
||||
'm', message, self.reset)))
|
||||
'm', message, self.reset)))
|
||||
|
||||
return message
|
||||
|
||||
|
@ -17,7 +17,7 @@ def dojinshi_parser(id):
|
||||
|
||||
try:
|
||||
response = requests.get(url).content
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.critical('%s%s' % tuple(e.message))
|
||||
sys.exit()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user