# Path: utils/process.py
# def get_stdout(cmd, shell=False):
#     rc, stdout, stderr = run_cmd(cmd, shell=shell)
#     return stdout
# 
# Path: utils/v4l.py
# def v4l_get_current_device():
#     return os.environ.get('V4L2_TEST_DEVICE', '/dev/video0')


import os
from utils.process import get_stdout
from utils.v4l import v4l_get_current_device
    from utils.run import run_test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2015, Florent Thiery 


cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink -v | grep v4l2src0"

def run():
    try:
        caps = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).split('caps = ')[1].strip().replace('\\', '')
        msg = "Default caps are: %s" %caps
        return (True, msg)
    except Exception as e:
        print(e)

# Path: utils/process.py
# def get_stdout(cmd, shell=False):
#     rc, stdout, stderr = run_cmd(cmd, shell=shell)
#     return stdout
# 
# Path: utils/v4l.py
# def v4l_get_current_device():
#     return os.environ.get('V4L2_TEST_DEVICE', '/dev/video0')


# Path: tests/v4l/default_caps.py
import os
from utils.process import get_stdout
from utils.v4l import v4l_get_current_device
    from utils.run import run_test

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2015, Florent Thiery 


cmd_pattern = "gst-launch-1.0 v4l2src device=%s num-buffers=1 ! fakesink -v | grep v4l2src0"

def run():
    try:
        caps = get_stdout(cmd_pattern %v4l_get_current_device(), shell=True).split('caps = ')[1].strip().replace('\\', '')
        msg = "Default caps are: %s" %caps
        return (True, msg)
    except Exception as e:
        print(e)

        return (False, "Autonegociation failed")