本文整理汇总了Python中scanner.Scanner.start方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.start方法的具体用法?Python Scanner.start怎么用?Python Scanner.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scanner.Scanner
的用法示例。
在下文中一共展示了Scanner.start方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: raw_input
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import start [as 别名]
from scanner import Scanner
if __name__=='__main__':
url = raw_input('Enter a starting url from which to dig: ');
scan = Scanner();
scan.start(url);
示例2: Speccy
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import start [as 别名]
class Speccy(object):
heatmap = {}
max_per_freq = {}
freq_min = 2402.0
freq_max = 2472.0
power_min = -110.0
power_max = -20.0
last_x = freq_max
mpf_gen = 0
mpf_gen_tbl = {}
hmp_gen = 0
hmp_gen_tbl = {}
show_envelope = True
show_heatmap = True
lastframe = 0
redraws = 0
color_map = None
sf = None
def __init__(self, iface):
self.color_map = self.gen_pallete()
self.scanner = Scanner(iface)
fn = '%s/spectral_scan0' % self.scanner.get_debugfs_dir()
self.sf = spectrum_file.open(fn)
def quit(self, *args):
Gtk.main_quit()
def cleanup(self, *args):
self.scanner.stop()
def on_key_press(self, w, event):
key = Gdk.keyval_name(event.keyval)
if key == 's':
self.show_heatmap = not self.show_heatmap
elif key == 'l':
self.show_envelope = not self.show_envelope
elif key == 'q':
self.quit()
def gen_pallete(self):
# create a 256-color gradient from blue->green->white
start_col = (0.1, 0.1, 1.0)
mid_col = (0.1, 1.0, 0.1)
end_col = (1.0, 1.0, 1.0)
colors = [0] * 256
for i in range(0, 256):
if i < 128:
sf = (128.0 - i) / 128.0
sf2 = i / 128.0
colors[i] = (start_col[0] * sf + mid_col[0] * sf2,
start_col[1] * sf + mid_col[1] * sf2,
start_col[2] * sf + mid_col[2] * sf2)
else:
sf = (256.0 - i) / 128.0
sf2 = (i - 128.0) / 128.0
colors[i] = (mid_col[0] * sf + end_col[0] * sf2,
mid_col[1] * sf + end_col[1] * sf2,
mid_col[2] * sf + end_col[2] * sf2)
return colors
def sample_to_viewport(self, freq, power, wx, wy):
# normalize both frequency and power to [0,1] interval, and
# then scale by window size
freq_normalized = (freq - self.freq_min) / (self.freq_max - self.freq_min)
freq_scaled = freq_normalized * wx
power_normalized = (power - self.power_min) / (self.power_max - self.power_min)
power_scaled = power_normalized * wy
# flip origin to bottom left for y-axis
power_scaled = wy - power_scaled
return (freq_scaled, power_scaled)
def draw_centered_text(self, cr, text, x, y):
x_bearing, y_bearing, width, height = cr.text_extents(text)[:4]
cr.move_to(x - width / 2 - x_bearing, y - height / 2 - y_bearing)
cr.show_text(text)
def draw_grid(self, cr, wx, wy):
# clear the viewport with a black rectangle
cr.rectangle(0, 0, wx, wy)
cr.set_source_rgb(0, 0, 0)
cr.fill()
cr.set_source_rgb(1, 1, 1)
cr.set_line_width(0.5)
cr.set_dash([2.0, 2.0])
for freq in range(int(self.freq_min), int(self.freq_max), 5):
sx, sy = self.sample_to_viewport(freq, self.power_min, wx, wy)
ex, ey = self.sample_to_viewport(freq, self.power_max, wx, wy)
cr.move_to(sx, sy)
cr.line_to(ex, ey)
cr.stroke()
#.........这里部分代码省略.........
示例3: AthBenchmark
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import start [as 别名]
class AthBenchmark(object):
def __init__(self, iface):
self.scanner = Scanner(iface)
fn = '%s/spectral_scan0' % self.scanner.get_debugfs_dir()
self.file_reader = SpectrumFileReader(fn)
self.interface = iface
def get_samples(self, duration):
sps = 0
end = datetime.now() + timedelta(seconds=duration)
while datetime.now() < end:
try:
ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
except Queue.Empty:
continue
sps += len(samples) / (17 + 56) # (header + payload in HT20)
print "total: %d sps" % sps
sps /= float(duration)
return sps
# count samples in chanscan
def benchmark_chanscan(self, duration=5, samplecount=8):
print "\nrun benchmark chanscan with samplecount=%d, duration=%d " % (samplecount, duration)
self.scanner.cmd_set_samplecount(samplecount)
self.scanner.mode_chanscan()
self.scanner.start()
sps = self.get_samples(duration=duration)
self.scanner.stop()
self.file_reader.flush()
print "%.2f sps, chanscan" % sps
return sps
# count samples in bg mode (w/o) load
def benchmark_background(self, duration=5):
print "\nrun benchmark background with duration=%d " % duration
self.scanner.mode_noninvasive_background()
self.scanner.dev_add_monitor()
self.scanner.start()
sps = self.get_samples(duration=duration)
self.scanner.stop()
self.file_reader.flush()
print "%.2f sps, background scan " % sps
return sps
def benchmark_manual(self, samplecount=127):
print "\nrun benchmark manual with samplecount=%d " % samplecount
self.scanner.mode_manual()
self.scanner.cmd_manual()
self.scanner.cmd_set_samplecount(samplecount)
self.scanner.dev_add_monitor()
self.scanner.cmd_trigger()
sps = 0
reread = 3
while reread:
try:
ts, samples = self.file_reader.sample_queue.get(timeout=0.1)
sps += len(samples) / (17 + 56) # (header + payload in HT20)
except Queue.Empty:
pass
reread -= 1
self.scanner.stop()
self.file_reader.flush()
print "got %d samples in manual mode" % sps
return sps
def main(self):
samplecount = [1, 10, 50, 100, 150, 200, 255]
for sc in samplecount:
sps = self.benchmark_chanscan( duration=5, samplecount=sc)
print "sps / samplecount: %.2f" % (sps / sc)
time.sleep(0.2)
self.benchmark_background(duration=5)
time.sleep(0.2)
self.benchmark_manual(samplecount=127)
time.sleep(0.2)
self.cleanup()
def cleanup(self):
# self.scanner.stop()
self.file_reader.stop()
示例4: Widget
# 需要导入模块: from scanner import Scanner [as 别名]
# 或者: from scanner.Scanner import start [as 别名]
class Widget(QDialog):
SCAN_BUTTON_TEXT = '&Scan'
SCAN_BUTTON_PAUSE_TEXT = '&Pause'
SCAN_BUTTON_RESUME_TEXT = '&Resume'
INIT_PATH = 'E:/Movie'
#INIT_PATH = '.'
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
self.setWindowTitle('File Scanner')
self.scanningList = QTextEdit()
self.dirEdit = QLineEdit()
self.openButton = QPushButton('&Open')
self.scanButton = QPushButton(self.SCAN_BUTTON_TEXT)
self.stopButton = QPushButton('Stop')
self.scanningList.setReadOnly(True)
self.dirEdit.setEnabled(False)
self.scanButton.setEnabled(False)
self.stopButton.setEnabled(False)
self.openButton.clicked.connect(self.openDir)
self.scanButton.clicked.connect(self.onScanButtonClicked)
self.stopButton.clicked.connect(self.stopScan)
lt = QVBoxLayout()
lt.addWidget(self.scanningList)
lt_ = QHBoxLayout()
lt_.addWidget(self.dirEdit)
lt_.addWidget(self.openButton)
lt_.addWidget(self.scanButton)
lt_.addWidget(self.stopButton)
lt.addLayout(lt_)
self.setLayout(lt)
self.controlEvent = threading.Condition()
self.status = ['stopped']
self.idleTimer = QTimer()
self.idleTimer.setInterval(0)
self.idleTimer.timeout.connect(self.onIdle)
if not os.path.exists(self.INIT_PATH):
self.INIT_PATH = '.'
self.openDir(QDir(self.INIT_PATH).canonicalPath())
def onScanButtonClicked(self):
if self.status[0] == 'stopped':
self.scanDir()
elif self.status[0] == 'running':
self.pauseScan()
elif self.status[0] == 'paused':
self.resumeScan()
def openDir(self, path=None):
if path is None:
path = QFileDialog.getExistingDirectory()
if path:
self.dirEdit.setText(path)
self.scanButton.setEnabled(True)
def scanDir(self):
self.scanningList.clear()
path = self.dirEdit.text()
# construct a new scanner every time
# so we won't bother ungot items if we do a premature stop
self.scanner = Scanner(path, self.controlEvent, self.status)
self.fpathsQueue = self.scanner.queue
self.status[0] = 'running'
self.scanButton.setText(self.SCAN_BUTTON_PAUSE_TEXT)
self.stopButton.setEnabled(True)
self.idleTimer.start()
self.scanner.start()
def pauseScan(self):
with self.controlEvent:
self.status[0] = 'paused'
self.idleTimer.stop()
self.scanButton.setText(self.SCAN_BUTTON_RESUME_TEXT)
def resumeScan(self):
with self.controlEvent:
self.status[0] = 'running'
self.idleTimer.start()
self.controlEvent.notifyAll()
self.scanButton.setText(self.SCAN_BUTTON_PAUSE_TEXT)
def stopScan(self):
# stop idle so we won't get item from the fpathQueue anymore
self.idleTimer.stop()
# trigger the event
with self.controlEvent:
self.status[0] = 'stopped'
#.........这里部分代码省略.........