本文整理匯總了Python中subprocess.getstatusoutput方法的典型用法代碼示例。如果您正苦於以下問題:Python subprocess.getstatusoutput方法的具體用法?Python subprocess.getstatusoutput怎麽用?Python subprocess.getstatusoutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類subprocess
的用法示例。
在下文中一共展示了subprocess.getstatusoutput方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_innodb_file_per_table
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def check_innodb_file_per_table(self):
"""
Function for checking MySQL innodb_file_per_table option.
It is needed for "Transportable Tablespace" concept.
:return: True/False
"""
statement = "select @@global.innodb_file_per_table"
run_command = self.create_mysql_client_command(statement=statement)
logger.info("Checking if innodb_file_per_table is enabled")
status, output = subprocess.getstatusoutput(run_command)
if status == 0 and int(output[-1]) == 1:
logger.info("OK: innodb_file_per_table is enabled!")
return True
elif status == 0 and int(output[-1]) == 0:
logger.info("OK: innodb_file_per_table is disabled!")
return False
else:
logger.error("FAILED: InnoDB file per-table Check")
logger.error(output)
raise RuntimeError("FAILED: InnoDB file per-table Check")
示例2: check_mysql_version
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def check_mysql_version(self):
"""
Function for checking MySQL version.
Version must be >= 5.6 for using "Transportable Tablespace" concept.
:return: True/False
"""
statement = "select @@version"
run_command = self.create_mysql_client_command(statement=statement)
logger.info("Checking MySQL version")
status, output = subprocess.getstatusoutput(run_command)
if status == 0 and ('5.6' in output):
logger.info("You have correct version of MySQL")
return True
elif status == 0 and ('5.7' in output):
logger.info("You have correct version of MySQL")
return True
elif status == 0 and ('5.7' not in output) and ('5.6' not in output):
logger.error("Your MySQL server is not supported. MySQL version must be >= 5.6")
raise RuntimeError("Your MySQL server is not supported. MySQL version must be >= 5.6")
else:
logger.error("FAILED: MySQL version check")
logger.error(output)
raise RuntimeError("FAILED: MySQL version check")
示例3: start_mysql_func
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def start_mysql_func(self, start_tool=None, options=None):
# Starting MySQL
logger.info("Starting MySQL server: ")
if start_tool is None:
args = self.start_mysql
else:
args = start_tool
if options is not None:
start_command = "{} {}".format(args, options)
else:
start_command = args
status, output = subprocess.getstatusoutput(start_command)
if status == 0:
logger.info("Starting MySQL ...")
logger.info(output)
return True
else:
logger.error("Error occurred while starting MySQL!")
logger.error(output)
raise RuntimeError("Error occurred while starting MySQL!")
示例4: clone_pxb
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def clone_pxb(self):
# Clone PXB from github based on branch values from config file.
pxb_branches = self.pxb_branches.split()
for branch in pxb_branches:
clone_cmd = "git clone {} -b {} {}/PXB-{}"
if not os.path.exists("{}/PXB-{}".format(self.testpath, branch)):
logger.debug("Started to clone PXB...")
status, output = subprocess.getstatusoutput(
clone_cmd.format(self.pxb_gitcmd, branch, self.testpath, branch))
if status == 0:
logger.debug("PXB-{} cloned ready to build".format(branch))
else:
logger.error("Cloning PXB-{} failed".format(branch))
logger.error(output)
return False
return True
示例5: build_pxb
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def build_pxb(self):
# Building pxb from source
# For this purpose will use build_{}_pxb.sh scripts from this folder
pxb_branches = self.pxb_branches.split()
saved_path = os.getcwd()
dir_path = os.path.dirname(os.path.realpath(__file__))
for branch in pxb_branches:
pxb_path = "{}/PXB-{}".format(self.testpath, branch)
os.chdir(pxb_path)
build_cmd = "{}/build_pxb.sh {} {}".format(dir_path, self.testpath, branch)
status, output = subprocess.getstatusoutput(build_cmd)
if status == 0:
logger.debug("PXB build succeeded")
os.chdir(saved_path)
else:
logger.error("PXB build failed")
logger.error(output)
os.chdir(saved_path)
return False
return True
示例6: prepare_startup
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def prepare_startup(self, basedir_path):
# Method for calling startup.sh file from percona-qa folder
saved_path = os.getcwd()
os.chdir(basedir_path)
startup_cmd = "{}/percona-qa/startup.sh"
logger.debug("Started to run startup.sh file...")
status, output = subprocess.getstatusoutput(startup_cmd.format(self.testpath))
if status == 0:
logger.debug("Running startup.sh succeeded")
os.chdir(saved_path)
return True
else:
logger.error("Running startup.sh failed")
logger.error(output)
os.chdir(saved_path)
return False
示例7: prepare_start_dynamic
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def prepare_start_dynamic(basedir_path):
# Method for calling start_dynamic.sh from basedir.
# It will generate start_dynamic executables in basedir.
saved_path = os.getcwd()
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(basedir_path)
start_dynamic = "{}/start_dynamic.sh".format(dir_path)
logger.debug("Running start_dynamic.sh here...")
status, output = subprocess.getstatusoutput(start_dynamic)
if status == 0:
logger.debug("Running start_dynamic.sh succeeded")
os.chdir(saved_path)
return True
else:
logger.error("Running start_dynamic.sh failed")
logger.error(output)
os.chdir(saved_path)
return False
示例8: wipe_server_all
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def wipe_server_all(basedir_path, options=None):
# Method for calling "all" script which is created inside PS basedir
saved_path = os.getcwd()
os.chdir(basedir_path)
logger.debug("Using all_no_cl script here...")
if options is not None:
all_cmd = "./all_no_cl {}"
status, output = subprocess.getstatusoutput(all_cmd.format(options))
else:
all_cmd = "./all_no_cl"
status, output = subprocess.getstatusoutput(all_cmd)
if status == 0:
logger.debug("Server wiped for fresh start!")
os.chdir(saved_path)
return True
else:
logger.error("All script run failed")
logger.error(output)
os.chdir(saved_path)
return False
示例9: extract_xb_archive
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def extract_xb_archive(self, file_name):
# General method for extracting XB archives
# It will create target folder inside test path
extract_cmd = "tar -xf {}/{} -C {}"
if os.path.isfile("{}/{}".format(self.testpath, file_name)):
if not os.path.isdir("{}/target/{}".format(self.testpath, file_name[:-7])):
status, output = subprocess.getstatusoutput(extract_cmd.format(self.testpath, file_name, self.testpath))
if status == 0:
logger.debug("Extracted from {}".format(file_name))
return True
else:
logger.error("Failed to extract from {}".format(file_name))
logger.error(output)
return False
else:
logger.debug("The 'target' folder already there...")
return True
else:
logger.debug("Could not find {}".format(file_name))
return False
示例10: create_slave_shutdown_file
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def create_slave_shutdown_file(basedir, num):
"""
Static method for creating shutdown file for slave
:param basedir: Basedir path
:param num: The number for slave
:return: True on success
:raise: RuntimeError on fail
"""
with open("{}/stop_node{}".format(basedir, num), 'w+') as stop_file:
shutdown_slave = "{}/bin/mysqladmin -uroot -S{}/sock{}.sock shutdown".format(basedir, basedir, num)
stop_file.write(shutdown_slave)
# give u+x to this file
chmod = "chmod u+x {}/stop_node{}".format(basedir, num)
status, output = subprocess.getstatusoutput(chmod)
if status == 0:
logger.debug("chmod succeeded for {}/stop_node{}".format(basedir, num))
return True
else:
raise RuntimeError("Failed to chmod {}/stop_node{}".format(basedir, num))
示例11: scan
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def scan(self, addr:str):
print(INFO, 'Scanning...')
exitcode, output = subprocess.getstatusoutput('sdptool records --xml ' + addr)
if exitcode != 0:
sys.exit(exitcode)
# print('[DEBUG] output:', output)
self.parse_sdptool_output(output)
# services = find_service(address=addr)
# # print(services)
# # print('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
# for service in services:
# print('Name:', service['name'] )
# print('ProtocolDescriptorList', service['protocol'])
# print('channel/PSM', service['port'])
# print('ServiceClassIDList:', service['service-classes'])
# print('Profiles:', service['profiles'])
# print('Description:', service['description'])
# print('Provider:', service['provider'])
# print('ServiceID', service['service-id'])
# print()
示例12: getPlantUMLVersion
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def getPlantUMLVersion():
"""Provides the plantUML version"""
if JAR_PATH is None:
return "n/a", None
try:
status, output = getstatusoutput('java -jar ' + JAR_PATH + ' -version')
if status != 0:
return "n/a", None
for line in output.splitlines():
# PlantUML version 1.2019.05 (Sat Apr 20 11:45:36 GMT-05:00 2019)
line = line.strip()
if line.startswith('PlantUML version'):
return line.split('version', 1)[1].strip(), JAR_PATH
except:
return "n/a", None
return "could not determine", JAR_PATH
示例13: connect
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def connect(self):
"""
Establishes the actual connection to the referred RSE.
As a quick and dirty impelementation we just use this method to check if the lcg tools are available.
If we decide to use gfal, init should be done here.
:raises RSEAccessDenied: Cannot connect.
"""
status, lcglscommand = getstatusoutput('which lcg-ls')
if status:
raise exception.RSEAccessDenied('Cannot find lcg tools')
endpoint_basepath = self.path2pfn(self.attributes['prefix'])
status, result = getstatusoutput('%s -vv $LCGVO -b --srm-timeout 60 -D srmv2 -l %s' % (lcglscommand, endpoint_basepath))
if status:
if result == '':
raise exception.RSEAccessDenied('Endpoint not reachable. lcg-ls failed with status code %s but no further details.' % (str(status)))
else:
raise exception.RSEAccessDenied('Endpoint not reachable : %s' % str(result))
示例14: get_token
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def get_token(oc_path):
"""
Get authentication token from OC command line tool
Returns:
The bearer token to the init_setup function
"""
global USER_NAME, PASSWORD, IP
print("Logging into your OpenShift Cluster")
status, _ = subprocess.getstatusoutput(oc_path + "oc login "+IP+" -u "+USER_NAME+" -p "+ \
PASSWORD +" --insecure-skip-tls-verify=true")
if status == 0:
print("Successfully logged into the OpenShift Cluster")
else:
print("Could not login, please enter correct login credentials")
exit(1)
token = subprocess.getoutput(oc_path + "oc whoami -t")
return token
#General Function for get calls
示例15: validate_kibana
# 需要導入模塊: import subprocess [as 別名]
# 或者: from subprocess import getstatusoutput [as 別名]
def validate_kibana(installer_ip, port):
"""
Validate kibana operator by checking the status of the operator and GUI console
"""
status, output = subprocess.getstatusoutput("systemctl status kibana")
if status == 0:
print("Kibana is Active")
output = "CLOSED"
print("Waiting for Kibana GUI to load..")
while output != "OPEN":
#pingtest.py program is used to ping IP address along with the PORT number \
# and verify if its open or closed
_, output = subprocess.getstatusoutput("python pingtest.py "+installer_ip+" "+ port+" 2> /dev/null && \
echo OPEN || echo CLOSED")
print("Kibana GUI is available for use on the installer IP.. ")
else:
print("Kibana is not running..")
#function to deploy logstash operator