Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.. note::
Only works when :attr:`relogin_available` is ``True``.
.. code:: python
if client.relogin_available: client.relogin()
else:
client.login(user, pass)
:returns: login result
:rtype: :class:`.EResult`
"""
if self.relogin_available:
return self.login(self.username, '', self.login_key)
return EResult.Fail
def _pre_login(self):
if self.logged_on:
self._LOG.debug("Trying to login while logged on???")
raise RuntimeError("Already logged on")
if not self.connected and not self._connecting:
if not self.connect():
return EResult.Fail
if not self.channel_secured:
resp = self.wait_event(self.EVENT_CHANNEL_SECURED, timeout=10)
# some CMs will not send hello
if resp is None:
if self.connected:
self.wait_event(self.EVENT_DISCONNECTED)
return EResult.TryAnotherCM
return EResult.OK
def _pre_login(self):
if self.logged_on:
self._LOG.debug("Trying to login while logged on???")
raise RuntimeError("Already logged on")
if not self.connected and not self._connecting:
if not self.connect():
return EResult.Fail
if not self.channel_secured:
resp = self.wait_event(self.EVENT_CHANNEL_SECURED, timeout=10)
# some CMs will not send hello
if resp is None:
if self.connected:
self.wait_event(self.EVENT_DISCONNECTED)
return EResult.TryAnotherCM
return EResult.OK
def __init__(self, message, eresult=EResult.Fail):
Exception.__init__(self, message, eresult)
self.message = message
self.eresult = EResult(eresult) #: :class:`.EResult`
message.body.eresult_sentryfile = EResult.OK
message.body.sha_sentryfile = sha1_hash(sentry)
if auth_code:
message.body.auth_code = auth_code
if two_factor_code:
message.body.two_factor_code = two_factor_code
self.send(message)
resp = self.wait_msg(EMsg.ClientLogOnResponse, timeout=30)
if resp and resp.body.eresult == EResult.OK:
self.sleep(0.5)
return EResult(resp.body.eresult) if resp else EResult.Fail
message.body.eresult_sentryfile = EResult.OK
message.body.sha_sentryfile = sha1_hash(sentry)
if auth_code:
message.body.auth_code = auth_code
if two_factor_code:
message.body.two_factor_code = two_factor_code
self.send(message)
resp = self.wait_msg(EMsg.ClientLogOnResponse, timeout=30)
if resp and resp.body.eresult == EResult.OK:
self.sleep(0.5)
return EResult(resp.body.eresult) if resp else EResult.Fail