1 Star 0 Fork 0

orgcollector/pypi-mirrors

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test_run.py 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
ibigbug 提交于 2017-09-24 15:26 . add timeout
#!/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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/orgcollector/pypi-mirrors.git
git@gitee.com:orgcollector/pypi-mirrors.git
orgcollector
pypi-mirrors
pypi-mirrors
master

搜索帮助