How about abstract a function to accept cmd and call subprocess/print output/get exit code. Like https://github.com/otcshare/build-infrastructure/blob/1469_work/scripts/common/chromium_utils.py#L910