• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fdesc.writeToFD函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中twisted.internet.fdesc.writeToFD函数的典型用法代码示例。如果您正苦于以下问题:Python writeToFD函数的具体用法?Python writeToFD怎么用?Python writeToFD使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了writeToFD函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _dump_file

    def _dump_file(self, file, submission_gus, file_gus):

        result = {}
        result['file_gus'] = file_gus
        result['name'] = file['filename']
        result['type'] = file['content_type']
        result['size'] = len(file['body'])

        # XXX verify this token what's is it
        result['token'] = submission_gus

        if not os.path.isdir(config.advanced.submissions_dir):
            print "%s does not exist. Creating it." % config.advanced.submissions_dir
            os.mkdir(config.advanced.submissions_dir)

        the_submission_dir = config.advanced.submissions_dir

        # this happen only at the first execution
        if not os.path.isdir(the_submission_dir):
            os.mkdir(the_submission_dir)

        filelocation = os.path.join(the_submission_dir, file_gus)

        print "Saving file \"%s\" of %d byte [%s] type, to %s" % \
              (result['name'], result['size'], result['type'], filelocation )

        with open(filelocation, 'w+') as fd:
            fdesc.setNonBlocking(fd.fileno())
            fdesc.writeToFD(fd.fileno(), file['body'])

        return result
开发者ID:hellais,项目名称:GLBackend,代码行数:31,代码来源:fileoperations.py


示例2: updateReport

 def updateReport(self, report_filename, data):
     try:
         with open(report_filename, 'a+') as fd:
             fdesc.setNonBlocking(fd.fileno())
             fdesc.writeToFD(fd.fileno(), data)
     except IOError as e:
         e.OONIBError(404, "Report not found")
开发者ID:not-the-nsa,项目名称:ooni-backend,代码行数:7,代码来源:handlers.py


示例3: contentReceived

    def contentReceived(self, chunk):
        #log.msg('Content %s bytes received:', len(chunk))
        fdesc.writeToFD(self.file, chunk)
        
        if self.beginning == 2:
            log.msg('File should be closed here')

        return self.headerReceived, HEADER_LENGTH
开发者ID:grodniewicz,项目名称:zeroD,代码行数:8,代码来源:itclient2.py


示例4: process_image

    def process_image(self, payload, **kwargs):
        """ Writes images to the cache """

        filecache_loc = settings.CACHE_LOCATION
        webcache_loc = settings.WEB_CACHE_LOCATION
        cache_filename_parts = payload['image_path'].split('.')
        filefront = cache_filename_parts[0]
        fileend = cache_filename_parts[1]
        cache_filename = ''

        original_filename = '%s.%s' % (
            filefront,
            fileend,
        )
        cache_filename = '%s_%sx%s_%s.%s' % (
            filefront,
            payload['width'],
            payload['height'],
            payload['mode'],
            fileend,
        )

        file_cache = os.path.join(filecache_loc, cache_filename)
        web_cache = os.path.join(webcache_loc, cache_filename)

        # Files are normally binned in subdir, create them in cache
        dirs = os.path.dirname(file_cache)
        try:
            os.makedirs(dirs)
        except os.error:
            pass

        if 'skip_resize' in payload.keys():
            # Just save/servwe original image as there is no resized image
            file_cache = os.path.join(filecache_loc, original_filename)
            web_cache = os.path.join(webcache_loc, original_filename)

        # Save image to be served
        fd = open(file_cache, 'w')
        fdesc.setNonBlocking(fd.fileno())
        yield fdesc.writeToFD(fd.fileno(), payload['image'])
        fd.close()

        if 'skip_resize' not in payload.keys():
            # If image to be served has beenr esized, also cache full size image
            file_cache = os.path.join(filecache_loc, original_filename)
            fd = open(file_cache, 'w')
            fdesc.setNonBlocking(fd.fileno())
            yield fdesc.writeToFD(fd.fileno(), payload['original_image'])
            fd.close()

        if settings.DEBUG:
            log.msg(
                "[%s] Cached image location: %s" % (datetime.now().isoformat(), file_cache),
                logLevel=logging.DEBUG
            )

        defer.returnValue(web_cache)
开发者ID:Frowse,项目名称:openross,代码行数:58,代码来源:cacher.py


示例5: writeSomeData

 def writeSomeData(self, data):
     self._write_buf += data
     while True:
         length = self.get_frame(self._write_buf)
         if length == -1:
             break
         frame = self._write_buf[:length]
         self._write_buf = self._write_buf[length:]
         fdesc.writeToFD(self.tunfd, frame)
开发者ID:alexsunday,项目名称:pyvpn,代码行数:9,代码来源:server.py


示例6: do_verbose_log

    def do_verbose_log(self, content):
        """
        Record in the verbose log the content as defined by Cyclone wrappers.
        """
        content = sanitize_str(content)

        try:
            with open(GLSetting.httplogfile, "a+") as fd:
                fdesc.writeToFD(fd.fileno(), content + "\n")
        except Exception as excep:
            log.err("Unable to open %s: %s" % (GLSetting.httplogfile, excep))
开发者ID:rowanthorpe,项目名称:GLBackend,代码行数:11,代码来源:base.py


