File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -164,10 +164,13 @@ async def ssh(
164164 cmd .extend (ssh_opts .split () if isinstance (ssh_opts , str ) else ssh_opts )
165165 cmd .extend ([command ])
166166 loop = self .model .loop
167- process = await asyncio .create_subprocess_exec (* cmd , loop = loop )
168- await process .wait ()
167+ process = await asyncio .create_subprocess_exec (
168+ * cmd , loop = loop , stdout = asyncio .subprocess .PIPE , stderr = asyncio .subprocess .PIPE )
169+ stdout , stderr = await process .communicate ()
169170 if process .returncode != 0 :
170- raise JujuError ("command failed: %s" % cmd )
171+ raise JujuError ("command failed: %s with %s" % (cmd , stderr .decode ()))
172+ # stdout is a bytes-like object, returning a string might be more useful
173+ return stdout .decode ()
171174
172175 def status_history (self , num = 20 , utc = False ):
173176 """Get status history for this machine.
You can’t perform that action at this time.
0 commit comments