From 427d57141f75521b35e830551d618ea32b24ab35 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Fri, 20 Nov 2020 16:11:05 +0100 Subject: [PATCH] Improve docker-compose-config experience (#2266) * Improve docker-compose-config experience * Black * Isort * Don't look for a virtual env * Use python3 -m pip instead of pip3 for consistency * Black * Add set -ex --- docker-compose-config.py | 14 +++++++++++--- docker-compose-config.sh | 6 ++++++ 2 files changed, 17 insertions(+), 3 deletions(-) mode change 100755 => 100644 docker-compose-config.py create mode 100755 docker-compose-config.sh diff --git a/docker-compose-config.py b/docker-compose-config.py old mode 100755 new mode 100644 index 2a154c265ff..df1369becc3 --- a/docker-compose-config.py +++ b/docker-compose-config.py @@ -2,8 +2,13 @@ import secrets import string from typing import Optional -import yaml -from yaml.loader import FullLoader +try: + import yaml + from yaml.loader import FullLoader +except ImportError: + raise ImportError( + "Missing pyyaml! Install it with command `python3 -m pip install pyyaml` to run this configurator." + ) FILE_PATH = "docker-compose.yml" @@ -76,4 +81,7 @@ def main(): if __name__ == "__main__": - main() + try: + main() + except KeyboardInterrupt: + print("\nConfiguration canceled.") diff --git a/docker-compose-config.sh b/docker-compose-config.sh new file mode 100755 index 00000000000..fd6a1fab73a --- /dev/null +++ b/docker-compose-config.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -ex +python3 -m pip install pyyaml +echo +python3 docker-compose-config.py