def shutdown(self):
     """Prepares the EQ to be closed."""
     self._inotify_notifier_gral.stop()
     self._inotify_notifier_antr.stop()
     reactor.removeReader(self._inotify_reader_gral)
     reactor.removeReader(self._inotify_reader_antr)
     self._processor.shutdown()
예제 #2
0
 def _delegateFD(self):
     # Take out the fd from twisted reactor and pass it to element
     # using it
     # See http://twistedmatrix.com/trac/ticket/1796
     reactor.removeReader(self._transport)
     self._gstElement.connectFd(self._fd)
     self._gstElement.emit('connected')
예제 #3
0
 def closeReader(self):
     if self.fd is not None:
         reactor.removeReader(self)
         self.fd.close()
         self.fd = None
         self.iterator = None
     return
예제 #4
0
    def connectionMade(self):
        sockFD = self.transport.fileno()
        childFDs = {0: sockFD, 1: sockFD}
        if self.factory.stderrFile:
            childFDs[2] = self.factory.stderrFile.fileno()

        # processes run by inetd expect blocking sockets
        # FIXME: maybe this should be done in process.py?  are other uses of
        #        Process possibly affected by this?
        fdesc.setBlocking(sockFD)
        if childFDs.has_key(2):
            fdesc.setBlocking(childFDs[2])

        service = self.factory.service
        uid = service.user
        gid = service.group

        # don't tell Process to change our UID/GID if it's what we
        # already are
        if uid == os.getuid():
            uid = None
        if gid == os.getgid():
            gid = None

        process.Process(None, service.program, service.programArgs, os.environ,
                        None, None, uid, gid, childFDs)

        reactor.removeReader(self.transport)
        reactor.removeWriter(self.transport)
예제 #5
0
파일: bluez.py 프로젝트: manuelnaranjo/AIRi
 def close(self):
     reactor.removeReader(self)
     self.sock.setblocking(True)
     self.sock.close()
     self.sock = None
     if self.address.lower() in SCOReader.clients:
         del SCOReader.clients[self.address.lower()]
예제 #6
0
파일: airidroid.py 프로젝트: aircable/AIRi
    def connectionLost(self, reason):
        self.socket.close()

        # stop monitoring this socket
        from twisted.internet import reactor

        reactor.removeReader(self)
예제 #7
0
파일: bluez.py 프로젝트: ygl-rg/AIRi
 def close(self):
     reactor.removeReader(self)
     self.sock.setblocking(True)
     self.sock.close()
     self.sock = None
     if self.address.lower() in SCOReader.clients:
         del SCOReader.clients[self.address.lower()]
예제 #8
0
 def shutdown(self):
     print 'shutting down database listener'
     reactor.removeReader(self)
     self.conn.close()
     self.conn = None
     self.corker.stop()
     self.corker = None
예제 #9
0
    def _handleNewClient(self, request):
        # everything fulfilled, serve to client
        fdi = request.fdIncoming
        if not self._writeHeaders(request):
            self.debug("[fd %5d] not adding as a client" % fdi)
            return

        # take over the file descriptor from Twisted by removing them from
        # the reactor
        # spiv told us to remove* on request.transport, and that works
        # then we figured out that a new request is only a Reader, so we
        # remove the removedWriter - this is because we never write to the
        # socket through twisted, only with direct os.write() calls from
        # _writeHeaders.

        # see http://twistedmatrix.com/trac/ticket/1796 for a guarantee
        # that this is a supported way of stealing the socket
        fd = fdi
        self.debug("[fd %5d] taking away from Twisted" % fd)
        reactor.removeReader(request.transport)
        #reactor.removeWriter(request.transport)

        # check if it's really an open fd (i.e. that twisted didn't close it
        # before the removeReader() call)
        try:
            fcntl.fcntl(fd, fcntl.F_GETFL)
        except IOError, e:
            if e.errno == errno.EBADF:
                self.warning("[fd %5d] is not actually open, ignoring" % fd)
            else:
                self.warning("[fd %5d] error during check: %s (%d)" % (
                    fd, e.strerror, e.errno))
            return
예제 #10
0
    def connectionMade(self):
        sockFD = self.transport.fileno()
        childFDs = {0: sockFD, 1: sockFD}
        if self.factory.stderrFile:
            childFDs[2] = self.factory.stderrFile.fileno()

        # processes run by inetd expect blocking sockets
        # FIXME: maybe this should be done in process.py?  are other uses of
        #        Process possibly affected by this?
        fdesc.setBlocking(sockFD)
        if childFDs.has_key(2):
            fdesc.setBlocking(childFDs[2])

        service = self.factory.service
        uid = service.user
        gid = service.group

        # don't tell Process to change our UID/GID if it's what we
        # already are
        if uid == os.getuid():
            uid = None
        if gid == os.getgid():
            gid = None

        process.Process(None, service.program, service.programArgs, os.environ,
                        None, None, uid, gid, childFDs)

        reactor.removeReader(self.transport)
        reactor.removeWriter(self.transport)
예제 #11
0
    def connectionLost(self, reason):
        self.sock.close()
        from twisted.internet import reactor

        reactor.removeReader(self)

        reactor.stop()
예제 #12
0
    def _handleNewClient(self, request):
        # everything fulfilled, serve to client
        fdi = request.fdIncoming
        if not self._writeHeaders(request):
            self.debug("[fd %5d] not adding as a client" % fdi)
            return

        # take over the file descriptor from Twisted by removing them from
        # the reactor
        # spiv told us to remove* on request.transport, and that works
        # then we figured out that a new request is only a Reader, so we
        # remove the removedWriter - this is because we never write to the
        # socket through twisted, only with direct os.write() calls from
        # _writeHeaders.

        # see http://twistedmatrix.com/trac/ticket/1796 for a guarantee
        # that this is a supported way of stealing the socket
        fd = fdi
        self.debug("[fd %5d] taking away from Twisted" % fd)
        reactor.removeReader(request.transport)
        #reactor.removeWriter(request.transport)

        # check if it's really an open fd (i.e. that twisted didn't close it
        # before the removeReader() call)
        try:
            fcntl.fcntl(fd, fcntl.F_GETFL)
        except IOError, e:
            if e.errno == errno.EBADF:
                self.warning("[fd %5d] is not actually open, ignoring" % fd)
            else:
                self.warning("[fd %5d] error during check: %s (%d)" %
                             (fd, e.strerror, e.errno))
            return
예제 #13
0
	def _close(self):
		if self.fd is not None:
			fd = self.fd
			self.fd = None
			reactor.removeReader(self)
			fd.close()
			fd = None
예제 #14
0
    def connectionLost(self, reason):
        self.sock.close()
        reactor.removeReader(self)

        try:
            reactor.stop()
        except Exception:
            pass
예제 #15
0
    def connectionLost(self,reason):
        self.sock.close()

        reactor.removeReader(self)

        for reader in reactor.getReaders():
            if isinstance(reader,PoetrySocket):
                return
        reactor.stop()
예제 #16
0
 def __del__(self):
     """ If the object dies, remove the reader for the reactor
     and clean up the fdesc if it's still open """
     reactor.removeReader(self)
     if hasattr(self, 'fdesc') and self.fdesc >= 0:
         try:
             os.close(self.fdesc)
         except OSError:
             pass
예제 #17
0
 def SCO_Data(self, sock, lost=False):
     if lost:
         reactor.removeReader(self.sco_socket)
         return
     self.buffer += sock.recv(bluetooth.sco_mtu)
     if len(self.buffer) >= 400:
         from airi.stream import MultiPartStream
         MultiPartStream.sendToClients(self.buffer,
                                       mime="application/octet-stream")
         self.buffer = ""
예제 #18
0
 def connectionLost(self, reason):
     self.sock.close()
     # stop monitoring this socket
     from twisted.internet import reactor
     reactor.removeReader(self)
     # see if there are any poetry sockets left
     for reader in reactor.getReaders():
         if isinstance(reader, PoetrySocket):
             return
     reactor.stop()  # no more poetry
예제 #19
0
    def release(self):
        reactor.removeReader(self)
        if hasattr(self, '_fd') and self._fd >= 0:
            try:
                os.close(self._fd)
            except OSError:
                pass

        if hasattr(INotify, '_instance_'):
            del INotify._instance_
