forked from public/mirror-checker
Try a fix for unmatching dates of acceptable distance
This commit is contained in:
parent
dce2583550
commit
06f5f46bb1
17
project.py
17
project.py
|
@ -3,6 +3,7 @@ Contains abstract class for a mirrored project
|
|||
"""
|
||||
|
||||
from abc import ABC
|
||||
import re
|
||||
|
||||
import requests
|
||||
|
||||
|
@ -17,4 +18,18 @@ class Project(ABC):
|
|||
"""Check if project packages are up-to-date"""
|
||||
csc_url = CSC_MIRROR + data[project]["csc"] + data[project]["file"]
|
||||
upstream_url = data[project]["upstream"] + data[project]["file"]
|
||||
return requests.get(csc_url).text == requests.get(upstream_url).text
|
||||
CSC = requests.get(csc_url).text
|
||||
upstream = requests.get(upstream_url).text
|
||||
if upstream == CSC:
|
||||
return True
|
||||
|
||||
# Parse number differences
|
||||
bad_re = '[a-zA-Z \-\n]+'
|
||||
if re.search(bad_re, CSC):
|
||||
# print(re.search(bad_re, CSC).group().strip())
|
||||
CSC = re.sub(bad_re, '', CSC)
|
||||
upstream = re.sub(bad_re, '', upstream)
|
||||
try:
|
||||
return int(upstream) - int(CSC) < data[project]["out_of_sync_interval"]
|
||||
except ValueError:
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue