本文整理汇总了Python中mysql.utilities.common.server.Server.show_server_variable方法的典型用法代码示例。如果您正苦于以下问题:Python Server.show_server_variable方法的具体用法?Python Server.show_server_variable怎么用?Python Server.show_server_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysql.utilities.common.server.Server
的用法示例。
在下文中一共展示了Server.show_server_variable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show_options
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import show_server_variable [as 别名]
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.")
示例2: int
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import show_server_variable [as 别名]
if conn_val["port"] is not None:
conn_val["port"] = int(conn_val["port"])
else:
conn_val["port"] = 0
server_options = {
'conn_info' : conn_val,
'role' : "server%d" % i,
}
conn = Server(server_options)
try:
conn.connect()
server_list.add_new_server(conn)
print("CONNECTED")
res = conn.show_server_variable("basedir")
#print res
basedir = res[0][1]
# Here we capture any exception and print the error message.
# Since all util errors (exceptions) derive from Exception, this is
# safe.
except Exception:
_, err, _ = sys.exc_info()
print("%sFAILED%s" % (BOLD_ON, BOLD_OFF))
if conn.connect_error is not None:
print(conn.connect_error)
print("ERROR: %s" % str(err))
if server_list.num_servers() == 0:
print("ERROR: Failed to connect to any servers listed.")
sys.exit(1)
示例3: _shutdown_running_servers
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import show_server_variable [as 别名]
def _shutdown_running_servers(server_list, processes, basedir):
"""Shutdown any running servers.
processes[in] The list of processes to shutdown with the form:
(process_id, [datadir|port])
basedir[in] The starting path to search for mysqladmin tool
Returns bool - True - servers shutdown attempted
False - no servers to shutdown
"""
if len(processes) < 1:
return False
for process in processes:
datadir = os.getcwd()
connection = {
"user" : "root",
"passwd" : "root",
"host" : "localhost",
"port" : None,
"unix_socket" : None
}
if os.name == "posix":
connection["unix_socket"] = os.path.join(process[1], "mysql.sock")
elif os.name == "nt":
connection["port"] = process[1]
if os.name == "posix":
print(" Process id: %6d, Data path: %s" % \
(int(process[0]), process[1]))
elif os.name == "nt":
print(" Process id: %6d, Port: %s" % \
(int(process[0]), process[1]))
# 1) connect to the server.
server_options = {
'conn_info' : connection,
}
svr = Server(server_options)
ok_to_shutdown = True
try:
svr.connect()
except: # if we cannot connect, don't try to shut it down.
ok_to_shutdown = False
print(" WARNING: shutdown failed - cannot connect.")
if not ok_to_shutdown and os.name == "posix":
# Attempt kill
os.system("kill -9 %s" % process[0])
# 2) if nt, verify datadirectory
if os.name == "nt" and ok_to_shutdown:
res = svr.show_server_variable("datadir")
server_datadir = res[0][1]
ok_to_shudown = (server_datadir.find(datadir) >= 0)
# 3) call shutdown method from mutlib Server_list class
if ok_to_shutdown and svr:
try:
server_list.stop_server(svr)
except MUTLibError:
_, e, _ = sys.exc_info()
print(" WARNING: shutdown failed: " + e.errmsg)
return True
示例4: _shutdown_running_servers
# 需要导入模块: from mysql.utilities.common.server import Server [as 别名]
# 或者: from mysql.utilities.common.server.Server import show_server_variable [as 别名]
def _shutdown_running_servers(server_list, processes, basedir):
"""Shutdown any running servers.
processes[in] The list of processes to shutdown with the form:
(process_id, [datadir|port])
basedir[in] The starting path to search for mysqladmin tool
Returns bool - True - servers shutdown attempted
False - no servers to shutdown
"""
if len(processes) < 1:
return False
for process in processes:
datadir = os.getcwd()
connection = {
"user": "root",
"passwd": "root",
"host": "localhost",
"port": None,
}
if os.name == "posix":
try:
connection["port"] = get_port(process[0])
except MUTLibError:
connection["port"] = -1 # try to kill it forcefully later
elif os.name == "nt":
connection["port"] = process[1]
if os.name == "posix":
print(" Process id: {0:>6}, Data path: {1}".format(process[0],
process[1]))
elif os.name == "nt":
print(" Process id: {0:>6}, Port: {1}".format(process[0],
process[1]))
# 1) connect to the server.
server_options = {
'conn_info': connection,
}
svr = Server(server_options)
ok_to_shutdown = True
try:
svr.connect()
except UtilError: # if we cannot connect, don't try to shut it down.
ok_to_shutdown = False
print(" WARNING: shutdown failed - cannot connect.")
if not ok_to_shutdown:
if os.name == "posix":
# Attempt kill
ret_code = subprocess.call(["kill", "-9",
" {0}".format(process[0])])
# wait until connection is closed
for _ in range(CONNECTION_CLOSE_WAIT_TIMEOUT):
try:
sock = socket.create_connection((svr.host, svr.port))
sock.close()
time.sleep(1)
except socket.error:
# could not connect, connection is closed
break
else:
print(" WARNING: timeout waiting for connection to "
"process {0} to close".format(process[0]))
if ret_code:
print(" WARNING: shutdown failed: Killing process {0}"
"returned error code {1}".format(process[0],
ret_code))
else:
ret_code = subprocess.call("taskkill /F /T /PID {0}".format(
process[0]))
if ret_code not in (0, 128):
print(" WARNING: shutdown failed: Killing process {0} "
"returned error code {1}".format(process[0],
ret_code))
# 2) if nt, verify datadirectory
if os.name == "nt" and ok_to_shutdown:
res = svr.show_server_variable("datadir")
server_datadir = res[0][1]
ok_to_shutdown = (server_datadir.find(datadir) >= 0)
# 3) call shutdown method from mutlib Server_list class
if ok_to_shutdown and svr:
try:
server_list.stop_server(svr)
except MUTLibError:
_, e, _ = sys.exc_info()
print(" WARNING: shutdown failed: " + e.errmsg)
return True