def testInfoToList(self): value = "a=1;b=@;c=c;d=1@" expected = ['a=1', 'b=@', 'c=c', 'd=1@'] result = util.info_to_list(value) self.assertEqual(result, expected) value = "a=1:b=@:c=c:d=1@" result = util.info_to_list(value, ':') self.assertEqual(result, expected)
def infoBinStatistics(self): stats = util.info_to_list(self.info("bins")) stats.pop() stats = [value.split(':') for value in stats] stat_dict = {} for stat in stats: values = util.info_to_list(stat[1], ',') values = ";".join(filter(lambda v: '=' in v, values)) values = util.info_to_dict(values) stat_dict[stat[0]] = values return stat_dict
def infoNamespaces(self): """ Get a list of namespaces for this node. asinfo -v "namespaces" Returns: list -- list of namespaces """ return util.info_to_list(self.info("namespaces"))
def _infoServicesHelper(self, services): """ Takes an info services response and returns a list. """ if not services: return [] s = map(util.info_to_tuple, util.info_to_list(services)) return map(lambda v: (v[0], int(v[1])), s)
def infoSetStatistics(self): stats = self.info("sets") stats = util.info_to_list(stats) stats.pop() stats = [util.info_colon_to_dict(stat) for stat in stats] sets = {} for stat in stats: ns_name = stat['ns_name'] set_name = stat['set_name'] key = (ns_name, set_name) if key not in sets: sets[key] = {} set_dict = sets[key] set_dict.update(stat) return sets
def infoSIndex(self): return [util.info_to_dict(v, ':') for v in util.info_to_list(self.info("sindex"))[:-1]]