http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11731
Revision: 11731 Author: drtrigon Date: 2013-07-08 17:42:58 +0000 (Mon, 08 Jul 2013) Log Message: ----------- bug fix; ask user for permission BEFORE downloading and installing external code
Modified Paths: -------------- trunk/pywikipedia/externals/__init__.py
Modified: trunk/pywikipedia/externals/__init__.py =================================================================== --- trunk/pywikipedia/externals/__init__.py 2013-07-08 16:52:06 UTC (rev 11730) +++ trunk/pywikipedia/externals/__init__.py 2013-07-08 17:42:58 UTC (rev 11731) @@ -33,7 +33,7 @@ modules_needed = { 'patch.exe': ({}, # for win32 only, unix/linux is already equipped with a patch tool { 'url': 'http://downloads.sourceforge.net/project/gnuwin32/patch/2.5.9-7/patch-2.5.9-...', - 'path': 'bin/patch.exe'}), # OK + 'path': 'bin/patch.exe'}), # OK 'crontab': ({}, #{ 'url': 'https://github.com/josiahcarlson/parse-crontab/archive/master.zip', # 'path': 'parse-crontab-master/crontab',}), # OK @@ -96,7 +96,7 @@ '_ocropus': ({}, {}, { 'url': 'https://code.google.com/p/ocropus', - 'rev': 'ocropus-0.6'}), # OK + 'rev': 'ocropus-0.6'}), # OK # TODO: vvv (further clean-up and unlink - check with 'svn list') # 'opencv': $ svn propedit svn:externals externals/. # opencv https://svn.toolserver.org/svnroot/drtrigon/externals/opencv @@ -288,7 +288,7 @@
def download_install(package, module, path): - if package: + if package and show_question(module): lowlevel_warning(u'Download package "%s" from %s' % (module, package['url'])) import mimetypes @@ -311,7 +311,7 @@ % (module, os.path.join(path, module))) if len(mime) > 1: import StringIO - if mime[1] == 'zip' or mime[1] == 'x-zip-compressed': + if mime[1] in ['zip', 'x-zip-compressed']: import zipfile arch = zipfile.ZipFile(StringIO.StringIO(response.read())) elif mime[1] == 'x-tar': @@ -347,7 +347,7 @@
def mercurial_repo_install(package, module, path): - if package: + if package and show_question(module): cmd = 'hg clone' lowlevel_warning(u'Mercurial clone "%s" from %s' % (module, package['url'])) @@ -373,10 +373,11 @@ return if download_install(modules_needed[m][1], m, path): return - if mercurial_repo_install(modules_needed[m][2], m, path): + if (len(modules_needed[m]) > 2) and\ + mercurial_repo_install(modules_needed[m][2], m, path): return
- pywikibot.error(u'Package "%s" could not be found nor installed!' % m) + lowlevel_warning(u'Package "%s" could not be found nor installed!' % m)
def check_setup_all():
pywikipedia-svn@lists.wikimedia.org