本文整理汇总了Python中Filter.applyTimeFilterOnFile方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.applyTimeFilterOnFile方法的具体用法?Python Filter.applyTimeFilterOnFile怎么用?Python Filter.applyTimeFilterOnFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter.applyTimeFilterOnFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import applyTimeFilterOnFile [as 别名]
def render(caseName, filePath, additionalFiles=[], type="png", start="", end="", xtics=""):
syslog.syslog("PCAP APP: renderGraph: started: " + str(datetime.datetime.now()))
colors = ["red", "black", "yellow", "green", "blue", "cyan", "orange", "violet"]
originFileName = helper.getDBNameFromPath(filePath)
dirpath = os.path.dirname(filePath) + "/tmp"
dirpath = CASES_DIR + caseName + TMP_DIR
shutil.copy(GRAPH_SCRIPT_DIR + "Makefile", dirpath)
if type == "png":
shutil.copy(GRAPH_SCRIPT_DIR + "throughput.gpi", dirpath + "/" + "throughput.gpi")
else:
shutil.copy(GRAPH_SCRIPT_DIR + "throughputDetail.gpi", dirpath + "/" + "throughput.gpi")
data = open(dirpath + "/" + os.path.basename(filePath) + ".data", "w")
syslog.syslog("PCAP APP: Processing file: " + filePath + " started: " + str(datetime.datetime.now()))
subprocess.call(["tshark", "-q", "-nr", filePath, "-t", "ad", "-z" "io,stat,1"], stdout=data)
syslog.syslog("PCAP APP: Processing file: " + filePath + " ended: " + str(datetime.datetime.now()))
script = open(dirpath + "/throughput.gpi", "a")
if xtics != "":
try:
xtics = int(xtics)
script.write("set xtics " + str(xtics) + "\n")
except ValueError:
pass
f = helper.getFilter(caseName, helper.getDBNameFromPath(filePath))
info = helper.getReadableFileInfo(helper.getDBNameFromPath(filePath), caseName)
if info[4]:
originFileName = info[4]
syslog.syslog("PCAP APP: " + helper.getDBNameFromPath(filePath))
plot = (
'plot "'
+ os.path.basename(data.name)
+ '" using 2:4 every ::13 with lines ls 1 lc rgb "'
+ colors[0]
+ '" title "'
+ originFileName
+ ", filter: "
+ f
+ '"'
)
syslog.syslog("PCAP APP: " + plot)
data.close()
i = 1
for file in additionalFiles:
filePath = CASES_DIR + caseName + PCAP_DIR + file
ret = Filter.applyTimeFilterOnFile(filePath, caseName, start, end)
if ret:
filePath = ret
dirpath = os.path.dirname(filePath)
data = open(dirpath + "/" + file.replace("/", "-") + ".data", "w")
syslog.syslog("PCAP APP: Processing file: " + file + " started: " + str(datetime.datetime.now()))
subprocess.call(["tshark", "-q", "-nr", filePath, "-t", "ad", "-z" "io,stat,1"], stdout=data)
syslog.syslog("PCAP APP: Processing file: " + file + " ended: " + str(datetime.datetime.now()))
info = helper.getReadableFileInfo(file, caseName)
f = helper.getFilter(caseName, file)
if info[4] != "n/a":
file = info[4]
plot += (
', "'
+ os.path.basename(data.name)
+ '" using 2:4 every ::13 with lines ls 1 lc rgb "'
+ colors[i % 8]
+ '" title "'
+ file
+ ",filter: "
+ f
+ '"'
)
data.close()
i += 1
script.write(plot)
script.close()
os.chdir(dirpath)
if type == "png":
subprocess.check_output(["make", "png"])
ret = dirpath + "/throughput.png"
else:
subprocess.check_output(["make"])
ret = dirpath + "/throughput.pdf"
syslog.syslog("PCAP APP: renderGraph: ended: " + str(datetime.datetime.now()))
return ret
示例2:
# 需要导入模块: import Filter [as 别名]
# 或者: from Filter import applyTimeFilterOnFile [as 别名]
# when applying filter on currently selected file, crete new tmp file
if "applyFilter" in actions:
start = form['start'].value if form.has_key('start') else ''
end = form['end'].value if form.has_key('end') else ''
if form.has_key('filterContent'):
filteredFileName = Filter.applyTmpFilter(form['filePath'].value, form['filterContent'].value, form['caseName'].value)
if filteredFileName:
form['filePath'].value = CASES_DIR + form['caseName'].value + TMP_DIR + filteredFileName
fileName = filteredFileName
else:
pagesToRender.remove(renderGraph)
message = "<strong>Error!</strong> Rendering graph Error, make sure you use right filter syntax."
messageType = "error"
if start and end:
ret = Filter.applyTimeFilterOnFile(form['filePath'].value, caseName, start, end, override = False)
form['filePath'].value = ret
if "uploadFile" in actions:
if form.has_key('caseName') and form.has_key('uploadFileItem'):
ret = saveFile.saveFile(form['caseName'].value, form['uploadFileItem'])
message = ret[0]
messageType = ret[1]
else:
message = "You have to choose a file."
if "deleteFile" in actions:
if form.has_key('clearTmp'):
helper.clearTmp(form['caseName'].value)
pagesToRender = ['case','saveFile']