diff options
Diffstat (limited to 'rpkid/rpki')
-rw-r--r-- | rpkid/rpki/adns.py | 19 | ||||
-rw-r--r-- | rpkid/rpki/async.py | 26 | ||||
-rw-r--r-- | rpkid/rpki/config.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/csv_utils.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/exceptions.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/http.py | 29 | ||||
-rw-r--r-- | rpkid/rpki/ipaddrs.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/irdb/__init__.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/irdb/models.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/irdb/router.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/irdb/zookeeper.py | 30 | ||||
-rw-r--r-- | rpkid/rpki/irdbd.py | 9 | ||||
-rw-r--r-- | rpkid/rpki/log.py | 1 | ||||
-rw-r--r-- | rpkid/rpki/mysql_import.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/oids.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/old_irdbd.py | 16 | ||||
-rw-r--r-- | rpkid/rpki/publication.py | 3 | ||||
-rw-r--r-- | rpkid/rpki/rcynic.py | 70 | ||||
-rw-r--r-- | rpkid/rpki/relaxng.py | 8 | ||||
-rw-r--r-- | rpkid/rpki/resource_set.py | 64 | ||||
-rw-r--r-- | rpkid/rpki/rootd.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/rpkic.py | 10 | ||||
-rw-r--r-- | rpkid/rpki/rpkid.py | 1 | ||||
-rw-r--r-- | rpkid/rpki/rpkid_tasks.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/sql.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/sundial.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/up_down.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/x509.py | 45 | ||||
-rw-r--r-- | rpkid/rpki/xml_utils.py | 2 |
29 files changed, 186 insertions, 197 deletions
diff --git a/rpkid/rpki/adns.py b/rpkid/rpki/adns.py index efee897f..736d793a 100644 --- a/rpkid/rpki/adns.py +++ b/rpkid/rpki/adns.py @@ -4,7 +4,7 @@ dnspython package. $Id$ -Copyright (C) 2010--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2010--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -34,8 +34,13 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import asyncore, socket, time, sys -import rpki.async, rpki.sundial, rpki.log +import asyncore +import socket +import time +import sys +import rpki.async +import rpki.sundial +import rpki.log try: import dns.resolver, dns.rdatatype, dns.rdataclass, dns.name, dns.message @@ -364,12 +369,12 @@ if __name__ == "__main__": e) if True: - for qtype in (dns.rdatatype.A, dns.rdatatype.AAAA, dns.rdatatype.HINFO): - test_query("subvert-rpki.hactrn.net", qtype) + for t in (dns.rdatatype.A, dns.rdatatype.AAAA, dns.rdatatype.HINFO): + test_query("subvert-rpki.hactrn.net", t) test_query("nonexistant.rpki.net") test_query("subvert-rpki.hactrn.net", qclass = dns.rdataclass.CH) - for host in ("subvert-rpki.hactrn.net", "nonexistant.rpki.net"): - test_getaddrinfo(host) + for h in ("subvert-rpki.hactrn.net", "nonexistant.rpki.net"): + test_getaddrinfo(h) rpki.async.event_loop() diff --git a/rpkid/rpki/async.py b/rpkid/rpki/async.py index 178bfb7b..4a6a1627 100644 --- a/rpkid/rpki/async.py +++ b/rpkid/rpki/async.py @@ -106,17 +106,7 @@ timer_queue = [] class timer(object): """ - Timer construct for event-driven code. It can be used in either of two ways: - - - As a virtual class, in which case the subclass should provide a - handler() method to receive the wakup event when the timer expires; or - - - By setting an explicit handler callback, either via the - constructor or the set_handler() method. - - Subclassing is probably more Pythonic, but setting an explict - handler turns out to be very convenient when combined with bound - methods to other objects. + Timer construct for event-driven code. """ ## @var gc_debug @@ -185,13 +175,6 @@ class timer(object): """ return self in timer_queue - def handler(self): - """ - Handle a timer that has expired. This must either be overriden by - a subclass or set dynamically by set_handler(). - """ - raise NotImplementedError - def set_handler(self, handler): """ Set timer's expiration handler. This is an alternative to @@ -202,13 +185,6 @@ class timer(object): """ self.handler = handler - def errback(self, e): - """ - Error callback. May be overridden, or set with set_errback(). - """ - rpki.log.error("Unhandled exception from timer: %s" % e) - rpki.log.traceback() - def set_errback(self, errback): """ Set a timer's errback. Like set_handler(), for errbacks. diff --git a/rpkid/rpki/config.py b/rpkid/rpki/config.py index 8957315f..cc5b6580 100644 --- a/rpkid/rpki/config.py +++ b/rpkid/rpki/config.py @@ -4,7 +4,7 @@ ConfigParser module. $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -87,6 +87,8 @@ class parser(object): if default_dirname is not None: filenames.append("%s/%s" % (default_dirname, default_filename)) + f = fn = None + for fn in filenames: try: f = open(fn) @@ -130,7 +132,7 @@ class parser(object): section = self.default_section if self.cfg.has_option(section, option): matches.append((-1, self.get(option, section = section))) - for key, value in self.cfg.items(section): + for key in self.cfg.options(section): s = key.rsplit(".", 1) if len(s) == 2 and s[0] == option and s[1].isdigit(): matches.append((int(s[1]), self.get(option, section = section))) diff --git a/rpkid/rpki/csv_utils.py b/rpkid/rpki/csv_utils.py index 352aebd9..30d07560 100644 --- a/rpkid/rpki/csv_utils.py +++ b/rpkid/rpki/csv_utils.py @@ -3,7 +3,7 @@ CSV utilities, moved here from myrpki.py. $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -71,7 +71,7 @@ class csv_reader(object): def __enter__(self): return self - def __exit__(self, type, value, traceback): + def __exit__(self, _type, value, traceback): self.file.close() class csv_writer(object): @@ -92,7 +92,7 @@ class csv_writer(object): def __enter__(self): return self - def __exit__(self, type, value, traceback): + def __exit__(self, _type, value, traceback): self.close() def close(self): diff --git a/rpkid/rpki/exceptions.py b/rpkid/rpki/exceptions.py index 68ea3bf6..0f5dbc49 100644 --- a/rpkid/rpki/exceptions.py +++ b/rpkid/rpki/exceptions.py @@ -3,7 +3,7 @@ Exception definitions for RPKI modules. $Id$ -Copyright (C) 2009--2010 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/rpkid/rpki/http.py b/rpkid/rpki/http.py index 7d47826e..c3eae1fe 100644 --- a/rpkid/rpki/http.py +++ b/rpkid/rpki/http.py @@ -3,7 +3,7 @@ HTTP utilities, both client and server. $Id$ -Copyright (C) 2009-2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -82,11 +82,6 @@ enable_ipv6_servers = True # far too much of the world. enable_ipv6_clients = False -## @var use_adns -# Whether to use rpki.adns code. This is still experimental, so it's -# not (yet) enabled by default. -use_adns = False - ## @var have_ipv6 # Whether the current machine claims to support IPv6. Note that just # because the kernel supports it doesn't mean that the machine has @@ -95,6 +90,7 @@ use_adns = False # SRI-NIC.ARPA?" seems a bit dated...). Don't set this, it's set # automatically by probing using the socket() system call at runtime. try: + # pylint: disable=W0702,W0104 socket.socket(socket.AF_INET6).close() socket.IPPROTO_IPV6 socket.IPV6_V6ONLY @@ -103,6 +99,16 @@ except: else: have_ipv6 = True +## @var use_adns + +# Whether to use rpki.adns code. This is still experimental, so it's +# not (yet) enabled by default. +use_adns = False +try: + import rpki.adns +except ImportError: + pass + def supported_address_families(enable_ipv6): """ IP address families on which servers should listen, and to consider @@ -590,7 +596,7 @@ class http_listener(asyncore.dispatcher): asyncore.dispatcher.__init__(self) self.handlers = handlers try: - af, socktype, proto, canonname, sockaddr = addrinfo + af, socktype, proto, canonname, sockaddr = addrinfo # pylint: disable=W0612 self.create_socket(af, socktype) self.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) try: @@ -614,8 +620,8 @@ class http_listener(asyncore.dispatcher): stream for it and pass along all of our handler data. """ try: - s, client = self.accept() - self.log("Accepting connection from %s" % addr_to_string(client)) + s, c = self.accept() + self.log("Accepting connection from %s" % addr_to_string(c)) http_server(sock = s, handlers = self.handlers) except (rpki.async.ExitNow, SystemExit): raise @@ -669,7 +675,6 @@ class http_client(http_stream): self.log("Bypassing DNS for localhost") self.gotaddrinfo(localhost_addrinfo()) else: - import rpki.adns # This should move to start of file once we've decided to inflict it on all users families = supported_address_families(enable_ipv6_clients) self.log("Starting ADNS lookup for %s in families %r" % (self.host, families)) rpki.adns.getaddrinfo(self.gotaddrinfo, self.dns_error, self.host, families) @@ -804,7 +809,7 @@ class http_client(http_stream): if bad: try: raise rpki.exceptions.HTTPTimeout - except: + except: # pylint: disable=W0702 self.handle_error() else: self.queue.detach(self) @@ -886,7 +891,7 @@ class http_queue(object): self.log("Detaching client %r" % client_) self.client = None - def return_result(self, client, result, detach = False): + def return_result(self, client, result, detach = False): # pylint: disable=W0621 """ Client stream has returned a result, which we need to pass along to the original caller. Result may be either an HTTP response diff --git a/rpkid/rpki/ipaddrs.py b/rpkid/rpki/ipaddrs.py index 9b67d0f0..d096e1d4 100644 --- a/rpkid/rpki/ipaddrs.py +++ b/rpkid/rpki/ipaddrs.py @@ -13,7 +13,7 @@ once, here, thus avoiding a lot of duplicate code elsewhere. $Id$ -Copyright (C) 2009 Internet Systems Consortium ("ISC") +Copyright (C) 2009-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/rpkid/rpki/irdb/__init__.py b/rpkid/rpki/irdb/__init__.py index 14365e10..64c9ee6c 100644 --- a/rpkid/rpki/irdb/__init__.py +++ b/rpkid/rpki/irdb/__init__.py @@ -19,6 +19,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ +# pylint: disable=W0401 + from rpki.irdb.models import * from rpki.irdb.zookeeper import Zookeeper from rpki.irdb.router import DBContextRouter, database diff --git a/rpkid/rpki/irdb/models.py b/rpkid/rpki/irdb/models.py index 8a41647d..e408612e 100644 --- a/rpkid/rpki/irdb/models.py +++ b/rpkid/rpki/irdb/models.py @@ -7,7 +7,7 @@ Django GUI code, so be careful. $Id$ -Copyright (C) 2011 Internet Systems Consortium ("ISC") +Copyright (C) 2011-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -22,6 +22,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ +# pylint: disable=W0232 + import django.db.models import rpki.x509 import rpki.sundial @@ -294,7 +296,7 @@ class CA(django.db.models.Model): return result def revoke(self, cert): - Revocations.objects.create( + Revocation.objects.create( issuer = self, revoked = rpki.sundial.now(), serial = cert.certificate.getSerial(), diff --git a/rpkid/rpki/irdb/router.py b/rpkid/rpki/irdb/router.py index 3036a58b..fad78b36 100644 --- a/rpkid/rpki/irdb/router.py +++ b/rpkid/rpki/irdb/router.py @@ -77,7 +77,7 @@ class database(object): def __init__(self, name, on_entry = None, on_exit = None): if not isinstance(name, str): - raise ValueError("database name must be a string, not %r" % value) + raise ValueError("database name must be a string, not %r" % name) self.name = name self.on_entry = on_entry self.on_exit = on_exit @@ -88,7 +88,7 @@ class database(object): self.former = DBContextRouter._database DBContextRouter._database = self.name - def __exit__(self, type, value, traceback): + def __exit__(self, _type, value, traceback): assert DBContextRouter._database is self.name DBContextRouter._database = self.former if self.on_exit is not None: diff --git a/rpkid/rpki/irdb/zookeeper.py b/rpkid/rpki/irdb/zookeeper.py index 49416b89..9747bb30 100644 --- a/rpkid/rpki/irdb/zookeeper.py +++ b/rpkid/rpki/irdb/zookeeper.py @@ -18,17 +18,10 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import subprocess -import csv -import re +# pylint: disable=W0612 + import os -import getopt -import sys -import base64 -import time -import glob import copy -import warnings import rpki.config import rpki.cli import rpki.sundial @@ -45,10 +38,9 @@ import rpki.irdb import django.db.transaction from lxml.etree import (Element, SubElement, ElementTree, - fromstring as ElementFromString, - tostring as ElementToString) + tostring as ElementToString) -from rpki.csv_utils import (csv_reader, csv_writer, BadCSVSyntax) +from rpki.csv_utils import csv_reader @@ -116,7 +108,7 @@ class PEM_writer(object): try: if compare and pem == open(filename, "r").read(): return - except: + except: # pylint: disable=W0702 pass tempname += ".%s.tmp" % os.getpid() mode = 0400 if filename.endswith(".key") else 0444 @@ -233,7 +225,7 @@ class Zookeeper(object): if handle is None: raise MissingHandle - self.handle= handle + self.handle = handle def set_logstream(self, logstream): @@ -529,7 +521,7 @@ class Zookeeper(object): try: self.resource_ca.children.get(handle = child_handle).delete() except rpki.irdb.Child.DoesNotExist: - self.log("No such child \"%s\"" % arg) + self.log("No such child \"%s\"" % child_handle) @django.db.transaction.commit_on_success @@ -605,7 +597,7 @@ class Zookeeper(object): try: self.resource_ca.parents.get(handle = parent_handle).delete() except rpki.irdb.Parent.DoesNotExist: - self.log("No such parent \"%s\"" % arg) + self.log("No such parent \"%s\"" % parent_handle) @django.db.transaction.commit_on_success @@ -724,7 +716,7 @@ class Zookeeper(object): try: self.server_ca.clients.get(handle = client_handle).delete() except rpki.irdb.Client.DoesNotExist: - self.log("No such client \"%s\"" % arg) + self.log("No such client \"%s\"" % client_handle) @django.db.transaction.commit_on_success @@ -773,9 +765,9 @@ class Zookeeper(object): assert repository_handle is not None try: - self.resource_ca.repositories.get(handle = arg).delete() + self.resource_ca.repositories.get(handle = repository_handle).delete() except rpki.irdb.Repository.DoesNotExist: - self.log("No such repository \"%s\"" % arg) + self.log("No such repository \"%s\"" % repository_handle) @django.db.transaction.commit_on_success diff --git a/rpkid/rpki/irdbd.py b/rpkid/rpki/irdbd.py index 908c3325..dafdaff9 100644 --- a/rpkid/rpki/irdbd.py +++ b/rpkid/rpki/irdbd.py @@ -42,7 +42,6 @@ import os import time import getopt import urlparse -import warnings import rpki.http import rpki.config import rpki.resource_set @@ -144,7 +143,7 @@ class main(object): def __init__(self, **kwargs): - global rpki + global rpki # pylint: disable=W0602 os.environ["TZ"] = "UTC" time.tzset() @@ -192,7 +191,7 @@ class main(object): def main(self): - global rpki + global rpki # pylint: disable=W0602 from django.conf import settings startup_msg = self.cfg.get("startup-message", "") @@ -220,8 +219,8 @@ class main(object): "PORT" : "" }}, INSTALLED_APPS = ("rpki.irdb",),) - import rpki.irdb - + import rpki.irdb # pylint: disable=W0621 + # Entirely too much fun with read-only access to transactional databases. # # http://stackoverflow.com/questions/3346124/how-do-i-force-django-to-ignore-any-caches-and-reload-data diff --git a/rpkid/rpki/log.py b/rpkid/rpki/log.py index 7c20c3c1..2b48cb6d 100644 --- a/rpkid/rpki/log.py +++ b/rpkid/rpki/log.py @@ -171,6 +171,7 @@ def log_repr(obj, *tokens): IDs as needed, includes self_handle when available. """ + # pylint: disable=W0702 words = ["%s.%s" % (obj.__class__.__module__, obj.__class__.__name__)] try: words.append("{%s}" % obj.self.self_handle) diff --git a/rpkid/rpki/mysql_import.py b/rpkid/rpki/mysql_import.py index ac2b580d..40ccc348 100644 --- a/rpkid/rpki/mysql_import.py +++ b/rpkid/rpki/mysql_import.py @@ -16,7 +16,7 @@ object from this module. Looks kind of strange, but seems to work. $Id$ -Copyright (C) 2011 Internet Systems Consortium ("ISC") +Copyright (C) 2011-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -45,6 +45,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ +# pylint: disable=W0611 + from __future__ import with_statement import warnings diff --git a/rpkid/rpki/oids.py b/rpkid/rpki/oids.py index 35b4453a..dc596f0b 100644 --- a/rpkid/rpki/oids.py +++ b/rpkid/rpki/oids.py @@ -3,7 +3,7 @@ OID database. $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/rpkid/rpki/old_irdbd.py b/rpkid/rpki/old_irdbd.py index c63ce9e2..6cc6cb14 100644 --- a/rpkid/rpki/old_irdbd.py +++ b/rpkid/rpki/old_irdbd.py @@ -37,9 +37,19 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import sys, os, time, getopt, urlparse, warnings -import rpki.http, rpki.config, rpki.resource_set, rpki.relaxng -import rpki.exceptions, rpki.left_right, rpki.log, rpki.x509 +import sys +import os +import time +import getopt +import urlparse +import rpki.http +import rpki.config +import rpki.resource_set +import rpki.relaxng +import rpki.exceptions +import rpki.left_right +import rpki.log +import rpki.x509 from rpki.mysql_import import MySQLdb diff --git a/rpkid/rpki/publication.py b/rpkid/rpki/publication.py index 8c50aeee..975d5fc9 100644 --- a/rpkid/rpki/publication.py +++ b/rpkid/rpki/publication.py @@ -205,7 +205,7 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace): """ assert name == self.element_name, "Unexpected name %s, stack %s" % (name, stack) if text: - self.payload = self.payload_type(Base64 = text) + self.payload = self.payload_type(Base64 = text) # pylint: disable=E1102 stack.pop() def toXML(self): @@ -221,6 +221,7 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace): """ Action dispatch handler. """ + # pylint: disable=E0203 try: if self.client is None: raise rpki.exceptions.BadQuery, "Client query received on control channel" diff --git a/rpkid/rpki/rcynic.py b/rpkid/rpki/rcynic.py index 6f5da2ca..d6c00710 100644 --- a/rpkid/rpki/rcynic.py +++ b/rpkid/rpki/rcynic.py @@ -16,9 +16,8 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -__revision__ = '$Id$' +__version__ = '$Id$' -import sys import os import rpki.x509 import rpki.exceptions @@ -175,7 +174,7 @@ class rcynic_file_iterator(object): self.rcynic_dir = os.path.join(rcynic_root, authenticated_subdir) def __iter__(self): - for root, dirs, files in os.walk(self.rcynic_dir): + for root, dirs, files in os.walk(self.rcynic_dir): # pylint: disable=W0612 for filename in files: filename = os.path.join(root, filename) ext = os.path.splitext(filename)[1] @@ -183,26 +182,26 @@ class rcynic_file_iterator(object): yield file_name_classes[ext](filename) class validation_status_element(object): - def __init__(self, *args, **kwargs): - self.attrs = [] - for k,v in kwargs.iteritems(): - setattr(self, k, v) - # attribute names are saved so that the __repr__ method can - # display the subset of attributes the user specified - self.attrs.append(k) - self._obj = None - - def get_obj(self): - if not self._obj: - self._obj = self.file_class(filename=self.filename, uri=self.uri) - return self._obj - - def __repr__(self): - v = [self.__class__.__name__, 'id=%s' % str(id(self))] - v.extend(['%s=%s' % (x, getattr(self, x)) for x in self.attrs]) - return '<%s>' % (' '.join(v),) - - obj = property(get_obj) + def __init__(self, *args, **kwargs): + self.attrs = [] + for k, v in kwargs.iteritems(): + setattr(self, k, v) + # attribute names are saved so that the __repr__ method can + # display the subset of attributes the user specified + self.attrs.append(k) + self._obj = None + + def get_obj(self): + if not self._obj: + self._obj = self.file_class(filename=self.filename, uri=self.uri) + return self._obj + + def __repr__(self): + v = [self.__class__.__name__, 'id=%s' % str(id(self))] + v.extend(['%s=%s' % (x, getattr(self, x)) for x in self.attrs]) + return '<%s>' % (' '.join(v),) + + obj = property(get_obj) class rcynic_xml_iterator(object): """ @@ -251,25 +250,26 @@ class rcynic_xml_iterator(object): # determine the path to this object if status == 'object_accepted': - d = self.authenticated_subdir + d = self.authenticated_subdir elif generation == 'backup': - d = self.authenticated_old_subdir + d = self.authenticated_old_subdir else: - d = self.unauthenticated_subdir + d = self.unauthenticated_subdir filename = os.path.join(d, self.uri_to_filename(uri)) ext = os.path.splitext(filename)[1] if ext in file_name_classes: - yield validation_status_element(timestamp=timestamp, generation=generation, uri=uri, - status=status, filename=filename, file_class=file_name_classes[ext]) + yield validation_status_element(timestamp = timestamp, generation = generation, + uri=uri, status = status, filename = filename, + file_class = file_name_classes[ext]) def label_iterator(xml_file): - """ - Returns an iterator which contains all defined labels from an rcynic XML - output file. Each item is a tuple of the form - (label, kind, description). - """ + """ + Returns an iterator which contains all defined labels from an rcynic XML + output file. Each item is a tuple of the form + (label, kind, description). + """ - for label in ElementTree(file=xml_file).find("labels"): - yield label.tag, label.get("kind"), label.text.strip() + for label in ElementTree(file=xml_file).find("labels"): + yield label.tag, label.get("kind"), label.text.strip() diff --git a/rpkid/rpki/relaxng.py b/rpkid/rpki/relaxng.py index c3f239d4..962858c7 100644 --- a/rpkid/rpki/relaxng.py +++ b/rpkid/rpki/relaxng.py @@ -4,7 +4,7 @@ import lxml.etree ## @var left_right ## Parsed RelaxNG left_right schema -left_right = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encoding="UTF-8"?> +left_right = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: left-right-schema.rnc 4588 2012-07-06 19:43:56Z sra $ @@ -1037,7 +1037,7 @@ left_right = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" enc ## @var up_down ## Parsed RelaxNG up_down schema -up_down = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encoding="UTF-8"?> +up_down = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: up-down-schema.rnc 3913 2011-07-01 17:04:18Z sra $ @@ -1289,7 +1289,7 @@ up_down = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encodi ## @var publication ## Parsed RelaxNG publication schema -publication = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encoding="UTF-8"?> +publication = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: publication-schema.rnc 4588 2012-07-06 19:43:56Z sra $ @@ -1879,7 +1879,7 @@ publication = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" en ## @var myrpki ## Parsed RelaxNG myrpki schema -myrpki = lxml.etree.RelaxNG(lxml.etree.fromstring('''<?xml version="1.0" encoding="UTF-8"?> +myrpki = lxml.etree.RelaxNG(lxml.etree.fromstring(r'''<?xml version="1.0" encoding="UTF-8"?> <!-- $Id: myrpki.rnc 4430 2012-04-17 16:00:14Z sra $ diff --git a/rpkid/rpki/resource_set.py b/rpkid/rpki/resource_set.py index 38217223..f0d096d5 100644 --- a/rpkid/rpki/resource_set.py +++ b/rpkid/rpki/resource_set.py @@ -64,14 +64,16 @@ class resource_range(object): directly. """ - def __init__(self, min, max): - assert min.__class__ is max.__class__, "Type mismatch, %r doesn't match %r" % (min.__class__, max.__class__) - assert min <= max, "Mis-ordered range: %s before %s" % (min, max) - self.min = min - self.max = max + def __init__(self, range_min, range_max): + assert range_min.__class__ is range_max.__class__, \ + "Type mismatch, %r doesn't match %r" % (range_min.__class__, range_max.__class__) + assert range_min <= range_max, "Mis-ordered range: %s before %s" % (range_min, range_max) + self.min = range_min + self.max = range_max def __cmp__(self, other): - assert self.__class__ is other.__class__, "Type mismatch, comparing %r with %r" % (self.__class__, other.__class__) + assert self.__class__ is other.__class__, \ + "Type mismatch, comparing %r with %r" % (self.__class__, other.__class__) return cmp(self.min, other.min) or cmp(self.max, other.max) class resource_range_as(resource_range): @@ -87,10 +89,10 @@ class resource_range_as(resource_range): datum_type = long - def __init__(self, min, max): + def __init__(self, range_min, range_max): resource_range.__init__(self, - long(min) if isinstance(min, int) else min, - long(max) if isinstance(max, int) else max) + long(range_min) if isinstance(range_min, int) else range_min, + long(range_max) if isinstance(range_max, int) else range_max) def __str__(self): """ @@ -196,19 +198,19 @@ class resource_range_ip(resource_range): self.prefixlen() result.append(self) except rpki.exceptions.MustBePrefix: - min = self.min - max = self.max - while max >= min: - bits = int(math.log(long(max - min + 1), 2)) + range_min = self.min + range_max = self.max + while range_max >= range_min: + bits = int(math.log(long(range_max - range_min + 1), 2)) while True: mask = ~(~0 << bits) - assert min + mask <= max - if min & mask == 0: + assert range_min + mask <= range_max + if range_min & mask == 0: break assert bits > 0 bits -= 1 - result.append(self.make_prefix(min, min.bits - bits)) - min = min + mask + 1 + result.append(self.make_prefix(range_min, range_min.bits - bits)) + range_min = range_min + mask + 1 @classmethod def from_strings(cls, a, b = None): @@ -400,16 +402,14 @@ class resource_set(list): this = set1.pop(0) that = set2.pop(0) assert type(this) is type(that) - if this.min < that.min: min = this.min - else: min = that.min - if this.max > that.max: max = this.max - else: max = that.max - result.append(type(this)(min, max)) - while set1 and set1[0].max <= max: - assert set1[0].min >= min + range_min = min(this.min, that.min) + range_max = max(this.max, that.max) + result.append(type(this)(range_min, range_max)) + while set1 and set1[0].max <= range_max: + assert set1[0].min >= range_min del set1[0] - while set2 and set2[0].max <= max: - assert set2[0].min >= min + while set2 and set2[0].max <= range_max: + assert set2[0].min >= range_min del set2[0] return type(self)(result) @@ -449,20 +449,20 @@ class resource_set(list): if not self: return False if type(item) is type(self[0]): - min = item.min - max = item.max + range_min = item.min + range_max = item.max else: - min = item - max = item + range_min = item + range_max = item lo = 0 hi = len(self) while lo < hi: mid = (lo + hi) / 2 - if self[mid].max < max: + if self[mid].max < range_max: lo = mid + 1 else: hi = mid - return lo < len(self) and self[lo].min <= min and self[lo].max >= max + return lo < len(self) and self[lo].min <= range_min and self[lo].max >= range_max __contains__ = contains diff --git a/rpkid/rpki/rootd.py b/rpkid/rpki/rootd.py index ce4afd86..6da7081b 100644 --- a/rpkid/rpki/rootd.py +++ b/rpkid/rpki/rootd.py @@ -10,7 +10,7 @@ Usage: python rootd.py [ { -c | --config } configfile ] $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -299,7 +299,7 @@ class main(object): try: crl = rpki.x509.CRL(DER_file = os.path.join(self.rpki_root_dir, self.rpki_root_crl)) self.crl_number = crl.getCRLNumber() - except: + except: # pylint: disable=W0702 self.crl_number = 0 self.crl_number += 1 return self.crl_number diff --git a/rpkid/rpki/rpkic.py b/rpkid/rpki/rpkic.py index aed41680..f00e15b5 100644 --- a/rpkid/rpki/rpkic.py +++ b/rpkid/rpki/rpkic.py @@ -39,16 +39,10 @@ PERFORMANCE OF THIS SOFTWARE. # modules, or anything that imports Django modules. Bottom line is # that we don't import such modules until we need them. -import csv -import re import os import getopt import sys -import base64 import time -import glob -import copy -import warnings import rpki.config import rpki.cli import rpki.sundial @@ -116,7 +110,7 @@ class main(rpki.cli.Cmd): rpki.cli.Cmd.__init__(self, self.argv) def read_config(self): - global rpki + global rpki # pylint: disable=W0602 cfg = rpki.config.parser(self.cfg_file, "myrpki") cfg.set_global_flags() @@ -137,7 +131,7 @@ class main(rpki.cli.Cmd): INSTALLED_APPS = ("rpki.irdb",), ) - import rpki.irdb + import rpki.irdb # pylint: disable=W0621 try: rpki.irdb.models.ca_certificate_lifetime = rpki.sundial.timedelta.parse( diff --git a/rpkid/rpki/rpkid.py b/rpkid/rpki/rpkid.py index 6334a9d4..fca30288 100644 --- a/rpkid/rpki/rpkid.py +++ b/rpkid/rpki/rpkid.py @@ -42,7 +42,6 @@ import os import time import getopt import sys -import lxml.etree import re import random import rpki.resource_set diff --git a/rpkid/rpki/rpkid_tasks.py b/rpkid/rpki/rpkid_tasks.py index cc57e189..b2ab5469 100644 --- a/rpkid/rpki/rpkid_tasks.py +++ b/rpkid/rpki/rpkid_tasks.py @@ -259,7 +259,7 @@ class UpdateChildrenTask(AbstractTask): new_resources = old_resources & irdb_resources & ca_detail.latest_ca_cert.get_3779resources() if new_resources.empty(): - rpki.log.debug("Resources shrank to the null set, revoking and withdrawing child %s certificate SKI %s" % (child.child_handle, child_cert.cert.gSKI())) + rpki.log.debug("Resources shrank to the null set, revoking and withdrawing child %s certificate SKI %s" % (self.child.child_handle, child_cert.cert.gSKI())) child_cert.revoke(publisher = self.publisher) ca_detail.generate_crl(publisher = self.publisher) ca_detail.generate_manifest(publisher = self.publisher) diff --git a/rpkid/rpki/sql.py b/rpkid/rpki/sql.py index 1bb607cc..c4c9a7ae 100644 --- a/rpkid/rpki/sql.py +++ b/rpkid/rpki/sql.py @@ -3,7 +3,7 @@ SQL interface code. $Id$ -Copyright (C) 2009 Internet Systems Consortium ("ISC") +Copyright (C) 2009-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -176,7 +176,7 @@ class sql_persistent(object): sql_debug = False @classmethod - def sql_fetch(cls, gctx, id): + def sql_fetch(cls, gctx, id): # pylint: disable=W0622 """ Fetch one object from SQL, based on its primary key. @@ -312,7 +312,7 @@ class sql_persistent(object): Delete this object from SQL. """ if self.sql_in_db: - id = getattr(self, self.sql_template.index) + id = getattr(self, self.sql_template.index) # pylint: disable=W0622 if self.sql_debug: rpki.log.debug("sql_fetch_delete(%r, %r)" % (self.sql_template.delete, id)) self.sql_delete_hook() diff --git a/rpkid/rpki/sundial.py b/rpkid/rpki/sundial.py index b3dcb2e9..b8a78ea3 100644 --- a/rpkid/rpki/sundial.py +++ b/rpkid/rpki/sundial.py @@ -15,7 +15,7 @@ inspection of the datetime module, to wit: $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/rpkid/rpki/up_down.py b/rpkid/rpki/up_down.py index 521b3352..cea4e27f 100644 --- a/rpkid/rpki/up_down.py +++ b/rpkid/rpki/up_down.py @@ -3,7 +3,7 @@ RPKI "up-down" protocol. $Id$ -Copyright (C) 2009--2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/rpkid/rpki/x509.py b/rpkid/rpki/x509.py index 6aa6adea..a7f04304 100644 --- a/rpkid/rpki/x509.py +++ b/rpkid/rpki/x509.py @@ -48,7 +48,6 @@ import base64 import lxml.etree import os import subprocess -import sys import email.mime.application import email.utils import mailbox @@ -508,7 +507,7 @@ class DER_object(object): d.update(self.get_DER()) return "%s %s %s" % (uri, self.creation_timestamp, "".join(("%02X" % ord(b) for b in d.digest()))) - except: + except: # pylint: disable=W0702 return uri class X509(DER_object): @@ -542,7 +541,7 @@ class X509(DER_object): Get the rpki.POW value of this certificate. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = rpki.POW.X509.derRead(self.get_DER()) return self.POW @@ -846,7 +845,7 @@ class PKCS10(DER_object): Get the rpki.POW value of this certification request. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = rpki.POW.PKCS10.derRead(self.get_DER()) return self.POW @@ -1026,7 +1025,7 @@ class RSA(DER_object): Get the rpki.POW value of this keypair. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = rpki.POW.Asymmetric.derReadPrivate(self.get_DER()) return self.POW @@ -1085,7 +1084,7 @@ class RSApublic(DER_object): Get the rpki.POW value of this public key. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = rpki.POW.Asymmetric.derReadPublic(self.get_DER()) return self.POW @@ -1172,7 +1171,7 @@ class CMS_object(DER_object): Get the rpki.POW value of this CMS_object. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = self.POW_class.derRead(self.get_DER()) return self.POW @@ -1473,15 +1472,15 @@ class SignedManifest(DER_CMS_object): filelist.append((name.rpartition("/")[2], d.digest())) filelist.sort(key = lambda x: x[0]) - pow = cls.POW_class() - pow.setVersion(version) - pow.setManifestNumber(serial) - pow.setThisUpdate(thisUpdate.toGeneralizedTime()) - pow.setNextUpdate(nextUpdate.toGeneralizedTime()) - pow.setAlgorithm(POWify_OID(rpki.oids.name2oid["id-sha256"])) - pow.addFiles(filelist) + obj = cls.POW_class() + obj.setVersion(version) + obj.setManifestNumber(serial) + obj.setThisUpdate(thisUpdate.toGeneralizedTime()) + obj.setNextUpdate(nextUpdate.toGeneralizedTime()) + obj.setAlgorithm(POWify_OID(rpki.oids.name2oid["id-sha256"])) + obj.addFiles(filelist) - self = cls(POW = pow) + self = cls(POW = obj) self.sign(keypair, certs) return self @@ -1501,11 +1500,11 @@ class ROA(DER_CMS_object): """ ipv4 = ipv4.to_POW_roa_tuple() if ipv4 else None ipv6 = ipv6.to_POW_roa_tuple() if ipv6 else None - pow = cls.POW_class() - pow.setVersion(version) - pow.setASID(asn) - pow.setPrefixes(ipv4 = ipv4, ipv6 = ipv6) - self = cls(POW = pow) + obj = cls.POW_class() + obj.setVersion(version) + obj.setASID(asn) + obj.setPrefixes(ipv4 = ipv4, ipv6 = ipv6) + self = cls(POW = obj) self.sign(keypair, certs) return self @@ -1531,7 +1530,7 @@ class ROA(DER_CMS_object): text.append("%s/%s-%s" % (prefix, prefixlen, maxprefixlen)) text.sort() msg = "%s %s %s" % (msg, asn, ",".join(text)) - except: + except: # pylint: disable=W0702 pass return msg @@ -1667,7 +1666,7 @@ class XML_CMS_object(Wrapped_CMS_object): if self.saxify is None: return self.get_content() else: - return self.saxify(self.get_content()) + return self.saxify(self.get_content()) # pylint: disable=E1102 def check_replay(self, timestamp): """ @@ -1762,7 +1761,7 @@ class CRL(DER_object): Get the rpki.POW value of this CRL. """ self.check() - if not self.POW: + if not self.POW: # pylint: disable=E0203 self.POW = rpki.POW.CRL.derRead(self.get_DER()) return self.POW diff --git a/rpkid/rpki/xml_utils.py b/rpkid/rpki/xml_utils.py index 2e8a8691..156d0e48 100644 --- a/rpkid/rpki/xml_utils.py +++ b/rpkid/rpki/xml_utils.py @@ -3,7 +3,7 @@ XML utilities. $Id$ -Copyright (C) 2009-2011 Internet Systems Consortium ("ISC") +Copyright (C) 2009-2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above |