aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/deploy/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside-tools/deploy/commands.py')
-rw-r--r--sources/pyside-tools/deploy/commands.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/sources/pyside-tools/deploy/commands.py b/sources/pyside-tools/deploy/commands.py
new file mode 100644
index 000000000..92745367f
--- /dev/null
+++ b/sources/pyside-tools/deploy/commands.py
@@ -0,0 +1,31 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+import subprocess
+import sys
+import logging
+
+"""
+All utility functions for deployment
+"""
+
+
+def run_command(command, dry_run: bool):
+ command_str = " ".join([str(cmd) for cmd in command])
+ try:
+ if not dry_run:
+ subprocess.check_call(command, shell=(sys.platform == "win32"))
+ else:
+ print(command_str + "\n")
+ except FileNotFoundError as error:
+ logging.exception(f"[DEPLOY]: {error.filename} not found")
+ raise
+ except subprocess.CalledProcessError as error:
+ logging.exception(
+ f"[DEPLOY]: Command {command_str} failed with error {error} and return_code"
+ f"{error.returncode}"
+ )
+ raise
+ except Exception as error:
+ logging.exception(f"[DEPLOY]: Command {command_str} failed with error {error}")
+ raise