Skip to content

Commit b228f5a

Browse files
mplsgrantpinheadmz
authored andcommitted
use with for subprocess
1 parent c8020cf commit b228f5a

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/warnet/main.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,23 @@ def quickstart():
4848
"""Setup warnet"""
4949
try:
5050
# Requirements checks
51-
process = subprocess.Popen(
51+
with subprocess.Popen(
5252
["/bin/bash", str(QUICK_START_PATH)],
5353
stdout=subprocess.PIPE,
5454
stderr=subprocess.STDOUT,
5555
universal_newlines=True,
5656
env=dict(os.environ, TERM="xterm-256color"),
57-
)
58-
if process.stdout:
59-
for line in iter(process.stdout.readline, ""):
60-
click.echo(line, nl=False)
61-
process.stdout.close()
62-
return_code = process.wait()
63-
if return_code != 0:
64-
click.secho(
65-
f"Quick start script failed with return code {return_code}", fg="red", bold=True
66-
)
67-
click.secho("Install missing requirements before proceeding", fg="yellow")
68-
return False
57+
) as process:
58+
if process.stdout:
59+
for line in iter(process.stdout.readline, ""):
60+
click.echo(line, nl=False)
61+
return_code = process.wait()
62+
if return_code != 0:
63+
click.secho(
64+
f"Quick start script failed with return code {return_code}", fg="red", bold=True
65+
)
66+
click.secho("Install missing requirements before proceeding", fg="yellow")
67+
return False
6968

7069
# New project setup
7170
questions = [

0 commit comments

Comments
 (0)