aboutsummaryrefslogtreecommitdiff
path: root/rpkid
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2012-10-18 23:53:23 +0000
committerRob Austein <sra@hactrn.net>2012-10-18 23:53:23 +0000
commitc4be735c645bdbcb86b2448899a3aa664d5e97df (patch)
treeebaa086e7376be3a512eab0fccce05494ef602a5 /rpkid
parent5897dfa4261927dafabc3ed6c16f27aa932efc42 (diff)
pylint
svn path=/branches/tk274/; revision=4786
Diffstat (limited to 'rpkid')
-rw-r--r--rpkid/Makefile.in2
-rw-r--r--rpkid/irbe_cli.py105
-rw-r--r--rpkid/rpki-sql-backup.py2
-rw-r--r--rpkid/rpki-sql-setup.py8
-rw-r--r--rpkid/rpki-start-servers.py1
-rw-r--r--rpkid/rpki/adns.py19
-rw-r--r--rpkid/rpki/async.py26
-rw-r--r--rpkid/rpki/config.py6
-rw-r--r--rpkid/rpki/csv_utils.py6
-rw-r--r--rpkid/rpki/exceptions.py2
-rw-r--r--rpkid/rpki/http.py29
-rw-r--r--rpkid/rpki/ipaddrs.py2
-rw-r--r--rpkid/rpki/irdb/__init__.py2
-rw-r--r--rpkid/rpki/irdb/models.py6
-rw-r--r--rpkid/rpki/irdb/router.py4
-rw-r--r--rpkid/rpki/irdb/zookeeper.py30
-rw-r--r--rpkid/rpki/irdbd.py9
-rw-r--r--rpkid/rpki/log.py1
-rw-r--r--rpkid/rpki/mysql_import.py4
-rw-r--r--rpkid/rpki/oids.py2
-rw-r--r--rpkid/rpki/old_irdbd.py16
-rw-r--r--rpkid/rpki/publication.py3
-rw-r--r--rpkid/rpki/rcynic.py70
-rw-r--r--rpkid/rpki/relaxng.py8
-rw-r--r--rpkid/rpki/resource_set.py64
-rw-r--r--rpkid/rpki/rootd.py4
-rw-r--r--rpkid/rpki/rpkic.py10
-rw-r--r--rpkid/rpki/rpkid.py1
-rw-r--r--rpkid/rpki/rpkid_tasks.py2
-rw-r--r--rpkid/rpki/sql.py6
-rw-r--r--rpkid/rpki/sundial.py2
-rw-r--r--rpkid/rpki/up_down.py2
-rw-r--r--rpkid/rpki/x509.py45
-rw-r--r--rpkid/rpki/xml_utils.py2
-rw-r--r--rpkid/setup.py4
-rw-r--r--rpkid/tests/myrpki-xml-parse-test.py6
-rw-r--r--rpkid/tests/smoketest.py60
-rw-r--r--rpkid/tests/testpoke.py4
-rw-r--r--rpkid/tests/yamlconf.py16
-rw-r--r--rpkid/tests/yamltest.py38
40 files changed, 326 insertions, 303 deletions
diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in
index 12c264b3..1e90f502 100644
--- a/rpkid/Makefile.in
+++ b/rpkid/Makefile.in
@@ -131,7 +131,7 @@ tags: Makefile
find . -type f \( -name '*.py' -o -name '*.sql' -o -name '*.rnc' -o -name '*.py.in' \) ! -name relaxng.py ! -name sql_schemas.py | etags -
lint:
- pylint --rcfile ${abs_top_srcdir}/buildtools/pylint.rc rpki/[a-z]*.py *d.py rpki-*.py rpkic.py irbe_cli.py tests/*.py
+ pylint --rcfile ${abs_top_srcdir}/buildtools/pylint.rc rpki/*.py rpki/irdb/*.py *.py tests/*.py
# Documentation
diff --git a/rpkid/irbe_cli.py b/rpkid/irbe_cli.py
index 520b186d..0a458009 100644
--- a/rpkid/irbe_cli.py
+++ b/rpkid/irbe_cli.py
@@ -3,7 +3,7 @@ Command line IR back-end control program for rpkid and pubd.
$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
@@ -95,6 +95,7 @@ class cmd_elt_mixin(reply_elt_mixin):
"""
Parse options for this class.
"""
+ # pylint: disable=W0621
opts, argv = getopt.getopt(argv, "", [x + "=" for x in self.attributes + self.elements if x not in self.excludes] + list(self.booleans))
for o, a in opts:
o = o[2:]
@@ -148,47 +149,48 @@ class cmd_msg_mixin(object):
# left-right protcol
-class self_elt(cmd_elt_mixin, rpki.left_right.self_elt):
- pass
+class left_right_msg(cmd_msg_mixin, rpki.left_right.msg):
-class bsc_elt(cmd_elt_mixin, rpki.left_right.bsc_elt):
+ class self_elt(cmd_elt_mixin, rpki.left_right.self_elt):
+ pass
- excludes = ("pkcs10_request",)
+ class bsc_elt(cmd_elt_mixin, rpki.left_right.bsc_elt):
- def client_query_signing_cert(self, arg):
- """--signing_cert option."""
- self.signing_cert = rpki.x509.X509(Auto_file = arg)
+ excludes = ("pkcs10_request",)
- def client_query_signing_cert_crl(self, arg):
- """--signing_cert_crl option."""
- self.signing_cert_crl = rpki.x509.CRL(Auto_file = arg)
+ def client_query_signing_cert(self, arg):
+ """--signing_cert option."""
+ self.signing_cert = rpki.x509.X509(Auto_file = arg)
- def client_reply_decode(self):
- global pem_out
- if pem_out is not None and self.pkcs10_request is not None:
- if isinstance(pem_out, str):
- pem_out = open(pem_out, "w")
- pem_out.write(self.pkcs10_request.get_PEM())
+ def client_query_signing_cert_crl(self, arg):
+ """--signing_cert_crl option."""
+ self.signing_cert_crl = rpki.x509.CRL(Auto_file = arg)
-class parent_elt(cmd_elt_mixin, rpki.left_right.parent_elt):
- pass
+ def client_reply_decode(self):
+ global pem_out
+ if pem_out is not None and self.pkcs10_request is not None:
+ if isinstance(pem_out, str):
+ pem_out = open(pem_out, "w")
+ pem_out.write(self.pkcs10_request.get_PEM())
-class child_elt(cmd_elt_mixin, rpki.left_right.child_elt):
- pass
+ class parent_elt(cmd_elt_mixin, rpki.left_right.parent_elt):
+ pass
-class repository_elt(cmd_elt_mixin, rpki.left_right.repository_elt):
- pass
+ class child_elt(cmd_elt_mixin, rpki.left_right.child_elt):
+ pass
-class list_published_objects_elt(cmd_elt_mixin, rpki.left_right.list_published_objects_elt):
- excludes = ("uri",)
+ class repository_elt(cmd_elt_mixin, rpki.left_right.repository_elt):
+ pass
-class list_received_resources_elt(cmd_elt_mixin, rpki.left_right.list_received_resources_elt):
- excludes = ("parent_handle", "notBefore", "notAfter", "uri", "sia_uri", "aia_uri", "asn", "ipv4", "ipv6")
+ class list_published_objects_elt(cmd_elt_mixin, rpki.left_right.list_published_objects_elt):
+ excludes = ("uri",)
-class report_error_elt(reply_elt_mixin, rpki.left_right.report_error_elt):
- pass
+ class list_received_resources_elt(cmd_elt_mixin, rpki.left_right.list_received_resources_elt):
+ excludes = ("parent_handle", "notBefore", "notAfter", "uri", "sia_uri", "aia_uri", "asn", "ipv4", "ipv6")
+
+ class report_error_elt(reply_elt_mixin, rpki.left_right.report_error_elt):
+ pass
-class left_right_msg(cmd_msg_mixin, rpki.left_right.msg):
pdus = dict((x.element_name, x)
for x in (self_elt, bsc_elt, parent_elt, child_elt, repository_elt,
list_published_objects_elt, list_received_resources_elt, report_error_elt))
@@ -201,36 +203,37 @@ class left_right_cms_msg(rpki.left_right.cms_msg):
# Publication protocol
-class config_elt(cmd_elt_mixin, rpki.publication.config_elt):
+class publication_msg(cmd_msg_mixin, rpki.publication.msg):
- def client_query_bpki_crl(self, arg):
- """
- Special handler for --bpki_crl option.
- """
- self.bpki_crl = rpki.x509.CRL(Auto_file = arg)
+ class config_elt(cmd_elt_mixin, rpki.publication.config_elt):
-class client_elt(cmd_elt_mixin, rpki.publication.client_elt):
- pass
+ def client_query_bpki_crl(self, arg):
+ """
+ Special handler for --bpki_crl option.
+ """
+ self.bpki_crl = rpki.x509.CRL(Auto_file = arg)
-class certificate_elt(cmd_elt_mixin, rpki.publication.certificate_elt):
- pass
+ class client_elt(cmd_elt_mixin, rpki.publication.client_elt):
+ pass
-class crl_elt(cmd_elt_mixin, rpki.publication.crl_elt):
- pass
+ class certificate_elt(cmd_elt_mixin, rpki.publication.certificate_elt):
+ pass
+
+ class crl_elt(cmd_elt_mixin, rpki.publication.crl_elt):
+ pass
-class manifest_elt(cmd_elt_mixin, rpki.publication.manifest_elt):
- pass
+ class manifest_elt(cmd_elt_mixin, rpki.publication.manifest_elt):
+ pass
-class roa_elt(cmd_elt_mixin, rpki.publication.roa_elt):
- pass
+ class roa_elt(cmd_elt_mixin, rpki.publication.roa_elt):
+ pass
-class report_error_elt(reply_elt_mixin, rpki.publication.report_error_elt):
- pass
+ class report_error_elt(reply_elt_mixin, rpki.publication.report_error_elt):
+ pass
-class ghostbuster_elt(cmd_elt_mixin, rpki.publication.ghostbuster_elt):
- pass
+ class ghostbuster_elt(cmd_elt_mixin, rpki.publication.ghostbuster_elt):
+ pass
-class publication_msg(cmd_msg_mixin, rpki.publication.msg):
pdus = dict((x.element_name, x)
for x in (config_elt, client_elt, certificate_elt, crl_elt,
manifest_elt, roa_elt, report_error_elt,
diff --git a/rpkid/rpki-sql-backup.py b/rpkid/rpki-sql-backup.py
index b6e7320a..ea11d957 100644
--- a/rpkid/rpki-sql-backup.py
+++ b/rpkid/rpki-sql-backup.py
@@ -6,7 +6,7 @@ For the moment, this just writes all the SQL to stdout.
$Id$
-Copyright (C) 2010 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
diff --git a/rpkid/rpki-sql-setup.py b/rpkid/rpki-sql-setup.py
index be138b0e..700d150a 100644
--- a/rpkid/rpki-sql-setup.py
+++ b/rpkid/rpki-sql-setup.py
@@ -4,7 +4,7 @@ root password, pulls other information from rpki.conf.
$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
@@ -19,8 +19,10 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, getopt, sys, rpki.config, getpass, warnings
-
+import getopt
+import sys
+import getpass
+import rpki.config
import rpki.sql_schemas
from rpki.mysql_import import MySQLdb
diff --git a/rpkid/rpki-start-servers.py b/rpkid/rpki-start-servers.py
index e7061062..722f51e6 100644
--- a/rpkid/rpki-start-servers.py
+++ b/rpkid/rpki-start-servers.py
@@ -58,6 +58,7 @@ cfg = rpki.config.parser(cfg_file, "myrpki")
def run(name):
+ # pylint: disable=E1103
cmd = (sys.executable, os.path.join(rpkid_dir, name), "-c", cfg.filename)
if debug:
proc = subprocess.Popen(cmd + ("-d",), stdout = open(name + ".log", "a"), stderr = subprocess.STDOUT)
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
diff --git a/rpkid/setup.py b/rpkid/setup.py
index 348aa544..fbf0547e 100644
--- a/rpkid/setup.py
+++ b/rpkid/setup.py
@@ -1,6 +1,6 @@
# $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
@@ -37,6 +37,8 @@ ac_libexecdir = os.getenv("AC_LIBEXECDIR", "").strip()
# this insanity is to kludge around pre-existing OpenSSL libraries
# that would screw up our build without these gymnastics.
+# pylint: disable=W0622
+
pow = Extension("rpki.POW._POW", ["ext/POW.c"],
extra_compile_args = ac_cflags,
extra_link_args = ac_ldflags + ac_libs)
diff --git a/rpkid/tests/myrpki-xml-parse-test.py b/rpkid/tests/myrpki-xml-parse-test.py
index 5aaf5cbf..6818dbe5 100644
--- a/rpkid/tests/myrpki-xml-parse-test.py
+++ b/rpkid/tests/myrpki-xml-parse-test.py
@@ -3,7 +3,7 @@ Test parser and display tool for myrpki.xml files.
$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
@@ -29,9 +29,9 @@ if False:
relaxng.assertValid(tree)
-def showitems(x):
+def showitems(y):
if False:
- for k, v in x.items():
+ for k, v in y.items():
if v:
print " ", k, v
diff --git a/rpkid/tests/smoketest.py b/rpkid/tests/smoketest.py
index 3321f04e..07ad4d0e 100644
--- a/rpkid/tests/smoketest.py
+++ b/rpkid/tests/smoketest.py
@@ -17,7 +17,7 @@ things that don't belong in yaml_script.
$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
@@ -46,9 +46,25 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
"""
-import os, yaml, warnings, subprocess, signal, time, getopt, sys, errno
-import rpki.resource_set, rpki.sundial, rpki.x509, rpki.http
-import rpki.log, rpki.left_right, rpki.config, rpki.publication, rpki.async
+# pylint: disable=W0621
+
+import os
+import yaml
+import subprocess
+import signal
+import time
+import getopt
+import sys
+import errno
+import rpki.resource_set
+import rpki.sundial
+import rpki.x509
+import rpki.http
+import rpki.log
+import rpki.left_right
+import rpki.config
+import rpki.publication
+import rpki.async
from rpki.mysql_import import MySQLdb
@@ -194,21 +210,21 @@ def main():
# Apparently os.walk() can't tell the difference between directories
# and symlinks to directories, so we have to handle both.
for root, dirs, files in os.walk(".", topdown = False):
- for file in files:
- if not file.endswith(".key"):
- os.remove(os.path.join(root, file))
- for dir in dirs:
+ for fn in files:
+ if not fn.endswith(".key"):
+ os.remove(os.path.join(root, fn))
+ for d in dirs:
try:
- os.rmdir(os.path.join(root, dir))
+ os.rmdir(os.path.join(root, d))
except OSError, e:
if e.errno == errno.ENOTDIR:
- os.remove(os.path.join(root, dir))
+ os.remove(os.path.join(root, d))
else:
raise
rpki.log.info("Reading master YAML configuration")
y = yaml_script.pop(0)
-
+
rpki.log.info("Constructing internal allocation database")
db = allocation_db(y)
@@ -218,6 +234,7 @@ def main():
rpki.log.info("Constructing BPKI keys and certs for pubd")
setup_bpki_cert_chain(pubd_name, ee = ("PUBD", "IRBE"))
+
for a in db:
a.setup_bpki_certs()
@@ -322,6 +339,7 @@ def main():
for proc, name in ((rootd_process, "rootd"),
(pubd_process, "pubd"),
(rsyncd_process, "rsyncd")):
+ # pylint: disable=E1103
if proc is not None:
rpki.log.info("Killing %s, pid %s" % (name, proc.pid))
try:
@@ -416,10 +434,7 @@ class allocation_db(list):
a.crl_interval = a.parent.crl_interval
if a.regen_margin is None:
a.regen_margin = a.parent.regen_margin
- i = 0
- for j in xrange(4):
- i = a.sia_base.index("/", i) + 1
- a.client_handle = a.sia_base[i:].rstrip("/")
+ a.client_handle = "/".join(a.sia_base.split("/")[4:]).rstrip("/")
self.root.closure()
self.map = dict((a.name, a) for a in self)
self.engines = [a for a in self if a.is_engine]
@@ -782,6 +797,7 @@ class allocation(object):
"""
Kill daemons for this entity.
"""
+ # pylint: disable=E1103
rpki.log.info("Killing daemons for %s" % self.name)
try:
for proc in (self.rpkid_process, self.irdbd_process):
@@ -1175,15 +1191,13 @@ def setup_publication(pubd_sql):
Set up publication daemon.
"""
rpki.log.info("Configure publication daemon")
- publication_dir = os.getcwd() + "/publication/"
+ publication_dir = os.getcwd() + "/publication"
assert rootd_sia.startswith("rsync://")
- i = 0
- for j in xrange(4):
- i = rootd_sia.index("/", i + 1)
global rsyncd_dir
- rsyncd_dir = publication_dir.rstrip("/") + rootd_sia[i:]
- pubd_dir = rsyncd_dir
- os.makedirs(pubd_dir + "root/trunk")
+ rsyncd_dir = publication_dir + "/".join(rootd_sia.split("/")[4:])
+ if not rsyncd_dir.endswith("/"):
+ rsyncd_dir += "/"
+ os.makedirs(rsyncd_dir + "root/trunk")
db = MySQLdb.connect(db = pubd_db_name, user = pubd_db_user, passwd = pubd_db_pass)
cur = db.cursor()
db.autocommit(True)
@@ -1199,7 +1213,7 @@ def setup_publication(pubd_sql):
"pubd_db_name" : pubd_db_name,
"pubd_db_user" : pubd_db_user,
"pubd_db_pass" : pubd_db_pass,
- "pubd_dir" : pubd_dir }
+ "pubd_dir" : rsyncd_dir }
f = open(pubd_name + ".conf", "w")
f.write(pubd_fmt_1 % d)
f.close()
diff --git a/rpkid/tests/testpoke.py b/rpkid/tests/testpoke.py
index ad20992d..49919709 100644
--- a/rpkid/tests/testpoke.py
+++ b/rpkid/tests/testpoke.py
@@ -12,7 +12,7 @@ Default configuration file is testpoke.yaml, override with --yaml option.
$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
@@ -154,7 +154,7 @@ def do_revoke():
dispatch = { "list" : do_list, "issue" : do_issue, "revoke" : do_revoke }
-def fail(e):
+def fail(e): # pylint: disable=W0621
rpki.log.traceback(debug)
sys.exit("Testpoke failed: %s" % e)
diff --git a/rpkid/tests/yamlconf.py b/rpkid/tests/yamlconf.py
index d0ff6b4f..deb7890f 100644
--- a/rpkid/tests/yamlconf.py
+++ b/rpkid/tests/yamlconf.py
@@ -36,15 +36,15 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-
"""
+# pylint: disable=W0702,W0621,W0602
+
import subprocess
import re
import os
import sys
import yaml
-import signal
import time
import argparse
import rpki.resource_set
@@ -57,8 +57,8 @@ import rpki.sql_schemas
from rpki.mysql_import import MySQLdb
-section_regexp = re.compile("\s*\[\s*(.+?)\s*\]\s*$")
-variable_regexp = re.compile("\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
+section_regexp = re.compile(r"\s*\[\s*(.+?)\s*\]\s*$")
+variable_regexp = re.compile(r"\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
flat_publication = False
only_one_pubd = True
@@ -672,10 +672,10 @@ def body():
ts = timestamp()
for root, dirs, files in os.walk(test_dir, topdown = False):
- for file in files:
- os.unlink(os.path.join(root, file))
- for dir in dirs:
- os.rmdir(os.path.join(root, dir))
+ for fn in files:
+ os.unlink(os.path.join(root, fn))
+ for d in dirs:
+ os.rmdir(os.path.join(root, d))
if not quiet:
print
diff --git a/rpkid/tests/yamltest.py b/rpkid/tests/yamltest.py
index a0903b42..a5f72788 100644
--- a/rpkid/tests/yamltest.py
+++ b/rpkid/tests/yamltest.py
@@ -15,7 +15,7 @@ Still to do:
$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
@@ -42,19 +42,31 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
-
"""
-import subprocess, re, os, getopt, sys, yaml, signal, time
-import rpki.resource_set, rpki.sundial, rpki.config, rpki.log
-import rpki.csv_utils, rpki.x509
+# pylint: disable=W0702,W0621
+
+import subprocess
+import re
+import os
+import getopt
+import sys
+import yaml
+import signal
+import time
+import rpki.resource_set
+import rpki.sundial
+import rpki.config
+import rpki.log
+import rpki.csv_utils
+import rpki.x509
# Nasty regular expressions for parsing config files. Sadly, while
# the Python ConfigParser supports writing config files, it does so in
# such a limited way that it's easier just to hack this ourselves.
-section_regexp = re.compile("\s*\[\s*(.+?)\s*\]\s*$")
-variable_regexp = re.compile("\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
+section_regexp = re.compile(r"\s*\[\s*(.+?)\s*\]\s*$")
+variable_regexp = re.compile(r"\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$")
def cleanpath(*names):
"""
@@ -99,11 +111,11 @@ class roa_request(object):
return "%s: %s" % (self.asn, self.v4 or self.v6)
@classmethod
- def parse(cls, yaml):
+ def parse(cls, y):
"""
Parse a ROA request from YAML format.
"""
- return cls(yaml.get("asn"), yaml.get("ipv4"), yaml.get("ipv6"))
+ return cls(y.get("asn"), y.get("ipv4"), y.get("ipv6"))
class allocation_db(list):
"""
@@ -577,10 +589,10 @@ try:
if not skip_config:
for root, dirs, files in os.walk(test_dir, topdown = False):
- for file in files:
- os.unlink(os.path.join(root, file))
- for dir in dirs:
- os.rmdir(os.path.join(root, dir))
+ for fn in files:
+ os.unlink(os.path.join(root, fn))
+ for d in dirs:
+ os.rmdir(os.path.join(root, d))
# Read first YAML doc in file and process as compact description of
# test layout and resource allocations. Ignore subsequent YAML docs,