Skip to content
Browse files

Pick up when multiple install directories exist.

  • Loading branch information...
1 parent 5310cab commit 231859678e8749126e3a909e62f06b22f58aa226 @kemayo committed Feb 18, 2009
Showing with 25 additions and 11 deletions.
  1. +25 −11 waup.py
View
36 waup.py
@@ -144,28 +144,33 @@ def install_addon(name, force = False, clean = False):
print("Skipping %s; latest version already installed." % name)
return True
zip = zipfile.ZipFile(_fetch(project['file_url']))
- project['install_dir'] = re.search(r'^([^/]+)/', zip.filelist[0].filename).group(1)
- install_to = os.path.join(WOW_DIRECTORY, project['install_dir'])
- if clean and os.path.exists(install_to):
- _removedir(install_to)
+ project['install_dir'] = _top_level_directories(zip)
+
+ if clean:
+ for d in project['install_dir']:
+ install_to = os.path.join(WOW_DIRECTORY, project['install_dir'])
+ if os.path.exists(install_to):
+ _removedir(install_to)
_unzip(zip, WOW_DIRECTORY)
zip.close()
print("%s now installed at %s" % (name, project['guid']))
CACHE['addons'][name] = project
+ return True
def uninstall_addon(name):
project = CACHE['addons'].get(name)
if not project:
print("Couldn't uninstall %s; not installed.")
- return
- if os.path.exists(os.path.join(WOW_DIRECTORY, project['install_dir'])):
- _removedir(os.path.join(WOW_DIRECTORY, project['install_dir']))
- else:
- print("Couldn't delete install directory; %s not found." % project['install_dir'])
+ return False
+ for path in project['install_dir']:
+ if os.path.exists(os.path.join(WOW_DIRECTORY, path)):
+ _removedir(os.path.join(WOW_DIRECTORY, path))
+ else:
+ print("Couldn't delete install directory; %s not found." % path)
print("%s uninstalled" % name)
@@ -186,8 +191,13 @@ def load_cache():
pickled_versions.close()
# We managed to load the list of addons. Now, let's check to see whether any have been uninstalled...
for project, info in cache.get('addons').items():
- if not (info.get('install_dir') and os.path.isdir(os.path.join(WOW_DIRECTORY, info['install_dir']))):
- # Addon directory is gone. Mark as uninstalled.
+ if type(info['install_dir']) != set:
+ info['install_dir'] = set([info['install_dir']])
+ for d in info['install_dir']:
+ if not (os.path.isdir(os.path.join(WOW_DIRECTORY, d))):
+ info['install_dir'].remove(d)
+ if not info['install_dir']:
+ # Addon directory is gone. Mark as uninstalled. (An empty set == False)
del(cache['addons'][project])
print("Couldn't find %s, removing from list of installed projects." % project)
except EOFError:
@@ -245,6 +255,10 @@ def _permissions_from_external_attr(l):
# This produces an integer, suitable for passing to os.chmod (i.e., for 0755: 493)
return int(''.join([str(i) for i in p]), 2)
+def _top_level_directories(zip):
+ dirs = set(f.filename.split('/')[0] for f in zip.filelist)
+ return dirs
+
def _fetch(url):
"""A generic URL-fetcher, which handles gzipped content, returns a file-like object"""
request = urllib2.Request(url)

0 comments on commit 2318596

Please sign in to comment.
Something went wrong with that request. Please try again.