Added option of configuration file in standard input

dev
Laura Nguyen 1 year ago
parent d04b65928e
commit 2ff0b0c69b
  1. 26
      example.in
  2. 10
      main.py

@ -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

@ -6,6 +6,7 @@ This mirror status checker determines whether CSC mirror is up-to-date with upst
import time
import os
import sys
import requests
from arch import Arch
from ceph import Ceph
@ -106,8 +107,12 @@ if __name__ == "__main__":
with open("data.json", "r", encoding = "utf-8") as 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())
for distro in data:
for distro in distros:
try:
if distro == "CPAN":
res_json = requests.get("http://mirrors.cpan.org/cpan-json.txt").json()
@ -134,6 +139,9 @@ if __name__ == "__main__":
continue
elif distro == "IPFire":
checker_result = ipfire_checker()
elif distro not in data:
print(f"Failure: {distro} does not exist")
continue
else:
checker_result = general_checker(data, distro)
if checker_result:

Loading…
Cancel
Save