From e2150d729239c42e358482a3fdfa52246c48ac05 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Thu, 3 Feb 2022 08:28:29 +0100 Subject: merged with 2021.11 upstream --- Reflector.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Reflector.py') 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']) @@ -885,6 +893,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='', help=( @@ -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, -- cgit v1.2.3-54-g00ecf