当前位置: 首页>>代码示例>>Python>>正文


Python server.Server类代码示例

本文整理汇总了Python中mysql.utilities.common.server.Server的典型用法代码示例。如果您正苦于以下问题:Python Server类的具体用法?Python Server怎么用?Python Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_connect

    def check_connect(self, port, full_datadir, name="cloned_server"):

        new_server = None
        # Create a new instance
        conn = {
            "user"   : "root",
            "passwd" : "root",
            "host"   : "localhost",
            "port"   : port,
            "unix_socket" : full_datadir + "/mysql.sock"
        }
        if os.name != "posix":
            conn["unix_socket"] = None
        
        server_options = {
            'conn_info' : conn,
            'role'      : name,
        }
        new_server = Server(server_options)
        if new_server is None:
            return None
        
        # Connect to the new instance
        try:
            new_server.connect()
        except UtilError, e:
            raise MUTLibError("Cannot connect to spawned server.")
开发者ID:LinhDart,项目名称:mysql-utilities,代码行数:27,代码来源:clone_server.py

示例2: check_connect

    def check_connect(port, name="cloned_server", conn_dict=None):
        """Check connection.

        port[in]    Server port.
        name[in]    Server name.
        """
        conn = {"user": "root", "passwd": "root", "host": "localhost",
                "port": port}

        if conn_dict is not None:
            conn.update(conn_dict)

        server_options = {'conn_info': conn, 'role': name, }
        new_server = Server(server_options)
        if new_server is None:
            return None

        # Connect to the new instance
        try:
            new_server.connect()
        except UtilError as err:
            raise MUTLibError("Cannot connect to spawned server: {0}".format(
                err.errmsg))

        return new_server
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:25,代码来源:clone_server.py

示例3: test

class test(mutlib.System_test):
    """clone server parameters
    This test exercises the parameters for mysqlserverclone
    """

    def check_prerequisites(self):
        return self.check_num_servers(1)

    def setup(self):
        # No setup needed
        self.new_server = None
        return True

    def _test_server_clone(self, cmd_str, comment, kill=True, capture_all=False):
        self.results.append(comment+"\n")
        port1 = int(self.servers.get_next_port())
        cmd_str += " --new-port=%d " % port1
        full_datadir = os.path.join(os.getcwd(), "temp_%s" % port1)
        cmd_str += " --new-data=%s --delete " % full_datadir
        res = self.exec_util(cmd_str, "start.txt")
        for line in open("start.txt").readlines():
            # Don't save lines that have [Warning] or don't start with #
            index = line.find("[Warning]")
            if capture_all or (index <= 0 and line[0] == '#'):
                self.results.append(line)
        if res:
            raise MUTLibError("%s: failed" % comment)
       
        # Create a new instance
        conn = {
            "user"   : "root",
            "passwd" : "root",
            "host"   : "localhost",
            "port"   : port1,
            "unix_socket" : full_datadir + "/mysql.sock"
        }
        if os.name != "posix":
            conn["unix_socket"] = None
        
        server_options = {
            'conn_info' : conn,
            'role'      : "cloned_server_2",
        }
        self.new_server = Server(server_options)
        if self.new_server is None:
            return False
        
        if kill:
            # Connect to the new instance
            try:
                self.new_server.connect()
            except UtilError, e:
                self.new_server = None
                raise MUTLibError("Cannot connect to spawned server.")
            self.servers.stop_server(self.new_server)

        self.servers.clear_last_port()

        return True
开发者ID:LinhDart,项目名称:mysql-utilities,代码行数:59,代码来源:clone_server_parameters.py

