Revision: 8794
Author: xqt
Date: 2010-12-26 08:46:15 +0000 (Sun, 26 Dec 2010)
Log Message:
-----------
raise runtimeError if api call is unsuccessfull
Modified Paths:
--------------
trunk/pywikipedia/generate_family_file.py
Modified: trunk/pywikipedia/generate_family_file.py
===================================================================
--- trunk/pywikipedia/generate_family_file.py 2010-12-26 00:23:35 UTC (rev 8793)
+++ trunk/pywikipedia/generate_family_file.py 2010-12-26 08:46:15 UTC (rev 8794)
@@ -75,12 +75,14 @@
print "Determining other languages...",
try:
iw = json.load(urlopen(w.api + "?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local&format=json"))
+ if 'error' in iw:
+ raise RuntimeError ('%s/n%s' % (iw['error']['code'], iw['error']['info']))
self.langs = [wiki for wiki in iw['query']['interwikimap'] if u'language' in wiki]
print u' '.join(sorted([wiki[u'prefix'] for wiki in self.langs]))
except HTTPError, e:
self.langs = []
print e, "; continuing..."
-
+
if len([lang for lang in self.langs if lang['url'] == w.iwpath]) == 0:
self.langs.append({u'language': w.lang,
u'local': u'',
@@ -220,7 +222,7 @@
raise
data = e.read()
pass
-
+
if not self.REwgEnableApi.search(data):
print "*** WARNING: Api does not seem to be enabled on %s" % fromurl
try: