예제 #1
0
def main():
    """Start the script"""
    args = get_cli_arguments(_CMD_ARGS, description="mysql_errors.py")
    if not args.source:
        print("--source argument i.e. path to mysql source directory is "
              "required.")
        exit(4)
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    try:
        check_mysql_version_freshness()
        check_execution_location()
    except RuntimeError:
        raise
        print("Execute this script from the root of Connector/Python source")
        exit(3)
    except ValueError as err:
        print("Update script: {}".format(err))
        exit(3)

    mysql_version = ()
    try:
        checks = [
            os.path.join(args.source, ERR_SERVER_FILE),
            os.path.join(args.source, ERR_CLIENT_HEADER),
            os.path.join(args.source, ERR_CLIENT_CFILE),
        ]
        check_mysql_source(args.source, checks)

        mysql_version = get_mysql_version_from_source(args.source)
        check_mysql_version(mysql_version)
    except ValueError as err:
        print("The given MySQL source can not be used: {}".format(err))
        exit(3)
    else:
        logging.debug("Using MySQL v{ver} sources found in {loc}".format(
            ver="{:d}.{:d}.{:d}".format(*mysql_version), loc=args.source))

    output_folder = args.output or os.path.join('lib', 'mysql', 'connector')
    logging.debug("Output folder: {}".format(output_folder))

    try:
        myerrmsgs = MySQLErrorsProcessor(
            args.source, mysql_version, output_folder)
    except _ParseError as err:
        print(err)
        exit(1)
    else:
        myerrmsgs.write_module()
        myerrmsgs.write_locale_errors(language=args.language)
def main():
    """Start the script"""
    args = get_cli_arguments(_CMD_ARGS, description="mysql_charsets")
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    try:
        check_mysql_version_freshness()
    except ValueError as err:
        print("Update script: {}".format(err))
        exit(3)

    config = _DB_CONFIG.copy()
    config['host'] = args.host
    config['port'] = args.port
    config['user'] = args.user
    config['password'] = args.password
    config['unix_socket'] = args.unix_socket

    mysql_version = (99, 9, 9)
    try:
        cnx = mysql.connector.connect(**config)
        mysql_version = cnx.get_server_version()
        cnx.close()
        check_mysql_version(mysql_version)
    except mysql.connector.Error as exc:
        print("Failed connecting to MySQL server: {error}".format(
            error=str(exc)))
        exit(3)
    except ValueError as err:
        print("The given MySQL server can not be used: {}".format(err))
        exit(3)
    else:
        logging.debug("Using MySQL v{ver}".format(ver="{:d}.{:d}.{:d}".format(
            *mysql_version)))

    if args.output:
        output_folder = args.output
        cext_output_folder = args.output
    else:
        output_folder = os.path.join('lib', 'mysql', 'connector')
        cext_output_folder = os.path.join('src', 'include')

    charset_info = get_charset_info(config)
    write_module(mysql_version, charset_info, output_folder)
예제 #3
0
def main():
    """Start the script"""
    args = get_cli_arguments(
        _CMD_ARGS, description="mysql_charsets")
    if args.debug:
        logging.basicConfig(level=logging.DEBUG)

    try:
        check_mysql_version_freshness()
    except ValueError as err:
        print("Update script: {}".format(err))
        exit(3)

    config = _DB_CONFIG.copy()
    config['host'] = args.host
    config['port'] = args.port
    config['user'] = args.user
    config['password'] = args.password
    config['unix_socket'] = args.unix_socket

    mysql_version = (99, 9, 9)
    try:
        cnx = mysql.connector.connect(**config)
        mysql_version = cnx.get_server_version()
        cnx.close()
        check_mysql_version(mysql_version)
    except mysql.connector.Error as exc:
        print("Failed connecting to MySQL server: {error}".format(
            error=str(exc)))
        exit(3)
    except ValueError as err:
        print("The given MySQL server can not be used: {}".format(err))
        exit(3)
    else:
        logging.debug("Using MySQL v{ver}".format(
            ver="{:d}.{:d}.{:d}".format(*mysql_version)))

    if args.output:
        output_folder = args.output
    else:
        output_folder = os.path.join('lib', 'mysql', 'connector')

    write_module(mysql_version, output_folder, config)