示例4: setup

    def setup(self):
        self.res_fname = "result.txt"

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server1 = self.servers.spawn_server("rep_master_gtid", mysqld, True)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server2 = self.servers.spawn_server("rep_slave1_gtid", mysqld, True)
        mysqld = MYSQL_OPTS_DEFAULT.format(port=self.servers.view_next_port())
        self.server3 = self.servers.spawn_server("rep_slave2_gtid", mysqld, True)

        for server in [self.server1, self.server2, self.server3]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg, server.role))
        conn_info = {
            "user": ssl_user,
            "passwd": ssl_pass,
            "host": self.server0.host,
            "port": self.server0.port,
            "ssl_ca": ssl_c_ca,
            "ssl_cert": ssl_c_cert,
            "ssl_key": ssl_c_key,
        }

        conn_info["port"] = self.server1.port
        conn_info["port"] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info["port"] = self.server2.port
        conn_info["port"] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info["port"] = self.server3.port
        conn_info["port"] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        # Reset spawned servers (clear binary log and GTID_EXECUTED set)
        self.reset_master([self.server1, self.server2, self.server3])

        # Set replication topology.
        self.reset_topology([self.server2, self.server3])

        return True
开发者ID:fengshao0907,项目名称:mysql-utilities,代码行数:49,代码来源:rpl_sync_ssl.py

示例5: do_command

    def do_command(self):
        """ Check and execute the audit log command (previously set by the the
        options of the object constructor).
        """
        # Check for valid command
        command = self.options.get("command", None)
        if not command in VALID_COMMANDS:
            raise UtilError("Invalid command.")

        command_value = self.options.get("value", None)
        # Check for valid value if needed
        if (command_requires_value(command)
           and not check_command_value(command, command_value)):
            raise UtilError("Please provide the correct value for the %s "
                            "command." % command)

        # Copy command does not need the server
        if command == "COPY":
            self._copy_log()
            return True

        # Connect to server
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()

        # Now execute the command
        print "#\n# Executing %s command.\n#\n" % command
        try:
            if command == "POLICY":
                server.exec_query("SET @@GLOBAL.audit_log_policy = %s" %
                                  command_value)
            elif command == "ROTATE":
                self._rotate_log(server)
            else:  # "ROTATE_ON_SIZE":
                server.exec_query("SET @@GLOBAL.audit_log_rotate_on_size = %s"
                                  % command_value)
        finally:
            server.disconnect()

        return True
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:40,代码来源:audit_log.py

示例6: purge

    def purge(self):
        """The purge method for a standalone server.

        Determines the latest log file to purge, which becomes the target
        file to purge binary logs to in case no other file is specified.
        """
        # Connect to server
        self.server = Server({'conn_info': self.server_cnx_val})
        self.server.connect()

        # Check required privileges
        check_privileges(self.server, BINLOG_OP_PURGE,
                         ["SUPER", "REPLICATION SLAVE"],
                         BINLOG_OP_PURGE_DESC, self.verbosity, self._report)

        # retrieve active binlog info
        binlog_file_name, active_binlog_file, index_last_in_use = (
            get_binlog_info(self.server, reporter=self._report,
                            server_name="server", verbosity=self.verbosity)
        )

        # Verify this server is not a Master.
        processes = self.server.exec_query("SHOW PROCESSLIST")
        binlog_dump = False
        for process in processes:
            if process[4] == "Binlog Dump":
                binlog_dump = True
                break
        hosts = self.server.exec_query("SHOW SLAVE HOSTS")
        if binlog_dump or hosts:
            if hosts and not self.verbosity:
                msg_v = " For more info use verbose option."
            else:
                msg_v = ""
            if self.verbosity >= 1:
                for host in hosts:
                    self._report("# WARNING: Slave with id:{0} at {1}:{2} "
                                 "is connected to this server."
                                 "".format(host[0], host[1], host[2]))
            raise UtilError("The given server is acting as a master and has "
                            "slaves connected to it. To proceed please use the"
                            " --master option.{0}".format(msg_v))

        target_binlog_index = self.get_target_binlog_index(binlog_file_name)

        self._purge(index_last_in_use, active_binlog_file, binlog_file_name,
                    target_binlog_index)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:47,代码来源:binlog_admin.py