예제 #20
0
 def SCO_Data(self, sock, lost=False):
     if lost:
         reactor.removeReader(self.sco_socket)
         return
     self.buffer += sock.recv(bluetooth.sco_mtu)
     if len(self.buffer) >= 400:
         from airi.stream import MultiPartStream
         MultiPartStream.sendToClients(self.buffer,
             mime="application/octet-stream")
         self.buffer = ""
예제 #21
0
	def doRead(self):
		reactor.removeReader(self)
		try:
			fd = recvfd(self.fd)[0]
		except Exception as e:
			self._close()
			self.proc.got_no_fd(e)
		else:
			self._close()
			self.proc.got_fd(fd)
예제 #22
0
    def connectionLost(self, reason):
        self.sock.close()

        from twisted.internet import reactor
        reactor.removeReader(self)

        for reader in reactor.getReaders():
            if isinstance(reader, PoetrySocket):
                return

        reactor.stop()
예제 #23
0
    def dataReceived(self, data):
        """
        Overridden to stop trying to read data while outputting a response.

        This stops netcat from quitting before it gets the output!
        """
        reactor.removeReader(self.reader)
        retval = LineOnlyReceiver.dataReceived(self, data)
        reactor.getThreadPool().callInThreadWithCallback(
            self.processLinesDone, self.processLines)
        return retval
예제 #24
0
    def dataReceived(self, data):
        """
        Overridden to stop trying to read data while outputting a response.

        This stops netcat from quitting before it gets the output!
        """
        reactor.removeReader(self.reader)
        retval = LineOnlyReceiver.dataReceived(self, data)
        reactor.getThreadPool().callInThreadWithCallback(
            self.processLinesDone, self.processLines)
        return retval
예제 #25
0
 def __del__(self):
     reactor.removeReader(self)
     if self.rd_fd >= 0:
         try:
             os.close(self.rd_fd)
         except OSError:
             pass
     if self.wr_fd >= 0:
         try:
             os.close(self.wr_fd)
         except OSError:
             pass
예제 #26
0
 def stopReading(self):
     """Remove this listener from the reactor."""
     try:
         reactor.removeReader(self)
     except IOError as error:
         # ENOENT here means that the fd has already been unregistered
         # from the underlying poller. It is as yet unclear how we get
         # into this state, so for now we ignore it. See epoll_ctl(2).
         if error.errno != ENOENT:
             raise
     finally:
         self.connectionFileno = None
예제 #27
0
    def connectionLost(self, reason):
        self.sock.close()
        reactor.removeReader(self)

        # see if there are any poetry sockets left
        for reader in reactor.getReaders():
            if isinstance(reader, RawSocket):
                return
        try:
            reactor.stop()  # no more poetry
        except Exception:
            pass
예제 #28
0
    def release(self):
        """
        Release the inotify file descriptor and do the necessary cleanup
        """
        reactor.removeReader(self)
        if hasattr(self, '_fd') and self._fd >= 0:
            try:
                os.close(self._fd)
            except OSError:
                pass

        if hasattr(INotify, '_instance_'):
            del INotify._instance_
예제 #29
0
    def release(self):
        """
        Release the inotify file descriptor and do the necessary cleanup
        """
        reactor.removeReader(self)
        if hasattr(self, '_fd') and self._fd >= 0:
            try:
                os.close(self._fd)
            except OSError:
                pass

        if hasattr(INotify, '_instance_'):
            del INotify._instance_
예제 #30
0
    def connectionLost(self, reason):
        self.sock.close()

        # stop monitoring this socket
        from twisted.internet import reactor
        reactor.removeReader(self)

        # see if there are any poetry sockets left
        for reader in reactor.getReaders():
            if isinstance(reader, PoetrySocket):
                return

        reactor.stop() # no more poetry
예제 #31
0
def socket_remove(id, condition=IO_READ):
    """
    Removes the IRead/WriteDescriptor object with this socket from
    the Twisted reactor.
    """
    global __sockobjs
    sockobj = __sockobjs[condition].get(id)

    if sockobj:
        if condition == IO_READ:
            reactor.removeReader(sockobj)
        elif condition == IO_WRITE:
            reactor.removeWriter(sockobj)
        del __sockobjs[condition][id]
