Example #1
0
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.Site()
    except AttributeError:
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' %
            unicode(version.getversion_onlinerepo()))

    log(u'SITE VERSION: %s' % unicode(site.live_version()))

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    # imported modules
    log(u'MODULES:')
    for item in list(sys.modules.keys()):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    # messages on bot discussion page?
    if site.logged_in():
        if site.messages():
            messagestate = 'unanswered'
        else:
            messagestate = 'none'
    else:
        messagestate = 'unknown (not logged in)'
    log(u'MESSAGES: %s' % messagestate)

    log(u'=== ' * 14)
Example #2
0
File: bot.py Project: lnls-fac/code
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.Site()
    except AttributeError:
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' % unicode(version.getversion_onlinerepo()))

    log(u'SITE VERSION: %s' % unicode(site.live_version()))

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    # imported modules
    log(u'MODULES:')
    for item in list(sys.modules.keys()):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    # messages on bot discussion page?
    if site.logged_in():
        if site.messages():
            messagestate = 'unanswered'
        else:
            messagestate = 'none'
    else:
        messagestate = 'unknown (not logged in)'
    log(u'MESSAGES: %s' % messagestate)

    log(u'=== ' * 14)
Example #3
0
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))
Example #4
0
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))
Example #5
0
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))
Example #6
0
def writelogheader():
    """
    Save additional version, system and status info to the logfile in use,
    so that the user can look it up later to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.getSite()
    except AttributeError:
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' % unicode((version.getversion().strip(),
                                      version.getversion_onlinerepo(),
                                      site.live_version())))
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    # imported modules
    log(u'MODULES:')
    for item in sys.modules.keys():
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    # messages on bot discussion page?
    log(u'MESSAGES: %s' % ('unanswered' if site.messages() else 'none'))

    log(u'=== ' * 14)
Example #7
0
def writelogheader():
    """
    Save additional version, system and status info to the logfile in use,
    so that the user can look it up later to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.getSite()
    except AttributeError:
        return

    log(u'=== Pywikipediabot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' % unicode(
            (version.getversion().strip(), version.getversion_onlinerepo(),
             site.live_version())))
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    # imported modules
    log(u'MODULES:')
    for item in sys.modules.keys():
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver and (ver[0] == u'$'):
            log(u'  %s' % ver)

    # messages on bot discussion page?
    log(u'MESSAGES: %s' % ('unanswered' if site.messages() else 'none'))

    log(u'=== ' * 14)
Example #8
0
import pywikibot
from pywikibot.version import getversion
try:
    import httplib2
except ImportError:
    httplib2 = {'__version__': 'n/a'}


def check_environ(environ_name):
    pywikibot.output('{0}: {1}'.format(environ_name,
                                       os.environ.get(environ_name,
                                                      'Not set')))


