Skip to content
Snippets Groups Projects
Commit 3a5a84bd authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-657: logging, and only login/logout if needed

parent 656a1423
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,7 @@ class MoMClient:
if self.__logged_in:
return
logger.debug("logging in to MoM on url: %s", self.__momURLlogin)
self.__browser.open(self.__momURLlogin)
forms = list(self.__browser.forms())
self.__browser.form = forms[0]
......@@ -70,14 +71,18 @@ class MoMClient:
if 200 != ret_code:
raise Exception("Logging into MoM failed: http return code = " + ret_code)
logger.debug("logged in on MoM on url: %s", self.__momURLlogin)
self.__logged_in = True
except Exception as e:
raise Exception("Logging into MoM on %s failed: %s" % (self.__momURLlogin, str(e)))
def logout(self):
try:
self.__browser.open(self.__momURLlogout)
self.__logged_in = False
if self.__logged_in:
logger.info("logging out of MoM on url: %s", self.__momURLlogout)
self.__browser.open(self.__momURLlogout)
self.__logged_in = False
logger.info("logged out of MoM on url: %s", self.__momURLlogout)
except Exception as e:
logger.warning("Logging out of MoM failed: " + str(e))
......@@ -98,7 +103,7 @@ class MoMClient:
params = {"exportId" : export_id, "status" : status_id}
statusUrl = self.__momURLsetStatus + '?' + urllib.parse.urlencode(params)
logger.debug("updating MoM: " + statusUrl)
logger.info("updating MoM: " + statusUrl)
response = self.__browser.open(statusUrl)
reply = [line.decode('utf-8') for line in response.readlines()]
if reply == ['ok']:
......@@ -116,7 +121,7 @@ class MoMClient:
params['message'] = message
statusUrl = self.__momURLsetStatus + '?' + urllib.parse.urlencode(params)
logger.debug("updating MoM: " + statusUrl)
logger.info("updating MoM: " + statusUrl)
response = self.__browser.open(statusUrl)
reply = [line.decode('utf-8') for line in response.readlines()]
if reply == ['ok']:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment