예제 #1
0
    def get_call(self, *args, **kwargs):
        full_call, cli_args = testenv.process_args(*args, **kwargs)

        indices = self.const_indices.copy()
        indices.extend(full_call.split(' '))
        artifact = self.manifest.get_one(*indices)  # wrap exception?
        if not artifact:
            raise Exception('object "{}" not defined'.format(indices))

        invocation_key = self.manifest_options.get(INVOCATION_KEY,
                                                   INVOCATION_KEY)
        invocation = artifact.get(invocation_key, None)
        if not invocation:
            bin = artifact.get(BINARY_KEY, '')
            artifact_name = ' '.join([bin, artifact.get(PATH_KEY, '')]).strip()
            if len(artifact_name) == 0:
                raise Exception(
                    'object "{}" must contain one of "{}", "bin", or "path": {}'
                    .format(indices, invocation_key, artifact))
            invocation = '{} {}'.format(artifact_name, PLACEHOLDER_ARGS)

        chdir_key = self.manifest_options.get(CHDIR_KEY, CHDIR_KEY)
        chdir = artifact.get(chdir_key, None)
        return escape_placeholder(
            insert_into(invocation, PLACEHOLDER_ARGS, cli_args)), chdir
예제 #2
0
  def get_call(self, *args, **kwargs):
    full_call, cli_args = testenv.process_args(*args, **kwargs)

    indices = self.const_indices.copy()
    indices.extend(full_call.split(' '))
    artifact = self.manifest.get_one(*indices)  # wrap exception?
    if not artifact:
      raise Exception('object "{}" not defined'.format(indices))
    try:
      bin = artifact.get(BINARY_KEY, '')
      artifact = ' '.join([bin, artifact['path']])
    except Exception as e:
      raise Exception('object "{}" does not contain "path": {}'.format(
          indices, e))
    return '{} {}'.format(artifact, cli_args)
예제 #3
0
def process_call(all_args, kwargs):
    """The call is invoked as: ARTIFACT KWARGS POSITIONAL_KW_ARGS POSITIONAL_ARGS

  Args:
    args: List of arguments that comprise the actual call. The zeroth arg is the
      generic artifact name (see class description). Subsequent args are
      positional args.
    kwargs: Named arguments. Note that arguments whose names begin with an
      underscore (`_`) are treated specially as "positional kw" args: they are
        sorted, and then their values only are insertedas positional arguments
        before the normal positional arguments.
  """
    all_args = list(all_args)
    args = all_args[1:]
    full = all_args[0]
    service = None
    version = None
    rpc = None
    sample = None

    # parse the call into parts
    call_parts = full.split(':')
    if len(call_parts) > 2:
        raise ValueError('cannot parse call "{}"'.format(full))

    if len(call_parts) == 2:
        # Service[.Subservice ...].Version.RPC:sample
        sample = call_parts[1]
        rpc_parts = call_parts[0].split('.')
        if len(rpc_parts) > 0:
            rpc = rpc_parts.pop()
        if len(rpc_parts) > 0:
            version = rpc_parts.pop()
        if len(rpc_parts) > 0:
            service = '.'.join(rpc_parts)

    full_call, cli_args = testenv.process_args(*all_args, **kwargs)
    return service, version, rpc, sample, full_call, cli_args