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

Python util.run_cmd函数代码示例

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

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



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

示例1: git_checkout

def git_checkout(repo_path, checkout_path, ref):
    ''' Check out a git repository to a given reference and path.
        
        This function is assumed to be run in a lock.
    '''
    jlogger.info('Checking out to ' + checkout_path)

    if not exists(checkout_path):
        mkdir(checkout_path)
    
    hash_file = checkout_path + '.commit-hash'
    commit_hash = get_ref_sha(repo_path, ref)
    
    do_checkout = True
    
    if exists(hash_file):
        previous_hash = open(hash_file).read().strip()
        
        if previous_hash == commit_hash:
            jlogger.debug('Skipping checkout to '+checkout_path)
            do_checkout = False

    if do_checkout:
        run_cmd(('git', '--work-tree='+checkout_path, 'checkout', ref, '--', '.'), repo_path)
    
    touch(checkout_path)
    
    with open(hash_file, 'w') as file:
        print >> file, commit_hash
开发者ID:code-for-england,项目名称:git-jekyll-preview,代码行数:29,代码来源:git.py


示例2: stop_and_get_result

    def stop_and_get_result(self):
        """ Returns the result as a TcpdumpResult object. """
        
        util.run_cmd('pkill tcpdump').wait()
        
        # Parse the number of packets dropped by the kernel.
                
        logf = open('/tmp/tcpdump.log')
        result = TcpdumpResult()
            
        for line in logf:
                    
            r = re.search('(\d+) packets received by filter', line)
            if r: 
                result.recvd_pkt_count = int(r.group(1))
                
            r = re.search('(\d+) packets dropped by kernel', line)
            if r: 
                result.dropped_pkt_count = int(r.group(1))
        
        logf.close()
    
        # Displays the result of tcpdump    

        if self.config.verbose:
            print 'TCPDUMP - received packets:',
            print result.recvd_pkt_count
            print 'dropped packets:',
            print result.dropped_pkt_count
            
        return result
开发者ID:crazyideas21,项目名称:swclone,代码行数:31,代码来源:tcpdump.py


示例3: jekyll_build

def jekyll_build(checkout_path):
    '''
    '''
    checkout_lock = checkout_path + '.jekyll-lock'
    jekyll_path = join(checkout_path, '_site')
    built_hash_file = checkout_path + '.built-hash'
    hash_file = checkout_path + '.commit-hash'

    if exists(jekyll_path) and is_fresh(jekyll_path):
        return jekyll_path
    
    with locked_file(checkout_lock):
        do_build = True
    
        if exists(built_hash_file):
            built_hash = open(built_hash_file).read().strip()
            commit_hash = open(hash_file).read().strip()
        
            if built_hash == commit_hash:
                jlogger.debug('Skipping build to ' + jekyll_path)
                do_build = False
    
        if do_build:
            jlogger.info('Building jekyll ' + jekyll_path)
            run_cmd(('jekyll', 'build'), checkout_path)
        
            if exists(hash_file):
                copyfile(hash_file, built_hash_file)
    
        touch(jekyll_path)

    return jekyll_path
开发者ID:code-for-england,项目名称:git-jekyll-preview,代码行数:32,代码来源:jekyll.py


示例4: run_tests2

def run_tests2():
    if not os.path.exists("premake4.lua"):
        return "premake4.lua doesn't exist in current directory (%s)" % os.getcwd()
    err = run_premake()
    if err != None:
        return err
    p = os.path.join("vs-premake", "all_tests.sln")
    if not os.path.exists(p):
        return "%s doesn't exist" % p
    os.chdir("vs-premake")
    try:
        util.kill_msbuild()
    except:
        return "util.kill_msbuild() failed"
    try:
        (out, err, errcode) = util.run_cmd("devenv",
                                           "all_tests.sln", "/build", "Release")
        if errcode != 0:
            return "devenv.exe failed to build all_tests.sln\n" + fmt_out_err(out, err)
    except:
        return "devenv.exe not found"
    p = os.path.join("..", "obj-rel")
    os.chdir(p)
    test_files = [f for f in os.listdir(".") if is_test_exe(f)]
    print("Running %d test executables" % len(test_files))
    for f in test_files:
        try:
            (out, err, errcode) = util.run_cmd(f)
            if errcode != 0:
                return "%s failed with:\n%s" % (f, fmt_out_err(out, err))
            print(fmt_out_err(out, err))
        except:
            return "%s failed to run" % f
    return None
开发者ID:Andy-Amoy,项目名称:sumatrapdf,代码行数:34,代码来源:runtests.py


示例5: run_step

def run_step(step):
    '''run one step'''

    # remove old logs
    util.run_cmd('/bin/rm -f logs/*.BIN logs/LASTLOG.TXT')

    if step == "prerequisites":
        return test_prerequisites()

    if step == 'build.ArduPlane':
        return util.build_SIL('ArduPlane')

    if step == 'build.APMrover2':
        return util.build_SIL('APMrover2')

    if step == 'build.ArduCopter':
        return util.build_SIL('ArduCopter')

    if step == 'defaults.ArduPlane':
        return get_default_params('ArduPlane')

    if step == 'defaults.ArduCopter':
        return get_default_params('ArduCopter')

    if step == 'defaults.APMrover2':
        return get_default_params('APMrover2')

    if step == 'fly.ArduCopter':
        return arducopter.fly_ArduCopter(viewerip=opts.viewerip, map=opts.map)

    if step == 'fly.CopterAVC':
        return arducopter.fly_CopterAVC(viewerip=opts.viewerip, map=opts.map)

    if step == 'fly.ArduPlane':
        return arduplane.fly_ArduPlane(viewerip=opts.viewerip, map=opts.map)

    if step == 'drive.APMrover2':
        return apmrover2.drive_APMrover2(viewerip=opts.viewerip, map=opts.map)

    if step == 'build.All':
        return build_all()

    if step == 'build.Binaries':
        return build_binaries()

    if step == 'build.DevRelease':
        return build_devrelease()

    if step == 'build.Examples':
        return build_examples()

    if step == 'build.Parameters':
        return build_parameters()

    if step == 'convertgpx':
        return convert_gpx()

    raise RuntimeError("Unknown step %s" % step)
开发者ID:cfluking,项目名称:ardupilot,代码行数:58,代码来源:autotest.py


示例6: start

 def start(self):        
     """ 
     Sniff traffic. Save the text output to check for kernel-dropped packets. 
     
     """    
     util.run_cmd('tcpdump -i ', self.config.sniff_iface,
                  ' -vnnxStt -s 96 -w ', self.config.tmp_pcap_file, 
                  ' "%s" > /tmp/tcpdump.log 2>&1' % self._filter)
     time.sleep(2)
开发者ID:crazyideas21,项目名称:swclone,代码行数:9,代码来源:tcpdump.py


示例7: build_release

def build_release(stats, ver):
	config = "CFG=rel"
	obj_dir = "obj-rel"
	extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
	platform = "PLATFORM=X86"

	shutil.rmtree(obj_dir, ignore_errors=True)
	shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)
	(out, err, errcode) = run_cmd("nmake", "-f", "makefile.msvc", config, extcflags, platform, "all_sumatrapdf")

	log_path = os.path.join(get_logs_cache_dir(), ver + "_rel_log.txt")
	build_log = out + "\n====STDERR:\n" + err
	build_log = strip_empty_lines(build_log)
	open(log_path, "w").write(build_log)

	stats.rel_build_log = ""
	stats.rel_failed = False
	if errcode != 0:
		stats.rel_build_log = build_log
		stats.rel_failed = True
		return

	stats.rel_sumatrapdf_exe_size = file_size_in_obj("SumatraPDF.exe")
	stats.rel_sumatrapdf_no_mupdf_exe_size = file_size_in_obj("SumatraPDF-no-MuPDF.exe")
	stats.rel_libmupdf_dll_size = file_size_in_obj("libmupdf.dll")
	stats.rel_nppdfviewer_dll_size = file_size_in_obj("npPdfViewer.dll")
	stats.rel_pdffilter_dll_size = file_size_in_obj("PdfFilter.dll")
	stats.rel_pdfpreview_dll_size = file_size_in_obj("PdfPreview.dll")

	build_installer_data(obj_dir)
	run_cmd_throw("nmake", "-f", "makefile.msvc", "Installer", config, platform, extcflags)
	p = os.path.join(obj_dir, "Installer.exe")
	stats.rel_installer_exe_size = file_size(p)
开发者ID:Jshauk,项目名称:sumatrapdf,代码行数:33,代码来源:buildbot.py


示例8: build_parameters

def build_parameters():
    '''run the param_parse.py script'''
    print("Running param_parse.py")
    if util.run_cmd(util.reltopdir('Tools/autotest/param_metadata/param_parse.py'), dir=util.reltopdir('.')) != 0:
        print("Failed param_parse.py")
        return False
    return True
开发者ID:0919061,项目名称:ardupilot,代码行数:7,代码来源:autotest.py


示例9: build_examples

def build_examples():
    """run the build_examples.sh script"""
    print("Running build_examples.sh")
    if util.run_cmd(util.reltopdir("Tools/scripts/build_examples.sh"), dir=util.reltopdir(".")) != 0:
        print("Failed build_examples.sh")
        return False
    return True
开发者ID:travmason,项目名称:ardupilot-mpng,代码行数:7,代码来源:autotest.py


示例10: build_parameters

def build_parameters():
    """run the param_parse.py script"""
    print("Running param_parse.py")
    if util.run_cmd(util.reltopdir("Tools/autotest/param_metadata/param_parse.py"), dir=util.reltopdir(".")) != 0:
        print("Failed param_parse.py")
        return False
    return True
开发者ID:travmason,项目名称:ardupilot-mpng,代码行数:7,代码来源:autotest.py


示例11: build_examples

def build_examples():
    '''run the build_examples.sh script'''
    print("Running build_examples.sh")
    if util.run_cmd(util.reltopdir('Tools/scripts/build_examples.sh'), dir=util.reltopdir('.')) != 0:
        print("Failed build_examples.sh")
        return False
    return True
开发者ID:0919061,项目名称:ardupilot,代码行数:7,代码来源:autotest.py


示例12: is_vs2008

def is_vs2008():
    # vcbuild.exe no longer exists for VS2010 and later
    try:
        (out, err, errcode) = util.run_cmd("vcbuild", "/help")
        return errcode == 0
    except:
        return False
开发者ID:DavidWiberg,项目名称:sumatrapdf,代码行数:7,代码来源:runtests.py


示例13: parse_pkt

 def parse_pkt(self, pkt_func):
     """
     Loops to parse output from tcpdump. An example would be:
 
     [recvd_time     ]                 [   ] <- (flow_id + pktgen.MIN_PORT)
     1329098408.055825 IP 192.168.1.20.10007 > 192.168.1.1.9: UDP, length 22
           0x0000:    4500 0032 066e 0000 2011 10e8 c0a8 0114 <- ignore
           0x0010:    c0a8 0101 2717 0009 001e 0000 be9b e955 <- ignore
           0x0020:    0000 066f 4f38 6ea6 000e 4402 0000 0000 
                      [seq_num] [tvsec  ] [tvusec ]
                     ... the rest of the lines can be ignored
 
     Each time a new packet arrives, invokes the pkt_func callback function.
     The pkt_func should have arguments (flow_id, seq_number, sent_time,
     recvd_time). This allows users to handle incoming packets, based on
     these four parameters, accordingly.
 
     """    
     # Initialize fields to extract.
     recvd_time = flow_id = seq_num = tvsec = tvusec = None
 
     # Regex applied on udp header to extract recvd_time and flow_id.
     regex_udp = re.compile('(\d+\.\d+) IP .*\.(\d+) >')
 
     # Regex applied on the pktgen payload.
     regex_pktgen = re.compile('0x0020:\s+(.{10})(.{10})(.{10})')
 
     # Parse with tcpdump -r
     p_tcpdump = util.run_cmd('tcpdump -nnxStt -r ', 
                               self.config.tmp_pcap_file,
                               stdout=subprocess.PIPE)
 
     for line in p_tcpdump.stdout:
 
         re_udp = regex_udp.search(line)
         if re_udp:
             recvd_time = float(re_udp.group(1))
             flow_id = int(re_udp.group(2)) - pktgen.Pktgen.MIN_PORT
             continue
 
         re_pktgen = regex_pktgen.search(line)
         if re_pktgen:
 
             # Here, the seq_num is a global value. We need to convert it to
             # a per-flow sequence number.
             seq_num = util.hex_to_int(re_pktgen.group(1))
             seq_num = seq_num / self.config.flow_count
 
             # Convert the recvd timestamp to float.
             tvsec = util.hex_to_int(re_pktgen.group(2))
             tvusec = util.hex_to_int(re_pktgen.group(3))
             sent_time = tvsec + tvusec / 1000000.0
 
             # We should have obtained all necessary fields to form a packet.
             assert None not in (recvd_time, flow_id)
             pkt_func(flow_id, seq_num, sent_time, recvd_time)
 
             # Reset all fields.
             recvd_time = flow_id = seq_num = tvsec = tvusec = None
开发者ID:crazyideas21,项目名称:swclone,代码行数:59,代码来源:tcpdump.py


示例14: run_premake

def run_premake(action="vs2010"):
    try:
        (out, err, errcode) = util.run_cmd("premake4", action)
        if errcode != 0:
            return out + err
    except:
        return "premake4.exe not in %PATH%"
    return None
开发者ID:Andy-Amoy,项目名称:sumatrapdf,代码行数:8,代码来源:runtests.py


示例15: build_clean

def build_clean(ver):
    config = "CFG=rel"
    obj_dir = "obj-rel"
    extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % str(ver)
    platform = "PLATFORM=X86"
    shutil.rmtree(obj_dir, ignore_errors=True)
    shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)
    (out, err, errcode) = util.run_cmd("nmake", "-f", "makefile.msvc", config, extcflags, platform, "all_sumatrapdf")
开发者ID:DavidWiberg,项目名称:sumatrapdf,代码行数:8,代码来源:efi_cmp.py


示例16: verify_efi_present

def verify_efi_present():
	try:
		(out, err, errcode) = util.run_cmd("efi.exe")
	except:
		print("Must have efi.exe in the %PATH%!!!")
		sys.exit(1)
	if "Usage:" not in out:
		print("efi.exe created unexpected output:\n%s" % out)
		sys.exit(1)
开发者ID:Jshauk,项目名称:sumatrapdf,代码行数:9,代码来源:buildbot.py


示例17: build_mac

def build_mac():
	(out, err, errcode) = util.run_cmd("./build.sh")
	if errcode != 0:
		print_error(out, err, errcode)
		# trying to be helpful and tell user how to resolve specific problems
		# TODO: also detect lack of pcre
		if "No package 'liblzma' found" in err:
			fatal("\nIf you're using homebrew, you need to install xz package to get liblzma\nRun: brew install xz")
		sys.exit(1)
开发者ID:kjk,项目名称:the_silver_searcher,代码行数:9,代码来源:runtests.py


示例18: convert_gpx

def convert_gpx():
    '''convert any tlog files to GPX and KML'''
    import glob
    mavlog = glob.glob("buildlogs/*.tlog")
    for m in mavlog:
        util.run_cmd(util.reltopdir("../mavlink/pymavlink/tools/mavtogpx.py") + " --nofixcheck " + m)
        gpx = m + '.gpx'
        kml = m + '.kml'
        util.run_cmd('gpsbabel -i gpx -f %s -o kml,units=m,floating=1,extrude=1 -F %s' % (gpx, kml), checkfail=False)
        util.run_cmd('zip %s.kmz %s.kml' % (m, m), checkfail=False)
        util.run_cmd("mavflightview.py --imagefile=%s.png %s" % (m,m))
    return True
开发者ID:0919061,项目名称:ardupilot,代码行数:12,代码来源:autotest.py


示例19: main

def main():
	verify_started_in_right_directory()
	config = "CFG=rel"
	obj_dir = "obj-rel"
	ver = "1000" # doesn't matter what version we claim
	extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
	platform = "PLATFORM=X86"
	shutil.rmtree(obj_dir, ignore_errors=True)
	shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)
	(out, err, errcode) = run_cmd("nmake", "-f", "makefile.msvc", "WITH_ANALYZE=yes", config, extcflags, platform, "all_sumatrapdf")
	pretty_print_errors(out)
开发者ID:Jens1970,项目名称:sumatrapdf,代码行数:11,代码来源:build-analyze.py


示例20: build_all

def build_all():
    '''run the build_all.sh script'''
    print("Running build_all.sh")
    flags = ""
    if opts.incremental == True:
        print("Building for incremental")
        flags = "-i"
    if util.run_cmd(util.reltopdir('Tools/scripts/build_all.sh') + " " + flags , dir=util.reltopdir('.')) != 0:
        print("Failed build_all.sh")
        return False
    return True
开发者ID:nwind21,项目名称:ardupilot,代码行数:11,代码来源:autotest_n21.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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