def main(*args: str) -> None: """Print pywikibot version and important settings.""" pywikibot.output('Pywikibot: ' + getversion()) pywikibot.output('Release version: ' + pywikibot.__version__) pywikibot.output('setuptools version: ' + setuptools.__version__) pywikibot.output('mwparserfromhell version: ' + mwparserfromhell.__version__) pywikibot.output('wikitextparser version: ' + wikitextparser.__version__) pywikibot.output('requests version: ' + requests.__version__) has_wikimedia_cert = False if (not hasattr(requests, 'certs') or not hasattr(requests.certs, 'where') or not callable(requests.certs.where)): pywikibot.output(' cacerts: not defined') elif not os.path.isfile(requests.certs.where()): pywikibot.output(' cacerts: {} (missing)'.format( requests.certs.where())) else: pywikibot.output(' cacerts: ' + requests.certs.where()) with codecs.open(requests.certs.where(), 'r', 'utf-8') as cert_file: text = cert_file.read() if WMF_CACERT in text: has_wikimedia_cert = True pywikibot.output(' certificate test: {}'.format( ('ok' if has_wikimedia_cert else 'not ok'))) if not has_wikimedia_cert: pywikibot.output(' Please reinstall requests!') pywikibot.output('Python: ' + sys.version) toolforge_env_hostname = get_toolforge_hostname() if toolforge_env_hostname: pywikibot.output('Toolforge hostname: ' + toolforge_env_hostname) # check environment settings settings = {key for key in os.environ if key.startswith('PYWIKIBOT')} settings.update( ['PYWIKIBOT_DIR', 'PYWIKIBOT_DIR_PWB', 'PYWIKIBOT_NO_USER_CONFIG']) for environ_name in sorted(settings): pywikibot.output('{}: {}'.format( environ_name, os.environ.get(environ_name, 'Not set') or "''")) pywikibot.output('Config base dir: ' + pywikibot.config.base_dir) for family, usernames in pywikibot.config.usernames.items(): if not usernames: continue pywikibot.output('Usernames for family {!r}:'.format(family)) for lang, username in usernames.items(): pywikibot.output('\t{}: {}'.format(lang, username))
def main(*args): """Print pywikibot version and important settings.""" pywikibot.output('Pywikibot: %s' % getversion()) pywikibot.output('Release version: %s' % pywikibot.__release__) pywikibot.output('requests version: %s' % requests.__version__) has_wikimedia_cert = False if (not hasattr(requests, 'certs') or not hasattr(requests.certs, 'where') or not callable(requests.certs.where)): pywikibot.output(' cacerts: not defined') elif not os.path.isfile(requests.certs.where()): pywikibot.output(' cacerts: %s (missing)' % requests.certs.where()) else: pywikibot.output(' cacerts: %s' % requests.certs.where()) with codecs.open(requests.certs.where(), 'r', 'utf-8') as cert_file: text = cert_file.read() if WMF_CACERT in text: has_wikimedia_cert = True pywikibot.output(u' certificate test: %s' % ('ok' if has_wikimedia_cert else 'not ok')) if not has_wikimedia_cert: pywikibot.output( ' Please reinstall requests!') pywikibot.output('Python: %s' % sys.version) toolforge_env_hostname = get_toolforge_hostname() if toolforge_env_hostname: pywikibot.output('Toolforge hostname: {0}'.format( toolforge_env_hostname)) check_environ('PYWIKIBOT2_DIR') check_environ('PYWIKIBOT2_DIR_PWB') check_environ('PYWIKIBOT2_NO_USER_CONFIG') pywikibot.output('Config base dir: {0}'.format(pywikibot.config2.base_dir)) for family, usernames in pywikibot.config2.usernames.items(): if usernames: pywikibot.output('Usernames for family "{0}":'.format(family)) for lang, username in usernames.items(): sysop_name = pywikibot.config2.sysopnames.get(family, {}).get(lang) if not sysop_name: sysop_name = 'no sysop configured' elif sysop_name == username: sysop_name = 'also sysop' pywikibot.output('\t{0}: {1} ({2})'.format(lang, username, sysop_name))
def main(*args) -> None: """Print pywikibot version and important settings.""" pywikibot.output('Pywikibot: ' + getversion()) pywikibot.output('Release version: ' + pywikibot.__version__) pywikibot.output('requests version: ' + requests.__version__) has_wikimedia_cert = False if (not hasattr(requests, 'certs') or not hasattr(requests.certs, 'where') or not callable(requests.certs.where)): pywikibot.output(' cacerts: not defined') elif not os.path.isfile(requests.certs.where()): pywikibot.output(' cacerts: {} (missing)'.format( requests.certs.where())) else: pywikibot.output(' cacerts: ' + requests.certs.where()) with codecs.open(requests.certs.where(), 'r', 'utf-8') as cert_file: text = cert_file.read() if WMF_CACERT in text: has_wikimedia_cert = True pywikibot.output(' certificate test: {}' .format(('ok' if has_wikimedia_cert else 'not ok'))) if not has_wikimedia_cert: pywikibot.output(' Please reinstall requests!') pywikibot.output('Python: ' + sys.version) toolforge_env_hostname = get_toolforge_hostname() if toolforge_env_hostname: pywikibot.output('Toolforge hostname: ' + toolforge_env_hostname) check_environ('PYWIKIBOT_DIR') check_environ('PYWIKIBOT_DIR_PWB') check_environ('PYWIKIBOT_NO_USER_CONFIG') pywikibot.output('Config base dir: ' + pywikibot.config2.base_dir) for family, usernames in pywikibot.config2.usernames.items(): if not usernames: continue pywikibot.output('Usernames for family "{0}":'.format(family)) for lang, username in usernames.items(): pywikibot.output('\t{0}: {1}'.format(lang, username))