本文整理汇总了Python中Analyzer.Analyzer.analyze方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer.analyze方法的具体用法?Python Analyzer.analyze怎么用?Python Analyzer.analyze使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer.Analyzer
的用法示例。
在下文中一共展示了Analyzer.analyze方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: runAnAnalyzer
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
def runAnAnalyzer(channels, baseCuts, infile, outdir,
maxEvents, intLumi, cleanRows, cutModifiers):
'''
Run an Analyzer.
Intended for use in threads, such that several processes all do this once.
'''
outfile = outdir+'/'+(infile.split('/')[-1])
try:
analyzer = Analyzer(channels, baseCuts, infile, outfile,
maxEvents, intLumi,
cleanRows, cutModifiers=cutModifiers)
# Exceptions won't print from threads without help
except Exception as e:
print "**********************************************************************"
print "EXCEPTION"
print "Caught exception:"
print e
print "While initializing analyzer for {} with base cuts {} and modifiers [{}]".format(infile, baseCuts, ', '.join(m for m in cutModifiers))
print "Killing task"
print "**********************************************************************"
return
try:
analyzer.analyze()
except Exception as e:
print "**********************************************************************"
print "EXCEPTION"
print "Caught exception:"
print e
print "While running analyzer for {} with base cuts {} and modifiers [{}]".format(infile, baseCuts, ', '.join(m for m in cutModifiers))
print "Killing task"
print "**********************************************************************"
return
示例2: analyze
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
def analyze(self, resource):
analysis = Analyzer.analyze(self, resource)
analysis.add_messages(self._lib_message_list)
if self._js_lint_proc_args is None:
analysis.mark_as_bad()
analysis.add_error('No suitable JSLint runner (cscript.exe, node.js or rhino) could be found.')
return analysis
try:
js_lint_proc = subprocess.Popen(self._js_lint_proc_args, -1, None, subprocess.PIPE,
subprocess.PIPE, subprocess.PIPE)
js_lint_proc_outputs = js_lint_proc.communicate(resource.content)
except Exception as e:
analysis.add_error("An exception what thrown while running JsLint: %s\n%s" %
(str(e), traceback.format_exc))
return analysis
# The JSLint process returns 1 if it finds lint
if js_lint_proc.returncode != 0 and js_lint_proc.returncode != 1:
analysis.add_error('The JSLint process exited with return code %d\nArguments: %s\n Output: %s'
% (js_lint_proc.returncode, self._js_lint_proc_args, js_lint_proc_outputs))
return analysis
analysis.mark_as_good() # Assume that JSLint produced no complaints until parsing one from the process output
for js_lint_proc_output in js_lint_proc_outputs:
js_lint_complaints = js_lint_proc_output.split("Lint at ")
for complaint in js_lint_complaints:
if len(complaint.strip()):
analysis.mark_as_bad()
js_lint_complaint = JsLintComplaint(complaint)
analysis.add_error(str(js_lint_complaint))
return analysis
示例3: run
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
def run(self,timeFrom = None,timeTo = None):
self.timeFrom = timeFrom
self.timeTo = timeTo
self.dataCenter = dataCenter.dataCenter()
feeds = self.dataCenter.getFeedsForPAT(dataProvider = self.dataProvider,storageType = self.storageType,instruments = self.instruments,
period=self.period,timeTo = timeTo,timeFrom=timeFrom)
self.feed = feeds[self.instrument]
#mid strategy
self.strat = dma_crossover.DMACrossOver(feed=self.feed, instrument=self.instrument,shortPeriod=self.shortPeriod,
longPeriod=self.longPeriod,money=self.money)
#self.strat.setUseAdjustedValues(False)
#mid results
self.initAnalyzer()
result = self.strat.run()
if(self.toPlot):
analyzer = Analyzer(Globals=[])
dataForCandle = dataCenter.getCandleData(dataProvider = self.dataProvider,dataStorage = self.storageType,dataPeriod = self.period,
symbol = self.instrument,dateStart=timeFrom,dateEnd = timeTo)
analyzer.analyze(result,dataForCandle)
self.analyzers.append(analyzer)
return result
示例4: analyze
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
def analyze(self, resource):
analysis = Analyzer.analyze(self, resource)
# This analyzer only computes the size of the content, it does not judge the quality
if resource.content:
lines = resource.content.split('\n')
else:
lines = []
analysis.mark_as_good()
if len(lines) == 1:
line_noun = 'line'
else:
line_noun = 'lines'
char_count = reduce(lambda count, x: count + len(x), lines, 0)
analysis.add_message('%s: %d characters in %d %s for %d bytes' % (resource.path_to_file, char_count, len(lines), line_noun, resource.size))
return analysis
示例5: SQLHandler
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
sql = SQLHandler()
reddit = Reddit()
analyzer = Analyzer()
count += 1
print "Beginning Iteration " + str(count)
print "Gathering Comments"
comments = reddit.getNewComments()
views = sql.getViews()
print "Processing Data"
for comment in comments:
flag = True
words = [x.lower().strip() for x in comment[0].split()]
thenorthan = thenOrThan(words)
for i in views:
if comment[1] == i[0]:
flag = False
break
if (flag):
flag = analyzer.analyze(sql, reddit, comment, words, thenorthan)
if (flag):
analyzer.processWordsForDB(sql, reddit, comment, words, thenorthan)
print "Sleeping for 1 minute"
time.sleep(60)
示例6: SimpleMonitor
# 需要导入模块: from Analyzer import Analyzer [as 别名]
# 或者: from Analyzer.Analyzer import analyze [as 别名]
class SimpleMonitor(Routing.SimpleSwitch):
LLDP_SEND_GUARD = .05
LLDP_SEND_PERIOD_PER_PORT = .9
TIMEOUT_CHECK_PERIOD = 5.
LINK_TIMEOUT = TIMEOUT_CHECK_PERIOD * 2
LINK_LLDP_DROP = 5
LLDP_PACKET_LEN = len(LLDPPacket.lldp_packet(0, 0, DONTCARE_STR, 0))
DEFAULT_TTL = 120
def __init__(self, *args, **kwargs):
super(SimpleMonitor, self).__init__(*args, **kwargs)
self.is_active = True
#Topology Discovery
self.link_discovery = True
self.port_state = {} # datapath_id => ports
self.ports = PortDataState() # Port class -> PortData class
self.links = LinkState() # Link class -> timestamp
self.link_length = 0
self.switch_ports = {}
self.dpid_to_ip = map_switch_dpid()
#NPS SDN Specific Dictionary##################################################
self.dpid_to_node = {0x00012c59e5107640:1, 0x0001c4346b94a200:2,\
0x0001c4346b99dc00:4, 0x0001c4346b946200:5,\
0x0001c4346b971ec0:6, 0x0001f0921c219d40:13}
##############################################################################
self.active_ips = {}
self.arp_table = {}
#SDN Application data structures
self.blacklist = []
self.throttle_list = []
#SDN Application Flags
#This call assigns self.analyze, self.topology,
#and self.fingerprint and sets up those apps
self._n_fingerprint = True
self._n_topology = True
self._n_analyze = True
self._load_settings()
#Listen for a signal that tells the controller to update
#its settings. This is really tempramental.
#signal.signal(signal.SIGUSR1, self._load_settings)
self.threads.append(hub.spawn(self._monitor))
self.threads.append(hub.spawn(self._listener))
self.throttle_list = []
def _load_settings(self, signal=None, frame=None):
print("Loading the settings file")
with open("control_node_settings", "r") as f:
for line in f.readlines():
exec(line)
# If the fingerprint app is checked to run and has not been run yet,
# then do all the following.
if self.fingerprint and self._n_fingerprint:
self._n_fingerprint = False
self.fingerprints = {}
self.fingerprint_list = createFingerPrintList('fingerprint.xml')
self.cluster = Cluster()
self.session = self.cluster.connect('fingerprints')
db = self.session.execute_async("select * from fpspat")
for row in db.result():
mac_addr = row.mac
self.fingerprints[mac_addr] = {'ip':row.ip, 'os':row.os,\
'switch':row.switch, 'port':row.port,\
'hostname':row.hostname, 'history':row.history}
print("Downloaded Fingerprint Database \n")
if self.analyze and self._n_analyze:
self.analyzer = Analyzer()
self._n_analyze = False
with open('V','w') as f:
f.flush()
with open('D','w') as f:
f.flush()
with open('L','w') as f:
f.flush()
if self.topology and self._n_topology:
self._n_topology = False
self.lldp_event = hub.Event()
self.link_event = hub.Event()
self.threads.append(hub.spawn(self.lldp_loop))
self.threads.append(hub.spawn(self.link_loop))
def _listener(self):
"""
This function will continuously open a file
named 'commands' and execute each line in
#.........这里部分代码省略.........