Exemplo n.º 1
0
def _connect_to_wp_mysql(cfg):
    kwds = {'read_default_file': REPLICA_MY_CNF}
    if utils.running_in_tools_labs():
        # Get the project database name (and ultimately the database server's
        # hostname) from the name of the database we want, as per:
        # https://wikitech.wikimedia.org/wiki/Help:Tool_Labs/Database#Naming_conventions
        xxwiki = cfg.database.replace('_p', '')
        kwds['host'] = '%s.analytics.db.svc.eqiad.wmflabs' % xxwiki
    return _connect(**kwds)
Exemplo n.º 2
0
def _connect_to_wp_mysql(cfg):
    kwds = {'read_default_file': REPLICA_MY_CNF}
    if utils.running_in_tools_labs():
        # Get the project database name (and ultimately the database server's
        # hostname) from the name of the database we want, as per:
        # https://wikitech.wikimedia.org/wiki/Help:Tool_Labs/Database#Naming_conventions
        xxwiki = cfg.database.replace('_p', '')
        kwds['host'] = '%s.analytics.db.svc.eqiad.wmflabs' % xxwiki
    return _connect(**kwds)
Exemplo n.º 3
0
def _connect_to_wp_mysql(cfg):
    kwds = {'read_default_file': REPLICA_MY_CNF}
    if utils.running_in_tools_labs():
        # Get the project database name (and ultimately the database server's
        # hostname) from the name of the database we want, as per:
        # https://wikitech.wikimedia.org/wiki/Help:Tool_Labs/Database#Naming_conventions
        xxwiki = cfg.database.replace('_p', '')
        kwds['host'] = '%s.analytics.db.svc.eqiad.wmflabs' % xxwiki
    elif os.getenv('CH_LOCAL_SSH_PORT') is not None:
        # Local development with SSH port forwarding.
        kwds.update({
            'port': int(os.getenv('CH_LOCAL_SSH_PORT')),
            'host': '127.0.0.1'
        })
    return _connect(**kwds)
Exemplo n.º 4
0
    try:
        _update_db_tools_labs(cfg)
    except Exception as e:
        traceback.print_exc(file = sys.stderr)
        email('Failed to build database for %s' % cfg.lang_code, logfiles)
        sys.exit(1)
    utils.mkdir_p(cfg.log_dir)
    for logfile in logfiles:
        os.rename(logfile, os.path.join(cfg.log_dir, logfile))

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Update the CitationHunt databases.')
    parser.add_argument('lang_code',
        help='One of the language codes in ../config.py')
    args = parser.parse_args()

    if not utils.running_in_tools_labs():
        print('Not running in Tools Labs!', file=sys.stderr)
        sys.exit(1)

    if args.lang_code not in config.LANG_CODES_TO_LANG_NAMES:
        print('Invalid lang code! Use one of: ', end=' ', file=sys.stderr)
        print(list(config.LANG_CODES_TO_LANG_NAMES.keys()), file=sys.stderr)
        parser.print_usage()
        sys.exit(1)

    cfg = config.get_localized_config(args.lang_code)
    update_db_tools_labs(cfg)
Exemplo n.º 5
0
    logfile = 'citationhunt_update_' + cfg.lang_code + '.err'
    file(logfile, 'w').close()  # truncate logfile

    try:
        _update_db_tools_labs(cfg)
    except Exception, e:
        traceback.print_exc(file = sys.stderr)
        email('Failed to build database for %s' % cfg.lang_code, logfile)
        sys.exit(1)
    email('All done for %s!' % cfg.lang_code, logfile)

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Update the CitationHunt databases.')
    parser.add_argument('lang_code',
        help='One of the language codes in ../config.py')
    args = parser.parse_args()

    if not (utils.running_in_tools_labs() and utils.running_in_virtualenv()):
        print >>sys.stderr, 'Not running in a virtualenv in Tools Labs!'
        sys.exit(1)

    if args.lang_code not in config.lang_code_to_config:
        print >>sys.stderr, 'Invalid lang code! Use one of: ',
        print >>sys.stderr, config.lang_code_to_config.keys()
        parser.print_usage()
        sys.exit(1)

    cfg = config.get_localized_config(args.lang_code)
    update_db_tools_labs(cfg)
Exemplo n.º 6
0
def _connect_to_ch_mysql():
    kwds = {'read_default_file': REPLICA_MY_CNF}
    if utils.running_in_tools_labs():
        kwds['host'] = TOOLS_LABS_CH_MYSQL_HOST
    return _connect(**kwds)
Exemplo n.º 7
0
    try:
        _update_db_tools_labs(cfg)
    except Exception, e:
        traceback.print_exc(file = sys.stderr)
        email('Failed to build database for %s' % cfg.lang_code, logfiles)
        sys.exit(1)
    utils.mkdir_p(cfg.log_dir)
    for logfile in logfiles:
        os.rename(logfile, os.path.join(cfg.log_dir, logfile))

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Update the CitationHunt databases.')
    parser.add_argument('lang_code',
        help='One of the language codes in ../config.py')
    args = parser.parse_args()

    if not (utils.running_in_tools_labs() and utils.running_in_virtualenv()):
        print >>sys.stderr, 'Not running in a virtualenv in Tools Labs!'
        sys.exit(1)

    if args.lang_code not in config.LANG_CODES_TO_LANG_NAMES:
        print >>sys.stderr, 'Invalid lang code! Use one of: ',
        print >>sys.stderr, config.LANG_CODES_TO_LANG_NAMES.keys()
        parser.print_usage()
        sys.exit(1)

    cfg = config.get_localized_config(args.lang_code)
    update_db_tools_labs(cfg)
Exemplo n.º 8
0
def _connect_to_ch_mysql():
    kwds = {'read_default_file': REPLICA_MY_CNF}
    if utils.running_in_tools_labs():
        kwds['host'] = TOOLS_LABS_CH_MYSQL_HOST
    return _connect(**kwds)