if __name__ == '__main__':
    pywikibot.output('Pywikibot: %s' % getversion())
    pywikibot.output('Release version: %s' % pywikibot.__release__)
    pywikibot.output('httplib2 version: %s' % httplib2.__version__)
    if not hasattr(httplib2, 'CA_CERTS'):
        httplib2.CA_CERTS = ''
    pywikibot.output('  cacerts: %s' % httplib2.CA_CERTS)
    has_wikimedia_cert = False
    if os.path.isfile(httplib2.CA_CERTS):
        with open(httplib2.CA_CERTS, 'r') as cert_file:
            text = cert_file.read()
            if 'MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs' in text:
                has_wikimedia_cert = True
    pywikibot.output(u'    certificate test: %s' %
                     ('ok' if has_wikimedia_cert else 'not ok'))
    pywikibot.output('Python: %s' % sys.version)
    if not __import__('unicodedata').normalize(
Example #9
0
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # If a http thread is not available, it's too early to print a header
    # that includes version information, which may need to query a server.
    # The http module can't be imported due to circular dependencies.
    http = sys.modules.get('pywikibot.comms.http', None)
    if not http or not hasattr(http, 'threads') or not len(http.threads):
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    # config file dir
    log(u'CONFIG FILE DIR: %s' % pywikibot.config2.base_dir)

    all_modules = sys.modules.keys()

    # These are the main dependencies of pywikibot.
    check_package_list = ['httplib2', 'mwparserfromhell']

    # report all imported packages
    if config.verbose_output:
        check_package_list += all_modules

    packages = version.package_versions(check_package_list)

    log(u'PACKAGES:')
    for name in sorted(packages.keys()):
        info = packages[name]
        if 'path' not in info:
            if 'type' in info:
                info['path'] = '[' + info['type'] + ']'
            else:
                info['path'] = '[path unknown]'
        if 'ver' not in info:
            info['ver'] = '??'
        if 'err' in info:
            log(u'  %(name)s: %(err)s' % info)
        else:
            log(u'  %(name)s (%(path)s) = %(ver)s' % info)

    # imported modules
    log(u'MODULES:')
    for item in list(all_modules):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' % unicode(version.getversion_onlinerepo()))

    log(u'=== ' * 14)
Example #10
0
import sys
import os
import pywikibot
from pywikibot.version import getversion
try:
    import httplib2
except ImportError:
    httplib2 = {'__version__': 'n/a'}


def check_environ(environ_name):
    pywikibot.output('{0}: {1}'.format(environ_name, os.environ.get(environ_name, 'Not set')))


if __name__ == '__main__':
    pywikibot.output('Pywikibot: %s' % getversion())
    pywikibot.output('Release version: %s' % pywikibot.__release__)
    pywikibot.output('httplib2 version: %s' % httplib2.__version__)
    if not hasattr(httplib2, 'CA_CERTS'):
        httplib2.CA_CERTS = ''
    pywikibot.output('  cacerts: %s' % httplib2.CA_CERTS)
    has_wikimedia_cert = False
    if os.path.isfile(httplib2.CA_CERTS):
        with open(httplib2.CA_CERTS, 'r') as cert_file:
            text = cert_file.read()
            if 'MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs' in text:
                has_wikimedia_cert = True
    pywikibot.output(u'    certificate test: %s' % ('ok' if has_wikimedia_cert else 'not ok'))
    pywikibot.output('Python: %s' % sys.version)
    normalize_text = u'\u092e\u093e\u0930\u094d\u0915 \u091c\u093c\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917'
Example #11
0
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.Site()
    except AttributeError:
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    all_modules = sys.modules.keys()

    # These are the main dependencies of pywikibot.
    check_package_list = ['httplib2', 'mwparserfromhell']

    # report all imported packages
    if config.verbose_output:
        check_package_list += all_modules

    packages = version.package_versions(check_package_list)

    log(u'PACKAGES:')
    for name in sorted(packages.keys()):
        info = packages[name]
        if 'path' not in info:
            if 'type' in info:
                info['path'] = '[' + info['type'] + ']'
            else:
                info['path'] = '[path unknown]'
        if 'ver' not in info:
            info['ver'] = '??'
        if 'err' in info:
            log(u'  %(name)s: %(err)s' % info)
        else:
            log(u'  %(name)s (%(path)s) = %(ver)s' % info)

    # imported modules
    log(u'MODULES:')
    for item in list(all_modules):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' % unicode(version.getversion_onlinerepo()))

    log(u'SITE VERSION: %s' % site.version())

    # messages on bot discussion page?
    if site.logged_in():
        if site.messages():
            messagestate = 'unanswered'
        else:
            messagestate = 'none'
    else:
        messagestate = 'unknown (not logged in)'
    log(u'MESSAGES: %s' % messagestate)

    log(u'=== ' * 14)
Example #12
0
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # if site not available it's too early to print a header (work-a-round)
    try:
        site = pywikibot.Site()
    except AttributeError:
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: %s' % unicode(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: %s' % unicode(os.uname()))

    all_modules = sys.modules.keys()

    # These are the main dependencies of pywikibot.
    check_package_list = ['httplib2', 'mwparserfromhell']

    # report all imported packages
    if config.verbose_output:
        check_package_list += all_modules

    packages = version.package_versions(check_package_list)

    log(u'PACKAGES:')
    for name in sorted(packages.keys()):
        info = packages[name]
        if 'path' not in info:
            if 'type' in info:
                info['path'] = '[' + info['type'] + ']'
            else:
                info['path'] = '[path unknown]'
        if 'ver' not in info:
            info['ver'] = '??'
        if 'err' in info:
            log(u'  %(name)s: %(err)s' % info)
        else:
            log(u'  %(name)s (%(path)s) = %(ver)s' % info)

    # imported modules
    log(u'MODULES:')
    for item in list(all_modules):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' %
            unicode(version.getversion_onlinerepo()))

    log(u'SITE VERSION: %s' % site.version())

    # messages on bot discussion page?
    if site.logged_in():
        if site.messages():
            messagestate = 'unanswered'
        else:
            messagestate = 'none'
    else:
        messagestate = 'unknown (not logged in)'
    log(u'MESSAGES: %s' % messagestate)

    log(u'=== ' * 14)
