本文整理汇总了Python中subprocess.Popen.match方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.match方法的具体用法?Python Popen.match怎么用?Python Popen.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类subprocess.Popen
的用法示例。
在下文中一共展示了Popen.match方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FeatureCompute
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import match [as 别名]
def FeatureCompute(currentdirname):
for (thisDir, subsHere, filesHere) in os.walk(currentdirname):
for filename in filesHere:
(shortname, extension) = os.path.splitext(filename)
pcapfullname = os.path.join(thisDir,filename)
#featurefilename =
if( os.path.isfile(pcapfullname) and (extension==".pcap" or extension == ".PCAP" ) ):
#fullfeaturefilename=pcapfullname+".arff"
#cmd1_s= "rm %s" % (APPCONFIG.GlobalConfig['tmp_arff_filename'])
if os.path.isfile(APPCONFIG.GlobalConfig['tmp_arff_filename']):
os.remove(APPCONFIG.GlobalConfig['tmp_arff_filename'])
cmd1_s='OpenDPI_demo -f %s' % pcapfullname
p = Popen(cmd1_s, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT,close_fds=True)
output = p.stdout.read()
prog=re.compile("###.*###")
m = prog.search(output)
p = re.compile('[a-zA-Z0-9,[email protected]#_]')
app_str_limited=''
for i in m.group(0):
if p.match(i):
app_str_limited+=i
else:
app_str_limited+='='
appfilename=pcapfullname+"."+app_str_limited+".arff"
logging.info ("computing feature to: %s" % appfilename)
cmd2_s= "netmate -f %s" % (pcapfullname )
cmd3_s= "mv %s %s"%(APPCONFIG.GlobalConfig['tmp_arff_filename'],appfilename)
#os.system(cmd1_s)
#os.system(cmd2_s)
#os.system(cmd3_s)
allcmd_s=("%s && %s"%(cmd2_s,cmd3_s))
os.system(allcmd_s)
else:
logging.info ("%s is not a directory" % pcapfullname )
pass
示例2: Popen
# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import match [as 别名]
#!/bin/python
import re
import subprocess
from subprocess import Popen
p = Popen(["xsel", "-o"], stdout=subprocess.PIPE)
output, err = p.communicate()
out = str(output).replace("b'", "").replace("\\n'", "")
words = out.split(" ")
p = re.compile(r"^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\.-]*)*\/?")
for word in words:
#print(word)
#print(p.findall(word))
if p.match(word) != None:
# print(word)
subprocess.call(["xdg-open", word])