import pywikibot
pywikibot.__version__
'$Id: e4000cc8b1ddcd00ae795cdeca1a4c903d8a321e $'
site = pywikibot.Site("id", "wikipedia")
site
APISite("id", "wikipedia")
pagetest = pywikibot.Page(site, "id")
pagetest.exists()
True
site.username()
'Gombang'
page = pywikibot.Page(site, 'test')
page.exists()
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
WARNING:pywiki:API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
---------------------------------------------------------------------------
NoUsername                                Traceback (most recent call last)
<ipython-input-13-e44e2866f6f3> in <module>()
----> 1 page.exists()

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in exists(self)
    705         @rtype: bool
    706         """
--> 707         return self.site.page_exists(self)
    708 
    709     @property

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in site(self)
    148     def site(self):
    149         """Return the Site object for the wiki on which this Page resides."""
--> 150         return self._link.site
    151 
    152     def version(self):

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in site(self)
   5098         """
   5099         if not hasattr(self, "_site"):
-> 5100             self.parse()
   5101         return self._site
   5102 

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in parse(self)
   5083                                          "title")
   5084 
-> 5085         if self._site.namespaces[self._namespace].case == 'first-letter':
   5086             t = first_upper(t)
   5087 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in namespaces(self)
   1006         """Return dict of valid namespaces on this wiki."""
   1007         if not hasattr(self, '_namespaces'):
-> 1008             self._namespaces = NamespacesDict(self._build_namespaces())
   1009         return self._namespaces
   1010 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _build_namespaces(self)
   2579         # For versions lower than 1.14, APISite needs to override
   2580         # the defaults defined in Namespace.
-> 2581         is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
   2582 
   2583         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in version(self)
   2686         if not version:
   2687             try:
-> 2688                 version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
   2689             except pywikibot.data.api.APIError:
   2690                 # May occur if you are not logged in (no API read permissions).

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1648                 elif not Siteinfo._is_expired(cached[1], expiry):
   1649                     return copy.deepcopy(cached[0])
-> 1650         preloaded = self._get_general(key, expiry)
   1651         if not preloaded:
   1652             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_general(self, key, expiry)
   1594                         u"', '".join(props)), _logger)
   1595             props += ['general']
-> 1596             default_info = self._get_siteinfo(props, expiry)
   1597             for prop in props:
   1598                 self._cache[prop] = default_info[prop]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1520             # warnings are handled later
   1521             request._warning_handler = warn_handler
-> 1522             data = request.submit()
   1523         except api.APIError as e:
   1524             if e.code == 'siunknown_siprop':

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2326         cached_available = self._load_cache()
   2327         if not cached_available:
-> 2328             self._data = super(CachedRequest, self).submit()
   2329             self._write_cache(self._data)
   2330         else:

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2163             if 'mwoauth-invalid-authorization' in code:
   2164                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2165                                  % (self.site, info))
   2166             # raise error
   2167             try:

NoUsername: Failed OAuth authentication for wikipedia:test: The authorization headers in your request are for a user that does not exist here
pagetest.text = "Hello World"
dir(pagetest)
['__class__',
 '__delattr__',
 '__dict__',
 '__dir__',
 '__doc__',
 '__eq__',
 '__format__',
 '__ge__',
 '__getattribute__',
 '__gt__',
 '__hash__',
 '__init__',
 '__le__',
 '__lt__',
 '__module__',
 '__ne__',
 '__new__',
 '__reduce__',
 '__reduce_ex__',
 '__repr__',
 '__setattr__',
 '__sizeof__',
 '__str__',
 '__subclasshook__',
 '__unicode__',
 '__weakref__',
 '_cmpkey',
 '_cosmetic_changes_hook',
 '_getInternals',
 '_get_parsed_page',
 '_latest_cached_revision',
 '_link',
 '_namespace_obj',
 '_revisions',
 '_save',
 '_text',
 'applicable_protections',
 'aslink',
 'autoFormat',
 'backlinks',
 'botMayEdit',
 'canBeEdited',
 'categories',
 'change_category',
 'content_model',
 'contributingUsers',
 'contributors',
 'coordinates',
 'data_item',
 'data_repository',
 'defaultsort',
 'delete',
 'depth',
 'editTime',
 'embeddedin',
 'encoding',
 'exists',
 'expand_text',
 'extlinks',
 'fullVersionHistory',
 'full_url',
 'get',
 'getCategoryRedirectTarget',
 'getCreator',
 'getDeletedRevision',
 'getLatestEditors',
 'getMovedTarget',
 'getOldVersion',
 'getRedirectTarget',
 'getReferences',
 'getRestrictions',
 'getTemplates',
 'getVersionHistory',
 'getVersionHistoryTable',
 'image_repository',
 'imagelinks',
 'interwiki',
 'isAutoTitle',
 'isCategory',
 'isCategoryRedirect',
 'isDisambig',
 'isEmpty',
 'isFlowPage',
 'isImage',
 'isIpEdit',
 'isRedirectPage',
 'isStaticRedirect',
 'isTalkPage',
 'is_flow_page',
 'iterlanglinks',
 'itertemplates',
 'langlinks',
 'lastNonBotUser',
 'latestRevision',
 'latest_revision',
 'latest_revision_id',
 'linkedPages',
 'loadDeletedRevisions',
 'markDeletedRevision',
 'move',
 'moved_target',
 'namespace',
 'oldest_revision',
 'pageAPInfo',
 'permalink',
 'preloadText',
 'previousRevision',
 'previous_revision_id',
 'properties',
 'protect',
 'protection',
 'purge',
 'put',
 'put_async',
 'removeImage',
 'replaceImage',
 'revision_count',
 'revisions',
 'save',
 'section',
 'sectionFreeTitle',
 'set_redirect_target',
 'site',
 'templates',
 'templatesWithParams',
 'text',
 'title',
 'titleForFilename',
 'titleWithoutNamespace',
 'toggleTalkPage',
 'touch',
 'undelete',
 'urlname',
 'userName',
 'version',
 'watch']
