Use this entry point to call HL fiss funcs as though from the UNIX CLI.
       (see firecloud/tests/highlevel_tests.py:call_cli for usage examples)
188352
def main_as_cli(argv=None):
    ''''''
    try:
        result = main(argv)
    except Exception as e:
        result = __pretty_print_fc_exception(e)
    # FIXME: we should invert True/False return values to 0/1 here, to comply
    # with UNIX exit code semantics (and avoid problems with make, scripts, etc)
    return printToCLI(result)
461246
def call_command_handler(command, pymux, arguments):
    
    assert isinstance(arguments, list)

    # Resolve aliases.
    command = ALIASES.get(command, command)

    try:
        handler = COMMANDS_TO_HANDLERS[command]
    except KeyError:
        pymux.show_message('Invalid command: %s' % (command,))
    else:
        try:
            handler(pymux, arguments)
        except CommandException as e:
            pymux.show_message(e.message)
1246047
def call(self, fn, args, name='', cconv=None, tail=False, fastmath=()):
        
        inst = instructions.CallInstr(self.block, fn, args, name=name,
                                      cconv=cconv, tail=tail, fastmath=fastmath)
        self._insert(inst)
        return inst
753564
def execute_func(env, need, func_string):
    
    func_name, func_args, func_kwargs = _analyze_func_string(func_string)

    if func_name not in env.needs_functions.keys():
        raise SphinxError('Unknown dynamic sphinx-needs function: {}. Found in need: {}'.format(func_name, need['id']))

    func = env.needs_functions[func_name]['function']
    func_return = func(env, need, env.needs_all_needs, *func_args, **func_kwargs)

    if not isinstance(func_return, (str, int, float, list, unicode)) and func_return is not None:
        raise SphinxError('Return value of function {} is of type {}. Allowed are str, int, float'.format(
            func_name, type(func_return)))

    if isinstance(func_return, list):
        for element in func_return:
            if not isinstance(element, (str, int, float, unicode)):
                raise SphinxError('Element of return list of function {} is of type {}. '
                                  'Allowed are str, int, float'.format(func_name, type(func_return)))
    return func_return
955524
def call_plac(f):
    ""
    name = inspect.currentframe().f_back.f_globals['__name__']
    if name == '__main__':
        import plac
        res = plac.call(f)
        if callable(res): res()
    else: return f
301199
def main(args=sys.argv):
    

    parser = create_optparser(args[0])
    return cli(parser.parse_args(args[1:]))
312514
def browserstacker_command(func):
    
    pass_decorator = click.make_pass_decorator(APIWrapper)
    return cli.command()(pass_decorator(func))
848320
def execute(self):
        """"""
        if self._cli_arguments['cfn']:
            generate_sample_cfn_module(self.env_root)
        elif self._cli_arguments['sls']:
            generate_sample_sls_module(self.env_root)
        elif self._cli_arguments['sls-tsc']:
            generate_sample_sls_tsc_module(self.env_root)
        elif self._cli_arguments['stacker']:
            generate_sample_stacker_module(self.env_root)
        elif self._cli_arguments['tf']:
            generate_sample_tf_module(self.env_root)
        elif self._cli_arguments['cdk-tsc']:
            generate_sample_cdk_tsc_module(self.env_root)
        elif self._cli_arguments['cdk-py']:
            generate_sample_cdk_py_module(self.env_root)
        elif self._cli_arguments['cdk-csharp']:
            generate_sample_cdk_cs_module(self.env_root)
786933
def do_cli(function_name, stack_name, filter_pattern, tailing, start_time, end_time):
    

    LOG.debug("'logs' command is called")

    with LogsCommandContext(function_name,
                            stack_name=stack_name,
                            filter_pattern=filter_pattern,
                            start_time=start_time,
                            end_time=end_time,
                            # output_file is not yet supported by CLI
                            output_file=None) as context:

        if tailing:
            events_iterable = context.fetcher.tail(context.log_group_name,
                                                   filter_pattern=context.filter_pattern,
                                                   start=context.start_time)
        else:
            events_iterable = context.fetcher.fetch(context.log_group_name,
                                                    filter_pattern=context.filter_pattern,
                                                    start=context.start_time,
                                                    end=context.end_time)

        formatted_events = context.formatter.do_format(events_iterable)

        for event in formatted_events:
            # New line is not necessary. It is already in the log events sent by CloudWatch
            click.echo(event, nl=False)
1345705
def run_from_command_line():
    
    for commands_conf in firenado.conf.management['commands']:
        logger.debug("Loading %s commands from %s." % (
            commands_conf['name'],
            commands_conf['module']
        ))
        exec('import %s' % commands_conf['module'])
    command_index = 1
    for arg in sys.argv[1:]:
        command_index += 1
        if arg[0] != "-":
            break
    parser = FirenadoArgumentParser(prog=os.path.split(sys.argv[0])[1],
                                    add_help=False)
    parser.add_argument("-h", "--help", default=argparse.SUPPRESS)
    parser.add_argument("command", default="help", help="Command to executed")

    try:
        namespace = parser.parse_args(sys.argv[1:command_index])
        if not command_exists(namespace.command):
            show_command_line_usage(parser)
        else:
            run_command(namespace.command, sys.argv[command_index-1:])
    except FirenadoArgumentError:
        show_command_line_usage(parser, True)
324963
def run_func(func, *args, **kwargs):
    """"""
    ray.init()

    func = ray.remote(func)

    # NOTE: kwargs not allowed for now
    result = ray.get(func.remote(*args))

    # Inspect the stack to get calling example
    caller = inspect.stack()[1][3]
    print("%s: %s" % (caller, str(result)))

    return result
