"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.11.23/bin/python/isc/keyevent.py.in" (7 Sep 2020, 2826 Bytes) of package /linux/misc/dns/bind9/9.11.23/bind-9.11.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 ############################################################################
    2 # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3 #
    4 # This Source Code Form is subject to the terms of the Mozilla Public
    5 # License, v. 2.0. If a copy of the MPL was not distributed with this
    6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7 #
    8 # See the COPYRIGHT file distributed with this work for additional
    9 # information regarding copyright ownership.
   10 ############################################################################
   11 
   12 import time
   13 
   14 
   15 ########################################################################
   16 # Class keyevent
   17 ########################################################################
   18 class keyevent:
   19     """ A discrete key event, e.g., Publish, Activate, Inactive, Delete,
   20     etc. Stores the date of the event, and identifying information
   21     about the key to which the event will occur."""
   22 
   23     def __init__(self, what, key, when=None):
   24         self.what = what
   25         self.when = when or key.gettime(what)
   26         self.key = key
   27         self.sep = key.sep
   28         self.zone = key.name
   29         self.alg = key.alg
   30         self.keyid = key.keyid
   31 
   32     def __repr__(self):
   33         return repr((self.when, self.what, self.keyid, self.sep,
   34                      self.zone, self.alg))
   35 
   36     def showtime(self):
   37         return time.strftime("%a %b %d %H:%M:%S UTC %Y", self.when)
   38 
   39     # update sets of active and published keys, based on
   40     # the contents of this keyevent
   41     def status(self, active, published, output = None):
   42         def noop(*args, **kwargs): pass
   43         if not output:
   44             output = noop
   45 
   46         if not active:
   47             active = set()
   48         if not published:
   49             published = set()
   50 
   51         if self.what == "Activate":
   52             active.add(self.keyid)
   53         elif self.what == "Publish":
   54             published.add(self.keyid)
   55         elif self.what == "Inactive":
   56             if self.keyid not in active:
   57                 output("\tWARNING: %s scheduled to become inactive "
   58                        "before it is active"
   59                        % repr(self.key))
   60             else:
   61                 active.remove(self.keyid)
   62         elif self.what == "Delete":
   63             if self.keyid in published:
   64                 published.remove(self.keyid)
   65             else:
   66                 output("WARNING: key %s is scheduled for deletion "
   67                        "before it is published" % repr(self.key))
   68         elif self.what == "Revoke":
   69             # We don't need to worry about the logic of this one;
   70             # just stop counting this key as either active or published
   71             if self.keyid in published:
   72                 published.remove(self.keyid)
   73             if self.keyid in active:
   74                 active.remove(self.keyid)
   75 
   76         return active, published