Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _remove_session(self, name):
if name in self.get_sessions_list():
self._sessions[name].delete()
del self._sessions[name]
else:
raise SessionManagementException(u"Could not find '{}' session in list of saved sessions. Possible sessions are {}"
.format(name, self.get_sessions_list()))
def add_session(self, name, session):
if name in self._sessions:
raise SessionManagementException(u"Session with name '{}' already exists. Please delete the session"
u" first if you intend to replace it.".format(name))
self._sessions[name] = session
def get_any_session(self):
number_of_sessions = len(self._sessions)
if number_of_sessions == 1:
key = self.get_sessions_list()[0]
return self._sessions[key]
elif number_of_sessions == 0:
raise SessionManagementException(u"You need to have at least 1 client created to execute commands.")
else:
raise SessionManagementException(u"Please specify the client to use. Possible sessions are {}".format(
self.get_sessions_list()))
def get_any_session(self):
number_of_sessions = len(self._sessions)
if number_of_sessions == 1:
key = self.get_sessions_list()[0]
return self._sessions[key]
elif number_of_sessions == 0:
raise SessionManagementException(u"You need to have at least 1 client created to execute commands.")
else:
raise SessionManagementException(u"Please specify the client to use. Possible sessions are {}".format(
self.get_sessions_list()))
def get_session(self, name):
if name in self._sessions:
return self._sessions[name]
raise SessionManagementException(u"Could not find '{}' session in list of saved sessions. Possible sessions are {}".format(
name, self.get_sessions_list()))