代码拉取完成,页面将自动刷新
#!/usr/bin/env python
from jinja2 import Environment, FileSystemLoader
from mirrorlib import mirror_statuses
from utils import (find_number_of_packages)
from config import MIRRORS
def process_results(results):
""" process the results and gather data """
new_results = []
for d in results:
mirror = d.get('mirror')
status = d.get('status')
d['location'] = "n/a"
if status != 'Unavailable':
resp_list = ["1", "2", "3", "4", "5", "6",
"7", "8", "9", "10"] # faked out for test
age_list = ["1", "2", "3", "4", "5", "6",
"7", "8", "9", "10"] # faked out for test
d['num_packages'] = find_number_of_packages(mirror, d['scheme'])
d['resp_list'] = ",".join(resp_list)
d['age_list'] = ",".join(age_list)
new_results.append(d)
return new_results
def url_for(something):
return something
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)
if __name__ == '__main__':
run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。