fix compatibility with python2.6

This commit is contained in:
Romain Bignon 2012-01-21 16:45:32 +01:00
commit 65169a8a8d
2 changed files with 12 additions and 10 deletions

View file

@ -106,20 +106,21 @@ class WeboobRepos(ReplApplication):
continue continue
print 'Create archive for %s' % name print 'Create archive for %s' % name
with tarfile.open(tarname, 'w:gz') as tar: tar = tarfile.open(tarname, 'w:gz')
tar.add(module_path, arcname=name, filter=self._archive_filter) tar.add(module_path, arcname=name, exclude=self._archive_excludes)
tar.close()
# Copy icon. # Copy icon.
icon_path = os.path.join(module_path, 'favicon.png') icon_path = os.path.join(module_path, 'favicon.png')
if os.path.exists(icon_path): if os.path.exists(icon_path):
shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name)) shutil.copy(icon_path, os.path.join(repo_path, '%s.png' % name))
def _archive_filter(self, tarinfo): def _archive_excludes(self, filename):
# Skip *.pyc files in tarballs. # Skip *.pyc files in tarballs.
if tarinfo.name.endswith('.pyc'): if filename.endswith('.pyc'):
return None return True
# Don't include *.png files in tarball # Don't include *.png files in tarball
if tarinfo.name.endswith('.png'): if filename.endswith('.png'):
return None return True
return tarinfo return False

View file

@ -496,8 +496,9 @@ class Repositories(object):
progress.progress(0.7, 'Setting up module...') progress.progress(0.7, 'Setting up module...')
# Extract module from tarball. # Extract module from tarball.
with tarfile.open('', 'r:gz', fp) as tar: tar = tarfile.open('', 'r:gz', fp)
tar.extractall(self.modules_dir) tar.extractall(self.modules_dir)
tar.close()
self.versions.set(info.name, info.version) self.versions.set(info.name, info.version)