示例#1
0
def _convert_launch_chrome_options_to_external_metadata(parsed_args):
  metadata = parsed_args.additional_metadata

  for definition in manager.get_metadata_definitions():
    value = getattr(parsed_args, definition.python_name, None)
    if value is not None:
      metadata[definition.name] = value

  if bool(parsed_args.jdb_port or parsed_args.gdb):
    metadata['disableChildPluginRetry'] = True
    metadata['disableHeartbeat'] = True
    metadata['sleepOnBlur'] = False

  if (parsed_args.mode == 'atftest' or parsed_args.mode == 'system' or
      OPTIONS.get_system_packages()):
    # An app may briefly go through empty stack while running
    # addAccounts() in account manager service.
    # TODO(igorc): Find a more precise detection mechanism to support GSF,
    # implement empty stack timeout, or add a flag if this case is more common.
    metadata['allowEmptyActivityStack'] = True

  command = _generate_shell_command(parsed_args)
  if command:
    metadata['shell'] = command

  metadata['isDebugCodeEnabled'] = OPTIONS.is_debug_code_enabled()

  return metadata
示例#2
0
def _add_parser_arguments_for_metadata(parser):
    def convert_short_options_to_long(metadata_definition, value):
        if metadata_definition.short_value_mapping:
            mapping = metadata_definition.short_value_mapping
            if value in mapping:
                return mapping[value]
        return value

    group = parser.add_argument_group('Manifest metadata (auto-generated)')
    metadata_definitions = manager.get_metadata_definitions()

    for definition in metadata_definitions:
        argument_names = ['--' + definition.command_argument_name]
        if definition.short_option_name:
            argument_names.append('-' + definition.short_option_name)

        default = definition.default_value
        metadata_type = type(default)

        additional_params = {}
        if metadata_type is bool:
            action = 'store_true'
            if default is True:
                action = 'store_false'
            additional_params['action'] = action
        elif metadata_type is unicode:
            additional_params.update({
                'choices':
                definition.allowed_values,
                'type':
                functools.partial(convert_short_options_to_long, definition)
            })
        elif metadata_type is int:
            additional_params.update({
                'choices': definition.allowed_values,
                'type': int
            })
        else:
            raise Exception('Unknown metdata type: ' + str(metadata_type))

        group.add_argument(*argument_names,
                           dest=definition.python_name,
                           default=None,
                           help=definition.help,
                           **additional_params)
示例#3
0
def _add_parser_arguments_for_metadata(parser):
  def convert_short_options_to_long(metadata_definition, value):
    if metadata_definition.short_value_mapping:
      mapping = metadata_definition.short_value_mapping
      if value in mapping:
        return mapping[value]
    return value

  group = parser.add_argument_group('Manifest metadata (auto-generated)')
  metadata_definitions = manager.get_metadata_definitions()

  for definition in metadata_definitions:
    argument_names = ['--' + definition.command_argument_name]
    if definition.short_option_name:
      argument_names.append('-' + definition.short_option_name)

    default = definition.default_value
    metadata_type = type(default)

    additional_params = {}
    if metadata_type is bool:
      action = 'store_true'
      if default is True:
        action = 'store_false'
      additional_params['action'] = action
    elif metadata_type is unicode:
      additional_params.update({
          'choices': definition.allowed_values,
          'type': functools.partial(convert_short_options_to_long, definition)
      })
    elif metadata_type is int:
      additional_params.update({
          'choices': definition.allowed_values,
          'type': int
      })
    else:
      raise Exception('Unknown metdata type: ' + str(metadata_type))

    group.add_argument(
        *argument_names,
        dest=definition.python_name,
        default=None,
        help=definition.help,
        **additional_params)
示例#4
0
def main():
  metadata_definitions = manager.get_metadata_definitions()

  default_values = {}
  allowed_values = {}
  plugin_fields = []
  child_plugin_fields = []

  for definition in metadata_definitions:
    if definition.external_only:
      continue
    default_values[definition.name] = definition.default_value
    if definition.allowed_values:
      allowed_values[definition.name] = definition.allowed_values
    if definition.plugin:
      plugin_fields.append(definition.name)
    if definition.child_plugin:
      child_plugin_fields.append(definition.name)

  sys.stdout.write(_TEMPLATE.format(json.dumps(default_values, indent=2),
                                    json.dumps(allowed_values, indent=2),
                                    json.dumps(plugin_fields, indent=2),
                                    json.dumps(child_plugin_fields, indent=2)))