示例7: _bulk_insert

    def _bulk_insert(self, rows, new_db, destination=None):
        """Import data using bulk insert

        Reads data from a table and builds group INSERT statements for writing
        to the destination server specified (new_db.name).

        This method is designed to be used in a thread for parallel inserts.
        As such, it requires its own connection to the destination server.

        Note: This method does not print any information to stdout.

        rows[in]           a list of rows to process
        new_db[in]         new database name
        destination[in]    the destination server
        """
        if self.dest_vals is None:
            self.dest_vals = self.get_dest_values(destination)

        # Spawn a new connection
        server_options = {
            'conn_info': self.dest_vals,
            'role': "thread",
        }
        dest = Server(server_options)
        dest.connect()

        # Issue the write lock
        lock_list = [("%s.%s" % (new_db, self.q_tbl_name), 'WRITE')]
        my_lock = Lock(dest, lock_list, {'locking': 'lock-all', })

        # First, turn off foreign keys if turned on
        dest.disable_foreign_key_checks(True)

        if self.column_format is None:
            self.get_column_metadata()

        data_lists = self.make_bulk_insert(rows, new_db)
        insert_data = data_lists[0]
        blob_data = data_lists[1]

        # Insert the data first
        for data_insert in insert_data:
            try:
                dest.exec_query(data_insert, self.query_options)
            except UtilError, e:
                raise UtilError("Problem inserting data. "
                                "Error = %s" % e.errmsg)
开发者ID:akhan786,项目名称:LaunchDevelopment,代码行数:47,代码来源:table.py

示例8: setup

    def setup(self):
        try:
            mysqld = "--log-bin=mysql-bin {0}".format(ssl_server_opts())
            self.servers.spawn_server('ssl_server',
                                      mysqld, kill=False)
        except MUTLibError as err:
            raise MUTLibError("Cannot spawn needed servers: {0}"
                              "".format(err.errmsg))

        index = self.servers.find_server_by_name('ssl_server')
        self.server1 = self.servers.get_server(index)

        for server in [self.server1]:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
                grant_proxy_ssl_privileges(server, "ssl_opt", "ssl_opt_pass",
                                           ssl=False)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))

        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server1.host,
            'port': self.server1.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
            'ssl': 1
        }

        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        res = self.server1.exec_query("SHOW STATUS LIKE 'Ssl_cipher'")
        if not res[0][1]:
            raise MUTLibError("Cannot spawn a SSL server.")

        self.drop_all()
        self.load_test_data()

        return True
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:43,代码来源:ssl_connection_simple_test.py

示例9: check_audit_log

    def check_audit_log(self):
        """Verify if the audit log plugin is installed on the server.
        Return the message error if not, or None.
        """
        error = None
        server = Server({'conn_info': self.options.get("server_vals", None)})
        server.connect()
        # Check to see if the plug-in is installed
        if not server.supports_plugin("audit"):
            error = "The audit log plug-in is not installed on this " + \
                    "server or is not enabled."
        server.disconnect()

        return error
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:14,代码来源:audit_log.py

示例10: show_options

 def show_options(self):
     """ Show all audit log variables.
     """
     server = Server({'conn_info': self.options.get("server_vals", None)})
     server.connect()
     rows = server.show_server_variable("audit%")
     server.disconnect()
     if rows:
         print "#\n# Audit Log Variables and Options\n#"
         print_list(sys.stdout, "GRID", ['Variable_name', 'Value'],
                    rows)
         print
     else:
         raise UtilError("No audit log variables found.")
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:14,代码来源:audit_log.py

示例11: __init__

    def __init__(self, server_cnx_val, options):
        """Initiator.

        server_cnx_val[in] Dictionary with the connection values for the
                           server.
        options[in]        options for controlling behavior:
            logging        If logging is active or not.
            verbose        print extra data during operations (optional)
                           default value = False
            min_size       minimum size that the active binlog must have prior
                           to rotate it.
            dry_run        Don't actually rotate the active binlog, instead
                           it will print information about file name and size.
        """

        # Connect to server
        self.server = Server({'conn_info': server_cnx_val})
        self.server.connect()
        self.options = options
        self.verbosity = self.options.get("verbosity", 0)
        self.quiet = self.options.get("quiet", False)
        self.logging = self.options.get("logging", False)
        self.dry_run = self.options.get("dry_run", 0)
        self.binlog_min_size = self.options.get("min_size", False)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:24,代码来源:binlog_admin.py

