def __init__(self, req_handler, cnsconn): self.loop = pyev.Loop() self.watchers = [] self.req_handler = req_handler self.cnsconn = cnsconn self.watchers.append(self.loop.io(req_handler.rfile._sock, pyev.EV_READ, self.__on_rfile_io)) self.watchers.append(self.loop.io(cnsconn._sock, pyev.EV_READ, self.__on_cns_io))
def __init__(self): self.loop = pyev.Loop() self.sock, self.sock2 = socket.socketpair() self.sock.setblocking(False) self.sock2.setblocking(False) self.watcher = self.loop.io(self.sock.fileno(), pyev.EV_READ, lambda *args: 0) self.initial_session() self.operations = []
def setUp(self): self.loop = pyev.Loop() self.keyobj = security.get_keyobj( pem=resource_string("fluxmonitor", "data/test/private_1.pem")) keyobj = security.get_keyobj( der=resource_string("fluxmonitor", "data/test/public_1.pem")) security.add_trusted_keyobj(keyobj=keyobj) self.access_id = security.get_access_id(keyobj=keyobj)
def server_run(sock, service, handler): """运行thrift server""" thread_info = ThreadInfo(sock, service, handler) main_loop = pyev.Loop(0, data=thread_info) io_watcher = pyev.Io(sock, pyev.EV_READ, main_loop, on_request) io_watcher.start() stop_watcher = pyev.Signal(signal.SIGINT, main_loop, on_stop, priority=5) stop_watcher.start() main_loop.start()
def setUp(self): host = socket.socket() host.bind(("127.0.0.1", 0)) host.listen(1) self.client_sock = cs = socket.socket() cs.setblocking(False) cs.connect_ex(host.getsockname()) self.serverSock, self.clientEndpoint = host.accept() host.close() self.loop = pyev.Loop() _prepare_cert() s = Storage("security", "private") self.certfile = s.get_path("cert.pem") self.keyfile = s.get_path("sslkey.pem")
def __init__(self, datafile, probespath, probe_confs): self.active = False self.active_probes = 0 self.probespath = probespath self.loop = pyev.Loop() #self.queue = Queue() # initialize and start a idle watcher #self.idle_watcher = pyev.Idle(self.loop, self.idle_cb) #self.idle_watcher.start() # initialize and start a signal watchers sigterm_watcher = pyev.Signal(signal.SIGTERM, self.loop, self.sigterm_cb) sigterm_watcher.start() sigint_watcher = pyev.Signal(signal.SIGINT, self.loop, self.sigint_cb) sigint_watcher.start() self.loop.data = [sigterm_watcher, sigint_watcher] #self.loop.data.append(self.idle_watcher) # initialize storage logging.info("Init storage...") self.storage = Storage(datafile) # read in probes from config self.probes = [] index = 0 for probe_conf in probe_confs: self.check_command(probe_conf) self.check_data_type(probe_conf) self.check_dummy(probe_conf) # load filters self.load_filters(probe_conf) # load error filters self.load_error_filters(probe_conf) p = self.get_probe(index, self.storage, probe_conf, -1) p.register(self.loop) self.probes.append(p) if probe_conf.get("auto_start", False): self.start_probe(index) index = index + 1
def __init__(self, iface, essid, bssid, channel, beacon_interval_sec, packet_callback): self.active = False self.iface = iface self.essid = essid self.bssid = bssid self.channel = channel self.beacon_interval_sec = beacon_interval_sec self.packet_callback = packet_callback self.start_time_secs = time.time() self.sc = 0 self.sender = PacketSender(self.iface) self.beacon_packet = dot11.Dot11(addr1='ff:ff:ff:ff:ff:ff', \ addr2=self.bssid, \ addr3=self.bssid) \ / dot11.Dot11Beacon(cap='ESS+privacy') \ / dot11.Dot11Elt(ID='SSID', \ info=self.essid) \ / dot11.Dot11Elt(ID='DSset', \ info=chr(self.channel)) \ / dot11.Dot11Elt(ID='Rates', \ info='\x82\x84\x0b\x16') \ / dot11.Dot11Elt(ID='RSNinfo', info='\x01\x00\x00\x0f\xac' \ '\x04\x01\x00\x00\x0f' \ '\xac\x04\x01\x00\x00' \ '\x0f\xac\x02\x00\x00') self.watchers = { "interval": None, "timeout": None } self.loop = pyev.Loop() # initialize and start a signal watchers sigterm_watcher = pyev.Signal(signal.SIGTERM, self.loop, self.sigterm_cb) sigterm_watcher.start() sigint_watcher = pyev.Signal(signal.SIGINT, self.loop, self.sigint_cb) sigint_watcher.start() self.loop.data = [sigterm_watcher, sigint_watcher] self.sniff_thread = Thread(target=self.sniff, kwargs=dict(), name='sniff-thread') self.sniff_thread.setDaemon(True)
def __init__(self,name,in_q,out_q): multiprocessing.Process.__init__(self,group=None,name=name) self.in_q = in_q self.out_q = out_q self.loop = pyev.Loop(flags=pyev.recommended_backends()) self.watchers = [] self.client_count = 0 self.in_q_fd = self.in_q._reader.fileno() self.watchers.append(pyev.Io(self.in_q_fd, pyev.EV_READ, self.loop, self.in_q_cb)) self.cnxns = {} logging.debug("ServerWorker[{0}:{1}]: Instantiated.".format(os.getpid(),self.name))
def __init__(self, config): self.active = False self.config = config self.watcher = None self.loop = pyev.Loop() # initialize and start a signal watchers sigterm_watcher = pyev.Signal(signal.SIGTERM, self.loop, self.sigterm_cb) sigterm_watcher.start() sigint_watcher = pyev.Signal(signal.SIGINT, self.loop, self.sigint_cb) sigint_watcher.start() self.loop.data = [sigterm_watcher, sigint_watcher] # init GPIO GPIO.setmode(GPIO.BCM) GPIO.setup(config['GPIO_in'], GPIO.IN) GPIO.setup(config['GPIO_out'], GPIO.OUT, initial=GPIO.HIGH)
def __init__(self, callback=None, timeout=1.0, packet_limit=1000, packet_size=64): self.callback = callback self._timeout = timeout self._last_packet_timestamp = 0 self._packet_limit = packet_limit self._packet_size = packet_size self._hosts = [] self._id = 0 self._seq = 0 self._pending_hosts = [] self._packets = {} self._socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, ICMP) self._loop = pyev.Loop() self._io_watcher = self._loop.io( self._socket, pyev.EV_READ, self._on_receive ) self._idle_watcher = self._loop.idle(self._on_idle)
def __init__(self): self.loop = pyev.Loop(debug=True) self.loop.data = VirtualKernal()