• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python subprocess.getstatusoutput函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: check_status

def check_status():
    '''
    Check the status of process and pull out error messages.
    '''
    global update_err_msg, polling_err_msg
    if not update_proc:
        update_status = 'not started'
    elif update_proc.poll() is None:
        update_status = 'running({})'.format(update_proc.pid)
    else:  # dead
        update_status = 'exited({})'.format(update_proc.returncode)
        if update_err_msg == '':  # haven't pull out
            update_err_msg = update_proc.stderr.read().decode('utf-8')

    if not polling_proc:
        polling_status = 'not started'
    elif polling_proc.poll() is None:
        polling_status = 'running({})'.format(polling_proc.pid)
    else:  # dead
        polling_status = 'exited({})'.format(polling_proc.returncode)
        if polling_err_msg == '':  # haven't pull out
            polling_err_msg = polling_proc.stderr.read().decode('utf-8')

    # regenerate docs
    subprocess.getstatusoutput(DOCS_CMD)

    return update_status, polling_status
开发者ID:JoM-Lab,项目名称:JoM,代码行数:27,代码来源:daemon.py


示例2: build_one_container

def build_one_container(image_name, memory, code_address):
    """
    生成一个容器
    :param image_name: 镜像名字
    :param memory: 内存
    :param code_address: 代码zip地址
    :return: dict
    """

    port = get_one_able_post()
    system_image = get_realname_from_image_name(image_name)
    command = "docker run -d -m %dm -p %d:80 %s /bin/bash /tmp/start.sh '%s'" % (int(memory), port, system_image, code_address)

    code, _ = subprocess.getstatusoutput(command)
    if code != 0:
        return {"code": 10004}

    code, result = subprocess.getstatusoutput("docker ps | grep -v grep |grep 0.0.0.0:%d|awk -F ' ' '{print $1}'" % port)
    if code != 0:
        return {"code": 10004}

    # 记录新建容器端口情况
    obj = ContainerModel(port=port, container_id=result, memory=memory, code_address=code_address,
                         image_name=system_image, create_time=datetime.datetime.now())
    obj.save()

    return {"code": 0, "result": {"containerId": result, "port": port}}
开发者ID:richardy2012,项目名称:app,代码行数:27,代码来源:container.py


示例3: create_machine

def create_machine(project_name):
    """Create docker-machine environment and create if neccessary."""
    tool_name = re.sub(r'[\s_]', '-', project_name)
    machines = subprocess.getstatusoutput('docker-machine ls -q')
    machines = machines[1].split('\n')
    msg = """Activate with either:
        $ eval $(docker-machine env {envname})

        or if you have docker-machine bash completion:

        $ docker-machine use {envname}
        """.format(envname=tool_name)

    if not [i for i in machines if tool_name in i]:
        click.echo(
            "Creating: docker-machine env {}".format(tool_name)
        )
        status = subprocess.getstatusoutput(
            'docker-machine create --driver virtualbox {}'.format(tool_name))
        if status[0] == 0:
            click.secho("Docker-machine env `{}` created.".format(tool_name), fg='green')
            click.secho(msg, fg='yellow')
        else:
            click.secho(status[1], fg='red')
    else:
        click.secho("Docker-machine environment ready.", fg='green')
        click.secho(msg, fg='yellow')
开发者ID:dgonzo,项目名称:toadie,代码行数:27,代码来源:toadie.py


示例4: setEnvironmentDarwin

