diff options
author | Erovia <[email protected]> | 2020-03-29 14:29:44 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-29 14:29:44 +0200 |
commit | c89c0841468ad23153a9fc9578d344845df31a88 (patch) | |
tree | da17997995c2657511b3f4a8eefbdd0b3c3725a2 /lib/python/qmk/commands.py | |
parent | 13fff52f6b629e4345e7ea2296b3d100aa9df245 (diff) | |
download | qmk_firmware-c89c0841468ad23153a9fc9578d344845df31a88.tar.gz qmk_firmware-c89c0841468ad23153a9fc9578d344845df31a88.zip |
CLI: More MSYS2 fixes (#8577)0.8.81
* CLI: More MSYS2 fixes
Now I can fully setup and work with qmk_firmware on an MSYS2
installation without any errors or exceptions.
* Apply suggestions from code review
Co-Authored-By: skullydazed <[email protected]>
* Some improvements
* Remove unnecessary import
* Remove slow, unused code
Getting the version from GIT was slow on both Windows and Docker.
Until we find a better, faster way, this is removed.
* remove unused imports
* Implement @vomindoraan's suggestions
* refine how we pick the shell to use
* Apply @fauxpark's suggestions
fauxpark investigated the topic of shells in MSYS2 a bit and we come to the conclusion that the safest bet was to just use the user's shell.
Anything more just opens up more edge-cases than it solves.
Co-Authored-By: Ryan <[email protected]>
* Use `platform_id` in doctor
This will bring it in line with the new code.
Co-authored-by: skullydazed <[email protected]>
Co-authored-by: skullY <[email protected]>
Co-authored-by: Ryan <[email protected]>
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r-- | lib/python/qmk/commands.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 3d4ed16163..3424cdf085 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -1,6 +1,10 @@ """Helper functions for commands. """ import json +import os +import platform +import subprocess +import shlex import qmk.keymap @@ -61,3 +65,19 @@ def parse_configurator_json(configurator_file): user_keymap = json.load(configurator_file) return user_keymap + + +def run(command, *args, **kwargs): + """Run a command with subprocess.run + """ + platform_id = platform.platform().lower() + + if isinstance(command, str): + raise TypeError('`command` must be a non-text sequence such as list or tuple.') + + if 'windows' in platform_id: + safecmd = map(shlex.quote, command) + safecmd = ' '.join(safecmd) + command = [os.environ['SHELL'], '-c', safecmd] + + return subprocess.run(command, *args, **kwargs) |