예제 #32
0
def socket_remove(id, condition=IO_READ):
    """
    Removes the IRead/WriteDescriptor object with this socket from
    the Twisted reactor.
    """
    global __sockobjs
    sockobj = __sockobjs[condition].get(id)

    if sockobj:
        if condition == IO_READ:
            reactor.removeReader(sockobj)
        elif condition == IO_WRITE:
            reactor.removeWriter(sockobj)
        del __sockobjs[condition][id]
예제 #33
0
    def connectionLost(self, reason=None):
        self.sock.close()

        # Stop monitoring this socket
        from twisted.internet import reactor
        print("Reactor no longer monitored: %s" % reason)
        reactor.removeReader(self)

        # See if there are any poetry sockets left
        for reader in reactor.getReaders():
            if isinstance(reader, PoetrySocket):
                return

        reactor.stop()  # No more poetry
예제 #34
0
    def set_mode(self, mode_name, refresh=False):
        log.debug('Setting console mode: %s', mode_name)
        mode = self.modes.get(mode_name, None)
        if mode is None:
            log.error('Non-existent mode requested: %s', mode_name)
            return
        self.stdscr.erase()

        if self.active_mode:
            self.active_mode.pause()
            d = component.pause([self.active_mode.mode_name])

            def on_mode_paused(result, mode, *args):
                from deluge.ui.console.widgets.popup import PopupsHandler

                if isinstance(mode, PopupsHandler):
                    if mode.popup is not None:
                        # If popups are not removed, they are still referenced in the memory
                        # which can cause issues as the popup's screen will not be destroyed.
                        # This can lead to the popup border being visible for short periods
                        # while the current modes' screen is repainted.
                        log.error(
                            'Mode "%s" still has popups available after being paused.'
                            ' Ensure all popups are removed on pause!',
                            mode.popup.title,
                        )

            d.addCallback(on_mode_paused, self.active_mode)
            reactor.removeReader(self.active_mode)

        self.active_mode = mode
        self.statusbars.screen = self.active_mode

        # The Screen object is designed to run as a twisted reader so that it
        # can use twisted's select poll for non-blocking user input.
        reactor.addReader(self.active_mode)
        self.stdscr.clear()

        if self.active_mode._component_state == 'Stopped':
            component.start([self.active_mode.mode_name])
        else:
            component.resume([self.active_mode.mode_name])

        mode.resume()
        if refresh:
            mode.refresh()
        return mode
예제 #35
0
파일: inetd.py 프로젝트: fxia22/ASM_xf
def forkPassingFD(exe, args, env, user, group, fdesc):
    """Run exe as a child process, passing fdesc as fd 0.
    
    This will also make sure that fdesc is removed from the parent's reactor.
    """
    # This is half-cannibalised from twisted.internet.process.Process
    pid = os.fork()
    if pid == 0:    # Child
        try:
            # Close stdin/stdout (we keep stderr from the parent to report
            # errors with)
            for fd in range(2):
                os.close(fd)
            
            # Make the socket be fd 0 
            # (and fd 1, although I'm not sure if that matters)
            os.dup(fdesc.fileno())
            os.dup(fdesc.fileno())

            # Close unused file descriptors
            for fd in range(3, 256):
                try: os.close(fd)
                except: pass
            
            # Set uid/gid
            os.setgid(group)
            os.setuid(user)
            
            # Start the new process
            os.execvpe(exe, args, env)
        except:
            # If anything goes wrong, just die.
            stderr = os.fdopen(2, 'w')
            stderr.write('Unable to spawn child:\n')
            traceback.print_exc(file=stderr)

            # Close the socket so the client doesn't think it's still
            # connected to a server
            try:
                s = socket.fromfd(0, socket.AF_INET, socket.SOCK_STREAM)
                s.shutdown(2)
            except:
                pass
        os._exit(1)
    else:           # Parent
        reactor.removeReader(fdesc)
        reactor.removeWriter(fdesc)
    def test_getReaders(self):
        """
        Check that L{interfaces.IReactorFDSet.getReaders} reflects the actions
        made with L{interfaces.IReactorFDSet.addReader} and
        L{interfaces.IReactorFDSet.removeReader}.
        """
        s = socket.socket()
        self.addCleanup(s.close)

        c = Connection(s, protocol.Protocol())
        self.assertNotIn(c, reactor.getReaders())

        reactor.addReader(c)
        self.assertIn(c, reactor.getReaders())

        reactor.removeReader(c)
        self.assertNotIn(c, reactor.getReaders())
