PluginDownloader: add stepnem's and gsf's repositories; fix issue with non-root path

This commit is contained in:
Valentin Lorentz 2011-04-28 13:57:06 +02:00
parent f18429fdf7
commit 72600e54af
2 changed files with 56 additions and 10 deletions

View File

@ -66,7 +66,7 @@ class GithubRepository(GitRepository):
if not path.endswith('/'): if not path.endswith('/'):
path += '/' path += '/'
self._path = path self._path = path
self._downloadUrl = 'https://github.com/%s/%s/tarball/master' % \ self._downloadUrl = 'https://github.com/%s/%s/tarball/master' % \
( (
self._username, self._username,
@ -150,6 +150,7 @@ class GithubRepository(GitRepository):
if file.name.startswith(prefix + dirname): if file.name.startswith(prefix + dirname):
extractedFile = archive.extractfile(file) extractedFile = archive.extractfile(file)
newFileName = os.path.join(*file.name.split('/')[1:]) newFileName = os.path.join(*file.name.split('/')[1:])
newFileName = newFileName[len(self._path)-1:]
newFileName = os.path.join(directory, newFileName) newFileName = os.path.join(directory, newFileName)
if extractedFile is None: if extractedFile is None:
os.mkdir(newFileName) os.mkdir(newFileName)
@ -157,6 +158,8 @@ class GithubRepository(GitRepository):
open(newFileName, 'a').write(extractedFile.read()) open(newFileName, 'a').write(extractedFile.read())
finally: finally:
archive.close() archive.close()
fileObject2.close()
del archive, fileObject, fileObject2
def _getWritableDirectoryFromList(self, directories): def _getWritableDirectoryFromList(self, directories):
for directory in directories: for directory in directories:
@ -166,10 +169,32 @@ class GithubRepository(GitRepository):
repositories = { repositories = {
'ProgVal': GithubRepository('ProgVal', 'Supybot-plugins'), 'ProgVal': GithubRepository(
'ProgVal',
'Supybot-plugins'
),
'quantumlemur': GithubRepository( 'quantumlemur': GithubRepository(
'quantumlemur', 'quantumlemur',
'Supybot-plugins' 'Supybot-plugins',
),
'stepnem': GithubRepository(
'stepnem',
'supybot-plugins',
),
'gsf-snapshot': GithubRepository(
'gsf',
'supybot-plugins',
'Supybot-plugins-20060723',
),
'gsf-edsu': GithubRepository(
'gsf',
'supybot-plugins',
'edsu-plugins',
),
'gsf': GithubRepository(
'gsf',
'supybot-plugins',
'plugins',
), ),
} }

View File

@ -53,25 +53,46 @@ class PluginDownloaderTestCase(PluginTestCase):
finally: finally:
PluginTestCase.tearDown(self) PluginTestCase.tearDown(self)
def _testPluginInstalled(self, name):
assert os.path.isdir(pluginsPath + '/%s/' % name)
assert os.path.isfile(pluginsPath + '/%s/plugin.py' % name)
assert os.path.isfile(pluginsPath + '/%s/config.py' % name)
def testRepolist(self): def testRepolist(self):
self.assertResponse('repolist', 'quantumlemur, ProgVal') self.assertRegexp('repolist', '(.*, )?ProgVal(, .*)?')
self.assertRegexp('repolist', '(.*, )?quantumlemur(, .*)?')
self.assertRegexp('repolist ProgVal', '(.*, )?AttackProtector(, .*)?') self.assertRegexp('repolist ProgVal', '(.*, )?AttackProtector(, .*)?')
def testInstallProgVal(self): def testInstallProgVal(self):
self.assertError('plugindownloader install ProgVal Listener') self.assertError('plugindownloader install ProgVal Listener')
self.assertNotError('plugindownloader install ProgVal AttackProtector') self.assertNotError('plugindownloader install ProgVal AttackProtector')
self.assertError('plugindownloader install ProgVal Listener') self.assertError('plugindownloader install ProgVal Listener')
assert os.path.isdir(pluginsPath + '/AttackProtector/') self._testPluginInstalled('AttackProtector')
assert os.path.isfile(pluginsPath + '/AttackProtector/plugin.py')
assert os.path.isfile(pluginsPath + '/AttackProtector/config.py')
def testInstallQuantumlemur(self): def testInstallQuantumlemur(self):
self.assertError('plugindownloader install quantumlemur AttackProtector') self.assertError('plugindownloader install quantumlemur AttackProtector')
self.assertNotError('plugindownloader install quantumlemur Listener') self.assertNotError('plugindownloader install quantumlemur Listener')
self.assertError('plugindownloader install quantumlemur AttackProtector') self.assertError('plugindownloader install quantumlemur AttackProtector')
assert os.path.isdir(pluginsPath + '/Listener/') self._testPluginInstalled('Listener')
assert os.path.isfile(pluginsPath + '/Listener/plugin.py')
assert os.path.isfile(pluginsPath + '/Listener/config.py')
def testInstallStepnem(self):
self.assertNotError('plugindownloader install stepnem Freenode')
self._testPluginInstalled('Freenode')
def testGsf(self):
self.assertNotError('plugindownloader install gsf-snapshot Debian')
self._testPluginInstalled('Debian')
self.assertError('plugindownloader install gsf-snapshot Anagram')
self.assertError('plugindownloader install gsf-snapshot Acronym')
self.assertNotError('plugindownloader install gsf-edsu Anagram')
self._testPluginInstalled('Anagram')
self.assertError('plugindownloader install gsf-edsu Debian')
self.assertError('plugindownloader install gsf-edsu Acronym')
self.assertNotError('plugindownloader install gsf Acronym')
self._testPluginInstalled('Acronym')
self.assertError('plugindownloader install gsf Anagram')
self.assertError('plugindownloader install gsf Debian')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: