aboutsummaryrefslogtreecommitdiff
path: root/pw_cli
diff options
context:
space:
mode:
authorRob Mohr <mohrr@google.com>2020-07-09 07:01:50 -0700
committerCQ Bot Account <commit-bot@chromium.org>2020-07-21 21:58:13 +0000
commitdf2f1908a9665c29130d860f630e844dd1a9cd06 (patch)
tree72811aeffd502475c582c3afea91a58447ed2215 /pw_cli
parent3ab26ffcea3c1439d084d45f00a10bf7d4c41a63 (diff)
downloadpigweed-df2f1908a9665c29130d860f630e844dd1a9cd06.tar.gz
pw_env_setup: make all Python code 3.7-compatible
Make all Python code compatible with 3.7. Specifically, remove dependency on shlex.join(), a one-line function added in Python 3.8, and typing.Literal. Change-Id: I38f57c9f0ee7b8ef1c3e3d9ead456b2e60a4b42d Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13461 Reviewed-by: Michael Spang <spang@google.com> Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Rob Mohr <mohrr@google.com>
Diffstat (limited to 'pw_cli')
-rw-r--r--pw_cli/py/pw_cli/envparse.py6
-rw-r--r--pw_cli/py/pw_cli/process.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/pw_cli/py/pw_cli/envparse.py b/pw_cli/py/pw_cli/envparse.py
index 245099255..91445af1b 100644
--- a/pw_cli/py/pw_cli/envparse.py
+++ b/pw_cli/py/pw_cli/envparse.py
@@ -15,7 +15,7 @@
import argparse
import os
-from typing import Callable, Dict, Generic, IO, List, Literal, Mapping
+from typing import Callable, Dict, Generic, IO, List, Mapping
from typing import NamedTuple, Optional, TypeVar
@@ -172,7 +172,9 @@ def strict_bool(value: str) -> bool:
or value in _BOOLEAN_TRUE_EMOJI)
-OpenMode = Literal['r', 'rb', 'w', 'wb']
+# TODO(mohrr) Switch to Literal when no longer supporting Python 3.7.
+# OpenMode = Literal['r', 'rb', 'w', 'wb']
+OpenMode = str
class FileType:
diff --git a/pw_cli/py/pw_cli/process.py b/pw_cli/py/pw_cli/process.py
index d86dcfc4f..825dc0815 100644
--- a/pw_cli/py/pw_cli/process.py
+++ b/pw_cli/py/pw_cli/process.py
@@ -83,7 +83,8 @@ async def run_async(program: str,
Returns a CompletedProcess with details from the process.
"""
- _LOG.debug('Running `%s`', shlex.join([program, *args]))
+ _LOG.debug('Running `%s`',
+ ' '.join(shlex.quote(arg) for arg in [program, *args]))
env = os.environ.copy()
env[PW_SUBPROCESS_ENV] = '1'