Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit 7f28967

Browse files
committed
bug fix
1 parent 4f5d299 commit 7f28967

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

BugReporter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ def index(self):
187187
@cherrypy.expose
188188
@cherrypy.tools.json_out()
189189
def json(self):
190-
return get_data
190+
return get_data()

main.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
from functools import wraps
3838

3939

40-
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
40+
def retry(tries=4, delay=3, backoff=2):
4141
"""Retry calling the decorated function using an exponential backoff.
4242
4343
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
@@ -65,14 +65,11 @@ def f_retry(*args, **kwargs):
6565
try:
6666
return f(*args, **kwargs)
6767
except Exception as e:
68-
if isinstance(e,ExceptionToCheck):
69-
msg = "%s, Retrying in %d seconds..." % (str(e), mdelay)
70-
logging.warning(msg)
71-
time.sleep(mdelay)
72-
mtries -= 1
73-
mdelay *= backoff
74-
else:
75-
raise e
68+
msg = "%s, Retrying in %d seconds..." % (str(e), mdelay)
69+
logging.warning(msg)
70+
time.sleep(mdelay)
71+
mtries -= 1
72+
mdelay *= backoff
7673
return f(*args, **kwargs)
7774

7875
return f_retry # true decorator
@@ -129,11 +126,12 @@ def log_bug(self, exc:Exception, msg='', report = True, disable_notification = F
129126
info = BugReporter.exception(msg, exc, report = self.bug_reporter and report)
130127
logging.exception(msg, exc_info=exc)
131128
msg = html.escape(msg)
129+
tb_string = html.escape(info['tb_string'])
132130
message = (
133131
'<b>An exception was raised</b>\n'
134-
'L{line_no}@{file_name}: {exc_type}\n'
135-
f'{msg}\n'
136-
'<pre>{tb_string}</pre>'
132+
'<i>L{line_no}@{file_name}: {exc_type}<i>\n'
133+
f'{msg}\n\n'
134+
f'<pre>{tb_string}</pre>'
137135
).format_map(info)
138136

139137
if len(args):
@@ -164,7 +162,7 @@ def purge(self, html_str:str, images=True):
164162
tag.attrs = dict()
165163
return soup
166164

167-
@retry(HTTPError,10)
165+
@retry(10)
168166
def get_feed(self):
169167
with urlopen(self.source) as f:
170168
return f.read().decode('utf-8')

0 commit comments

Comments
 (0)