def setEnvironmentDarwin():
	brew_prefix=subprocess.getstatusoutput('brew --prefix')[1]
	if not brew_prefix:
		return 
	print("homebrew installed")
	opencv_version=subprocess.getstatusoutput('brew ls --versions opencv')[1]
	if not opencv_version:
		print("please install opencv by \n'brew install homebrew/science/opencv'")
	else:
		print("your opencv version is %s"%opencv_version)
	python_version=subprocess.getstatusoutput('python --version')[1].split(" ")[1]
	python_version="python"+".".join(python_version.split(".")[:-1])
	print(python_version)		
	PYTHONPATH=os.path.join(brew_prefix,"lib",python_version,"site-packages")
	print(PYTHONPATH)
	bashrc_fname=os.path.expanduser("~/.bashrc")
	bashrc_lines=open(bashrc_fname).read()
	if 'PYTHONPATH' not in os.environ :
		os.environ['PYTHONPATH']=PYTHONPATH
		print(os.environ['PYTHONPATH'])
		
	if os.environ['PYTHONPATH'] not in bashrc_lines :
		fp=open(bashrc_fname,"a")
		fp.write("\nexport PYTHONPATH=%s\n"%os.environ['PYTHONPATH'])
		fp.close()
	
	if PYTHONPATH not in os.environ['PYTHONPATH']:
		os.environ['PYTHONPATH']=" ".join(PYTHONPATH,os.environ['PYTHONPATH'])
		print(os.environ['PYTHONPATH'])
开发者ID:Ameb,项目名称:python-tesseract,代码行数:29,代码来源:test3.py


示例5: main

def main():
    '''
    Display HTML.
    '''
    (st, branch) = subprocess.getstatusoutput(BRANCH_CMD)
    (st, head) = subprocess.getstatusoutput(HEAD_CMD)
    update_status, polling_status = check_status()
    return '''\
<html><body>
<form action="/checkout" method="post">
current branch: {branch}
<input name="branch" type="text"/>
<input value="checkout" type="submit"/></form><br/>
current HEAD: {head}
<a href="/hook"><button type="button">pull and restart</button></a><br/><br/>
update proc: {update_status}<br/>
<pre>{update_err_msg}</pre><br/>
pollinging proc: {polling_status}<br/>
<pre>{polling_err_msg}</pre><br/>
<a href="/docs/">docs</a>
</body></html>
'''.format(branch=branch,
           head=head,
           update_status=update_status,
           update_err_msg=update_err_msg,
           polling_status=polling_status,
           polling_err_msg=polling_err_msg)
开发者ID:JoM-Lab,项目名称:JoM,代码行数:27,代码来源:daemon.py


示例6: unblock

 def unblock(self):
     '''
     '''
     st,output = getstatusoutput("pfctl -a switchyard -Fr") # flush rules
     log_debug("Flushing rules: {}".format(output))
     st,output = getstatusoutput("pfctl -X {}".format(self._token))
     log_info("Releasing pf: {}".format(output.replace('\n', '; ')))
开发者ID:ruanxuyi,项目名称:cs640,代码行数:7,代码来源:hostfirewall.py


示例7: main

def main(args):
    pc = PC()
    pc.add_func_path("../formulas")
    pc.load_formula_file("gf4d.frm")
    pc.load_formula_file("gf4d.cfrm")
    pc.compiler_name = "g++"
    pc.leave_dirty = True
    f = fractal.T(pc)
    f.loadFctFile(open(args[0]))
    outfile = f.compile()
    cfile = outfile[:-2] + "c"

    # compile the stub and the c file to create a program to profile
    files = " ".join(pc.cfiles + [cfile])
    
    cmd = "%s %s %s -o %s %s" % \
          (pc.compiler_name, files, "-g -pg -O3 -Ic -lpthread", "proftest", "")

    print(cmd)
    (status,output) = subprocess.getstatusoutput(cmd)
    if status != 0:
        raise Exception(
            "Error reported by C compiler:%s" % output)

    print(output)
    # compiled - hurrah! run it
    (status,output) = subprocess.getstatusoutput("./proftest")
    if status != 0:
        raise Exception(
            "Error reported by program:%s" % output)

    print(output)
开发者ID:edyoung,项目名称:gnofract4d,代码行数:32,代码来源:profutil.py


示例8: backup

