def __find_mirror_sort(sort_field, mirrors=None, reverse=False): """ Find the first mirror that is sorted by sort_field """ results = mirror_statuses(mirrors=mirrors, ping_master_mirror=False) new_list = sorted(results, key=operator.itemgetter(sort_field), reverse=reverse) return new_list[0]
def find_out_of_date_mirrors(mirrors=None): """ Find the mirrors that are out of date """ results = mirror_statuses(mirrors=mirrors) bad_mirrors = [] for r in results: if r.get('status') == STATUSES.get('RED'): bad_mirrors.append(r) return bad_mirrors
def run(): """ run everything """ results = mirror_statuses(mirrors=MIRRORS) if results: time_now = results[0].get('time_now', None) data = process_results(results) json_data = json_results(data) store_json_data(json_data) store_page_data(data, time_now)
def run(): """ run everything """ results = mirror_statuses(mirrors=MIRRORS) if results: time_now = results[0].get('time_now', None) data = process_results(results) env = Environment(loader=FileSystemLoader('templates')) # add the dummy url_for so it doesn't throw error. env.globals.update(url_for=url_for) template = env.get_template('index.html') context = {'data': data, 'date_now': time_now} print template.render(**context)