@@ -90,24 +90,33 @@ def _init_connection(self):
9090        We'll keep trying to execute a remote command that can't fail 
9191        (`/bin/true`), until we get a successful (0) exit code. 
9292        """ 
93-         self .check_output ("true" , timeout = 10 )
93+         self .check_output ("true" , timeout = 10 , debug = True )
94+ 
95+     def  run (self , cmd_string , timeout = None , * , check = False , debug = False ):
96+         """ 
97+         Execute the command passed as a string in the ssh context. 
98+ 
99+         If `debug` is set, pass `-vvv` to `ssh`. Note that this will clobber stderr. 
100+         """ 
101+         command  =  [
102+             "ssh" ,
103+             * self .options ,
104+             f"{ self .user } { self .host }  ,
105+             cmd_string ,
106+         ]
107+ 
108+         if  debug :
109+             command .insert (1 , "-vvv" )
94110
95-     def  run (self , cmd_string , timeout = None , * , check = False ):
96-         """Execute the command passed as a string in the ssh context.""" 
97111        return  self ._exec (
98-             [
99-                 "ssh" ,
100-                 * self .options ,
101-                 f"{ self .user } { self .host }  ,
102-                 cmd_string ,
103-             ],
112+             command ,
104113            timeout ,
105114            check = check ,
106115        )
107116
108-     def  check_output (self , cmd_string , timeout = None ):
117+     def  check_output (self , cmd_string , timeout = None ,  * ,  debug = False ):
109118        """Same as `run`, but raises an exception on non-zero return code of remote command""" 
110-         return  self .run (cmd_string , timeout , check = True )
119+         return  self .run (cmd_string , timeout , check = True ,  debug = debug )
111120
112121    def  _exec (self , cmd , timeout = None , check = False ):
113122        """Private function that handles the ssh client invocation.""" 
0 commit comments