Skip to content

Commit

Permalink
Improved error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
AcidWeb committed Sep 27, 2019
1 parent f88db18 commit b843f8f
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 18 deletions.
3 changes: 1 addition & 2 deletions CB/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ def cleanup(self, directories):

def parse_url(self, url):
if url.startswith('https://www.curseforge.com/wow/addons/'):
parser = CurseForgeAddon(self.parse_cf_id(url), self.cfCache, self.clientType, self.check_if_dev(url))
return parser
return CurseForgeAddon(self.parse_cf_id(url), self.cfCache, self.clientType, self.check_if_dev(url))
elif url.startswith('https://www.wowinterface.com/downloads/'):
return WoWInterfaceAddon(url, self.wowiCache)
elif url.startswith('https://www.tukui.org/addons.php?id='):
Expand Down
8 changes: 4 additions & 4 deletions CB/CurseForge.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def __init__(self, project, checkcache, clienttype, allowdev):
else:
self.payload = requests.get(f'https://addons-ecs.forgesvc.net/api/v2/addon/{project}',
headers=HEADERS).json()
if not len(self.payload['latestFiles']) > 0:
raise RuntimeError
self.name = self.payload['name'].strip().strip('\u200b')
if not len(self.payload['latestFiles']) > 0:
raise RuntimeError(f'{self.name}.\nThe project doesn\'t have any releases.')
self.clientType = clienttype
self.allowDev = allowdev
self.downloadUrl = None
Expand All @@ -37,7 +37,7 @@ def get_current_version(self):
if self.downloadUrl and self.currentVersion:
break
else:
raise RuntimeError
raise RuntimeError(f'{self.name}.\nFailed to find release for your client version.')

@retry()
def get_addon(self):
Expand All @@ -47,7 +47,7 @@ def get_addon(self):
self.directories.append(os.path.dirname(file))
self.directories = list(set(self.directories))
if len(self.directories) == 0 or self.directories == ['']:
raise RuntimeError
raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.')

def install(self, path):
self.get_addon()
Expand Down
2 changes: 1 addition & 1 deletion CB/GitLab.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_addon(self):
if file_info.is_dir() and file_info.filename.count('/') == 2 and '.gitlab' not in file_info.filename:
self.directories.append(file_info.filename.split('/')[1])
if len(self.directories) == 0 or self.directories == ['']:
raise RuntimeError
raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.')

def install(self, path):
self.get_addon()
Expand Down
2 changes: 1 addition & 1 deletion CB/Tukui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_addon(self):
self.directories.append(os.path.dirname(file))
self.directories = list(set(self.directories))
if len(self.directories) == 0 or self.directories == ['']:
raise RuntimeError
raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.')

def install(self, path):
self.get_addon()
Expand Down
3 changes: 1 addition & 2 deletions CB/WeakAura.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def check_updates(self):
payload = requests.get(f'https://data.wago.io/api/check/weakauras?ids={",".join(self.waList.keys())}',
headers={'api-key': self.apiKey, 'User-Agent': HEADERS['User-Agent']}).json()
if 'error' in payload or 'msg' in payload:
raise RuntimeError('Wago API failed to return proper data. '
'The page is down or provided API key is incorrect.')
raise RuntimeError
for aura in payload:
if 'username' in aura and (not self.username or aura['username'] != self.username):
if aura['version'] > self.waList[aura['slug']] and \
Expand Down
2 changes: 1 addition & 1 deletion CB/WoWInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def get_addon(self):
self.directories.append(os.path.dirname(file))
self.directories = list(set(self.directories))
if len(self.directories) == 0 or self.directories == ['']:
raise RuntimeError
raise RuntimeError(f'{self.name}.\nProject package is corrupted or incorrectly packaged.')

def install(self, path):
self.get_addon()
Expand Down
14 changes: 9 additions & 5 deletions CB/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import string
import random

__version__ = '2.6.1'
__version__ = '2.7.0'
__license__ = 'GPLv3'
__copyright__ = '2019, Paweł Jastrzębski <[email protected]>'
__docformat__ = 'restructuredtext en'
Expand All @@ -10,22 +10,26 @@
def retry(custom_error=False):
def wraps(func):
def inner(*args, **kwargs):
description = None
for i in range(3):
# noinspection PyBroadException
try:
result = func(*args, **kwargs)
except KeyboardInterrupt:
raise
except Exception:
except Exception as e:
description = e
continue
else:
return result
else:
if custom_error:
raise RuntimeError(custom_error)
else:
raise RuntimeError('Failed to parse addon data. There is some issue with the website or this addon '
'don\'t have release for your client version.')
if description:
raise RuntimeError(f'Failed to parse addon data: {description}')
else:
raise RuntimeError('Unknown error during parsing addon data. '
'There may be some issue with the website.')
return inner
return wraps

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ CLI addon updater for World of Warcraft.
The latest release can be found [here](https://github.com/AcidWeb/CurseBreaker/releases/latest).

## USAGE
Should be pretty self-explanatory. Place **CurseBreaker** EXE inside directory containing `Wow.exe` and start it up.\
Place **CurseBreaker** EXE inside directory containing `Wow.exe` and start it up. Read the instructions on the top of the screen.\
Already installed addons will not be recognized by **CurseBreaker** and they need to be reinstalled.\
This process can be partially automated by using the `import` command.\
Both _Retail_ and _Classic_ clients are supported. The client version is detected automatically.\
By default **CurseBreaker** create backups of entire `WTF` directory.
By default **CurseBreaker** will create backups of entire `WTF` directory.

## TIPS & TRICKS
- Command `uri_integration` can be used to enable integration with the CurseForge page.
Expand Down

0 comments on commit b843f8f

Please sign in to comment.