本文整理汇总了Python中config.conf.session方法的典型用法代码示例。如果您正苦于以下问题:Python conf.session方法的具体用法?Python conf.session怎么用?Python conf.session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类config.conf
的用法示例。
在下文中一共展示了conf.session方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import session [as 别名]
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()
示例2: load_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import session [as 别名]
def load_session(fname=None):
if fname is None:
fname = conf.session
try:
s = cPickle.load(gzip.open(fname,"rb"))
except IOError:
s = cPickle.load(open(fname,"rb"))
scapy_session = __builtin__.__dict__["scapy_session"]
scapy_session.clear()
scapy_session.update(s)
示例3: update_session
# 需要导入模块: from config import conf [as 别名]
# 或者: from config.conf import session [as 别名]
def update_session(fname=None):
if fname is None:
fname = conf.session
try:
s = cPickle.load(gzip.open(fname,"rb"))
except IOError:
s = cPickle.load(open(fname,"rb"))
scapy_session = __builtin__.__dict__["scapy_session"]
scapy_session.update(s)
################
##### Main #####
################