def backup():
    for (opath,spath) in paths:
        if (not os.path.exists(opath)):next
        if (not os.path.exists(spath)):cmd = 'mkdir -p '+spath;subprocess.getstatusoutput(cmd)
        isfile = os.path.isfile(opath)
        if (isfile):filename = opath.split('/')[-1]
        isdir = os.path.isdir(opath)
        if(isdir):dirname = os.path.dirname(opath).split('/')[-1]

        if (isfile):
            #print ('check file {0}|{1}'.format(filename,path))
            #subprocess.Popen('cp -u {0} {1}'.format(path,savepath+filename),shell=True).wait()
            cmd = 'cp -u {0} {1}'.format(opath,spath)
            (status, output) = subprocess.getstatusoutput(cmd)
            print ('status: %-3s dir: %-6s'%(status,filename))
            if (status):print (' '*3,output)
            #if (not status):
            #    print('succeeded\t copy file:\t{0}'.format(filename))
            #else:
            #    print('failed   \t copy file:\t{0}'.format(filename))
            #
        elif(isdir):

            #subprocess.Popen('cp -urv {0} {1}'.format(path,savepath+dirname),shell=True).wait()
            cmd ='cp -urv {0} {1}'.format(opath,spath)
            (status, output) = subprocess.getstatusoutput(cmd)
            print ('status: %-3s dir: %-8s'%(status,dirname))
            if (status):print (' '*3,output)
            #if (not status):
            #    print('succeeded\t copy dir:\t{0}'.format(dirname))
            #else:
            #    print('failed    \t copy  dir:\t{0}'.format(dirnme))
        else:
            #print ('path:{0} \tignored'.format(opath))
            print ( 'ignored \t %s' % (opath) )
开发者ID:Changgg,项目名称:openSUSE,代码行数:35,代码来源:auto.py


示例9: __init__

    def __init__(self, interfaces, rules):
        super().__init__(interfaces, rules)
        self._intf = interfaces
        st,output = getstatusoutput("iptables-save")
        self._saved_iptables = output
        self._arpignore = {}
        self._rulecmds = [ 'iptables -F', 'iptables -t raw -F' ]

        # --protocol {}  -i {} --port {}
        doall = False
        for r in rules:
            cmds = self._parse_rule(r)
            self._rulecmds.extend(cmds)
            if r == 'all':
                doall = True

        if doall:
            badintf = []
            for intf in interfaces:
                st,output = getstatusoutput('sysctl net.ipv4.conf.{}.arp_ignore'.format(intf))
                if st != 0:
                    badintf.append(intf)
                    continue
                self._arpignore[intf] = int(output.split()[-1])
                st,output = getstatusoutput('sysctl -w net.ipv4.conf.{}.arp_ignore=8'.format(intf))
            for intf in badintf:
                self._intf.remove(intf) # alias of interfaces, so just remove
                                        # from self._intf
        log_debug("Rules to install: {}".format(self._rulecmds))
开发者ID:ruanxuyi,项目名称:cs640,代码行数:29,代码来源:hostfirewall.py


示例10: install_splash

def install_splash(newsplashfile, msg=instmsg):
  status, splashdata = getstatusoutput("pacman -Ql eclipse")
  splash = ""
  for line in splashdata.split("\n"):
    if line.endswith("splash.bmp"):
        splash = line
        break
  try:
    splashfile = splash.split()[1]
  except IndexError:
    print("Unable to find eclipse splash image (got %s)" % (splash))
    exit(1)
  esplashdir = os.path.dirname(splashfile)
  today = "-".join(map(str, localtime()[0:6]))
  backupfile = os.path.join(progdir, "splash-backup-%s.bmp" % (today))
  if os.path.exists(splashfile):
    if 0 != getstatusoutput("mv -f %s %s" % (splashfile, backupfile))[0]:
      print(ver + "\n" + req)
      exit(1)
    print(msg, end=" ")
    if 0 != getstatusoutput("cp %s %s" % (newsplashfile, splashfile))[0]:
      print()
      print("Unable to install splash image to %s/" % (esplashdir))
      exit(1)
  else:
    splashdir = os.path.dirname(splashfile)
    if 0 != getstatusoutput("mkdir -p %s" % (splashdir))[0]:
      print(ver + "\n" + req)
      exit(1)
    print(msg, end=" ")
    if 0 != getstatusoutput("cp %s %s" % (newsplashfile, splashfile))[0]:
      print()
      print("Unable to install splash image to %s/" % (esplashdir))
      exit(1)
  print("done")
开发者ID:NovaCygni,项目名称:aur-mirror,代码行数:35,代码来源:setupsplash.py


示例11: getEnv

    def getEnv( self ):
        out = dict( )
        if compiler.isMSVC( ):
            compilerDirs = {
                "msvc2010": "VS100COMNTOOLS",
                "msvc2012": "VS110COMNTOOLS",
                "msvc2013": "VS120COMNTOOLS",
                "msvc2015": "VS140COMNTOOLS"
            }
            architectures = { "x86": "x86", "x64": "amd64", "x64_cross": "x86_amd64" }
            crossmodifier = ""
            if not compiler.isNative(): crossmodifier="_cross"
            status, result = subprocess.getstatusoutput( "\"%s\\..\\..\\VC\\vcvarsall.bat\" %s > NUL && set" % (
                os.getenv( compilerDirs[ compiler.getCompilerName( ) ] ), architectures[ compiler.architecture( ) + crossmodifier ]) )
            if status != 0:
                print( "Failed to setup msvc compiler", file = sys.stderr )
            out = self.stringToEnv( result )

        elif compiler.isIntel( ):
            architectures = { "x86": "ia32", "x64": "intel64" }
            programFiles = os.getenv( "ProgramFiles(x86)" ) or os.getenv( "ProgramFiles" )
            status, result = subprocess.getstatusoutput(
                "\"%s\\Intel\\Composer XE\\bin\\compilervars.bat\" %s > NUL && set" % (
                    programFiles, architectures[ compiler.architecture( ) ]) )
            if status != 0:
                print( "Failed to setup intel compiler", file = sys.stderr )
            out = self.stringToEnv( result )
        elif compiler.isMinGW( ):
            out = { "Path": os.getenv( "Path" ) }
        return out
开发者ID:TheOneRing,项目名称:emerge,代码行数:30,代码来源:EmergeSetupHelper.py


示例12: _test_unique_prompt

def _test_unique_prompt():
    import time
    time_start = time.time()
    LOG_FILE = 'remote.log'
    import subprocess
    subprocess.getstatusoutput('rm -fr %s'%LOG_FILE)
    log_file = open(LOG_FILE, 'wb+')
    h1 = SshHost('sunfire', 'geouser', 'geouser', logfile=log_file)
    h1.login(True)
    ssh_path = h1.docmd('which ssh')
    h1.switch_user('root', 'geoprobe', True)
    h2 = SshHost('xformer2', 'geo', 'geo.geo', h1)
    iret = h2.login(True)
    if(iret<0):
        h2 = SshHost('xformer2', 'geo', 'geo.geo', h1, ssh_path=ssh_path)
        iret = h2.login(True)
    h2.switch_user('root','inetinet')
    h2.logout()
    h2.login()
    h2.switch_user('root','inetinet')
    uptime = h2.docmd('uptime')
    print('uptime of xformer2: ', uptime)
    h2.quit_user()
    h2.logout()
    h2 = TelnetHost('xformer2', 'geo', 'geo.geo', h1)
    h2.login(True)
    h2.logout()
    h1.logout()
    log_file.close()
    time_end = time.time()
    print('done in %s minutes.'%str((time_end-time_start)/60.0))
开发者ID:ravenac95,项目名称:pexpect,代码行数:31,代码来源:remote.py


示例13: startPIGPIO

 def startPIGPIO(self):
    if sys.version_info[0] < 3:
        import commands
        status, process = commands.getstatusoutput('sudo pidof pigpiod')
        if status:  #  it wasn't running, so start it
            self.LogInfo ("pigpiod was not running")
            commands.getstatusoutput('sudo pigpiod')  # try to  start it
            time.sleep(0.5)
            # check it again        
            status, process = commands.getstatusoutput('sudo pidof pigpiod')
    else:      
        import subprocess
        status, process = subprocess.getstatusoutput('sudo pidof pigpiod')
        if status:  #  it wasn't running, so start it
            self.LogInfo ("pigpiod was not running")
            subprocess.getstatusoutput('sudo pigpiod')  # try to  start it
            time.sleep(0.5)
            # check it again        
            status, process = subprocess.getstatusoutput('sudo pidof pigpiod')
    
    if not status:  # if it was started successfully (or was already running)...
        pigpiod_process = process
        self.LogInfo ("pigpiod is running, process ID is {} ".format(pigpiod_process))
    
        try:
            pi = pigpio.pi()  # local GPIO only
            self.LogInfo ("pigpio's pi instantiated")
        except Exception as e:
            start_pigpiod_exception = str(e)
            self.LogError ("problem instantiating pi: {}".format(start_pigpiod_exception))
    else:
        self.LogError ("start pigpiod was unsuccessful.")
        return False
    return True
开发者ID:Nickduino,项目名称:Pi-Somfy,代码行数:34,代码来源:operateShutters.py


示例14: intltool_version

def intltool_version():
    '''
    Return the version of intltool as a tuple.
    '''
    if sys.platform == 'win32':
        cmd = ["perl", "-e print qx(intltool-update --version) =~ m/(\d+.\d+.\d+)/;"]
        try:
            ver, ret = subprocess.Popen(cmd ,stdout=subprocess.PIPE,
                stderr=subprocess.PIPE, shell=True).communicate()
            ver = ver.decode("utf-8")
            if ver > "":
                version_str = ver
            else:
                return (0,0,0)
        except:
            return (0,0,0)
    else:
        cmd = 'intltool-update --version 2> /dev/null' # pathological case
        retcode, version_str = subprocess.getstatusoutput(cmd)
        if retcode != 0:
            return None
        cmd = 'intltool-update --version 2> /dev/null | head -1 | cut -d" " -f3'
        retcode, version_str = subprocess.getstatusoutput(cmd)
        if retcode != 0: # unlikely but just barely imaginable, so leave it
            return None
    return tuple([int(num) for num in version_str.split('.')])
开发者ID:cz172638,项目名称:gramps,代码行数:26,代码来源:setup.py


示例15: ams_config

def ams_config():

    ams_unzip()
    project_war = '%s/%s/target/%s' %(svn_path,project_name,project_name)
    project_war_ver = '%s/%s/target/%s_%s' %(svn_path,project_name,project_name,ver)
    os.system('cp -Rf %s %s_%s' %(project_war,project_war,ver))
    for i in ['28080','29080']:
        for j in ['test','staging','production']:
            project_war_ver_env_port = '%s_%s_%s_%s' %(project_war,ver,j,i)
            web_xml = '%s/WEB-INF/web.xml' %(project_war_ver_env_port)
            applicationContext_xml = '%s/WEB-INF/classes/applicationContext.xml' %project_war_ver_env_port
            os.system('cp -Rf %s %s' %(project_war_ver,project_war_ver_env_port))
            if j == 'production' or j == 'staging':
                os.system("sed -r -i 's/(<param-value>)(development|test|production)(<\/param-value>)/\1production\3/g' %s" %web_xml)
                status,output = subprocess.getstatusoutput('grep -E "<param-value>production</param-value>" %s' %web_xml)
                if status != 0:
                    logg.error("项目的web.xml配置文件修改错误:%s" %web_xml)
                    exit_script()
            else:
                os.system("sed -r -i 's/(<param-value>)(development|test|production)(<\/param-value>)/\1%s\3/g' %s" %(j,web_xml))
                status,output = subprocess.getstatusoutput('grep -E "<param-value>%s</param-value>" %s' %(j,web_xml))
                if status != 0:
                    logg.error("项目的web.xml配置文件修改错误:%s" %web_xml)
                    exit_script()

            if i == '28080':
                ii = 29080
            elif i == '29080':
                ii == 28080
            os.system("sed -i -r 's/(property name=\"port\" value=\")%s/\1%s/g' %s" %(ii,i,applicationContext_xml))
            status,output = subprocess.getstatusoutput('grep -E "name=\"port\" *value=\"%s\"" %s' %(i,applicationContext_xml))
            if status != 0:
                logg.error("项目的配置文件修改错误:%s" %applicationContext_xml)
                exit_script()
开发者ID:893271511,项目名称:web,代码行数:34,代码来源:coderelease.py


示例16: svn_update

def svn_update():
    logg.info('开始更新代码')
    if not os.path.exists('%s/%s/.svn' %(svn_path,project_name)):
        status,output = subprocess.getstatusoutput('svn co %s %s/%s' %(repos,svn_path,project_name))
    else:
        status,output = subprocess.getstatusoutput('svn up -r %s %s/%s' %(ver,svn_path,project_name))
    if status == 0:
        logg.info('----svn update 成功')
    else:
        logg.error(output)
        logg.error('----svn update 失败')
        exit_script()

    if os.path.exists(need_inc):
        if not os.path.exists('%s/%s/src/main/webapp/inc/.svn/'):
            shell_cmd = '%s co http://svn/fenqi.d.xiaonei.com/fronted/xn.inc %s/%s/src/main/webapp/inc' %(SVN,svn_path,project_name)
        else:
            shell_cmd = '%s up %s/%s/src/main/webapp/inc' %(SVN,svn_path,project_name)

        status,output = subprocess.getstatusoutput(shell_cmd)
        if status == 0:
            logg.info('----update common inc 成功')
        else:
            logg.error(output)
            logg.error('----update common inc 失败')
            exit_script()
    else:
        logg.info("----不需要处理common inc")
    logg.info("结束更新代码 \n")
开发者ID:893271511,项目名称:web,代码行数:29,代码来源:coderelease.py


示例17: model_by_ip

def model_by_ip(ip_addr):
    """Get model switch by snmp. Return name of switch as
    name of module in switch packadge"""
    status,out =  getstatusoutput('snmpwalk -v 1 -c mrtg ' + \
            ip_addr + ' sysDescr.0')
    if status == 0 and '8000S' in out:
        status,model_port =  getstatusoutput('snmpwalk -v 1 -c mrtg ' + \
            ip_addr + ' mib-2.47.1.1.1.1.7.68420352')
        if '8000S/16' in model_port:
            model = 'AT8000_16'
        elif '8000S/24' in model_port:
            model = 'AT8000_24'
        elif '8000S/48' in model_port:
            model = 'AT8000_48'
        else:
            raise NotImplementedError('Unknown model Allied Telesis')
    elif status == 0 and '8012' in out:
        model = 'AT8012'
    elif status == 0 and 'AT-9924SP' in out:
        model = 'AT_9924SP'
    elif status == 0 and 'MES-3124F' in out:
        model = 'MES_3124F'
    elif status == 0 and 'MES-1024' in out:
        model = 'MES_1024'
    elif status == 0 and 'MES-3124' in out:
        model = 'MES_3124'
    elif status == 0 and 'MES-3024' in out:
        model = 'MES_3024'
    elif status == 0 and 'MES-2124' in out:
        model = 'MES_2124'
    elif status == 0 and 'ES-2024A' in out:
        model = 'ES_2024A'
    elif status == 0 and 'ES-2108' in out:
        model = 'ES_2108'
    elif status == 0 and 'DGS-3627G' in out:
        model = 'DGS_3627G'
    elif status == 0 and 'DES-2108' in out:
        model = 'DES_2108'
    elif status == 0 and 'C3550' in out:
        status,model_port = getstatusoutput('snmpwalk -v1 -c mrtg ' + \
                ip_addr +' SNMPv2-SMI::mib-2.47.1.1.1.1.2.1')
        if '3550 24' in model_port:
            model = 'C3550_24'
        elif '3550 48' in model_port:
            model = 'C3550_48'
        elif '3550 10' in model_port:
            model = 'C3550_12'
        else:
            raise NotImplementedError('Unknown model Cisco 3550')
    elif status == 0 and '3Com SuperStack 3 Switch 3250' in out:
        model = '3Com_SuperStack_50'
    elif status == 0 and '3Com SuperStack 3 Switch 3226' in out:
        model = '3Com_SuperStack_26'
    elif status == 0:
        raise NotImplementedError('switch with ip: \
                {0} is {1}'.format(ip_addr,'UNKNOWN'))
    else:
        raise NotImplementedError('no answer from ip: ' + ip_addr)
    return model
开发者ID:lexfer,项目名称:zabbix,代码行数:59,代码来源:Models.py


示例18: resize_all

def resize_all(allpics):
    for index, image in enumerate(allpics):
        for resolution in ["thumb", "small"]:
            exit_code = read_cmd(str(index), resolution)
    assert exit_code == 0, "Could not read " + str(index) + " from db, exit code: " + output
    getstatusoutput("rm *small.jpg")
    getstatusoutput("rm *thumb.jpg")
    print("Resized all pictures to all resolutions correctly")
开发者ID:vincenzobaz,项目名称:pictdb,代码行数:8,代码来源:bulk_test.py


示例19: move_datadir

    def move_datadir(self):

        # Move datadir to new directory
        print("####################################################################################################")
        print("Moving MySQL datadir to /tmp/mysql: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#")
        print("####################################################################################################")
        time.sleep(3)
        if os.path.isdir(self.tmpdir):
            rmdirc = 'rm -rf %s' % self.tmpdir
            status, output = subprocess.getstatusoutput(rmdirc)

            if status == 0:
                print("Emptied /tmp/mysql directory ...")

                try:
                    shutil.move(self.datadir, self.tmp)
                    print("Moved datadir to /tmp/mysql ...")
                except shutil.Error as err:
                    print("Error occurred while moving datadir")
                    print(err)
                    return False

                print("Creating an empty data directory ...")
                makedir = self.mkdir_command
                status2, output2 = subprocess.getstatusoutput(makedir)
                if status2 == 0:
                    print("/var/lib/mysql Created! ...")
                else:
                    print("Error while creating datadir")
                    print(output2)
                    return False

                return True

            else:
                print("Could not delete /tmp/mysql directory")
                print(output)
                return False

        else:
            try:
                shutil.move(self.datadir, self.tmp)
                print("Moved datadir to /tmp/mysql ...")
            except shutil.Error as err:
                print("Error occurred while moving datadir")
                print(err)
                return False

            print("Creating an empty data directory ...")
            makedir = self.mkdir_command
            status2, output2 = subprocess.getstatusoutput(makedir)
            if status2 == 0:
                print("/var/lib/mysql Created! ...")
                return True
            else:
                print("Error while creating datadir")
                print(output2)
                return False
开发者ID:marxistcheguevara,项目名称:MySQL-AutoXtraBackup,代码行数:58,代码来源:prepare.py


示例20: _test_read_write_helper

 def _test_read_write_helper(self, url, content_expected):
     url = util._make_internal_url(url)
     glconnect.get_unity().__write__(url, content_expected)
     content_read = glconnect.get_unity().__read__(url)
     self.assertEquals(content_read, content_expected)
     # clean up the file we wrote
     status, output = commands.getstatusoutput('hadoop fs -test -e ' + url)
     if status is 0:
         commands.getstatusoutput('hadoop fs -rm ' + url)
开发者ID:DataEinstein,项目名称:SFrame,代码行数:9,代码来源:test_io.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python subprocess.list2cmdline函数代码示例发布时间:2022-05-27
下一篇:
Python subprocess.getoutput函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap