PluginDownloader: Add error messages to assertion errors.

This commit is contained in:
Valentin Lorentz 2012-12-19 16:55:54 +00:00
parent 46a25b913c
commit 0607462dd5
1 changed files with 6 additions and 3 deletions

View File

@ -121,10 +121,12 @@ class GithubRepository(GitRepository):
dirname = ''.join((self._path, plugin)) dirname = ''.join((self._path, plugin))
directories = conf.supybot.directories.plugins() directories = conf.supybot.directories.plugins()
directory = self._getWritableDirectoryFromList(directories) directory = self._getWritableDirectoryFromList(directories)
assert directory is not None assert directory is not None, \
'No valid directory in supybot.directories.plugins.'
try: try:
assert archive.getmember(prefix + dirname).isdir() assert archive.getmember(prefix + dirname).isdir(), \
'This is not a valid plugin (it is a file, not a directory).'
for file in archive.getmembers(): for file in archive.getmembers():
if file.name.startswith(prefix + dirname): if file.name.startswith(prefix + dirname):
@ -133,7 +135,8 @@ class GithubRepository(GitRepository):
newFileName = newFileName[len(self._path)-1:] newFileName = newFileName[len(self._path)-1:]
newFileName = os.path.join(directory, newFileName) newFileName = os.path.join(directory, newFileName)
if os.path.exists(newFileName): if os.path.exists(newFileName):
assert os.path.isdir(newFileName) assert os.path.isdir(newFileName), newFileName + \
'should not be a file.'
shutil.rmtree(newFileName) shutil.rmtree(newFileName)
if extractedFile is None: if extractedFile is None:
os.mkdir(newFileName) os.mkdir(newFileName)