55
66import click
77
8+ from .util import run_command
9+
810MANIFEST_PATH = files ("manifests" )
911RPC_PATH = files ("images" ).joinpath ("rpc" )
1012
@@ -26,46 +28,6 @@ def cluster():
2628 pass
2729
2830
29- def run_command (command , stream_output = False , env = None ):
30- # Merge the current environment with the provided env
31- full_env = os .environ .copy ()
32- if env :
33- # Convert all env values to strings (only a safeguard)
34- env = {k : str (v ) for k , v in env .items ()}
35- full_env .update (env )
36-
37- if stream_output :
38- process = subprocess .Popen (
39- ["/bin/bash" , "-c" , command ],
40- stdout = subprocess .PIPE ,
41- stderr = subprocess .STDOUT ,
42- text = True ,
43- bufsize = 1 ,
44- universal_newlines = True ,
45- env = full_env ,
46- )
47-
48- for line in iter (process .stdout .readline , "" ):
49- print (line , end = "" )
50-
51- process .stdout .close ()
52- return_code = process .wait ()
53-
54- if return_code != 0 :
55- print (f"Command failed with return code { return_code } " )
56- return False
57- return True
58- else :
59- result = subprocess .run (
60- command , shell = True , capture_output = True , text = True , executable = "/bin/bash"
61- )
62- if result .returncode != 0 :
63- print (f"Error: { result .stderr } " )
64- return False
65- print (result .stdout )
66- return True
67-
68-
6931@cluster .command ()
7032@click .option ("--clean" , is_flag = True , help = "Remove configuration files" )
7133def setup_minikube (clean ):
0 commit comments