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

Python utils.get_temp_file函数代码示例

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

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



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

示例1: sendpfast

def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, iface=None):
    """Send packets at layer 2 using tcpreplay for performance
    pps:  packets per second
    mpbs: MBits per second
    realtime: use packet's timestamp, bending time with realtime value
    loop: number of times to process the packet list
    iface: output interface """
    if iface is None:
        iface = conf.iface
    argv = [conf.prog.tcpreplay, "--intf1=%s" % iface ]
    if pps is not None:
        argv.append("--pps=%i" % pps)
    elif mbps is not None:
        argv.append("--mbps=%i" % mbps)
    elif realtime is not None:
        argv.append("--multiplier=%i" % realtime)
    else:
        argv.append("--topspeed")

    if loop:
        argv.append("--loop=%i" % loop)

    f = get_temp_file()
    argv.append(f)
    wrpcap(f, x)
    try:
        subprocess.check_call(argv)
    except KeyboardInterrupt:
        log_interactive.info("Interrupted by user")
    except Exception,e:
        log_interactive.error("while trying to exec [%s]: %s" % (argv[0],e))
开发者ID:AP2AMR,项目名称:TuxCut,代码行数:31,代码来源:sendrecv.py


示例2: save_session

def save_session(fname=None, session=None, pickleProto=-1):
    if fname is None:
        fname = conf.session
        if not fname:
            conf.session = fname = utils.get_temp_file(keep=True)
            log_interactive.info("Use [%s] as session file" % fname)
    if session is None:
        session = __builtin__.__dict__["scapy_session"]

    to_be_saved = session.copy()
        
    if to_be_saved.has_key("__builtins__"):
        del(to_be_saved["__builtins__"])

    for k in to_be_saved.keys():
        if type(to_be_saved[k]) in [types.TypeType, types.ClassType, types.ModuleType]:
             log_interactive.error("[%s] (%s) can't be saved." % (k, type(to_be_saved[k])))
             del(to_be_saved[k])

    try:
        os.rename(fname, fname+".bak")
    except OSError:
        pass
    f=gzip.open(fname,"wb")
    cPickle.dump(to_be_saved, f, pickleProto)
    f.close()
开发者ID:0x90,项目名称:scapy-osx,代码行数:26,代码来源:main.py


示例3: pdfdump

 def pdfdump(self, filename=None, **kargs):
     """pdfdump(filename=None, layer_shift=0, rebuild=1)
     Creates a PDF file describing a packet. If filename is not provided a temporary file is created and xpdf is called."""
     canvas = self.canvas_dump(**kargs)
     if filename is None:
         fname = get_temp_file(autoext=".pdf")
         canvas.writePDFfile(fname)
         subprocess.Popen([conf.prog.pdfreader, fname+".pdf"])
     else:
         canvas.writePDFfile(filename)
开发者ID:7924102,项目名称:scapy,代码行数:10,代码来源:packet.py


示例4: pdfdump

 def pdfdump(self, filename = None, **kargs):
     """Creates a PDF file with a psdump of every packet
     filename: name of the file to write to. If empty, a temporary file is used and
               conf.prog.pdfreader is called"""
     d = self._dump_document(**kargs)
     if filename is None:
         filename = get_temp_file(autoext=".pdf")
         d.writePDFfile(filename)
         subprocess.Popen([conf.prog.pdfreader, filename+".pdf"])
     else:
         d.writePDFfile(filename)
     print
开发者ID:0x0d,项目名称:hijack,代码行数:12,代码来源:plist.py


示例5: scapy_write_history_file

def scapy_write_history_file(readline):
    if conf.histfile:
        try:
            readline.write_history_file(conf.histfile)
        except IOError,e:
            try:
                warning("Could not write history to [%s]\n\t (%s)" % (conf.histfile,e))
                tmp = utils.get_temp_file(keep=True)
                readline.write_history_file(tmp)
                warning("Wrote history to [%s]" % tmp)
            except:
                warning("Cound not write history to [%s]. Discarded" % tmp)
开发者ID:0x90,项目名称:scapy-osx,代码行数:12,代码来源:main.py


示例6: psdump

    def psdump(self, filename=None, **kargs):
        """psdump(filename=None, layer_shift=0, rebuild=1)
Creates an EPS file describing a packet. If filename is not provided a temporary file is created and gs is called."""
        canvas = self.canvas_dump(**kargs)
        if filename is None:
            fname = get_temp_file(autoext=".eps")
            canvas.writeEPSfile(fname)
            if WINDOWS:
                subprocess.Popen('"'+conf.prog.psreader+'" "'+fname+'.eps"')
            else:
                subprocess.Popen([conf.prog.psreader, fname+".eps"])
        else:
            canvas.writeEPSfile(filename)
开发者ID:AntBean,项目名称:scapy-com8aa1453d8d24,代码行数:13,代码来源:packet.py


示例7: sendpfast

def sendpfast(x, pps=None, mbps=None, realtime=None, loop=0, file_cache=False, iface=None, additional_options=None):
    """Send packets at layer 2 using tcpreplay for performance
    pps:  packets per second
    mpbs: MBits per second
    realtime: use packet's timestamp, bending time with realtime value
    loop: number of times to process the packet list
    file_cache: cache packets in RAM instead of reading from disk at each iteration
    iface: output interface
    additional_options: other commandline options, e.g. '--timer=gtod --preload-pcap'"""
    if iface is None:
        iface = conf.iface
    argv = [conf.prog.tcpreplay, "--intf1=%s" % iface ]
    if pps is not None:
        argv.append("--pps=%i" % pps)
    elif mbps is not None:
        argv.append("--mbps=%i" % mbps)
    elif realtime is not None:
        argv.append("--multiplier=%i" % realtime)
    else:
        argv.append("--topspeed")

    if loop:
        argv.append("--loop=%i" % loop)
        if file_cache:
            argv.append("--enable-file-cache")
    if additional_options is not None:
        argv.extend(additional_options.split())
    f = get_temp_file()
    argv.append(f)
    wrpcap(f, x)
    try:
        subprocess.check_call(argv)
    except KeyboardInterrupt:
        log_interactive.info("Interrupted by user")
    except Exception,e:
        log_interactive.error("while trying to exec [%s]: %s" % (argv[0],e))
开发者ID:AntBean,项目名称:scapy-com8aa1453d8d24,代码行数:36,代码来源:sendrecv.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.get_time_in_millisecs函数代码示例发布时间:2022-05-26
下一篇:
Python utils.get_tc_string函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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