Example #13
0
def main():
    locale.setlocale(locale.LC_ALL, '')
    print(sys.version)
    print(getversion())

    varglobals.init()
    #reload(sys)
    #sys.setdefaultencoding('utf-8')
    preguntem = True
    siteca = pywikibot.Site('ca')

    for pagina in fit:

        article = pagina
        article = article.rstrip()
        print(article.encode("utf-8"))

        # per treballar amb fitxer de proves, comentar a partir d'aquí
        pag = pywikibot.Page(siteca, article)
        min = 1
        tornar_amunt = False
        while True:
            try:
                txtorig = pag.get()
                break
            except pywikibot.IsRedirectPage:
                pag = pag.getRedirectTarget()
                txtorig = pag.get()
                article = pag.title()
                break
            except pywikibot.NoPage:
                tornar_amunt = True
                break
            except pywikibot.data.api.APIError:
                time.sleep(min * 60)
                min = min + 1
        # si no és de l'espai de noms normal no hi volem entrar
        if pag.namespace() != 0:
            continue
        if tornar_amunt:
            continue
        '''
   # per treballar amb fitxer de proves, comentar fins aquí

   txtorig = proves.read()
   '''

        varglobals.nom_article = article
        #xl = Xlate()
        xl = Xlate_esportista()

        txtnou = txtorig

        t = Text_art(article, txtnou, xl)

        #print u"Tot l'objecte text"
        #print t.__repr__().encode('utf-8')

        t.adapta()
        txtnou = t.genera()

        if txtorig != txtnou:
            try:
                pywikibot.showDiff(txtorig, txtnou)
                comentari = "Robot normalitza infotaula persona"

                # per treballar amb fitxer de proves, comentar a partir d'aquí
                if preguntem:
                    quefem = preguntar()
                    #quefem = -1
                    if quefem == 0:
                        preguntem = False
                    if quefem == 1 or quefem == 0:
                        print("Gravant")
                        pag.put(txtnou, summary=comentari, minor=False)
                        pass
                        #return 0
                    else:
                        pass  # no fem res
                        #exit(-1)
                else:
                    min = 1
                    while True:
                        try:
                            pag.put(txtnou, summary=comentari, minor=False)
                            pass
                            break
                        except (pywikibot.exceptions.OtherPageSaveError,
                                pywikibot.data.api.APIError):
                            print(
                                "******************** Error de salvat, esperem ********************"
                            )
                            time.sleep(min * 60)
                            min = min + 1

# per treballar amb fitxer de proves, comentar fins d'aquí

            except KeyboardInterrupt:
                return
                pass

    varglobals.fout.write("|}")
    varglobals.fout.close()
    varglobals.foutimatges.write("|}")
    varglobals.foutimatges.close()
Example #14
0
def writelogheader():
    """
    Save additional version, system and status info to the log file in use.

    This may help the user to track errors or report bugs.
    """
    # If a http thread is not available, it's too early to print a header
    # that includes version information, which may need to query a server.
    # The http module can't be imported due to circular dependencies.
    http = sys.modules.get('pywikibot.comms.http', None)
    if not http or not hasattr(http, 'threads') or not len(http.threads):
        return

    log(u'=== Pywikibot framework v2.0 -- Logging header ===')

    # script call
    log(u'COMMAND: {0}'.format(sys.argv))

    # script call time stamp
    log(u'DATE: %s UTC' % str(datetime.datetime.utcnow()))

    # new framework release/revision? (handleArgs needs to be called first)
    try:
        log(u'VERSION: %s' %
            version.getversion(online=config.log_pywiki_repo_version).strip())
    except version.ParseError:
        exception()

    # system
    if hasattr(os, 'uname'):
        log(u'SYSTEM: {0}'.format(os.uname()))

    # config file dir
    log(u'CONFIG FILE DIR: %s' % pywikibot.config2.base_dir)

    all_modules = sys.modules.keys()

    # These are the main dependencies of pywikibot.
    check_package_list = ['httplib2', 'mwparserfromhell']

    # report all imported packages
    if config.verbose_output:
        check_package_list += all_modules

    packages = version.package_versions(check_package_list)

    log(u'PACKAGES:')
    for name in sorted(packages.keys()):
        info = packages[name]
        if 'path' not in info:
            if 'type' in info:
                info['path'] = '[' + info['type'] + ']'
            else:
                info['path'] = '[path unknown]'
        if 'ver' not in info:
            info['ver'] = '??'
        if 'err' in info:
            log(u'  %(name)s: %(err)s' % info)
        else:
            log(u'  %(name)s (%(path)s) = %(ver)s' % info)

    # imported modules
    log(u'MODULES:')
    for item in list(all_modules):
        ver = version.getfileversion('%s.py' % item.replace('.', '/'))
        if ver:
            log(u'  %s' % ver)

    if config.log_pywiki_repo_version:
        log(u'PYWIKI REPO VERSION: %s' % version.getversion_onlinerepo())

    log(u'=== ' * 14)