Ejemplo n.º 1
0
  def _set_up(self, sys_argv):
    options, args = self._parse_args(sys_argv, 1)
    dump_path = args[1]
    shared_first_dump_paths = args[2:]
    alternative_dirs_dict = {}
    if options.alternative_dirs:
      for alternative_dir_pair in options.alternative_dirs.split(':'):
        target_path, host_path = alternative_dir_pair.split('@', 1)
        alternative_dirs_dict[target_path] = host_path
    (bucket_set, dumps) = SubCommand.load_basic_files(
        dump_path, True, alternative_dirs=alternative_dirs_dict)

    self._timestamp = options.timestamp

    pfn_counts_dict = {}
    for shared_first_dump_path in shared_first_dump_paths:
      shared_dumps = SubCommand._find_all_dumps(shared_first_dump_path)
      for shared_dump in shared_dumps:
        pfn_counts = PFNCounts.load(shared_dump)
        if pfn_counts.pid not in pfn_counts_dict:
          pfn_counts_dict[pfn_counts.pid] = []
        pfn_counts_dict[pfn_counts.pid].append(pfn_counts)

    policy_set = PolicySet.load(SubCommand._parse_policy_list(options.policy))
    return policy_set, dumps, pfn_counts_dict, bucket_set
Ejemplo n.º 2
0
    def _set_up(self, sys_argv):
        options, args = self._parse_args(sys_argv, 1)
        dump_path = args[1]
        shared_first_dump_paths = args[2:]
        alternative_dirs_dict = {}
        if options.alternative_dirs:
            for alternative_dir_pair in options.alternative_dirs.split(':'):
                target_path, host_path = alternative_dir_pair.split('@', 1)
                alternative_dirs_dict[target_path] = host_path
        (bucket_set, dumps) = SubCommand.load_basic_files(
            dump_path, True, alternative_dirs=alternative_dirs_dict)

        self._timestamp = options.timestamp

        pfn_counts_dict = {}
        for shared_first_dump_path in shared_first_dump_paths:
            shared_dumps = SubCommand._find_all_dumps(shared_first_dump_path)
            for shared_dump in shared_dumps:
                pfn_counts = PFNCounts.load(shared_dump)
                if pfn_counts.pid not in pfn_counts_dict:
                    pfn_counts_dict[pfn_counts.pid] = []
                pfn_counts_dict[pfn_counts.pid].append(pfn_counts)

        policy_set = PolicySet.load(
            SubCommand._parse_policy_list(options.policy))
        return policy_set, dumps, pfn_counts_dict, bucket_set
Ejemplo n.º 3
0
    def do(self, sys_argv):
        options, args = self._parse_args(sys_argv, 4)
        dump_path = args[1]
        target_policy = args[2]
        component_name = args[3]
        depth = args[4]
        alternative_dirs_dict = {}

        policy_set = PolicySet.load(
            SubCommand._parse_policy_list(target_policy))
        if not policy_set[target_policy].find_rule(component_name):
            sys.stderr.write("ERROR: Component %s not found in policy %s\n" %
                             (component_name, target_policy))
            return 1

        if options.alternative_dirs:
            for alternative_dir_pair in options.alternative_dirs.split(':'):
                target_path, host_path = alternative_dir_pair.split('@', 1)
                alternative_dirs_dict[target_path] = host_path
        (bucket_set, dump) = SubCommand.load_basic_files(
            dump_path, False, alternative_dirs=alternative_dirs_dict)

        ExpandCommand._output(dump, policy_set[target_policy], bucket_set,
                              component_name, int(depth), sys.stdout)
        return 0
Ejemplo n.º 4
0
  def do(self, sys_argv, out=sys.stdout):
    _, args = self._parse_args(sys_argv, 2)
    dump_path = args[1]
    target_policy = args[2]
    (bucket_set, dumps) = SubCommand.load_basic_files(dump_path, True)
    policy_set = PolicySet.load(SubCommand._parse_policy_list(target_policy))

    MapCommand._output(dumps, bucket_set, policy_set[target_policy], out)
    return 0
Ejemplo n.º 5
0
    def do(self, sys_argv, out=sys.stdout):
        _, args = self._parse_args(sys_argv, 2)
        dump_path = args[1]
        target_policy = args[2]
        (bucket_set, dumps) = SubCommand.load_basic_files(dump_path, True)
        policy_set = PolicySet.load(
            SubCommand._parse_policy_list(target_policy))

        MapCommand._output(dumps, bucket_set, policy_set[target_policy], out)
        return 0
Ejemplo n.º 6
0
    def do(self, sys_argv):
        _, args = self._parse_args(sys_argv, 4)
        dump_path = args[1]
        target_policy = args[2]
        component_name = args[3]
        depth = args[4]
        (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
        policy_set = PolicySet.load(SubCommand._parse_policy_list(target_policy))

        ExpandCommand._output(dump, policy_set[target_policy], bucket_set, component_name, int(depth), sys.stdout)
        return 0
Ejemplo n.º 7
0
    def do(self, sys_argv):
        _, args = self._parse_args(sys_argv, 4)
        dump_path = args[1]
        target_policy = args[2]
        component_name = args[3]
        depth = args[4]
        (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
        policy_set = PolicySet.load(
            SubCommand._parse_policy_list(target_policy))

        ExpandCommand._output(dump, policy_set[target_policy], bucket_set,
                              component_name, int(depth), sys.stdout)
        return 0
Ejemplo n.º 8
0
  def do(self, sys_argv):
    options, args = self._parse_args(sys_argv, 2)

    dump_path = args[1]
    target_policy = args[2]
    component = options.component

    (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
    policy_set = PolicySet.load(SubCommand._parse_policy_list(target_policy))

    with open(SubCommand._find_prefix(dump_path) + '.maps', 'r') as maps_f:
      maps_lines = maps_f.readlines()
    PProfCommand._output(
        dump, policy_set[target_policy], bucket_set, maps_lines, component,
        sys.stdout)

    return 0
Ejemplo n.º 9
0
    def do(self, sys_argv):
        options, args = self._parse_args(sys_argv, 2)

        dump_path = args[1]
        target_policy = args[2]
        component = options.component

        (bucket_set, dump) = SubCommand.load_basic_files(dump_path, False)
        policy_set = PolicySet.load(
            SubCommand._parse_policy_list(target_policy))

        with open(SubCommand._find_prefix(dump_path) + '.maps', 'r') as maps_f:
            maps_lines = maps_f.readlines()
        PProfCommand._output(dump, policy_set[target_policy], bucket_set,
                             maps_lines, component, sys.stdout)

        return 0
Ejemplo n.º 10
0
  def do(self, sys_argv):
    options, args = self._parse_args(sys_argv, 4)
    dump_path = args[1]
    target_policy = args[2]
    component_name = args[3]
    depth = args[4]
    alternative_dirs_dict = {}

    policy_set = PolicySet.load(SubCommand._parse_policy_list(target_policy))
    if not policy_set[target_policy].find_rule(component_name):
      sys.stderr.write("ERROR: Component %s not found in policy %s\n"
          % (component_name, target_policy))
      return 1

    if options.alternative_dirs:
      for alternative_dir_pair in options.alternative_dirs.split(':'):
        target_path, host_path = alternative_dir_pair.split('@', 1)
        alternative_dirs_dict[target_path] = host_path
    (bucket_set, dump) = SubCommand.load_basic_files(
        dump_path, False, alternative_dirs=alternative_dirs_dict)

    ExpandCommand._output(dump, policy_set[target_policy], bucket_set,
                          component_name, int(depth), sys.stdout)
    return 0