(adapter,
        frontend,
        ch_conf_file,
        user_info,
        lnb="UNIVERSAL",
        output=None,
        timeout=None,
        monitor=False)
return ps
Run zapper

    Args:
        adapter      : DVB adapter index
        frontend     : frontend
        ch_conf_file : Path to channel configurations file
        user_info    : Dictionary with user configurations
        lnb          : LNB type
        output       : Output filename (when recording)
        timeout      : Run the zap for this specified duration
        monitor      : Monitor mode. Monitors DVB traffic stats (throughput and
                       packets per second), but does not deliver data upstream.

    Returns:
        Subprocess object
Run zapper
Run zapper
def zap(adapter,
        frontend,
        ch_conf_file,
        user_info,
        lnb="UNIVERSAL",
        output=None,
        timeout=None,
        monitor=False):
    """Run zapper

    Args:
        adapter      : DVB adapter index
        frontend     : frontend
        ch_conf_file : Path to channel configurations file
        user_info    : Dictionary with user configurations
        lnb          : LNB type
        output       : Output filename (when recording)
        timeout      : Run the zap for this specified duration
        monitor      : Monitor mode. Monitors DVB traffic stats (throughput and
                       packets per second), but does not deliver data upstream.

    Returns:
        Subprocess object

    """

    util.print_header("Tuning the DVB-S2 Receiver")

    # LNB name to use when calling dvbv5-zap
    if (lnb is None):
        # Find suitable LNB within v4l-utils preset LNBs
        lnb = _find_v4l_lnb(user_info)['alias']

    print("Running dvbv5-zap")
    print("  - Config:   {}".format(ch_conf_file))
    print("  - Adapter:  {}".format(adapter))
    print("  - Frontend: {}".format(frontend))
    print("  - LNB:      {}".format(lnb))

    cmd = [
        "dvbv5-zap", "-c", ch_conf_file, "-a",
        str(adapter), "-f",
        str(frontend), "-l", lnb, "-v"
    ]

    rec_mode = output is not None
    if (rec_mode):
        cmd = cmd + ["-o", output]

        if (os.path.exists(output)):
            print("File %s already exists" % (output))

            # The recording is such that MPEG TS packets are overwritten one by
            # one. For instance, if previous ts file had 1000 MPEG TS packets,
            # when overwriting, the tool would overwrite each packet
            # individually. So if it was stopped for instance after the first
            # 10 MPEG TS packets, only the first 10 would be overwritten, the
            # remaining MPEG TS packets would remain in the ts file.
            #
            # The other option is to remove the ts file completely and start a
            # new one. This way, all previous ts packets are guaranteed to be
            # erased.
            raw_resp = input(
                "Remove and start new (R) or Overwrite (O)? [R/O] ")
            response = raw_resp.lower()

            if (response == "r"):
                os.remove(output)
            elif (response != "o"):
                raise ValueError("Unknown response")

    if (timeout is not None):
        cmd = cmd + ["-t", timeout]

    if (monitor):
        assert(output is None), \
            "Monitor mode does not work if recording (i.e. w/ -r flag)"
        cmd.append("-m")

    cmd.append("blocksat-ch")

    logger.debug("> " + " ".join(cmd))

    # Make sure the locale of dvbv5-zap is set to English. Otherwise, the
    # parser of "_parse_log" would not work.
    new_env = dict(os.environ)
    new_env['LC_ALL'] = 'C'

    if (monitor or rec_mode):
        ps = subprocess.Popen(cmd, env=new_env)
    else:
        ps = subprocess.Popen(cmd,
                              stdout=subprocess.DEVNULL,
                              stderr=subprocess.PIPE,
                              env=new_env,
                              universal_newlines=True)
    return ps
def zap ( adapter , frontend , ch_conf_file , user_info , lnb = "UNIVERSAL" , output = None , timeout = None , monitor = False ) : util . print_header ( "Tuning the DVB-S2 Receiver" ) # LNB name to use when calling dvbv5-zap if ( lnb is None ) : # Find suitable LNB within v4l-utils preset LNBs lnb = _find_v4l_lnb ( user_info ) [ 'alias' ] print ( "Running dvbv5-zap" ) print ( "  - Config:   {}" . format ( ch_conf_file ) ) print ( "  - Adapter:  {}" . format ( adapter ) ) print ( "  - Frontend: {}" . format ( frontend ) ) print ( "  - LNB:      {}" . format ( lnb ) ) cmd = [ "dvbv5-zap" , "-c" , ch_conf_file , "-a" , str ( adapter ) , "-f" , str ( frontend ) , "-l" , lnb , "-v" ] rec_mode = output is not None if ( rec_mode ) : cmd = cmd + [ "-o" , output ] if ( os . path . exists ( output ) ) : print ( "File %s already exists" % ( output ) ) # The recording is such that MPEG TS packets are overwritten one by # one. For instance, if previous ts file had 1000 MPEG TS packets, # when overwriting, the tool would overwrite each packet # individually. So if it was stopped for instance after the first # 10 MPEG TS packets, only the first 10 would be overwritten, the # remaining MPEG TS packets would remain in the ts file. # # The other option is to remove the ts file completely and start a # new one. This way, all previous ts packets are guaranteed to be # erased. raw_resp = input ( "Remove and start new (R) or Overwrite (O)? [R/O] " ) response = raw_resp . lower ( ) if ( response == "r" ) : os . remove ( output ) elif ( response != "o" ) : raise ValueError ( "Unknown response" ) if ( timeout is not None ) : cmd = cmd + [ "-t" , timeout ] if ( monitor ) : assert ( output is None ) , "Monitor mode does not work if recording (i.e. w/ -r flag)" cmd . append ( "-m" ) cmd . append ( "blocksat-ch" ) logger . debug ( "> " + " " . join ( cmd ) ) # Make sure the locale of dvbv5-zap is set to English. Otherwise, the # parser of "_parse_log" would not work. new_env = dict ( os . environ ) new_env [ 'LC_ALL' ] = 'C' if ( monitor or rec_mode ) : ps = subprocess . Popen ( cmd , env = new_env ) else : ps = subprocess . Popen ( cmd , stdout = subprocess . DEVNULL , stderr = subprocess . PIPE , env = new_env , universal_newlines = True ) return ps