def get_ingestions(self, num=None, filter_opts=None): log.info('getting ingestion history') if num: chunk_size = num log.info('explicit number of results requested: %s', chunk_size) elif filter_opts: chunk_size = 10 log.info('filters detected, defaulting number of results to %s', chunk_size) else: chunk_size = 100 log.info('using catch all default result limit of %s', chunk_size) settings = {'chunkSize': chunk_size, 'currentPage': 1} if filter_opts is not None: if not isDict(filter_opts): code_error('passed non-dictionary for filter opts to get_ingestions') for key, value in sorted(filter_opts.items()): log.info("filter: '%s' = '%s'", key, value) settings = merge_dicts(settings, filter_opts) log.info('settings: %s', settings) log.info('querying Zaloni for ingestion history') (req, self.query_time) = self.req(url='{url_base}/ingestion/publish/getFileIndex' .format(url_base=self.url_base), # orders by newest first, but seems to return last 10 anyway body=json.dumps(settings)) try: log.info('parsing JSON response') json_dict = json.loads(req.content) except ValueError as _: qquit('UNKNOWN', 'error parsing json returned by Zaloni: {0}'.format(_)) return json_dict
def print_table_row_prefix_counts(self): print('=' * self.total_width) print('{0:{1}}{2}'.format(self.key_prefix_header, self.key_prefix_width, self.separator), end='') print('{0:{1}}{2}{3}'.format(self.row_count_header, self.row_count_width, self.separator, self.row_count_pc_header) ) print('=' * self.total_width) tmp_list = [merge_dicts({'key_prefix': key}, self.rows[key]) for key in self.rows] if self.sort: if self.sort_desc: tmp_list.sort(key=lambda _: -_['row_count']) else: tmp_list.sort(key=lambda _: _['row_count']) for item in tmp_list: print('{0:{1}}{2}'.format(item['key_prefix'], self.key_prefix_width, self.separator), end='') print('{0:{1}}{2}{3:>10}'.format(item['row_count'], self.row_count_width, self.separator, item['pc']))
def print_table_row_prefix_counts(self): print('=' * self.total_width) print('{0:{1}}{2}'.format(self.key_prefix_header, self.key_prefix_width, self.separator), end='') print('{0:{1}}{2}{3}'.format(self.row_count_header, self.row_count_width, self.separator, self.row_count_pc_header) ) print('=' * self.total_width) tmp_list = [merge_dicts({'key_prefix': key}, self.rows[key]) for key in self.rows] if self.sort: if self.sort_desc: tmp_list.sort(key=lambda _: -_['row_count']) else: tmp_list.sort(key=lambda _: _['row_count']) for item in tmp_list: print('{0:{1}}{2}'.format(item['key_prefix'], self.key_prefix_width, self.separator), end='') print('{0:{1}}{2}{3:>10}'.format(item['row_count'], self.row_count_width, self.separator, item['pc']))
def print_key_prefix_counts(self): print('=' * self.total_width) print('{0:{1}}{2}'.format(self.metric_prefix_header, self.metric_prefix_width, self.separator), end='') print('{0:{1}}{2}{3}'.format(self.count_header, self.count_width, self.separator, self.count_pc_header)) print('=' * self.total_width) tmp_list = [ merge_dicts({'key': key}, self.keys[key]) for key in self.keys ] tmp_list.sort(key=lambda _: _['count']) for item in tmp_list: print('{0:{1}}{2}'.format(item['key'], self.metric_prefix_width, self.separator), end='') print('{0:{1}}{2}{3:>10}'.format(item['count'], self.count_width, self.separator, item['pc']))
def print_key_prefix_counts(self): print('=' * self.total_width) print('{0:{1}}{2}'.format(self.metric_prefix_header, self.metric_prefix_width, self.separator), end='') print('{0:{1}}{2}{3}'.format(self.count_header, self.count_width, self.separator, self.count_pc_header)) print('=' * self.total_width) tmp_list = [merge_dicts({'key': key}, self.keys[key]) for key in self.keys] tmp_list.sort(key=lambda _: _['count']) for item in tmp_list: print('{0:{1}}{2}'.format(item['key'], self.metric_prefix_width, self.separator), end='') print('{0:{1}}{2}{3:>10}'.format(item['count'], self.count_width, self.separator, item['pc']))