Skip to content

Commit

Permalink
set creationflags on Windows only (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Nov 8, 2023
1 parent 0f9c5f9 commit 84c2852
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion param/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import os, subprocess, json

def run_cmd(args, cwd=None):
kwargs = {}
if os.name == 'nt':
kwargs['creationflags'] = subprocess.CREATE_NO_WINDOW
proc = subprocess.Popen(args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
cwd=cwd,
creationflags=subprocess.CREATE_NO_WINDOW)
**kwargs)
output, error = (str(s.decode()).strip() for s in proc.communicate())

# Detects errors as _either_ a non-zero return code _or_ messages
Expand Down
6 changes: 6 additions & 0 deletions tests/testversion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from param.version import run_cmd


def test_run_cmd():
output = run_cmd(['echo', 'test'])
assert output == 'test'

0 comments on commit 84c2852

Please sign in to comment.