Ejemplo n.º 1
0
def get_edid():
    file_path = os.path.join(TMP_DIR, 'edid.dat')
    cmd = "tvservice -d {}".format(file_path)
    run_cmd(cmd)
    try:
        dat = read_file_contents(file_path)
        delete_file(file_path)
        return dat
    except:
        return "EMPTY"
Ejemplo n.º 2
0
def set_curl(enable, host=None, port=None, username=None, password=None):
    url_string = generate_proxy_url(host, port, username, password)
    data = 'proxy={url}'.format(url=url_string)

    files = [os.path.join(f, '.curlrc') for f in get_all_home_folders(root=True, skel=True)]
    for f in files:
        if not enable:
            delete_file(f)
        else:
            write_file_contents(f, data)
Ejemplo n.º 3
0
def get_edid():
    file_path = TMP_DIR + 'edid.dat'
    cmd = "tvservice -d {}".format(file_path)
    run_cmd(cmd)
    try:
        dat = read_file_contents(file_path)
        delete_file(file_path)
        return dat
    except:
        return "EMPTY"
Ejemplo n.º 4
0
def read_edid():
    edid_dat_path = '/tmp/edid.dat'

    delete_file(edid_dat_path)
    edid_txt, _, rc = run_cmd('tvservice -d {0} && edidparser {0}'.format(edid_dat_path))
    edid_txt = edid_txt.splitlines()
    if rc != 0:
        logger.error('error getting edid dat')
        return
    delete_file(edid_dat_path)
    return edid_txt
Ejemplo n.º 5
0
def read_edid():
    edid_dat_path = '/tmp/edid.dat'

    delete_file(edid_dat_path)
    edid_txt, _, rc = run_cmd('{0} -d {1} && edidparser {1}'.format(
        tvservice_path, edid_dat_path))
    edid_txt = edid_txt.splitlines()
    if rc != 0:
        logger.error("error getting edid dat")
        return
    delete_file(edid_dat_path)
    return edid_txt
Ejemplo n.º 6
0
def upgrade_python(appstate_before, visible=False):

    def visible_run(cmd):
        if visible:
            return run_print_output_error(cmd)
        else:
            return run_cmd_log(cmd)

    if not os.path.exists(python_modules_file):
        if visible:
            print 'python module file doesn\'t exists'
        return [], []

    if 'python-pip' in appstate_before or \
       'python-setuptools' in appstate_before:
        # remove old pip and setuptools
        cmd = 'yes "" | apt-get -y purge python-setuptools ' + \
              'python-virtualenv python-pip'
        visible_run(cmd)

    # installing/upgrading pip
    o, _, _ = run_cmd('pip -V')
    if 'pip 1.' in o:
        cmd = 'pip install --upgrade pip'
        visible_run(cmd)
    else:
        cmd = 'wget -q --no-check-certificate ' + \
              'https://raw.github.com/pypa/pip/master/contrib/get-pip.py ' + \
              '-O get-pip.py'
        visible_run(cmd)

        cmd = 'python get-pip.py'
        visible_run(cmd)

        delete_file('get-pip.py')

    # parse python modules
    python_modules = read_file_contents_as_lines(python_modules_file)

    ok_modules = []
    error_modules = []

    for module in python_modules:
        o, e, rc = visible_run('pip install --upgrade {}'.format(module))

        if rc == 0:
            if 'Successfully installed' in o:
                ok_modules.append(module)
        else:
            error_modules.append(module)

    return ok_modules, error_modules
Ejemplo n.º 7
0
def set_curl(enable, host=None, port=None, username=None, password=None):
    url_string = generate_proxy_url(host, port, username, password)
    data = 'proxy={url}'.format(url=url_string)

    files = [
        os.path.join(f, '.curlrc')
        for f in get_all_home_folders(root=True, skel=True)
    ]
    for f in files:
        if not enable:
            delete_file(f)
        else:
            write_file_contents(f, data)
Ejemplo n.º 8
0
def upgrade_python(appstate_before, visible=False):
    def visible_run(cmd):
        if visible:
            return run_print_output_error(cmd)
        else:
            return run_cmd_log(cmd)

    if not os.path.exists(python_modules_file):
        if visible:
            print "python module file doesn't exists"
        return [], []

    if 'python-pip' in appstate_before or \
       'python-setuptools' in appstate_before:
        # remove old pip and setuptools
        cmd = 'yes "" | apt-get -y purge python-setuptools ' + \
              'python-virtualenv python-pip'
        visible_run(cmd)

    # installing/upgrading pip
    o, _, _ = run_cmd('pip -V')
    if 'pip 1.' in o:
        cmd = 'pip install --upgrade pip'
        visible_run(cmd)
    else:
        cmd = 'wget -q --no-check-certificate ' + \
              'https://raw.github.com/pypa/pip/master/contrib/get-pip.py ' + \
              '-O get-pip.py'
        visible_run(cmd)

        cmd = 'python get-pip.py'
        visible_run(cmd)

        delete_file('get-pip.py')

    # parse python modules
    python_modules = read_file_contents_as_lines(python_modules_file)

    ok_modules = []
    error_modules = []

    for module in python_modules:
        o, e, rc = visible_run('pip install --upgrade {}'.format(module))

        if rc == 0:
            if 'Successfully installed' in o:
                ok_modules.append(module)
        else:
            error_modules.append(module)

    return ok_modules, error_modules
Ejemplo n.º 9
0
def read_edid():
    delete_file(TMP_EDID_DAT_PATH)

    cmd = '{tvservice} --dumpedid {edid_dat} && edidparser {edid_dat}'.format(
        tvservice=tvservice_path, edid_dat=TMP_EDID_DAT_PATH)
    edid_txt, _, rc = run_cmd(cmd)
    edid_txt = edid_txt.splitlines()

    if rc != 0:
        logger.error("error getting edid dat")
        return

    delete_file(TMP_EDID_DAT_PATH)
    return edid_txt
Ejemplo n.º 10
0
def get_hdmi_info():
    '''
    Returns a string with Display info
    '''
    # Current resolution
    cmd = "tvservice -s"
    o, _, _ = run_cmd(cmd)
    res = 'Current resolution: {}\n\n'.format(o)
    # edid file
    file_path = os.path.join(TMP_DIR, 'edid.dat')
    cmd = "tvservice -d {} && edidparser {}".format(file_path, file_path)
    edid, _, _ = run_cmd(cmd)
    delete_file(file_path)

    return res + edid
Ejemplo n.º 11
0
def get_hdmi_info():
    '''
    Returns a string with Display info
    '''
    # Current resolution
    cmd = "tvservice -s"
    o, _, _ = run_cmd(cmd)
    res = 'Current resolution: {}\n\n'.format(o)
    # edid file
    file_path = TMP_DIR + 'edid.dat'
    cmd = "tvservice -d {} && edidparser {}".format(file_path, file_path)
    edid, _, _ = run_cmd(cmd)
    delete_file(file_path)

    return res + edid
Ejemplo n.º 12
0
def read_edid():
    delete_file(TMP_EDID_DAT_PATH)

    cmd = '{tvservice} --dumpedid {edid_dat} && edidparser {edid_dat}'.format(
        tvservice=tvservice_path, edid_dat=TMP_EDID_DAT_PATH
    )
    edid_txt, _, rc = run_cmd(cmd)
    edid_txt = edid_txt.splitlines()

    if rc != 0:
        logger.error("error getting edid dat")
        return

    delete_file(TMP_EDID_DAT_PATH)
    return edid_txt
Ejemplo n.º 13
0
def delete_screenshot():
    '''
    Deletes the SCREENSHOT_PATH file
    '''
    delete_file(SCREENSHOT_PATH)
Ejemplo n.º 14
0
def delete_screenshot():
    '''
    Deletes the SCREENSHOT_PATH file
    '''
    delete_file(SCREENSHOT_PATH)