87543
def _cl_aws_cli(cls, file_info, region):
        
        s3file = cls._S3_FILE % {"bucket": file_info.bucket,
                                 "key": file_info.key,
                                 "region": ""}
        command = [os.path.join(os.path.dirname(sys.executable), "aws"),
                   "s3", "cp", "--region", region, s3file]
        return (command, "awscli")
7666
def call(sender, topic, *args, **kwargs):
    
    if not topic in _receivers:
        return
    items = _receivers[topic]
    def _cmp(x, y):
        return cmp(x[0], y[0])
    
    items.sort(_cmp)
    i = 0
    while i<len(items):
        nice, f = items[i]
        i = i + 1
        _f = f['func']
        if not _f:
            try:
                _f = import_attr(f['func_name'])
            except (ImportError, AttributeError) as e:
                logging.error("Can't import function %s" % f['func_name'])
                raise
            f['func'] = _f
        if callable(_f):
            kw = kwargs.copy()
            if not _test(kw, f):
                continue
            try:
                _f(sender, *args, **kw)
            except:
                func = _f.__module__ + '.' + _f.__name__
                logging.exception('Calling dispatch point [%s] %s(%r, %r) error!' % (topic, func, args, kw))
                raise
        else:
            raise Exception, "Dispatch point [%s] %r can't been invoked" % (topic, _f)
1050117
def call(cmd, *args, env: {}, stdin: "", chdir: nil)
        cmd  = bin.join(cmd.to_s).to_s
        args = args.map(&:to_s)
        env  = env.to_h.each_with_object({}) {|(k,v), h| h[k.to_s] = v.to_s}.merge({
          "PBS_DEFAULT"     => host,
          "LD_LIBRARY_PATH" => %{#{lib}:#{ENV["LD_LIBRARY_PATH"]}}
        })
        stdin = stdin.to_s
        chdir ||= "."
        o, e, s = Open3.capture3(env, cmd, *args, stdin_data: stdin, chdir: chdir.to_s)
        s.success? ? o : raise(PBS::Error, e)
      end
192987
function callFn(tpl, scope, option, buffer, parts, depth) {
  var caller, fn, command1;
  if (!depth) {
    command1 = findCommand(tpl.runtime.commands, tpl.root.config.commands, parts);
  }
  if (command1) {
    return command1.call(tpl, scope, option, buffer);
  } else if (command1 !== false) {
    caller = scope.resolve(parts.slice(0, -1), depth);
    fn = caller[parts[parts.length - 1]];
    if (fn) {
      // apply(x, undefined) error in ie8
      try {
        return fn.apply(caller, option.params || []);
      } catch (err) {
        buffer.error('Execute function `' + parts.join('.') + '` Error: ' + err.message);
        return buffer;
      }
    }
  }
  buffer.error('Command Not Found: ' + parts.join('.'));
  return buffer;
}
1176265
def cli(ctx, name,all):
    """"""
    ctx.gbc.say('all_example_functions',stuff=all_examples_functions, verbosity=1000)

    for example in all_examples_functions:
        if all or (name and example['name'] == name):
            if all:
                ctx.gbc.say('example',stuff=example, verbosity=100)
                name = example['name']
            #click.echo_via_pager(example['fun']())
            click.echo("#"*80)
            click.echo("### start of bubble example: "+name)
            click.echo("#"*80)
            click.echo(example['fun']())
            click.echo("#"*80)
            click.echo("### end of bubble example: "+name)
            click.echo("#"*80)
            click.echo()

        else:
            click.echo("available example: " + example['name'])
459502
def run():
    
    #Define the import statements
    impheader = """import sys
import conv_base

"""
    #Define the test case pattern
    pattern="""class Test%d(conv_base.%sCase):
    @classmethod
    def setUpClass(cls):
        cls.obsmode="%s"
        cls.spectrum="%s"
        cls.fname="C%s_%s.fits"
        cls.setup2()\n\n"""


    #We're going to split these by obsmode.
    outfiles = {'None':'sponly/sponly.py',
                'acs':'acs/acs.py',
                'nicmos':'nicmos/nicmos.py',
                'stis':'stis/stis.py',
                'wfc3,ir':'wfc3_ir/wfc3_ir.py',
                'wfc3,uvis1':'wfc3_uvis1/wfc3_uvis1.py',
                'wfc3,uvis2':'wfc3_uvis2/wfc3_uvis2.py',
                'oops':'oops/oops.py'
                }

    #And subclass for spectrum-only and thermal cases based on obsmode.
    casetype = {"None": "Spec",
                "nicmos": "Therm",
                "wfc3,ir": "Therm"}
    #Use with default=Comm
                
    #Open the database
    db = sqlite3.connect("/ssbwebv1/data1/pandokia/old/pdk/c3/db/pdk.db")


    #Open and initialize the output files
    setdirs(outfiles)
    for k in outfiles:
        outfiles[k] = open(outfiles[k], 'w')
        outfiles[k].write(impheader)

    count=0

    #Select unique (obsmode,spectrum) pairs from our database table of
    #commissioning tests. Sort them by obsmode.

    #Omit cases where spectrum is None, because we've verified that all
    #those obsmodes are duplicated elsewhere.

    #First the bp only. The purpose of these is thermal.
    c = db.execute(""" SELECT DISTINCT obsmode, spectrum
                       FROM synpysyn
                       WHERE spectrum != "None"
                       ORDER BY obsmode""")

    #Now loop over them, and define test cases.
    for x in c:
       obsmode, spectrum = x
       count+=1
       outkey=pickname(obsmode,outfiles)
       defn=pattern%(count,
                     casetype.get(outkey, "Comm"),
                     obsmode,spectrum,count,"%s")
       outfiles[outkey].write(defn)

    #Close all the files
    for k in outfiles:
        outfiles[k].close()