예제 #37
0
    def test_getReaders(self):
        """
        Check that L{interfaces.IReactorFDSet.getReaders} reflects the actions
        made with L{interfaces.IReactorFDSet.addReader} and
        L{interfaces.IReactorFDSet.removeReader}.
        """
        s = socket.socket()
        self.addCleanup(s.close)

        c = Connection(s, protocol.Protocol())
        self.assertNotIn(c, reactor.getReaders())

        reactor.addReader(c)
        self.assertIn(c, reactor.getReaders())

        reactor.removeReader(c)
        self.assertNotIn(c, reactor.getReaders())
예제 #38
0
    def set_mode(self, mode_name, refresh=False):
        log.debug('Setting console mode: %s', mode_name)
        mode = self.modes.get(mode_name, None)
        if mode is None:
            log.error('Non-existent mode requested: %s', mode_name)
            return
        self.stdscr.erase()

        if self.active_mode:
            self.active_mode.pause()
            d = component.pause([self.active_mode.mode_name])

            def on_mode_paused(result, mode, *args):
                from deluge.ui.console.widgets.popup import PopupsHandler
                if isinstance(mode, PopupsHandler):
                    if mode.popup is not None:
                        # If popups are not removed, they are still referenced in the memory
                        # which can cause issues as the popup's screen will not be destroyed.
                        # This can lead to the popup border being visible for short periods
                        # while the current modes' screen is repainted.
                        log.error('Mode "%s" still has popups available after being paused.'
                                  ' Ensure all popups are removed on pause!', mode.popup.title)
            d.addCallback(on_mode_paused, self.active_mode)
            reactor.removeReader(self.active_mode)

        self.active_mode = mode
        self.statusbars.screen = self.active_mode

        # The Screen object is designed to run as a twisted reader so that it
        # can use twisted's select poll for non-blocking user input.
        reactor.addReader(self.active_mode)
        self.stdscr.clear()

        if self.active_mode._component_state == 'Stopped':
            component.start([self.active_mode.mode_name])
        else:
            component.resume([self.active_mode.mode_name])

        mode.resume()
        if refresh:
            mode.refresh()
        return mode
예제 #39
0
    def startFeed(self, request):
        fdi = request.fdIncoming
        fd = request.transport.fileno()
        self._request[fd] = request
        print("2--> reached startFeed {0}".format(fd))

        if self._writeHeaders(request):
            print "4--> removing reader"
            reactor.removeReader(request.transport)
        else:
            print "removeReader error"
            return

        try:
            fcntl.fcntl(fd, fcntl.F_GETFL)
        except IOError:
            print "fcntl error"
            return

        self.streamer.add_client(fd)
예제 #40
0
    def connectionLost(self, reason):
        # Called when the connection is lost

        # This is called when the connection on a selectable object has been
        # lost.  It will be called whether the connection was closed explicitly,
        # an exception occurred in an event handler, or the other end of the
        # connection closed it first.
        
        self.sock.close()  # Close the socket and its associated file descriptor

        # stop monitoring this socket
        from twisted.internet import reactor
        reactor.removeReader(self)  # Remove this object from the monitored reader FDs

        # see if there are any poetry sockets left
        for reader in reactor.getReaders():
            if isinstance(reader, PoetrySocket):
                return

        reactor.stop()  # no more readers, no more poetry
예제 #41
0
	def startFeed(self,request):
		fdi = request.fdIncoming
		fd = request.transport.fileno()
		self._request[fd] = request
		print("2--> reached startFeed {0}".format(fd))
		
		if self._writeHeaders(request):
			print "4--> removing reader"
			reactor.removeReader(request.transport)
		else:
			print "removeReader error"
			return 
		
		try:
			fcntl.fcntl(fd,fcntl.F_GETFL)
		except IOError:
			print "fcntl error"
			return
		
		self.streamer.add_client(fd)
