forked from public/mirror-checker
Added option of configuration file in standard input
This commit is contained in:
parent
d04b65928e
commit
2ff0b0c69b
|
@ -0,0 +1,26 @@
|
||||||
|
AlmaLinux
|
||||||
|
Alpine
|
||||||
|
Apache
|
||||||
|
Arch
|
||||||
|
CentOS
|
||||||
|
Ceph
|
||||||
|
CPAN
|
||||||
|
Cygwin
|
||||||
|
Debian
|
||||||
|
DebianCD
|
||||||
|
DebianMultimedia
|
||||||
|
DebianPorts
|
||||||
|
DebianSecurity
|
||||||
|
Eclipse
|
||||||
|
Fedora
|
||||||
|
FreeBSD
|
||||||
|
GentooDistfiles
|
||||||
|
GentooPortage
|
||||||
|
GNOME
|
||||||
|
GNU
|
||||||
|
Gutenberg
|
||||||
|
IPFire
|
||||||
|
KDE
|
||||||
|
KDEApplicationData
|
||||||
|
Kernel
|
||||||
|
OpenBSD
|
10
main.py
10
main.py
|
@ -6,6 +6,7 @@ This mirror status checker determines whether CSC mirror is up-to-date with upst
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import requests
|
import requests
|
||||||
from arch import Arch
|
from arch import Arch
|
||||||
from ceph import Ceph
|
from ceph import Ceph
|
||||||
|
@ -106,8 +107,12 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
with open("data.json", "r", encoding = "utf-8") as file:
|
with open("data.json", "r", encoding = "utf-8") as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
|
if sys.stdin.isatty():
|
||||||
|
distros = data
|
||||||
|
else:
|
||||||
|
distros = [distro.rstrip() for distro in sys.stdin.readlines()]
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
for distro in data:
|
for distro in distros:
|
||||||
try:
|
try:
|
||||||
if distro == "CPAN":
|
if distro == "CPAN":
|
||||||
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
|
||||||
|
@ -134,6 +139,9 @@ if __name__ == "__main__":
|
||||||
continue
|
continue
|
||||||
elif distro == "IPFire":
|
elif distro == "IPFire":
|
||||||
checker_result = ipfire_checker()
|
checker_result = ipfire_checker()
|
||||||
|
elif distro not in data:
|
||||||
|
print(f"Failure: {distro} does not exist")
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
checker_result = general_checker(data, distro)
|
checker_result = general_checker(data, distro)
|
||||||
if checker_result:
|
if checker_result:
|
||||||
|
|
Loading…
Reference in New Issue