示例7: do_verbose_log

    def do_verbose_log(self, content):
        """
        Record in the verbose log the content as defined by Cyclone wrappers.
        """
        content = log_remove_escapes(content)
        content = log_encode_html(content)

        try:
            with open(GLSetting.httplogfile, 'a+') as fd:
                fdesc.writeToFD(fd.fileno(), content + "\n")
        except Exception as excep:
            log.err("Unable to open %s: %s" % (GLSetting.httplogfile, excep))
开发者ID:tonegas,项目名称:GlobaLeaks,代码行数:12,代码来源:base.py


示例8: receiveContent

    def receiveContent(self, chunk):

        start = time.time()
        log.msg('Content %s bytes received:', len(chunk))
        fdesc.writeToFD(self.file, chunk)

        if self.beginning == 2:
            log.msg('Last chunk go to processing')
            for websock in self.factory.browsers:
                websock.write(self.path.split('/')[-1].encode('utf-8')) 
            self.startProcessing()
        stop = time.time()
        return self.receiveHeader, HEADER_LENGTH
开发者ID:grodniewicz,项目名称:zeroD,代码行数:13,代码来源:itprotocol.py


示例9: do_verbose_log

    def do_verbose_log(self, content):
        """
        Record in the verbose log the content as defined by Cyclone wrappers.

        This option is only available in devel mode and intentionally does not filter
        any input/output; It should be used only for debug purposes.
        """

        try:
            with open(GLSettings.httplogfile, "a+") as fd:
                fdesc.writeToFD(fd.fileno(), content + "\n")
        except Exception as excep:
            log.err("Unable to open %s: %s" % (GLSettings.httplogfile, excep))
开发者ID:corvolino,项目名称:GlobaLeaks,代码行数:13,代码来源:base.py


示例10: updateReport

    def updateReport(self, report_id, parsed_request):

        log.debug("Got this request %s" % parsed_request)
        report_filename = os.path.join(config.main.report_dir,
                report_id)
        
        config.reports[report_id].refresh()

        try:
            with open(report_filename, 'a+') as fd:
                fdesc.setNonBlocking(fd.fileno())
                fdesc.writeToFD(fd.fileno(), parsed_request['content'])
        except IOError as exc:
            e.OONIBError(404, "Report not found")
        self.write({})
开发者ID:glamrock,项目名称:ooni-backend,代码行数:15,代码来源:handlers.py


示例11: writeSomeData

 def writeSomeData(self, data):
     """
     Write some data to the open process.
     """
     rv = fdesc.writeToFD(self.fd, data)
     if rv == len(data) and self.enableReadHack:
         self.startReading()
     return rv
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:8,代码来源:process.py


示例12: writeSomeData

 def writeSomeData(self, data):
     """
     Write data to the FIFO. Should not be used by protocols -
     use L{write<twisted.internet.abstract.FileDescriptor.write>} instead.
     """
     return writeToFD(self.fileno(), data)
开发者ID:Valodim,项目名称:irclogd,代码行数:6,代码来源:fifo.py


示例13: writeToReport

 def writeToReport(self, report_filename, data):
     with open(report_filename, 'w+') as fd:
         fdesc.setNonBlocking(fd.fileno())
         fdesc.writeToFD(fd.fileno(), data)
开发者ID:glamrock,项目名称:ooni-backend,代码行数:4,代码来源:handlers.py


示例14: writeToFile

 def writeToFile(self, data):
     if self.outputFile is not None:
         # Write to nonblocking output file descriptor
         fdesc.writeToFD(self.outputFile.fileno(), data)
开发者ID:sdrendall,项目名称:conditioningCage,代码行数:4,代码来源:mplayerStreamingInterface.py


示例15: writeSomeData

 def writeSomeData(self, data):
     """
     Write some data to the serial device.
     """
     return fdesc.writeToFD(self.fileno(), data)
开发者ID:xuhao1,项目名称:mavasync,代码行数:5,代码来源:serialport.py


示例16: writeSomeData

 def writeSomeData(self, data):
     rw = fdesc.writeToFD(self.fileno(), data)
     if rw == len(data) and self.backToReading:
         self.backToReading = False
         self.startReading()
     return rw
开发者ID:buben19,项目名称:twistedinput,代码行数:6,代码来源:device.py


示例17: write

 def write(self, data):
     fdesc.writeToFD(self._port.fileno(), data)
开发者ID:JvanDalfsen,项目名称:calvin-base,代码行数:2,代码来源:serialport.py


示例18: writeSomeData

 def writeSomeData(self, data):
     return fdesc.writeToFD(self.fp.fileno(), data)
开发者ID:JvanDalfsen,项目名称:calvin-base,代码行数:2,代码来源:filedescriptor.py


示例19: writeData

 def writeData(self,data):
     """docstring for writeData"""
     fdesc.writeToFD(self.outfile,data)
开发者ID:kyrios,项目名称:atemclient,代码行数:3,代码来源:files.py


示例20: write

 def write(self, d):
     """
     Write data to the pipe.
     """
     return fdesc.writeToFD(self.w, d)
开发者ID:AmirKhooj,项目名称:VTK,代码行数:5,代码来源:test_fdesc.py



注:本文中的twisted.internet.fdesc.writeToFD函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python glib2reactor.install函数代码示例发布时间:2022-05-27
下一篇:
Python fdesc.setNonBlocking函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap