From 72600e54af05c7b77ea1a5877eca1ef659e512a3 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Thu, 28 Apr 2011 13:57:06 +0200 Subject: [PATCH] PluginDownloader: add stepnem's and gsf's repositories; fix issue with non-root path --- plugins/PluginDownloader/plugin.py | 31 +++++++++++++++++++++++--- plugins/PluginDownloader/test.py | 35 ++++++++++++++++++++++++------ 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/plugins/PluginDownloader/plugin.py b/plugins/PluginDownloader/plugin.py index e4ec3f5fe..21d408d56 100644 --- a/plugins/PluginDownloader/plugin.py +++ b/plugins/PluginDownloader/plugin.py @@ -66,7 +66,7 @@ class GithubRepository(GitRepository): if not path.endswith('/'): path += '/' self._path = path - + self._downloadUrl = 'https://github.com/%s/%s/tarball/master' % \ ( self._username, @@ -150,6 +150,7 @@ class GithubRepository(GitRepository): if file.name.startswith(prefix + dirname): extractedFile = archive.extractfile(file) newFileName = os.path.join(*file.name.split('/')[1:]) + newFileName = newFileName[len(self._path)-1:] newFileName = os.path.join(directory, newFileName) if extractedFile is None: os.mkdir(newFileName) @@ -157,6 +158,8 @@ class GithubRepository(GitRepository): open(newFileName, 'a').write(extractedFile.read()) finally: archive.close() + fileObject2.close() + del archive, fileObject, fileObject2 def _getWritableDirectoryFromList(self, directories): for directory in directories: @@ -166,10 +169,32 @@ class GithubRepository(GitRepository): repositories = { - 'ProgVal': GithubRepository('ProgVal', 'Supybot-plugins'), + 'ProgVal': GithubRepository( + 'ProgVal', + 'Supybot-plugins' + ), 'quantumlemur': GithubRepository( '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', ), } diff --git a/plugins/PluginDownloader/test.py b/plugins/PluginDownloader/test.py index d19493cce..4f4135bff 100644 --- a/plugins/PluginDownloader/test.py +++ b/plugins/PluginDownloader/test.py @@ -53,25 +53,46 @@ class PluginDownloaderTestCase(PluginTestCase): finally: 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): - self.assertResponse('repolist', 'quantumlemur, ProgVal') + self.assertRegexp('repolist', '(.*, )?ProgVal(, .*)?') + self.assertRegexp('repolist', '(.*, )?quantumlemur(, .*)?') self.assertRegexp('repolist ProgVal', '(.*, )?AttackProtector(, .*)?') def testInstallProgVal(self): self.assertError('plugindownloader install ProgVal Listener') self.assertNotError('plugindownloader install ProgVal AttackProtector') self.assertError('plugindownloader install ProgVal Listener') - assert os.path.isdir(pluginsPath + '/AttackProtector/') - assert os.path.isfile(pluginsPath + '/AttackProtector/plugin.py') - assert os.path.isfile(pluginsPath + '/AttackProtector/config.py') + self._testPluginInstalled('AttackProtector') def testInstallQuantumlemur(self): self.assertError('plugindownloader install quantumlemur AttackProtector') self.assertNotError('plugindownloader install quantumlemur Listener') self.assertError('plugindownloader install quantumlemur AttackProtector') - assert os.path.isdir(pluginsPath + '/Listener/') - assert os.path.isfile(pluginsPath + '/Listener/plugin.py') - assert os.path.isfile(pluginsPath + '/Listener/config.py') + self._testPluginInstalled('Listener') + 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: