资源简介
fo test
代码片段和文件信息
#!/usr/bin/env python
# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
__doc__ = “““
gyptest.py -- test runner for GYP tests.
“““
import os
import optparse
import subprocess
import sys
class CommandRunner(object):
“““
Executor class for commands including “commands“ implemented by
Python functions.
“““
verbose = True
active = True
def __init__(self dictionary={}):
self.subst_dictionary(dictionary)
def subst_dictionary(self dictionary):
self._subst_dictionary = dictionary
def subst(self string dictionary=None):
“““
Substitutes (via the format operator) the values in the specified
dictionary into the specified command.
The command can be an (action string) tuple. In all cases we
perform substitution on strings and don‘t worry if something isn‘t
a string. (It‘s probably a Python function to be executed.)
“““
if dictionary is None:
dictionary = self._subst_dictionary
if dictionary:
try:
string = string % dictionary
except TypeError:
pass
return string
def display(self command stdout=None stderr=None):
if not self.verbose:
return
if type(command) == type(()):
func = command[0]
args = command[1:]
s = ‘%s(%s)‘ % (func.__name__ ‘ ‘.join(map(repr args)))
if type(command) == type([]):
# TODO: quote arguments containing spaces
# TODO: handle meta characters?
s = ‘ ‘.join(command)
else:
s = self.subst(command)
if not s.endswith(‘\n‘):
s += ‘\n‘
sys.stdout.write(s)
sys.stdout.flush()
def execute(self command stdout=None stderr=None):
“““
Executes a single command.
“““
if not self.active:
return 0
if type(command) == type(‘‘):
command = self.subst(command)
cmdargs = shlex.split(command)
if cmdargs[0] == ‘cd‘:
command = (os.chdir) + tuple(cmdargs[1:])
if type(command) == type(()):
func = command[0]
args = command[1:]
return func(*args)
else:
if stdout is sys.stdout:
# Same as passing sys.stdout except python2.4 doesn‘t fail on it.
subout = None
else:
# Open pipe for anything else so Popen works on python2.4.
subout = subprocess.PIPE
if stderr is sys.stderr:
# Same as passing sys.stderr except python2.4 doesn‘t fail on it.
suberr = None
elif stderr is None:
# Merge with stdout if stderr isn‘t specified.
suberr = subprocess.STDOUT
else:
# Open pipe for anything else so Popen works on python2.4.
suberr = subprocess.PIPE
p = subprocess.Popen(command
shell=(sys.platform == ‘win32‘)
stdout=subout
stderr=suberr)
p.wait()
if stdout is None:
self.stdout = p
相关资源
- NodeJS实战搭建博客_源码
- building the web of things Dominique D. Guina
- 深入浅出nodejs 最新版
- nodejs配套PPT
- node-v6.11.0-x64.msi
- node-v8.16.2-x64.msi
- node8.9.1-Windows版
- node-v12.14.0-x64.rar
- nodejs多本经典书籍
- nodejs实战pdf+源码 高清版
- nodejs智能音箱云端代码
- Node Js In Action(中文版)
- nodejs实战pdf 源码.zip
- 商城后台管理系统源码
- NodeJs实战pdf中文 高清+源码
- uploaded-v2.6-node-v12.18.1-win-x64
- nodejs in action中文版
- Node.js实战 第2季.完整版.pdf
- NodeJS 安装包
- nodejs
- 《深入浅出NodeJS》 高清非扫描版
- nodejs学习权威三本书
- Node.js 实战 中文第2版 高清
- Nodejs-v4.2.4以及npm和cnpm优雅安装
- Node.js-阿里云短信发送接口nodejs版本
- Node.js-支付宝当面付nodejsapisdk
- [vue2nodejsechartsjson]调查问卷
- nodejs+ajax用js实现前端后台demo
- 某课吧全栈第一期视频(blue主讲)
- 人脸识别Demo系列免费、带离线——人
评论
共有 条评论