本文整理汇总了Python中subprocess.Popen.index方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.index方法的具体用法?Python Popen.index怎么用?Python Popen.index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.index方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _execute
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def _execute(self):
try:
f_name = "tests/run_%s.py" % self.param('key')
f = open(f_name, "w")
data = self.param('text')
cf = generate_config_file(self.db)
cf_nums = len(cf.split("\n"))
f.write(cf)
f.write(data)
f.write("\n")
f.write(generate_report_script())
f.close()
res = Popen("/usr/bin/python3 %s" % (f_name), shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT).stdout.read()
res = str(res, "utf-8")
tmp = 'File "tests/run_%s.py", line ' % self.param('key')
try:
i_s = res.index(tmp) + len(tmp)
try:
i_e = res.index(",", i_s)
except:
i_e = res.index("\n", i_s)
res_s = res[0:i_s]
res_e = res[i_e:]
num = int(res[i_s:i_e]) - cf_nums + 1
return "".join([res_s, str(num), res_e])
except:
pass
return res
except Exception as e:
return "%s" % (e.args,)
示例2: GetMovieDuration
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def GetMovieDuration(path):
output = Popen(["ffmpeg", "-i", path], stdout=PIPE, stderr=STDOUT).communicate()[0]
start = output.index("Duration: ")
end = output.index(", start: ")
duration = output[start+len("Duration: "):end]
hours, mins,secs = duration.split(":")
totalSecs = float(hours)* 60 * 60 + float(mins) * 60 + float(secs)
return totalSecs
示例3: cleancss_ver
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def cleancss_ver(self):
if not hasattr(self, '_cleancss_ver'):
# out = b"MAJOR.MINOR.REVISION" // b"3.4.19" or b"4.0.0"
out, err = Popen(
['cleancss', '--version'], stdout=PIPE).communicate()
self._cleancss_ver = int(out[:out.index(b'.')])
return self._cleancss_ver
示例4: main
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def main():
first = True
for dir_ in dirs:
if first:
first = False
else:
print
print
key = os.path.split(dir_)[1]
print key
print "=" * len(key)
print
pattern = os.path.join(dir_, "*.po")
keys = ["translated", "fuzzy", "untranslated"]
ress = []
for fname in sorted(glob.glob(pattern)):
locale = os.path.split(fname)[1][:-3]
log = Popen(["env", "-i", "msgfmt", "-v", fname],
stderr=PIPE).stderr.read().split()
res = [locale, 0, 0, 0]
for idx, key in enumerate(keys):
try:
if key in log:
res[idx+1] = int(log[log.index(key)-1])
except:
pass
ress.append(res)
ress.sort(cmp=_cmp)
print 'locale\t%12s / %12s / %12s' % (keys[0], keys[1], keys[2])
for x in ress:
print "%s\t%12i / %12i / %12i" % tuple(x)
示例5: parse_keyid
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def parse_keyid(sig_filename):
args = ["gpg", "--list-packet", sig_filename]
out, err = Popen(args, stdout=PIPE, stderr=PIPE).communicate()
if err.decode('utf-8') != '':
print(err.decode('utf-8'))
return None
out = out.decode('utf-8')
ai = out.index('keyid') + len('keyid ')
bi = ai + out[ai:].index('\n')
return out[ai:bi].strip()
示例6: GetMovieFPS
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def GetMovieFPS(path):
#mplayer -vo null -nosound 0_0.mpg -ss 00:10:00 -endpos 00:00:01
output = Popen(["mplayer", "-vo", "null", "-nosound", path, "-endpos", "00:00:01"], stdout=PIPE, stderr=STDOUT).communicate()[0]
linestart = output.index("VIDEO: ")
lineend = linestart + output[linestart:].index("\n")
#print "line start,end:", linestart, lineend
line = output[linestart:lineend]
#print "line:", line
words = line.split()
#print "words:", words
fpsIndex = words.index("fps") - 1
fps = float(words[fpsIndex])
return fps
示例7: get_foreground_app
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import index [as 别名]
def get_foreground_app():
foregroundAppCode = Popen(["lsappinfo", "front"], stdout=PIPE).stdout.read()
foregroundAppInfo = Popen(["lsappinfo", "info", "-only", "name", foregroundAppCode], stdout=PIPE).stdout.read()
return foregroundAppInfo[foregroundAppInfo.index('=') + 2:-2]