@@ -345,11 +345,12 @@ def get_nav_link(driver, url, nav_class):
345345 return link
346346
347347
348- def shared_logout (driver , url , login , passwd , callbacks = {}):
348+ def shared_logout (driver , url , double_confirm , login , passwd , callbacks = {}):
349349 """Logout through the shared logout navmenu entry and confirm. Optionally
350350 execute any provided callbacks for confirm states. The callbacks dictionary
351351 should contain state names bound to functions accepting driver and state
352352 name like do_stuff(driver, state) .
353+ The double_confirm arg specifies if one or two confirm steps are needed.
353354 """
354355 status = True
355356 do_logout = False
@@ -380,21 +381,40 @@ def shared_logout(driver, url, login, passwd, callbacks={}):
380381 # print("DEBUG: click confirm elem: %s" % confirm_elem)
381382 confirm_elem .click ()
382383 # Upstream OID(C) may have additional logout step
383- print ("Confirm logout again" )
384- try :
385- confirm_elem = driver .find_element (by_what ('xpath' ),
386- "//button[@value='Yes']" )
387- # print("DEBUG: found confirm elem: %s" % confirm_elem)
388- state = 'logout-confirm-upstream'
389- if callbacks .get (state , None ):
390- callbacks [state ](driver , state )
391- # print("DEBUG: click confirm elem: %s" % confirm_elem)
392- confirm_elem .click ()
393- except Exception as exc :
394- print ("WARNING: failed in secondary logout: %s" % exc )
384+ if double_confirm :
385+ print ("Confirm logout again" )
386+ try :
387+ confirm_elem = driver .find_element (by_what ('xpath' ),
388+ "//button[@value='Yes']" )
389+ # print("DEBUG: found confirm elem: %s" % confirm_elem)
390+ state = 'logout-confirm-upstream'
391+ if callbacks .get (state , None ):
392+ callbacks [state ](driver , state )
393+ # print("DEBUG: click confirm elem: %s" % confirm_elem)
394+ confirm_elem .click ()
395+ except Exception as exc :
396+ print ("WARNING: failed in secondary logout: %s" % exc )
395397 else :
396398 status = False
397399 print ("Confirm login NOT found" )
398400
399401 print ("Finished logout: %s" % status )
400402 return status
403+
404+
405+ def mig_logout (driver , url , login , passwd , callbacks = {}):
406+ """Logout through the shared logout navmenu entry and confirm once. Optionally
407+ execute any provided callbacks for confirm states. The callbacks dictionary
408+ should contain state names bound to functions accepting driver and state
409+ name like do_stuff(driver, state) .
410+ """
411+ return shared_logout (driver , url , False , login , passwd , callbacks )
412+
413+
414+ def ucph_logout (driver , url , login , passwd , callbacks = {}):
415+ """Logout through the shared logout navmenu entry and try to confirm twice.
416+ Optionally execute any provided callbacks for confirm states. The callbacks
417+ dictionary should contain state names bound to functions accepting driver
418+ and state name like do_stuff(driver, state) .
419+ """
420+ return shared_logout (driver , url , True , login , passwd , callbacks )
0 commit comments