commit afc7b211cc79a93cd9bcd00896f5e8ecf2584d39
parent 86c094bdf1b2e48111b58617e46bf7b07a6afdfd
Author: Christian Grothoff <christian@grothoff.org>
Date: Wed, 1 May 2019 13:55:22 +0200
address a few style issues, point to design issues
Diffstat:
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/ascension/ascension.py b/ascension/ascension.py
@@ -523,12 +523,12 @@ class Ascender():
serial = serial.decode()
except sp.CalledProcessError:
serial = ""
- soa_serial = 0
+ soa_serial = None
soapattern = re.compile(r'.+\s(\d+),\d+,\d+,\d+,\d+', re.M)
if re.findall(soapattern, serial):
soa_serial = re.findall(soapattern, serial)[0]
else:
- soa_serial = 0
+ soa_serial = None
return soa_serial
@classmethod
@@ -543,6 +543,7 @@ class Ascender():
@classmethod
def get_zone_refresh_time(cls):
"""
+ @deprecated (use from DNS)
Extracts the current refresh time of the zone from GNS
:returns: refresh time of the current SOA record
"""
@@ -553,17 +554,18 @@ class Ascender():
serial = serial.decode()
except sp.CalledProcessError:
serial = ""
- refresh = 0
+ refresh = None
soapattern = re.compile(r'.+\s\d+,(\d+),\d+,\d+,\d+', re.M)
if re.findall(soapattern, serial):
refresh = re.findall(soapattern, serial)[0]
else:
- refresh = 0
+ refresh = None
return int(refresh)
@classmethod
def get_zone_retry_time(cls):
"""
+ @deprecated (use from DNS)
Extracts the current retry time of the zone from GNS
:returns: retry time of the current SOA record
"""
@@ -730,14 +732,14 @@ def main():
try:
sp.check_output([GNUNET_ARM_COMMAND, '-I'], timeout=1)
except sp.TimeoutExpired:
- logging.critical('GNUnet Services are not running!')
+ logging.critical('GNUnet services are not running!')
sys.exit(1)
# Initialize class instance
ascender = Ascender(domain, transferns, port, flags, minimum)
# Event loop for actual daemon
- while 1:
+ while True:
serial = ascender.get_zone_serial()
ascender.initial_zone_transfer(serial)
ascender.mirror_zone()
@@ -747,16 +749,18 @@ def main():
logging.info("Finished migration of the zone %s", ascender.domain)
else:
logging.info("Zone %s already up to date", ascender.domain)
+ # FIXME: use DNS SOA, from above, if fail retry time, if success refresh time
refresh = int(ascender.get_zone_refresh_time())
retry = int(ascender.get_zone_retry_time())
if standalone:
+ # FIXME: return non-zero on errors!
return 0
- if refresh == 0:
- logging.info("unable to refresh zone, retrying in %ds", retry)
+ if not refresh:
+ logging.info("Unable to refresh zone, retrying in %ds", retry)
time.sleep(retry)
else:
- logging.info("refreshing zone in %ds", refresh)
- print("refreshing zone in %ds" % refresh)
+ logging.info("Refreshing zone in %ds", refresh)
+ print("Refreshing zone in %ds" % refresh)
time.sleep(refresh)
if __name__ == '__main__':