pagetest._text
'Hello World'
pagetest.title
VERBOSE:pywiki:Found 1 wikipedia:test processes running, including this one.
WARNING: API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
WARNING:pywiki:API error mwoauth-invalid-authorization-invalid-user: The authorization headers in your request are for a user that does not exist here
---------------------------------------------------------------------------
NoUsername                                Traceback (most recent call last)
/srv/paws/lib/python3.4/site-packages/IPython/core/formatters.py in __call__(self, obj)
    697                 type_pprinters=self.type_printers,
    698                 deferred_pprinters=self.deferred_printers)
--> 699             printer.pretty(obj)
    700             printer.flush()
    701             return stream.getvalue()

/srv/paws/lib/python3.4/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    366                 if cls in self.type_pprinters:
    367                     # printer registered in self.type_pprinters
--> 368                     return self.type_pprinters[cls](obj, self, cycle)
    369                 else:
    370                     # deferred printer

/srv/paws/lib/python3.4/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    692     """A pprint that just redirects to the normal repr function."""
    693     # Find newlines and replace them with p.break_()
--> 694     output = repr(obj)
    695     for idx,output_line in enumerate(output.splitlines()):
    696         if idx:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in __repr__(self)
    311         """Return a more complete string representation."""
    312         if not PY2:
--> 313             title = repr(self.title())
    314         else:
    315             try:

/srv/paws/lib/python3.4/site-packages/pywikibot/tools/__init__.py in wrapper(*__args, **__kw)
   1355                              cls, depth)
   1356                     del __kw[old_arg]
-> 1357             return obj(*__args, **__kw)
   1358 
   1359         if not __debug__:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in title(self, underscore, withNamespace, withSection, asUrl, asLink, allowInterwiki, forceInterwiki, textlink, as_filename, insite)
    241         @rtype: unicode
    242         """
--> 243         title = self._link.canonical_title()
    244         label = self._link.title
    245         if withSection and self._link.section:

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in canonical_title(self)
   5151                               self.title)
   5152         else:
-> 5153             return self.title
   5154 
   5155     def ns_title(self, onsite=None):

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in title(self)
   5120         """
   5121         if not hasattr(self, "_title"):
-> 5122             self.parse()
   5123         return self._title
   5124 

/srv/paws/lib/python3.4/site-packages/pywikibot/page.py in parse(self)
   5083                                          "title")
   5084 
-> 5085         if self._site.namespaces[self._namespace].case == 'first-letter':
   5086             t = first_upper(t)
   5087 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in namespaces(self)
   1006         """Return dict of valid namespaces on this wiki."""
   1007         if not hasattr(self, '_namespaces'):
-> 1008             self._namespaces = NamespacesDict(self._build_namespaces())
   1009         return self._namespaces
   1010 

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _build_namespaces(self)
   2579         # For versions lower than 1.14, APISite needs to override
   2580         # the defaults defined in Namespace.
-> 2581         is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
   2582 
   2583         for nsdata in self.siteinfo.get('namespaces', cache=False).values():

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in version(self)
   2686         if not version:
   2687             try:
-> 2688                 version = self.siteinfo.get('generator', expiry=1).split(' ')[1]
   2689             except pywikibot.data.api.APIError:
   2690                 # May occur if you are not logged in (no API read permissions).

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in get(self, key, get_default, cache, expiry)
   1648                 elif not Siteinfo._is_expired(cached[1], expiry):
   1649                     return copy.deepcopy(cached[0])
-> 1650         preloaded = self._get_general(key, expiry)
   1651         if not preloaded:
   1652             preloaded = self._get_siteinfo(key, expiry)[key]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_general(self, key, expiry)
   1594                         u"', '".join(props)), _logger)
   1595             props += ['general']
-> 1596             default_info = self._get_siteinfo(props, expiry)
   1597             for prop in props:
   1598                 self._cache[prop] = default_info[prop]

/srv/paws/lib/python3.4/site-packages/pywikibot/site.py in _get_siteinfo(self, prop, expiry)
   1520             # warnings are handled later
   1521             request._warning_handler = warn_handler
-> 1522             data = request.submit()
   1523         except api.APIError as e:
   1524             if e.code == 'siunknown_siprop':

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2326         cached_available = self._load_cache()
   2327         if not cached_available:
-> 2328             self._data = super(CachedRequest, self).submit()
   2329             self._write_cache(self._data)
   2330         else:

/srv/paws/lib/python3.4/site-packages/pywikibot/data/api.py in submit(self)
   2163             if 'mwoauth-invalid-authorization' in code:
   2164                 raise NoUsername('Failed OAuth authentication for %s: %s'
-> 2165                                  % (self.site, info))
   2166             # raise error
   2167             try:

NoUsername: Failed OAuth authentication for wikipedia:test: The authorization headers in your request are for a user that does not exist here