예제 #42
0
def updateReactor():
    "Add/remove event handlers for SNMP file descriptors and timers"

    fds, t = netsnmp.snmp_select_info()
    if log.getEffectiveLevel() < logging.DEBUG:
        log.debug('reactor settings: %r, %r', fds, t)
    for fd in fds:
        if fd not in fdMap:
            reader = SnmpReader(fd)
            fdMap[fd] = reader
            reactor.addReader(reader)
    current = set(fdMap.keys())
    need = set(fds)
    doomed = current - need
    for d in doomed:
        reactor.removeReader(fdMap[d])
        del fdMap[d]
    if timer.callLater:
        timer.callLater.cancel()
        timer.callLater = None
    if t is not None:
        timer.callLater = reactor.callLater(t, checkTimeouts)
예제 #43
0
def updateReactor():
    "Add/remove event handlers for SNMP file descriptors and timers"

    fds, t = netsnmp.snmp_select_info()
    if log.getEffectiveLevel() < logging.DEBUG:
        log.debug('reactor settings: %r, %r', fds, t)
    for fd in fds:
        if fd not in fdMap:
            reader = SnmpReader(fd)
            fdMap[fd] = reader
            reactor.addReader(reader)
    current = set(fdMap.keys())
    need = set(fds)
    doomed = current - need
    for d in doomed:
        reactor.removeReader(fdMap[d])
        del fdMap[d]
    if timer.callLater:
        timer.callLater.cancel()
        timer.callLater = None
    if t is not None:
        timer.callLater = reactor.callLater(t, checkTimeouts)
예제 #44
0
 def stop_reading(self):
     """Unregister with the Twisted reactor."""
     reactor.removeReader(self)
예제 #45
0
 def pauseProducing(self):
     reactor.removeReader(self)
	def closeReader(self):
		if self.fd is not None:
			reactor.removeReader(self)
			self.fd.close()
			self.fd = None
			self.iterator = None
예제 #47
0
 def destroy(self):
     '''Convenience, not in twisted classes.'''
     TIreactor.removeReader(self)
     self.loseConnection()
예제 #48
0
 def shutdown(self):
     reactor.removeReader(self)
     self.socket.close()
예제 #49
0
 def set_mode(self, mode):
     reactor.removeReader(self.screen)
     self.screen = mode
     self.statusbars.screen = self.screen
     reactor.addReader(self.screen)
     mode.refresh()
예제 #50
0
파일: twistedr.py 프로젝트: hardys/eventlet
 def remove(self, descriptor):
     from twisted.internet import reactor
     reactor.removeReader(descriptor)
     reactor.removeWriter(descriptor)
예제 #51
0
 def disableSCO(self):
     if not self.sco_socket:
         return
     self.sco_socket.close()
     reactor.removeReader(self.sco_socket)
     self.sco_socket = None
예제 #52
0
 def stop(self):
     if self.__fd is not None:
         from twisted.internet import reactor
         reactor.removeReader(self)
         self.__fd.close()
         self.__fd = None
예제 #53
0
 def close(self):
     print "Closing descriptor."
     reactor.removeReader(self)
     self.pcap.open_dead(0, 0)
     self.pcap = None
     self.parent = None
예제 #54
0
 def connectionLost(self, unused):
     reactor.removeReader(self)
     self._protocol.close()
