本文整理汇总了Python中session.Session方法的典型用法代码示例。如果您正苦于以下问题:Python session.Session方法的具体用法?Python session.Session怎么用?Python session.Session使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类session
的用法示例。
在下文中一共展示了session.Session方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_new_session
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def start_new_session(self, name):
if self._session:
self.close_session()
self._is_temporary = True
self._session_name = name
self._date = strftime("%d_%m_%Y")
if self._date not in os.listdir(self._sessions_folder):
self._session_id = 1
self._session = Session(self._date, self._session_id, self._session_name)
self._session_folder = self._sessions_folder + self._session.path
os.mkdir(self._sessions_folder + self._date)
os.mkdir(self._session_folder)
else:
self._session_id = len(os.listdir(self._sessions_folder + self._date)) + 1
self._session = Session(self._date, self._session_id, self._session_name)
self._session_folder = self._sessions_folder + self._session.path
os.mkdir(self._session_folder)
self._initiate_reporters()
示例2: attach
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def attach(self, name, ch, delegate, force=False):
self.lock.acquire()
try:
ssn = self.attached.get(ch.id)
if ssn is not None:
if ssn.name != name:
raise ChannelBusy(ch, ssn)
else:
ssn = self.sessions.get(name)
if ssn is None:
ssn = Session(name, delegate=delegate)
self.sessions[name] = ssn
elif ssn.channel is not None:
if force:
del self.attached[ssn.channel.id]
ssn.channel = None
else:
raise SessionBusy(ssn)
self.attached[ch.id] = ssn
ssn.channel = ch
ch.session = ssn
return ssn
finally:
self.lock.release()
示例3: open_session
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def open_session(self, session_id, msg):
if session_id in self.sessions:
return 'CLS,' + session_id
remote_ip = None
client_version = None
if msg:
remote_ip = msg.get('RemoteIp', None)
client_version = msg.get('ClientVersion', None)
self.sessions[session_id] = [0, datetime.datetime.now(), Session( session_id, remote_ip, client_version ) ]
return 'OPN,' + session_id
示例4: load
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def load(self, user_input=None):
if not user_input:
self._raise_exception_specify("module")
self.session = Session(user_input[0])
# The module is incorrect
if not(self.session.correct_module()):
print_error('Invalid module')
self.session = None
else:
self.comp.set_commands_to_set(self.session.get_options_name())
示例5: command_start
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def command_start(self, bot, update):
chat_id = update.message.chat_id
if chat_id not in self.SESSIONS.keys():
self.messenger = interfaces.TelegramMessenger(bot, self.logger)
self.SESSIONS[chat_id] = session.Session(
chat_id, self.config_instance, self.logger)
self.SESSIONS[chat_id].set_messenger(self.messenger)
self.SESSIONS[chat_id].quiz = quiz.Quiz(self.SESSIONS[chat_id])
示例6: _load_previous_session
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def _load_previous_session(self, date, id):
self._session_name = self._get_session_name(date, id)
print "[+] Loading session '{}'!".format(self._session_name)
self._session = Session(date, id, self._session_name)
self._load_info_from_current_session()
示例7: load_session
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def load_session(self, index):
if index >= len(self._session_list):
print "[-] Session index out of bounds!"
return
if self._is_temporary:
self._cleanup_tmp_session()
self._session = self._session_list[index]
self._load_info_from_current_session()
示例8: _load_all_sessions
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def _load_all_sessions(self):
self._session_list = [
Session(datefolder, int(session.split("_")[0][-1]), "_".join(session.split("_")[1:]))
for datefolder in os.listdir(self._sessions_folder) if os.path.isdir(self._sessions_folder + "/" + datefolder)
for session in os.listdir(self._sessions_folder + "/" + datefolder)
]
示例9: create_session
# 需要导入模块: import session [as 别名]
# 或者: from session import Session [as 别名]
def create_session(self, user):
session = Session(self.next_session_id, user)
self.sessions[self.next_session_id] = session
self.next_session_id += 1
return session