11import json
2- import subprocess
2+
3+ from lib import commands
34
45from typing import Any , Dict , Literal , Union , overload
56
@@ -13,29 +14,28 @@ def xo_cli(action: str, args: Dict[str, str] = {}, *, check: bool = True, simple
1314 ...
1415@overload
1516def xo_cli (action : str , args : Dict [str , str ] = {}, * , check : bool = True , simple_output : Literal [False ],
16- use_json : bool = False ) -> subprocess . CompletedProcess :
17+ use_json : bool = False ) -> int :
1718 ...
1819@overload
1920def xo_cli (action : str , args : Dict [str , str ] = {}, * , check : bool = True , simple_output : bool = True ,
20- use_json : bool = False ) -> Union [subprocess . CompletedProcess , Any , str ]:
21+ use_json : bool = False ) -> Union [int , Any , str ]:
2122 ...
2223def xo_cli (action , args = {}, check = True , simple_output = True , use_json = False ):
2324 run_array = ['xo-cli' , action ]
2425 if use_json :
2526 run_array += ['--json' ]
2627 run_array += ["%s=%s" % (key , value ) for key , value in args .items ()]
27- res = subprocess .run (
28- run_array ,
29- stdout = subprocess .PIPE ,
30- stderr = subprocess .STDOUT ,
31- check = check
32- )
28+
29+ res = commands .local_cmd (run_array , check = check , decode = True )
30+
3331 if simple_output :
34- output = res .stdout . decode (). strip ()
32+ output = res .stdout
3533 if use_json :
3634 return json .loads (output )
3735 return output
38- return res
36+
37+ # XXX: doesn't seem to be used as by default simple_output is true
38+ return res .returncode
3939
4040def xo_object_exists (uuid ):
4141 lst = json .loads (xo_cli ('--list-objects' , {'uuid' : uuid }))
0 commit comments