示例12: load_test_data

def load_test_data(server, db_num=1):
    """Load/insert data into the test databases.

    A considerable amount of data should be considered in order to take some
    time to load, allowing mysqlrplsync to be executed at the same time the
    data is still being inserted.

    server[in]      Target server to load the test data.
    db_num[in]      Number of databases to load the data (by default: 1).
                    It is assumed that a matching number of test databases
                    have been previously created.

    Note: method prepared to be invoked by a different thread.
    """
    # Create a new server instance with a new connection (for multithreading).
    srv = Server({'conn_info': server})
    srv.connect()

    for db_index in xrange(db_num):
        db_name = '`test_rplsync_db{0}`'.format(
            '' if db_num == 1 else db_index
        )
        # Insert random data on all tables.
        random_values = string.letters + string.digits
        for _ in xrange(TEST_DB_NUM_ROWS):
            columns = []
            values = []
            for table_index in xrange(TEST_DB_NUM_TABLES):
                columns.append('rnd_txt{0}'.format(table_index))
                rnd_text = "".join(
                    [random.choice(random_values) for _ in xrange(20)]
                )
                values.append("'{0}'".format(rnd_text))
                insert = ("INSERT INTO {0}.`t{1}` ({2}) VALUES ({3})"
                          "").format(db_name, table_index, ', '.join(columns),
                                     ', '.join(values))
                srv.exec_query(insert)
                srv.commit()
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:38,代码来源:rpl_sync.py

示例13: _spawn_server

def _spawn_server(options):
    """Spawn a server to use for reading .frm files

    This method spawns a new server instance on the port specified by the
    user in the options dictionary.

    options[in]         Options from user

    Returns tuple - (Server instance, new datdir) or raises exception on error
    """
    verbosity = int(options.get("verbosity", 0))
    quiet = options.get("quiet", False)
    new_port = options.get("port", 3310)
    user = options.get("user", None)
    start_timeout = int(options.get("start_timeout", 10))

    # 1) create a directory to use for new datadir

    # If the user is not the same as the user running the script...
    if user_change_as_root(options):
        # Since Python libraries correctly restrict temporary folders to
        # the user who runs the script and /tmp is protected on some
        # platforms, we must create the folder in the current folder
        temp_datadir = os.path.join(os.getcwd(), str(uuid.uuid4()))
        os.mkdir(temp_datadir)
    else:
        temp_datadir = tempfile.mkdtemp()

    if verbosity > 1 and not quiet:
        print "# Creating a temporary datadir =", temp_datadir

    # 2) spawn a server pointed to temp
    if not quiet:
        if user:
            print("# Spawning server with --user={0}.".format(user))
        print "# Starting the spawned server on port %s ..." % new_port,
        sys.stdout.flush()

    bootstrap_options = {
        'new_data': temp_datadir,
        'new_port': new_port,
        'new_id': 101,
        'root_pass': "root",
        'mysqld_options': None,
        'verbosity': verbosity if verbosity > 1 else 0,
        'basedir': options.get("basedir"),
        'delete': True,
        'quiet': True if verbosity <= 1 else False,
        'user': user,
        'start_timeout': start_timeout,
    }
    if verbosity > 1 and not quiet:
        print

    try:
        serverclone.clone_server(None, bootstrap_options)
    except UtilError as error:
        if error.errmsg.startswith("Unable to communicate"):
            err = ". Clone server error: {0}".format(error.errmsg)
            proc_id = int(error.errmsg.split("=")[1].strip('.'))
            print("ERROR Attempting to stop failed spawned server. "
                  " Process id = {0}.".format(proc_id))
            if os.name == "posix":
                try:
                    os.kill(proc_id, subprocess.signal.SIGTERM)
                except OSError:
                    pass
            else:
                try:
                    subprocess.Popen("taskkill /F /T /PID %i" %
                                     proc_id, shell=True)
                except:
                    pass
            raise UtilError(_SPAWN_SERVER_ERROR.format(err))
        else:
            raise

    if verbosity > 1 and not quiet:
        print "# Connecting to spawned server"
    conn = {
        "user": "root",
        "passwd": "root",
        "host": "127.0.0.1",
        "port": options.get("port"),
    }
    server_options = {
        'conn_info': conn,
        'role': "frm_reader_bootstrap",
    }
    server = Server(server_options)
    try:
        server.connect()
    except UtilError:
        raise UtilError(_SPAWN_SERVER_ERROR.format(""))

    if not quiet:
        print "done."

    return (server, temp_datadir)
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:99,代码来源:read_frm.py

