@@ -1809,16 +1809,12 @@ async def print_trace_to (mc, contact):
18091809
18101810async def discover_path (mc , contact ):
18111811 await mc .ensure_contacts ()
1812- res = await mc .commands .send_path_discovery (contact )
1813- if res .type == EventType .ERROR :
1814- return None
1815- else :
1816- timeout = res .payload ["suggested_timeout" ]/ 600 if not "timeout" in contact or contact ['timeout' ]== 0 else contact ["timeout" ]
1817- res = await mc .wait_for_event (EventType .PATH_RESPONSE , timeout = timeout )
1818- if res is None :
1819- return {"error" : "timeout" }
1820- else :
1821- return res .payload
1812+ timeout = 0 if not "timeout" in contact else contact ["timeout" ]
1813+ res = await mc .commands .send_path_discovery_sync (contact , timeout )
1814+ if res is None :
1815+ return {"error" : "timeout" }
1816+ else :
1817+ return res .payload
18221818
18231819async def print_disc_trace_to (mc , contact ):
18241820 p = await discover_path (mc , contact )
@@ -2789,29 +2785,21 @@ async def next_cmd(mc, cmds, json_output=False):
27892785 sess = PromptSession ("Password: " , is_password = True )
27902786 password = await sess .prompt_async ()
27912787
2792- res = await mc .commands .send_login (contact , password )
2788+ timeout = 0 if not "timeout" in contact else contact ["timeout" ]
2789+ res = await mc .commands .send_login_sync (contact , password , timeout = timeout )
27932790 logger .debug (res )
2794- if res .type == EventType .ERROR :
2795- if json_output :
2796- print (json .dumps ({"error" : "Error while login" }))
2791+ if res is None :
2792+ print ("Login failed : Error or Timeout waiting response" )
2793+ elif json_output :
2794+ if res .type == EventType .LOGIN_SUCCESS :
2795+ print (json .dumps ({"login_success" : True }, indent = 4 ))
27972796 else :
2798- print (f"Error while loging: { res } " )
2799- else : # should probably wait for the good ack
2800- timeout = res .payload ["suggested_timeout" ]/ 800 if not "timeout" in contact or contact ['timeout' ]== 0 else contact ["timeout" ]
2801- res = await mc .wait_for_event (EventType .LOGIN_SUCCESS , timeout = timeout )
2802- logger .debug (res )
2803- if res is None :
2804- print ("Login failed : Timeout waiting response" )
2805- elif json_output :
2806- if res .type == EventType .LOGIN_SUCCESS :
2807- print (json .dumps ({"login_success" : True }, indent = 4 ))
2808- else :
2809- print (json .dumps ({"login_success" : False , "error" : "login failed" }, indent = 4 ))
2797+ print (json .dumps ({"login_success" : False , "error" : "login failed" }, indent = 4 ))
2798+ else :
2799+ if res .type == EventType .LOGIN_SUCCESS :
2800+ print ("Login success" )
28102801 else :
2811- if res .type == EventType .LOGIN_SUCCESS :
2812- print ("Login success" )
2813- else :
2814- print ("Login failed" )
2802+ print ("Login failed" )
28152803
28162804 case "logout" :
28172805 argnum = 1
0 commit comments