gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [ascension] 23/45: fixed non existing file


From: gnunet
Subject: [GNUnet-SVN] [ascension] 23/45: fixed non existing file
Date: Fri, 25 Jan 2019 10:02:23 +0100

This is an automated email from the git hooks/post-receive script.

rexxnor pushed a commit to branch master
in repository ascension.

commit ef5106902865aecc21998731b8237ab168e9e1ce
Author: rexxnor <address@hidden>
AuthorDate: Sun Oct 14 00:13:18 2018 +0200

    fixed non existing file
---
 gnsmigrator/gnsmigrator.py | 38 ++++++++++++++------------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/gnsmigrator/gnsmigrator.py b/gnsmigrator/gnsmigrator.py
index 0bc497f..3fa3ba4 100644
--- a/gnsmigrator/gnsmigrator.py
+++ b/gnsmigrator/gnsmigrator.py
@@ -394,27 +394,12 @@ class BaseMigrator():
         return domain.split('.')[0]
 
     @staticmethod
-    def get_current_serial(zonename):
+    def get_current_serial(domain):
         """
-        Extracts the current serial from a given zone
+        Gets the current serial for a given zone
         """
-        if zonename[-1] == '.':
-            zonename = zonename[:-1]
-        try:
-            serial = sp.check_output([GNUNET_GNS_COMMAND,
-                                      '-t', 'SOA',
-                                      '-u', '@.%s' % zonename])
-        except sp.CalledProcessError:
-            soa_serial = 0
-            return soa_serial
-        serial = serial.decode()
-        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
-        return soa_serial
-
+        soa_answer = dns.resolver.query(domain, 'SOA')
+        return soa_answer[0].serial
 
 class ZoneMigrator(BaseMigrator):
     """
@@ -437,7 +422,7 @@ class TLDMigrator(BaseMigrator):
         cls.zonegenerator = {}
 
     @classmethod
-    def initial_zone_transfer(cls, serial):
+    def initial_zone_transfer(cls, serial=None):
         """
         Transfer and initialize the zone
         """
@@ -479,24 +464,29 @@ class TLDMigrator(BaseMigrator):
             print(filenotfound)
 
         currentserial = cls.get_current_serial(cls.tld)
-        zoneserial = None
+        zoneserial = 0
         if zone:
             for record in zone.iterate_rdatas(rdtype=dns.rdatatype.SOA):
                 zoneserial = str(record[2]).split(' ')[2].split(',')[0]
                 break
         else:
-            if currentserial != zoneserial:
+            if zoneserial == 0:
+                cls.initial_zone_transfer()
+            if zoneserial < currentserial:
                 cls.transfer_zone()
+
             # zip and pickle the zone
             with gzip.open('%s.zone.gz' % cls.tld[:-1], 'wb') as zonefile:
                 pickle.dump(zone, zonefile)
 
     @classmethod
     def transfer_zone(cls, zone_factory=dns.zone.Zone,
-                      relativize=True, check_origin=True):
+                      relativize=True, check_origin=True
+                      ):
         """
         Do the actual zone transfer
         """
+        zone = None
         try:
             for message in cls.zonegenerator:
                 origin = message.origin
@@ -542,7 +532,7 @@ class TLDMigrator(BaseMigrator):
                 if record is None:
                     break
                 # execute thing to run on item
-                dnsname, ttl, authns = record
+                _, _, authns = record
                 if str(authns)[:-1] == ".":
                     authns = str(authns)[:-1]
                 else:

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]