http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11528
Revision: 11528 Author: drtrigon Date: 2013-05-12 21:55:40 +0000 (Sun, 12 May 2013) Log Message: ----------- bug fix; use pywikibot.comms.http instead of urllib2 (e.g. because of temporary not reachable servers)
Modified Paths: -------------- trunk/pywikipedia/catimages.py trunk/pywikipedia/externals/__init__.py
Modified: trunk/pywikipedia/catimages.py =================================================================== --- trunk/pywikipedia/catimages.py 2013-05-12 20:54:27 UTC (rev 11527) +++ trunk/pywikipedia/catimages.py 2013-05-12 21:55:40 UTC (rev 11528) @@ -93,16 +93,16 @@ import checkimages import dtbext # check for and install needed 'externals' dtbext.check_setup_all() # -import externals # check for and install needed 'externals' -externals.check_setup('colormath') # -externals.check_setup('jseg') # -externals.check_setup('jseg/jpeg-6b')# -#externals.check_setup('_mlpy') # -externals.check_setup('_music21') # -#externals.check_setup('opencv/haarcascades')# -externals.check_setup('pydmtx') # -externals.check_setup('py_w3c') # -externals.check_setup('_zbar') # +import externals # check for and install needed +externals.check_setup('colormath') # 'externals' modules +externals.check_setup('jseg') # +externals.check_setup('jseg/jpeg-6b') # +#externals.check_setup('_mlpy') # +externals.check_setup('_music21') # +#externals.check_setup('opencv/haarcascades') # +externals.check_setup('pydmtx') # <<< !!! test OS package management here !!! +externals.check_setup('py_w3c') # +externals.check_setup('_zbar') #
# DrTrigonBot framework packages target = os.path.join(scriptdir, 'dtbext')
Modified: trunk/pywikipedia/externals/__init__.py =================================================================== --- trunk/pywikipedia/externals/__init__.py 2013-05-12 20:54:27 UTC (rev 11527) +++ trunk/pywikipedia/externals/__init__.py 2013-05-12 21:55:40 UTC (rev 11528) @@ -25,22 +25,16 @@ # (?. checkout from svn/mercurial repo) # 3. svn:externals modules_needed = { -# TODO: vvv -# 'crontab' has to be moved and integrated (in)to externals as well 'crontab': ({}, #{ 'url': 'https://github.com/josiahcarlson/parse-crontab/archive/master.zip', # 'path': 'parse-crontab-master/crontab',}), # OK { 'url': 'https://github.com/josiahcarlson/parse-crontab/archive/1ec538ff67df6a207993a...', 'path': 'parse-crontab-1ec538ff67df6a207993a6c5b6988f4f628c5776/crontab',}),# OK -# TODO: vvv -# 'odf' has to be moved and integrated (in)to externals as well 'odf': ({}, #{ 'url': 'https://pypi.python.org/packages/source/o/odfpy/odfpy-0.9.6.tar.gz', # 'path': 'odfpy-0.9.6/odf',}), # OK { 'url': 'https://pypi.python.org/packages/source/o/odfpy/odfpy-0.9.4.tar.gz', 'path': 'odfpy-0.9.4/odf',}), # OK -# TODO: vvv -# 'openpyxl' has to be moved and integrated (in)to externals as well 'openpyxl': ({}, { 'url': 'https://bitbucket.org/ericgazoni/openpyxl/get/1.5.6.tar.gz', 'path': 'ericgazoni-openpyxl-e5934500ffac/openpyxl',}),# OK @@ -136,7 +130,7 @@ # 'colormath', 'jseg', 'jseg/jpeg-6b', '_mlpy', '_music21', # '_ocropus', 'opencv', 'opencv/haarcascades', 'pydmtx', # 'py_w3c', 'slic', '_zbar', '_bob', 'xbob_flandmark',] -modules_order = [#'crontab', 'odf', 'openpyxl', +modules_order = ['crontab', 'odf', 'openpyxl', 'colormath', 'jseg', 'jseg/jpeg-6b', '_music21', 'opencv/haarcascades', 'pydmtx', 'py_w3c', '_zbar',]
@@ -144,6 +138,7 @@ import os, sys
import wikipedia as pywikibot +from pywikibot.comms import http
sys.path.append(os.path.dirname(os.path.abspath(os.path.join(os.curdir, __file__)))) @@ -230,8 +225,10 @@ if package: pywikibot.warning(u'Download package "%s" from %s' % (module, package['url'])) - import urllib2, mimetypes - response = urllib2.urlopen(package['url']) + import mimetypes#, urllib2 + #response = urllib2.urlopen(package['url']) + response = http.request(pywikibot.getSite(), package['url'], + no_hostname = True, back_response = True)[0] pywikibot.warning(u'Size of download: %s byte(s)' % response.headers['Content-Length']) #mime = response.headers['Content-Type'].lower().split('/') @@ -281,8 +278,7 @@ return # if svn_repo_install(modules_needed[m][2]): # return - pywikibot.error(u'Package "%s" could not be found nor installed!' - % m) + pywikibot.error(u'Package "%s" could not be found nor installed!' % m)
def check_setup_all(): #for m in modules_needed: