Return string for CLI invocation of kal, for channel scan.
765193
def build_kal_scan_channel_string(kal_bin, channel, args):
    """"""
    option_mapping = {"gain": "-g",
                      "device": "-d",
                      "error": "-e"}
    base_string = "%s -v -c %s" % (kal_bin, channel)
    base_string += options_string_builder(option_mapping, args)
    return(base_string)
859107
def _get_initialized_channels_dict_for_service(self, org_id, service_id):
        ''''''
        fn = self._get_channels_info_file(org_id, service_id)
        if (os.path.isfile(fn)):
            return pickle.load( open( fn, "rb" ) )
        else:
            return {}
352482
def invocation():
    """"""
    cmdargs = [sys.executable] + sys.argv[:]
    invocation = " ".join(shlex.quote(s) for s in cmdargs)
    return invocation
298509
def get_x():
    '''
    
    '''
    cmd = 'setxkbmap -query | grep layout'
    out = __salt__['cmd.run'](cmd, python_shell=True).split(':')
    return out[1].strip()
1213266
def get_fptr(self):
        """"""
        cmpfunc = ctypes.CFUNCTYPE(ctypes.c_int,
                                   WPARAM,
                                   LPARAM,
                                   ctypes.POINTER(KBDLLHookStruct))
        return cmpfunc(self.handle_input)
1295835
def find_callback(args, kw=None):
    ''
    if args and callable(args[-1]):
        return args[-1], args[:-1]
    try:
        return kw['callback'], args
    except (KeyError, TypeError):
        return None, args
623998
def get_return_code(self, stderr=STDOUT):
        
        args = shlex.split(self.cmd)
        return call(args, stdout=PIPE, stderr=stderr)
1313084
def cli_info(self, event):
        """"""

        self.log('Instance:', self.instance,
                 'Dev:', self.development,
                 'Host:', self.host,
                 'Port:', self.port,
                 'Insecure:', self.insecure,
                 'Frontend:', self.frontendtarget)
289290
def rustcall(func, *args):
    """"""
    lib.semaphore_err_clear()
    rv = func(*args)
    err = lib.semaphore_err_get_last_code()
    if not err:
        return rv
    msg = lib.semaphore_err_get_last_message()
    cls = exceptions_by_code.get(err, SemaphoreError)
    exc = cls(decode_str(msg))
    backtrace = decode_str(lib.semaphore_err_get_backtrace())
    if backtrace:
        exc.rust_info = backtrace
    raise exc
765968
def _get_cl_version(p, config):
    
    if not p.get("has_cl_version", True):
        return ""
    try:
        prog = config_utils.get_program(p["cmd"], config)
    except config_utils.CmdNotFound:

        localpy_cmd = os.path.join(os.path.dirname(sys.executable), p["cmd"])
        if os.path.exists(localpy_cmd):
            prog = localpy_cmd
        else:
            return ""
    args = p.get("args", "")

    cmd = "{prog} {args}"
    subp = subprocess.Popen(cmd.format(**locals()), stdout=subprocess.PIPE,
                            stderr=subprocess.STDOUT,
                            shell=True)
    with contextlib.closing(subp.stdout) as stdout:
        if p.get("stdout_flag"):
            v = _parse_from_stdoutflag(stdout, p["stdout_flag"])
        elif p.get("paren_flag"):
            v = _parse_from_parenflag(stdout, p["paren_flag"])
        else:
            lines = [l.strip() for l in str(stdout.read()).split("\n") if l.strip()]
            v = lines[-1]
    if v.endswith("."):
        v = v[:-1]
    return v
1218066
def cli(  # pylint: disable=too-many-arguments
        ctx, target, config, c, commits, extra_path, ignore, msg_filename,
        verbose, silent, debug,
):
    

    try:
        if debug:
            logging.getLogger("gitlint").setLevel(logging.DEBUG)

        log_system_info()

        # Get the lint config from the commandline parameters and
        # store it in the context (click allows storing an arbitrary object in ctx.obj).
        config, config_builder = build_config(ctx, target, config, c, extra_path, ignore, verbose, silent, debug)

        LOG.debug(u"Configuration\n%s", ustr(config))

        ctx.obj = (config, config_builder, commits, msg_filename)

        # If no subcommand is specified, then just lint
        if ctx.invoked_subcommand is None:
            ctx.invoke(lint)

    except GitContextError as e:
        click.echo(ustr(e))
        ctx.exit(GIT_CONTEXT_ERROR_CODE)
983839
def determine_chan_detect_threshold(kal_out):
    """"""
    channel_detect_threshold = ""
    while channel_detect_threshold == "":
        for line in kal_out.splitlines():
            if "channel detect threshold: " in line:
                channel_detect_threshold = str(line.split()[-1])
        if channel_detect_threshold == "":
            print("Unable to parse sample rate")
            channel_detect_threshold = None
    return channel_detect_threshold
1025793
def determine_device(kal_out):
    """"""
    device = ""
    while device == "":
        for line in kal_out.splitlines():
            if "Using device " in line:
                device = str(line.split(' ', 2)[-1])
        if device == "":
            device = None
    return device
608943
def cmd(args, interact=False):
    """"""
    if isinstance(args, (str, bytes)):
        args = args.split()
    return CLI.cmd(args=args, interact=interact)
632192
def enter_cli_mode(self):
        """"""
        delay_factor = self.select_delay_factor(delay_factor=0)
        count = 0
        cur_prompt = ""
        while count < 50:
            self.write_channel(self.RETURN)
            time.sleep(0.1 * delay_factor)
            cur_prompt = self.read_channel()
            if re.search(r"admin@", cur_prompt) or re.search(
                r"^\$$", cur_prompt.strip()
            ):
                self.write_channel("cli" + self.RETURN)
                time.sleep(0.3 * delay_factor)
                self.clear_buffer()
                break
            elif ">" in cur_prompt or "%" in cur_prompt:
                break
            count += 1
1103627
def _scan_radio_channels(self, cradio, start=0, stop=125):
        
        return list(cradio.scan_channels(start, stop, (0xff,)))
126777
def getcallparams(
            self, target, conf=None, args=None, kwargs=None, exec_ctx=None
    ):
        """"""

        if args is None:
            args = []

        if kwargs is None:
            kwargs = {}

        if conf is None:
            conf = self.conf

        params = conf.params

        try:
            argspec = getargspec(target)

        except TypeError as tex:
            argspec = None
            callargs = {}

        else:
            try:
                callargs = getcallargs(target, *args, **kwargs)

            except TypeError as tex:
                if tex.args[0].endswith('\'{0}\''.format(argspec.args[0])):
                    args = [None]

                else:
                    raise

                try:
                    callargs = getcallargs(target, *args, **kwargs)

                except TypeError as tex:
                    if tex.args[0].endswith('\'{0}\''.format(argspec.args[0])):
                        args = []

                    else:
                        raise

                    callargs = getcallargs(target, *args, **kwargs)

                args = []

        pnames = set(params)

        for pname in pnames:

            if argspec and pname in argspec.args and (
                    (exec_ctx is not None and pname in exec_ctx)
                    or
                    callargs.get(pname) is None
            ):

                kwargs[pname] = params[pname].value

        if exec_ctx is not None:
            exec_ctx |= pnames

        return args, kwargs