Skip to content

Commit

Permalink
Improved error reporting (close #22)
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Sep 30, 2019
1 parent a6cba78 commit 1273e51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CB/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string
import random

__version__ = '2.7.0'
__version__ = '2.7.1'
__license__ = 'GPLv3'
__copyright__ = '2019, Paweł Jastrzębski <[email protected]>'
__docformat__ = 'restructuredtext en'
Expand Down
52 changes: 33 additions & 19 deletions CurseBreaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,21 @@ def auto_update(self):
os.system('pause')
sys.exit(1)

def handle_exception(self, e):
if len(self.tableData) > 1:
def handle_exception(self, e, table=True):
if len(self.tableData) > 1 and table:
printft(ANSI(self.table.table))
if getattr(sys, 'frozen', False):
printft(HTML(f'\n<ansibrightred>{str(e)}</ansibrightred>'))
if isinstance(e, list):
for es in e:
printft(HTML(f'\n<ansibrightred>{str(es)}</ansibrightred>'))
else:
printft(HTML(f'\n<ansibrightred>{str(e)}</ansibrightred>'))
else:
sys.tracebacklimit = 1000
traceback.print_exc()
if isinstance(e, list):
for es in e:
traceback.print_exception(es, es, es.__traceback__, limit=1000)
else:
traceback.print_exc(limit=1000)

def print_header(self):
os.system('cls')
Expand Down Expand Up @@ -284,25 +291,32 @@ def c_update(self, args, addline=False, update=True, force=False):
addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
self.core.bulk_check(addons)
with tqdm(total=len(addons), bar_format='{n_fmt}/{total_fmt} |{bar}|') as pbar:
exceptions = []
for addon in addons:
name, versionnew, versionold, modified = self.core.\
update_addon(addon if isinstance(addon, str) else addon['URL'], update, force)
if versionold:
if versionold == versionnew:
if modified:
self.tableData.append([f'{AC.LIGHTRED_EX}Modified{AC.RESET}', name, versionold])
try:
name, versionnew, versionold, modified = self.core.\
update_addon(addon if isinstance(addon, str) else addon['URL'], update, force)
if versionold:
if versionold == versionnew:
if modified:
self.tableData.append([f'{AC.LIGHTRED_EX}Modified{AC.RESET}', name, versionold])
else:
self.tableData.append([f'{AC.GREEN}Up-to-date{AC.RESET}', name, versionold])
else:
self.tableData.append([f'{AC.GREEN}Up-to-date{AC.RESET}', name, versionold])
if modified:
self.tableData.append([f'{AC.LIGHTRED_EX}Update suppressed{AC.RESET}',
name, versionold])
else:
self.tableData.append([f'{AC.YELLOW}{"Updated " if update else "Update available"}'
f'{AC.RESET}', name, f'{AC.YELLOW}{versionnew}{AC.RESET}'])
else:
if modified:
self.tableData.append([f'{AC.LIGHTRED_EX}Update suppressed{AC.RESET}', name, versionold])
else:
self.tableData.append([f'{AC.YELLOW}{"Updated " if update else "Update available"}'
f'{AC.RESET}', name, f'{AC.YELLOW}{versionnew}{AC.RESET}'])
else:
self.tableData.append([f'{AC.LIGHTBLACK_EX}Not installed{AC.RESET}', addon, ''])
self.tableData.append([f'{AC.LIGHTBLACK_EX}Not installed{AC.RESET}', addon, ''])
except Exception as e:
exceptions.append(e)
pbar.update(1)
printft(ANSI('\n' + self.table.table if addline else self.table.table))
if len(exceptions) > 0:
self.handle_exception(exceptions, False)

def c_force_update(self, args):
if args:
Expand Down

0 comments on commit 1273e51

Please sign in to comment.