示例14: setup

    def setup(self):
        self.res_fname = "result.txt"
        self.temp_files = []
        # Post failover script executed to detect failover events (by creating
        # a specific directory).
        if os.name == 'posix':
            self.fail_event_script = os.path.normpath("./std_data/"
                                                      "fail_event.sh")
        else:
            self.fail_event_script = os.path.normpath("./std_data/"
                                                      "fail_event.bat")

        # Directory created by the post failover script.
        self.failover_dir = os.path.normpath("./fail_event")

        # Remove log files (leftover from previous test).
        for log in self.log_range:
            try:
                os.unlink(_FAILOVER_LOG.format(log))
            except OSError:
                pass

        # Spawn servers
        self.server0 = self.servers.get_server(0)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server1 = self.servers.spawn_server("rep_master_gtid", mysqld,
                                                 True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server2 = self.servers.spawn_server("rep_slave1_gtid", mysqld,
                                                 True)
        mysqld = _DEFAULT_MYSQL_OPTS.format(port=self.servers.view_next_port())
        self.server3 = self.servers.spawn_server("rep_slave2_gtid", mysqld,
                                                 True)
        # Spawn server with --master-info-repository=TABLE and
        # --relay-log-info-repository=TABLE.
        mysqld = _MYSQL_OPTS_INFO_REPO_TABLE.format(
            port=self.servers.view_next_port()
        )
        self.server4 = self.servers.spawn_server("rep_slave3_gtid", mysqld,
                                                 True)
        # Spawn a server with MIR=FILE
        mysqld = _DEFAULT_MYSQL_OPTS_FILE.format(
            port=self.servers.view_next_port()
        )
        self.server5 = self.servers.spawn_server("rep_slave4_gtid", mysqld,
                                                 True)

        self.m_port = self.server1.port
        self.s1_port = self.server2.port
        self.s2_port = self.server3.port
        self.s3_port = self.server4.port
        self.s4_port = self.server5.port

        servers = [self.server1, self.server2, self.server3,
                   self.server4, self.server5]
        for server in servers:
            try:
                grant_proxy_ssl_privileges(server, ssl_user, ssl_pass)
            except UtilError as err:
                raise MUTLibError("{0} on:{1}".format(err.errmsg,
                                                      server.role))
        conn_info = {
            'user': ssl_user,
            'passwd': ssl_pass,
            'host': self.server0.host,
            'port': self.server0.port,
            'ssl_ca': ssl_c_ca,
            'ssl_cert': ssl_c_cert,
            'ssl_key': ssl_c_key,
        }

        conn_info['port'] = self.server1.port
        conn_info['port'] = self.server1.port
        self.server1 = Server.fromServer(self.server1, conn_info)
        self.server1.connect()

        conn_info['port'] = self.server2.port
        conn_info['port'] = self.server2.port
        self.server2 = Server.fromServer(self.server2, conn_info)
        self.server2.connect()

        conn_info['port'] = self.server3.port
        conn_info['port'] = self.server3.port
        self.server3 = Server.fromServer(self.server3, conn_info)
        self.server3.connect()

        conn_info['port'] = self.server4.port
        conn_info['port'] = self.server4.port
        self.server4 = Server.fromServer(self.server4, conn_info)
        self.server4.connect()

        conn_info['port'] = self.server5.port
        conn_info['port'] = self.server5.port
        self.server5 = Server.fromServer(self.server5, conn_info)
        self.server5.connect()

        # Update server list prior to check.
        servers = [self.server1, self.server2, self.server3,
                   self.server4, self.server5]

#.........这里部分代码省略.........
开发者ID:abooitt,项目名称:mysql-utilities,代码行数:101,代码来源:failover_daemon_ssl.py

示例15: _start_server

def _start_server(server_val, basedir, datadir, options=None):
    """Start an instance of a server in read only mode

    This method is used to start the server in read only mode. It will launch
    the server with --skip-grant-tables and --read_only options set.

    Caller must stop the server with _stop_server().

    server_val[in]    dictionary of server connection values
    basedir[in]       the base directory for the server
    datadir[in]       the data directory for the server
    options[in]       dictionary of options (verbosity)
    """
    if options is None:
        options = {}
    verbosity = options.get("verbosity", 0)
    start_timeout = options.get("start_timeout", 10)

    mysqld_path = get_tool_path(basedir, "mysqld", quote=True)

    print "# Server is offline."

    # Check server version
    print "# Checking server version ...",
    version = get_mysqld_version(mysqld_path)
    print "done."
    if version is not None and int(version[0]) >= 5:
        post_5_5 = int(version[1]) >= 5
        post_5_6 = int(version[1]) >= 6
        post_5_7_4 = int(version[1]) >= 7 and int(version[2]) > 4
    else:
        print("# Warning: cannot get server version.")
        post_5_5 = False
        post_5_6 = False
        post_5_7_4 = False

    # Get the user executing the utility to use in the mysqld options.
    # Note: the option --user=user_name is mandatory to start mysqld as root.
    user_name = getpass.getuser()

    # Start the instance
    if verbosity > 0:
        print "# Starting read-only instance of the server ..."
        print "# --- BEGIN (server output) ---"
    else:
        print "# Starting read-only instance of the server ...",
    args = shlex.split(mysqld_path)
    args.extend([
        "--no-defaults",
        "--skip-grant-tables",
        "--read_only",
        "--port=%(port)s" % server_val,
        "--basedir=" + basedir,
        "--datadir=" + datadir,
        "--user={0}".format(user_name),
    ])

    # It the server is 5.6 or later, we must use additional parameters
    if post_5_5:
        server_args = [
            "--skip-slave-start",
            "--default-storage-engine=MYISAM",
            "--server-id=0",
        ]
        if post_5_6:
            server_args.append("--default-tmp-storage-engine=MYISAM")
        if not post_5_7_4:
            server_args.append("--skip-innodb")
        args.extend(server_args)

    socket = server_val.get('unix_socket', None)
    if socket is not None:
        args.append("--socket=%(unix_socket)s" % server_val)
    if verbosity > 0:
        subprocess.Popen(args, shell=False)
    else:
        out = open(os.devnull, 'w')
        subprocess.Popen(args, shell=False, stdout=out, stderr=out)

    server_options = {
        'conn_info': server_val,
        'role': "read_only",
    }
    server = Server(server_options)

    # Try to connect to the server, waiting for the server to become ready
    # (retry start_timeout times and wait 1 sec between each attempt).
    # Note: It can take up to 10 seconds for Windows machines.
    i = 0
    while i < start_timeout:
        # Reset error and wait 1 second.
        error = None
        time.sleep(1)
        try:
            server.connect()
            break  # Server ready (connect succeed)! Exit the for loop.
        except UtilError as err:
            # Store exception to raise later (if needed).
            error = err
        i += 1
#.........这里部分代码省略.........
开发者ID:dzolnierz,项目名称:mysql-utilities,代码行数:101,代码来源:serverinfo.py


注:本文中的mysql.utilities.common.server.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。