aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r--lib/python/qmk/commands.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index 3d4ed1616..3424cdf08 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -1,6 +1,10 @@
1"""Helper functions for commands. 1"""Helper functions for commands.
2""" 2"""
3import json 3import json
4import os
5import platform
6import subprocess
7import shlex
4 8
5import qmk.keymap 9import qmk.keymap
6 10
@@ -61,3 +65,19 @@ def parse_configurator_json(configurator_file):
61 user_keymap = json.load(configurator_file) 65 user_keymap = json.load(configurator_file)
62 66
63 return user_keymap 67 return user_keymap
68
69
70def run(command, *args, **kwargs):
71 """Run a command with subprocess.run
72 """
73 platform_id = platform.platform().lower()
74
75 if isinstance(command, str):
76 raise TypeError('`command` must be a non-text sequence such as list or tuple.')
77
78 if 'windows' in platform_id:
79 safecmd = map(shlex.quote, command)
80 safecmd = ' '.join(safecmd)
81 command = [os.environ['SHELL'], '-c', safecmd]
82
83 return subprocess.run(command, *args, **kwargs)