@@ -39,7 +39,13 @@ def runOSProcess(command, logger, timeout=10, shell=False):
3939def get_password (password , session_key , logger ):
4040 #TODO move this into shared function to obtain passwords:
4141 context = os .path .dirname (os .path .dirname (__file__ ))
42-
42+
43+ if context .find ("/bin/" ) != - 1 or context .find ("\\ bin\\ " ) != - 1 :
44+ if context .find ("/bin/" ) != - 1 :
45+ context = context [:context .find ("/bin/" )]
46+ else :
47+ context = context [:context .find ("\\ bin\\ " )]
48+
4349 if platform .system () == "Windows" :
4450 start = context .rfind ("\\ " )
4551 else :
@@ -52,6 +58,9 @@ def get_password(password, session_key, logger):
5258 res = requests .get (url , headers = headers , verify = False )
5359 dict = json .loads (res .text )
5460 clear_password = False
61+ if not 'entry' in dict :
62+ logger .warn ("dict=%s did not contain the entries expected on url=%s while looking for password=%s" % (dict , url , password ))
63+ raise Exception ('Error while finding password' )
5564 for entry in dict ['entry' ]:
5665 logger .debug ("found=%s looking for :%s:" % (entry ['name' ], password ))
5766 if entry ['name' ].find (":" + password + ":" ) != - 1 :
@@ -66,6 +75,9 @@ def get_password(password, session_key, logger):
6675 logger .debug ("Trying url=%s with session_key to obtain name=%s" % (url , password ))
6776 res = requests .get (url , headers = headers , verify = False )
6877 dict = json .loads (res .text )
78+ if not 'entry' in dict :
79+ logger .warn ("dict=%s did not contain the entries expected on url=%s while looking for password=%s" % (dict , url , password ))
80+ raise Exception ('Error while finding password' )
6981 for entry in dict ['entry' ]:
7082 logger .debug ("found=%s looking for :%s:" % (entry ['name' ], password ))
7183 if entry ['name' ].find (":" + password + ":" ) != - 1 :
0 commit comments