myops/scripts/common/__init__.py
2021-06-22 19:17:37 +08:00

24 lines
657 B
Python

import subprocess
import logging
def run_cmd(cmd, shell=True):
'''
Run command with arguments, wait to complete and return ``True`` on success.
:param cls: The class as implicit first argument.
:param cmd: Command string to be executed.
:returns : ``True`` on success, otherwise ``None``.
:rtype : ``bool``
'''
# logger = logger.getLogger('SPOT.INGEST.COMMON.UTIL')
logging.debug('Execute command: {0}'.format(cmd))
try:
subprocess.call(cmd, shell=shell)
return True
except Exception as exc:
logging.error('[{0}] {1}'.format(
exc.__class__.__name__, exc.message))