def getFile(filename): with open(filename) as f: d = Deferred() fd = f.fileno() setNonBlocking(fd) readFromFD(fd, d.callback) return d
def getConf(self): try: logger.debug("Getting config file") with open(self.configPath) as f: fd = f.fileno() setNonBlocking(fd) readFromFD(fd, self.runConf) except IOError, e: self.d.errback(e)
def doRead(self): """ Called when my standard output stream is ready for reading. """ return fdesc.readFromFD( self.fd, lambda data: self.proto.childDataReceived(1, data))
def test_readFromEmpty(self): """ Verify that reading from a file descriptor with no data does not raise an exception and does not result in the callback function being called. """ l = [] result = fdesc.readFromFD(self.r, l.append) self.assertEqual(l, []) self.assertEqual(result, None)
def doRead(self): if self.direction == 'in': def _read_cb(data): return self.protocol.dataReceived(data.strip()) f = self._fds['gpio_node'] f.seek(0) return fdesc.readFromFD(f.fileno(), _read_cb)
def get_raw_data(cls, *args): if not cls.FILE_OBJ: cls.make_non_blocking_fdesc() d = Deferred() file_obj = cls.FILE_OBJ result = readFromFD(file_obj.fileno(), d.callback) file_obj.seek(0) cls.check_fdesc(result) return d
def read(self): """ Read data from the pipe. """ l = [] res = fdesc.readFromFD(self.r, l.append) if res is None: if l: return l[0] else: return b"" else: return res
def process(self): self.setHeader('Content-Type', 'text/html') if self.path[-1] == '/': self.path+="index.html" cwd = os.path.abspath(os.curdir) requested_path = os.path.relpath(self.path[1:], cwd) requested_path = os.path.abspath(requested_path) if (os.path.commonprefix([requested_path, cwd])!=cwd): self.setResponseCode(http.NOT_FOUND) self.write("<h1>404 Not Found</h1>") return if (os.path.islink(s.path[1:])): self.setResponseCode(http.NOT_FOUND) self.write("<h1>404 Not Found</h1>") return try: self.setResponseCode(200) f = open(self.path[1:]) d = Deferred() fd = f.fileno() fdesc.setNonBlocking(fd) d.addCallback(lambda data: self.write(data)) fdesc.readFromFD(fd, d.callback) except IOError: self.setResponseCode(http.NOT_FOUND) self.write("<h1>404 Not Found</h1>") self.finish()
def doRead(self): """ Read some bytes from the pipe and discard them. """ fdesc.readFromFD(self.fileno(), lambda data: None)
def doRead(self): """Some data's readable from serial device. """ return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
def doRead(self): fdesc.readFromFD(self._fd, self.protocol.dataReceived)
def doRead(self): """ This is called when the pipe becomes readable. """ return fdesc.readFromFD(self.fd, self.dataReceived)
def doRead(self): try: setBlocking(False,0) return fdesc.readFromFD(0, self.dataReceived) finally: fdesc.setBlocking(True,0)
def doRead(self): """ Some data's readable from serial device. """ return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
def read_whitelist(self): fd = os.open(Conf.static_whitelist, os.O_RDONLY | os.O_CREAT) fdesc.readFromFD(fd, self.process_whitelist)
def doRead(self): """ Read some data from the observed file descriptors """ fdesc.readFromFD(self._fd, self._doRead)
def doRead(self): print '~~~~~~~~~~~~~~~~~~~~~~~~~' fdesc.readFromFD(self.tunfd, self._doRead) print '~~~~~~~~~~~~~~~~~~~~~~~~~'
def get_threshold(self): ''' get threshold from file ''' fd = os.open(Conf.data_dir + '/' + Conf.threshold_file, os.O_RDONLY | os.O_CREAT) fdesc.readFromFD(fd, self.process_threshold)
def doRead(self): # TODO move this back out as soon as such versio of Twisted is # packaged. from twisted.internet import fdesc return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
def doRead(self): return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
def doRead(self): self.trigger() return fdesc.readFromFD(self.fp.fileno(), self.dataRead)
def doRead(self): return fdesc.readFromFD(self.fileno(), self.dataReceived)