예제 #55
0
    def doRead(self):
        c= self.stdscr.getch()
        if self.state == 0:
            if c == curses.KEY_DOWN:
                if self.current_connection >= self.displayed_connections:
                    self.current_connection = 0
                else:
                    self.current_connection = self.current_connection + 1
                self.show()
            elif c == curses.KEY_UP:
                if self.current_connection == 0:
                    self.current_connection = self.displayed_connections
                else:
                    self.current_connection = self.current_connection - 1
                self.show()
            elif c == curses.KEY_ENTER or c == 10:
                # if new connection, ask for username, password, hostname etc.
                if self.current_connection == self.displayed_connections:
                    curses.curs_set(1)
                    self.current_input = self.inputs[1]
                    self.state = 1
                    self.display_current_input_line()
                else:
                    # ok a recent connection has been selected
                    curses.curs_set(1)
                    c = self.connections[self.current_connection]
                    info = c.info
                    reactor.removeReader(self)
                    connection.connect_to_manager(self.stdscr, info)
        else:
            if c == curses.KEY_ENTER or c == 10:
                if self.state < 6:
                    self.inputs[self.state] = self.current_input
                if self.state < 5:
                    self.current_input = self.inputs[self.state+1]
                    self.state = self.state + 1
                    self.display_current_input_line()
                else:
                    # connect
                    reactor.removeReader(self)
                    try:
                        port = int(self.inputs[2])
                    except ValueError:
                        port = 7531
                    info = PBConnectionInfo(self.inputs[1], port,
                      self.inputs[3] == 'Yes', fpb.Authenticator(
                        username=self.inputs[4], password=self.inputs[5]))

                    connection.connect_to_manager(self.stdscr, info)
                    pass
            elif c == curses.KEY_BACKSPACE or c == 127:
                self.current_input = self.current_input[:-1]
                self.display_current_input_line()
            elif c == curses.KEY_UP:
                if self.state > 0:
                    self.current_input = self.inputs[self.state-1]
                    self.state = self.state - 1
                if self.state == 0:
                    # turn off cursor
                    curses.curs_set(0)
                self.display_current_input_line()
            elif c == curses.KEY_DOWN:
                pass
            else:
                self.current_input = self.current_input + chr(c)
                self.display_current_input_line()
예제 #56
0
파일: dnspion.py 프로젝트: zarat/scripts
 def connectionLost(self, reason):
     reactor.removeReader(self)
예제 #57
0
    def doRead(self):
        c = self.stdscr.getch()
        if self.state == 0:
            if c == curses.KEY_DOWN:
                if self.current_connection >= self.displayed_connections:
                    self.current_connection = 0
                else:
                    self.current_connection = self.current_connection + 1
                self.show()
            elif c == curses.KEY_UP:
                if self.current_connection == 0:
                    self.current_connection = self.displayed_connections
                else:
                    self.current_connection = self.current_connection - 1
                self.show()
            elif c == curses.KEY_ENTER or c == 10:
                # if new connection, ask for username, password, hostname etc.
                if self.current_connection == self.displayed_connections:
                    curses.curs_set(1)
                    self.current_input = self.inputs[1]
                    self.state = 1
                    self.display_current_input_line()
                else:
                    # ok a recent connection has been selected
                    curses.curs_set(1)
                    c = self.connections[self.current_connection]
                    info = c.info
                    reactor.removeReader(self)
                    connection.connect_to_manager(self.stdscr, info)
        else:
            if c == curses.KEY_ENTER or c == 10:
                if self.state < 6:
                    self.inputs[self.state] = self.current_input
                if self.state < 5:
                    self.current_input = self.inputs[self.state + 1]
                    self.state = self.state + 1
                    self.display_current_input_line()
                else:
                    # connect
                    reactor.removeReader(self)
                    try:
                        port = int(self.inputs[2])
                    except ValueError:
                        port = 7531
                    info = PBConnectionInfo(
                        self.inputs[1], port, self.inputs[3] == 'Yes',
                        fpb.Authenticator(username=self.inputs[4],
                                          password=self.inputs[5]))

                    connection.connect_to_manager(self.stdscr, info)
                    pass
            elif c == curses.KEY_BACKSPACE or c == 127:
                self.current_input = self.current_input[:-1]
                self.display_current_input_line()
            elif c == curses.KEY_UP:
                if self.state > 0:
                    self.current_input = self.inputs[self.state - 1]
                    self.state = self.state - 1
                if self.state == 0:
                    # turn off cursor
                    curses.curs_set(0)
                self.display_current_input_line()
            elif c == curses.KEY_DOWN:
                pass
            else:
                self.current_input = self.current_input + chr(c)
                self.display_current_input_line()
예제 #58
0
 def pauseProducing(self):
     log.msg("pauseProducing")
     reactor.removeReader(self)