1 Star 0 Fork 0

orgcollector/pypi-mirrors

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
daily.py 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
ibigbug 提交于 2017-09-24 15:26 . add timeout
from mirrorlib import find_out_of_date_mirrors
from config import MIRRORS
from notification import (
update_twitter_status, send_warning_email,
send_status_email)
def __tweet_outofdate(mirror, last_update):
""" Send a tweet saying we have a mirror out of date """
status = "{0} is out of date, it was last updated {1}".format(mirror,
last_update)
update_twitter_status(status)
def daily_out_of_date_mirror_check():
""" run everything """
results = find_out_of_date_mirrors(mirrors=MIRRORS)
if results:
email_message = ""
for res in results:
email_message += "{0} was last updated {1}\n".format(
res.get('mirror'),
res.get('time_diff_human'))
print("{0} is out of date. {1}".format(
res.get('mirror'), res.get('time_diff_human')))
# one tweet for each out of date mirror
__tweet_outofdate(res.get('mirror'), res.get('time_diff_human'))
# one email for all out of date mirrors
send_warning_email(email_message)
else:
print("All is good, sending Good message!")
send_status_email("[All Mirrors are up to date]")
def run():
""" run all of the daily cron jobs."""
daily_out_of_date_mirror_check()
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

搜索帮助