import pywikibot
import re
from pywikibot import pagegenerators
site = pywikibot.Site('en', 'wikipedia')
errorpage = pywikibot.Page(site, u"User:PearBOT/Aircraft specs problems")
page = pywikibot.Page(site, u"User:PearBOT/test")
text = page.text
templates=pywikibot.textlib.extract_templates_and_params(text,remove_disabled_parts="yes",strip = "yes")
for x in templates:
    if x[0] == "Aircraft specifications" or x[0] =="Aircraft specification" or x[0] == "Airtemp-test" or x[0] == "Airtemp-test" or x[0] == "aircraft specifications" or x[0] =="aircraft specification" or x[0] == "airtemp-test" or x[0] == "airtemp-test":
        if" (m|meter|metre|centimeter|centimeter|cm)",parameters.get("length main")):
        elif" (in|ft|inches|feet|foot|inch)",parameters.get("length main")):
            errorpage.text += "*Unknown prime unit at " 
            errorpage.text += page.full_url()
  "Added primeunit problem")
#print(templates[2].get("plane or copter?"))
#page.text = text"Bot test")
aircraft specifications
OrderedDict([('plane or copter?', 'copter'), ('jet or prop?', 'prop'), ('ref', 'Boeing CH-47D/F,<ref>{{cite web |url= |title=CH-47 Technical Specifications |publisher=Boeing |accessdate=19 March 2016 |archive-url= |archive-date=13 March 2016 |dead-url=no }}</ref> Army Chinook file,<ref>{{cite web |url= |title=CH-47 CHINOOK HELICOPTER |date=4 November 2014 | |accessdate=19 March 2016 |archive-url= |archive-date=29 March 2016 |dead-url=no }}</ref> International Directory<ref name="Frawley Military">Frawley, Gerard: \'\'The International Directory of Military Aircraft\'\', p. 49. Aerospace Publications Pty Ltd, 2002. {{ISBN|1-875671-55-2}}.</ref>'), ('crew', 'three (pilot, copilot, flight engineer or loadmaster)'), ('capacity', "<br />\n** 33–55 troops ''or''\n** 24 [[Litter (rescue basket)|litters]] and 3 attendants ''or''"), ('payload main', '24,000&nbsp;lb'), ('payload alt', '10,886&nbsp;kg'), ('length main', '98&nbsp;ft 10&nbsp;in<ref name=Boeing_CH-47F>{{cite web|url=|title=Boeing: H-47 Chinook||access-date=19 March 2016|archive-url=|archive-date=13 March 2016|dead-url=no}}</ref>'), ('length alt', "30.1&nbsp;m)\n* '''Fuselage length:''' 52&nbsp;ft (15.85&nbsp;m)\n* '''Fuselage width:''' 12 ft 5 in<ref name=Boeing_CH-47F/> (3.78 m"), ('span main', '60&nbsp;ft&nbsp;'), ('span alt', '18.3&nbsp;m'), ('height main', '18&nbsp;ft&nbsp;11&nbsp;in'), ('height alt', '5.7&nbsp;m'), ('area main', '5,600&nbsp;ft<sup>2</sup>'), ('area alt', '520&nbsp;m<sup>2</sup>'), ('empty weight main', '24,578&nbsp;lb'), ('empty weight alt', '11,148&nbsp;kg'), ('loaded weight main', ''), ('loaded weight alt', ''), ('max takeoff weight main', '50,000&nbsp;lb'), ('max takeoff weight alt', '22,680&nbsp;kg'), ('more general', ''), ('engine (prop)', '[[Lycoming T55|Lycoming T55-GA-714A]]'), ('type of prop', '[[turboshaft]]'), ('number of props', '2'), ('power main', '4,733&nbsp;[[horsepower|shp]]'), ('power alt', '3,529&nbsp;kW'), ('max speed main', '170&nbsp;[[knot (unit)|knots]]'), ('max speed alt', '196&nbsp;mph, 315&nbsp;km/h'), ('cruise speed main', '160&nbsp;kt'), ('cruise speed alt', '184&nbsp;mph, 296&nbsp;km/h'), ('stall speed main', ''), ('stall speed alt', ''), ('never exceed speed main', ''), ('never exceed speed alt', ''), ('range main', '400&nbsp;[[nautical mile|nmi]]'), ('range alt', '450&nbsp;mi, 741&nbsp;km'), ('combat radius main', '200&nbsp;nmi'), ('combat radius alt', '230 mi, 370&nbsp;km'), ('combat radius more', ''), ('ferry range main', '1,216&nbsp;nmi'), ('ferry range alt', "1,400&nbsp;mi, 2,252&nbsp;km<ref>United States of America. Naval Training Equipment Center. Department of the Navy. ''Recognition Study Cards – US and Foreign Aircraft''. Device 5E14H. LSN 6910-LL-C006462. Orlando, Florida. 1982. 55 Cards. '''Annotation''': 2252 kilometers.</ref>"), ('ferry range more', ''), ('ceiling main', '20,000&nbsp;ft'), ('ceiling alt', '6100&nbsp;m'), ('climb rate main', '1,522&nbsp;ft/min'), ('climb rate alt', '7.73&nbsp;m/s'), ('loading main', '9.5&nbsp;lb/ft<sup>2</sup>'), ('loading alt', '47&nbsp;kg/m<sup>2</sup>'), ('power/mass main', '0.28&nbsp;hp/lb'), ('power/mass alt', '460&nbsp;W/kg'), ('armament', '* Up to 3 pintle-mounted medium machine guns (1 on loading ramp and 2 at shoulder windows), generally 7.62&nbsp;mm (0.308&nbsp;in) [[M240 machine gun|M240]]/[[FN MAG]] machine guns, and can be armed with the 7.62&nbsp;mm [[Minigun|M134]] rotary machine gun'), ('avionics', '* Rockwell Collins Common Avionics Architecture System (CAAS) (MH-47G/CH-47F)')])
NoUsername                                Traceback (most recent call last)
/srv/paws/pwb/pywikibot/ in handle(func, self, *args, **kwargs)
    106         try:
--> 107             func(self, *args, **kwargs)
    108         # TODO: other "expected" error types to catch?

/srv/paws/pwb/pywikibot/ in _save(self, summary, watch, minor, botflag, cc, quiet, **kwargs)
   1292         done =, summary=summary, minor=minor,
-> 1293                                   watch=watch, bot=botflag, **kwargs)
   1294         if not done:

/srv/paws/pwb/pywikibot/ in callee(self, *args, **kwargs)
   1314             if grp == 'user':
-> 1315                 self.login(False)
   1316             elif grp == 'sysop':

/srv/paws/pwb/pywikibot/ in login(self, sysop, autocreate)
   2095                                              wrong=self.userinfo['name'],
-> 2096                                              right=self._username[sysop]))
   2097             else:

NoUsername: Logged in on wikipedia:en via OAuth as Trialpears, but expect as PearBot

During handling of the above exception, another exception occurred:

OtherPageSaveError                        Traceback (most recent call last)
<ipython-input-91-7b602e7b8b94> in <module>
     21             errorpage.text += "*Unknown prime unit at "
     22             errorpage.text += page.full_url()
---> 23   "Added primeunit problem")
     24             print("else")
     25             break

/srv/paws/pwb/pywikibot/tools/ in wrapper(*__args, **__kw)
   1736                              cls, depth)
   1737                     del __kw[old_arg]
-> 1738             return obj(*__args, **__kw)
   1740         if not __debug__:

/srv/paws/pwb/pywikibot/tools/ in wrapper(*__args, **__kw)
   1736                              cls, depth)
   1737                     del __kw[old_arg]
-> 1738             return obj(*__args, **__kw)
   1740         if not __debug__:

/srv/paws/pwb/pywikibot/ in save(self, summary, watch, minor, botflag, force, asynchronous, callback, apply_cosmetic_changes, quiet, **kwargs)
   1280         self._save(summary=summary, watch=watch, minor=minor, botflag=botflag,
   1281                    asynchronous=asynchronous, callback=callback,
-> 1282                    cc=apply_cosmetic_changes, quiet=quiet, **kwargs)
   1284     @allow_asynchronous

/srv/paws/pwb/pywikibot/ in wrapper(self, *args, **kwargs)
    126             pywikibot.async_request(handle, func, self, *args, **kwargs)
    127         else:
--> 128             handle(func, self, *args, **kwargs)
    130     manage_wrapping(wrapper, func)

/srv/paws/pwb/pywikibot/ in handle(func, self, *args, **kwargs)
    118                 if isinstance(err, pywikibot.PageSaveRelatedError):
    119                     raise err
--> 120                 raise pywikibot.OtherPageSaveError(self, err)
    121         if callback:
    122             callback(self, err)

OtherPageSaveError: Edit to page [[en:User:PearBOT/Aircraft specs problems]] failed:
Logged in on wikipedia:en via OAuth as Trialpears, but expect as PearBot