(cmd, timeout=60)
Execute cmd
Execute cmd
Execute cmd
def do_shell_command(cmd, timeout=60):
    """ Execute cmd
    """
    try:
        # capture output is only supported in py 3.7
        if sys.version_info.minor >= 7:
            result = subprocess.run(
                cmd.split(' '), timeout=timeout, capture_output=True)
        else:
            result = subprocess.run(
                cmd.split(' '),
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT,
                timeout=timeout
            )

        if result.stderr:
            return result.stderr.decode('utf8')

        return result.stdout.decode('utf8')

    except subprocess.TimeoutExpired:
        return None
def do_shell_command ( cmd , timeout = 60 ) : try : # capture output is only supported in py 3.7 if sys . version_info . minor >= 7 : result = subprocess . run ( cmd . split ( ' ' ) , timeout = timeout , capture_output = True ) else : result = subprocess . run ( cmd . split ( ' ' ) , stdout = subprocess . PIPE , stderr = subprocess . STDOUT , timeout = timeout ) if result . stderr : return result . stderr . decode ( 'utf8' ) return result . stdout . decode ( 'utf8' ) except subprocess . TimeoutExpired : return None