Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/Reflector.py
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2022-02-03 08:28:29 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2022-02-03 08:28:29 +0100
commite2150d729239c42e358482a3fdfa52246c48ac05 (patch)
tree34b17ce3038521f02c9448ae362564c9dbcb1d16 /Reflector.py
parent54f813dfee74bcdbe4bcad4caa2de450b107b188 (diff)
merged with 2021.11 upstream
Diffstat (limited to 'Reflector.py')
-rw-r--r--Reflector.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Reflector.py b/Reflector.py
index dee77dd..e0e0c00 100644
--- a/Reflector.py
+++ b/Reflector.py
@@ -497,6 +497,7 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too-
include=None,
exclude=None,
age=None,
+ delay=None,
isos=False,
ipv4=False,
ipv6=False
@@ -507,6 +508,7 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too-
self.include = tuple(re.compile(r) for r in include) if include else tuple()
self.exclude = tuple(re.compile(r) for r in exclude) if exclude else tuple()
self.age = age
+ self.delay = delay
self.isos = isos
self.ipv4 = ipv4
self.ipv6 = ipv6
@@ -551,6 +553,12 @@ class MirrorStatusFilter(): # pylint: disable=too-many-instance-attributes,too-
age = self.age * 60**2
mirrors = (m for m in mirrors if (m['last_sync'] + age) >= tim)
+ # Filter by delay. The delay is given as a float of hours and must be
+ # converted to seconds.
+ if self.delay is not None:
+ delay = self.delay * 3600
+ mirrors = (m for m in mirrors if m['delay'] <= delay)
+
# Filter by ISO hosing.
if self.isos:
mirrors = (m for m in mirrors if m['isos'])
@@ -886,6 +894,15 @@ def add_arguments(parser):
)
filters.add_argument(
+ '--delay', type=float, metavar='n',
+ help=(
+ '''Only return mirrors with a reported sync delay of n hours or
+ less, where n is a float. For example. to limit the results to
+ mirrors with a reported delay of 15 minutes or less, pass 0.25.'''
+ )
+ )
+
+ filters.add_argument(
'-c', '--country', dest='countries', action='append', metavar='<country name or code>',
help=(
'''Restrict mirrors to selected countries. Countries may be given by
@@ -1047,6 +1064,7 @@ def process_options(options, mirrorstatus=None, mirrors=None):
include=options.include,
exclude=options.exclude,
age=options.age,
+ delay=options.delay,
protocols=options.protocols,
isos=options.isos,
ipv4=options.ipv4,