本文整理汇总了Python中twisted.internet.fdesc.readFromFD函数的典型用法代码示例。如果您正苦于以下问题:Python readFromFD函数的具体用法?Python readFromFD怎么用?Python readFromFD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readFromFD函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getConf
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)
示例2: doRead
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))
示例3: test_readFromEmpty
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)
示例4: get_raw_data
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
示例5: read
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
示例6: process
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()
示例7: read_whitelist
def read_whitelist(self):
fd = os.open(Conf.static_whitelist, os.O_RDONLY | os.O_CREAT)
fdesc.readFromFD(fd, self.process_whitelist)
示例8: get_threshold
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)
示例9: doRead
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)
示例10: doRead
def doRead(self):
self.trigger()
return fdesc.readFromFD(self.fp.fileno(), self.dataRead)
示例11: doRead
def doRead(self):
return fdesc.readFromFD(self.fileno(), self.protocol.dataReceived)
示例12: doRead
def doRead(self):
try:
setBlocking(False,0)
return fdesc.readFromFD(0, self.dataReceived)
finally:
fdesc.setBlocking(True,0)
示例13: doRead
def doRead(self):
fdesc.readFromFD(self._fd, self.protocol.dataReceived)
示例14: doRead
def doRead(self):
"""
Read some data from the observed file descriptors
"""
fdesc.readFromFD(self._fd, self._doRead)
示例15: doRead
def doRead(self):
"""
Read some bytes from the pipe and discard them.
"""
fdesc.readFromFD(self.fileno(), lambda data: None)