aboutsummaryrefslogtreecommitdiff
path: root/rpki
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-05-29 22:31:15 +0000
committerRob Austein <sra@hactrn.net>2014-05-29 22:31:15 +0000
commit35c1ca65ac2b5cbd943248d59b3e02c6220b232f (patch)
treebf2daf07febf7cb352b8fcd530e62a1e5df89626 /rpki
parent07a045d1259f30878abba416b86373c05c929965 (diff)
PyLint
svn path=/trunk/; revision=5845
Diffstat (limited to 'rpki')
-rw-r--r--rpki/POW/__init__.py21
-rw-r--r--rpki/adns.py12
-rw-r--r--rpki/async.py34
-rw-r--r--rpki/cli.py11
-rw-r--r--rpki/config.py10
-rw-r--r--rpki/csv_utils.py8
-rw-r--r--rpki/daemonize.py37
-rw-r--r--rpki/exceptions.py8
-rw-r--r--rpki/gui/app/check_expired.py2
-rw-r--r--rpki/gui/app/urls.py10
-rw-r--r--rpki/gui/cacheview/misc.py4
-rw-r--r--rpki/http.py62
-rw-r--r--rpki/ipaddrs.py14
-rw-r--r--rpki/irdb/__init__.py6
-rw-r--r--rpki/irdb/models.py24
-rw-r--r--rpki/irdb/router.py6
-rw-r--r--rpki/irdb/zookeeper.py40
-rw-r--r--rpki/irdbd.py15
-rw-r--r--rpki/left_right.py26
-rw-r--r--rpki/log.py11
-rw-r--r--rpki/myrpki.py6
-rw-r--r--rpki/mysql_import.py12
-rw-r--r--rpki/oids.py7
-rw-r--r--rpki/old_irdbd.py7
-rw-r--r--rpki/pubd.py13
-rw-r--r--rpki/publication.py20
-rw-r--r--rpki/rcynic.py4
-rw-r--r--rpki/resource_set.py10
-rw-r--r--rpki/rootd.py43
-rw-r--r--rpki/rpkic.py13
-rw-r--r--rpki/rpkid.py239
-rw-r--r--rpki/rpkid_tasks.py103
-rw-r--r--rpki/rtr/client.py1
-rw-r--r--rpki/sql.py30
-rw-r--r--rpki/sql_schemas.py2
-rw-r--r--rpki/sundial.py16
-rw-r--r--rpki/up_down.py36
-rw-r--r--rpki/x509.py76
-rw-r--r--rpki/xml_utils.py14
39 files changed, 514 insertions, 499 deletions
diff --git a/rpki/POW/__init__.py b/rpki/POW/__init__.py
index 2c6c986a..a9371553 100644
--- a/rpki/POW/__init__.py
+++ b/rpki/POW/__init__.py
@@ -1,3 +1,24 @@
+# $Id$
+#
+# Copyright (C) 2014 Dragon Research Labs ("DRL")
+# Portions copyright (C) 2009--2013 Internet Systems Consortium ("ISC")
+# Portions copyright (C) 2006--2008 American Registry for Internet Numbers ("ARIN")
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notices and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
+# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
+# ISC, OR ARIN BE LIABLE FOR ANY SPECIAL, DIRECT, 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=W0622,W0401
+
from rpki.POW._POW import *
from rpki.POW._POW import __doc__
diff --git a/rpki/adns.py b/rpki/adns.py
index 725463fe..968684b5 100644
--- a/rpki/adns.py
+++ b/rpki/adns.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2010--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2003--2007, 2009, 2010 Nominum, Inc. ("NOMINUM")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND NOMINUM DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -61,7 +61,7 @@ nameservers = []
for ns in resolver.nameservers:
try:
nameservers.append((socket.AF_INET, dns.ipv4.inet_aton(ns)))
- continue
+ continue
except Exception:
pass
try:
@@ -69,7 +69,7 @@ for ns in resolver.nameservers:
continue
except Exception:
pass
- logger.error("Couldn't parse nameserver address %r" % ns)
+ logger.error("Couldn't parse nameserver address %r", ns)
class dispatcher(asyncore.dispatcher):
"""
@@ -120,7 +120,7 @@ class query(object):
if isinstance(qname, (str, unicode)):
qname = dns.name.from_text(qname)
if isinstance(qtype, str):
- qtype = dns.rdatatype.from_text(qtype)
+ qtype = dns.rdatatype.from_text(qtype)
if isinstance(qclass, str):
qclass = dns.rdataclass.from_text(qclass)
assert qname.is_absolute()
diff --git a/rpki/async.py b/rpki/async.py
index a0fbe3ef..da4b88b4 100644
--- a/rpki/async.py
+++ b/rpki/async.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -69,7 +69,7 @@ class iterator(object):
except (ExitNow, SystemExit):
raise
except Exception:
- logger.debug("Problem constructing iterator for %r" % (iterable,))
+ logger.debug("Problem constructing iterator for %s", repr(iterable))
raise
self.doit()
@@ -133,7 +133,7 @@ class timer(object):
"""
if self.gc_debug:
bt = traceback.extract_stack(limit = 3)
- logger.debug("%s from %s:%d" % (msg, bt[0][0], bt[0][1]))
+ logger.debug("%s from %s:%d", msg, bt[0][0], bt[0][1])
def set(self, when):
"""
@@ -156,7 +156,7 @@ class timer(object):
if gc_debug:
def __del__(self):
- logger.debug("Deleting %r" % self)
+ logger.debug("Deleting %r", self)
def cancel(self):
"""
@@ -206,12 +206,12 @@ class timer(object):
while timer_queue and now >= timer_queue[0].when:
t = timer_queue.pop(0)
if cls.run_debug:
- logger.debug("Running %r" % t)
+ logger.debug("Running %r", t)
try:
if t.handler is not None:
t.handler()
else:
- logger.warning("Timer %r expired with no handler set" % t)
+ logger.warning("Timer %r expired with no handler set", t)
except (ExitNow, SystemExit):
raise
except Exception, e:
@@ -293,14 +293,14 @@ def event_loop(catch_signals = (signal.SIGINT, signal.SIGTERM)):
while asyncore.socket_map or timer_queue:
t = timer.seconds_until_wakeup()
if debug_event_timing:
- logger.debug("Dismissing to asyncore.poll(), t = %s, q = %r" % (t, timer_queue))
+ logger.debug("Dismissing to asyncore.poll(), t = %s, q = %r", t, timer_queue)
asyncore.poll(t, asyncore.socket_map)
timer.runq()
if timer.gc_debug:
gc.collect()
if gc.garbage:
for i in gc.garbage:
- logger.debug("GC-cycle %r" % i)
+ logger.debug("GC-cycle %r", i)
del gc.garbage[:]
except ExitNow:
break
@@ -311,12 +311,12 @@ def event_loop(catch_signals = (signal.SIGINT, signal.SIGTERM)):
logger.error("Something is badly wrong, select() thinks we gave it a bad file descriptor.")
logger.error("Content of asyncore.socket_map:")
for fd in sorted(asyncore.socket_map.iterkeys()):
- logger.error(" fd %s obj %r" % (fd, asyncore.socket_map[fd]))
+ logger.error(" fd %s obj %r", fd, asyncore.socket_map[fd])
logger.error("Not safe to continue due to risk of spin loop on select(). Exiting.")
sys.exit(1)
- logger.error("event_loop() exited with exception %r, this is not supposed to happen, restarting" % e)
+ logger.exception("event_loop() exited with exception %r, this is not supposed to happen, restarting")
except Exception, e:
- logger.error("event_loop() exited with exception %r, this is not supposed to happen, restarting" % e)
+ logger.exception("event_loop() exited with exception %r, this is not supposed to happen, restarting")
else:
break
finally:
@@ -367,7 +367,7 @@ class sync_wrapper(object):
raise
except Exception, e:
self.eb(e)
-
+
event_defer(thunk)
event_loop()
if self.err is None:
@@ -396,7 +396,7 @@ class gc_summary(object):
"""
logger.debug("gc_summary: Running gc.collect()")
gc.collect()
- logger.debug("gc_summary: Summarizing (threshold %d)" % self.threshold)
+ logger.debug("gc_summary: Summarizing (threshold %d)", self.threshold)
total = {}
tuples = {}
for g in gc.get_objects():
@@ -413,10 +413,10 @@ class gc_summary(object):
logger.debug("gc_summary: Object type counts in descending order")
for name, count in total:
if count > self.threshold:
- logger.debug("gc_summary: %8d %s" % (count, name))
+ logger.debug("gc_summary: %8d %s", count, name)
logger.debug("gc_summary: Tuple content type signature counts in descending order")
for types, count in tuples:
if count > self.threshold:
- logger.debug("gc_summary: %8d (%s)" % (count, types))
+ logger.debug("gc_summary: %8d (%s)", count, types)
logger.debug("gc_summary: Scheduling next cycle")
self.timer.set(self.interval)
diff --git a/rpki/cli.py b/rpki/cli.py
index 1930f2b7..fa76155b 100644
--- a/rpki/cli.py
+++ b/rpki/cli.py
@@ -1,12 +1,12 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions 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
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR
@@ -40,6 +40,7 @@ class ExitArgparse(Exception):
"Exit method from ArgumentParser."
def __init__(self, message = None, status = 0):
+ super(ExitArgparse, self).__init__()
self.message = message
self.status = status
@@ -62,7 +63,7 @@ class Cmd(cmd.Cmd):
cmd.Cmd.__init__(self)
if argv:
self.onecmd(" ".join(argv))
- else:
+ else:
self.cmdloop_with_history()
def onecmd(self, line):
@@ -229,7 +230,7 @@ def parsecmd(subparsers, *arg_clauses):
intended to handle parsing for the entire program on the command line.
arg_clauses is a series of defarg() invocations defining arguments to be parsed
- by the argparse code.
+ by the argparse code.
The decorator will use arg_clauses to construct two separate argparse parser
instances: one will be attached to the global parser as a subparser, the
diff --git a/rpki/config.py b/rpki/config.py
index d5f58238..85dbb509 100644
--- a/rpki/config.py
+++ b/rpki/config.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -255,14 +255,14 @@ class parser(object):
try:
rpki.x509.XML_CMS_object.dump_outbound_cms = rpki.x509.DeadDrop(self.get("dump_outbound_cms"))
except OSError, e:
- logger.warning("Couldn't initialize mailbox %s: %s" % (self.get("dump_outbound_cms"), e))
+ logger.warning("Couldn't initialize mailbox %s: %s", self.get("dump_outbound_cms"), e)
except ConfigParser.NoOptionError:
pass
try:
rpki.x509.XML_CMS_object.dump_inbound_cms = rpki.x509.DeadDrop(self.get("dump_inbound_cms"))
except OSError, e:
- logger.warning("Couldn't initialize mailbox %s: %s" % (self.get("dump_inbound_cms"), e))
+ logger.warning("Couldn't initialize mailbox %s: %s", self.get("dump_inbound_cms"), e)
except ConfigParser.NoOptionError:
pass
diff --git a/rpki/csv_utils.py b/rpki/csv_utils.py
index e045b9af..9ba04a02 100644
--- a/rpki/csv_utils.py
+++ b/rpki/csv_utils.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -49,7 +49,7 @@ class csv_reader(object):
self.filename = filename
self.columns = columns
self.min_columns = min_columns
- self.comment_characters = comment_characters
+ self.comment_characters = comment_characters
self.file = open(filename, "r")
def __iter__(self):
diff --git a/rpki/daemonize.py b/rpki/daemonize.py
index 6e6f1a42..6a825566 100644
--- a/rpki/daemonize.py
+++ b/rpki/daemonize.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# Copyright (C) 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -14,18 +14,18 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
-# Some code borrowed from
+# Some code borrowed from
# http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
-#
+#
# (which was explicitly placed in public domain by its author), and from
-#
+#
# /usr/src/lib/libc/gen/daemon.c
-#
+#
# (the libc implementation of daemon(3) on FreeBSD), so:
-#
+#
# Portions copyright (c) 1990, 1993
# The Regents of the University of California. All rights reserved.
-#
+#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@@ -37,7 +37,7 @@
# 4. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
-#
+#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -58,12 +58,11 @@ because it was written to fit into an existing package and I didn't
want to drag in yet another external library just for this.
"""
-import sys
import os
+import sys
import atexit
import signal
import logging
-import rpki.log
logger = logging.getLogger(__name__)
@@ -95,18 +94,18 @@ def daemon(nochdir = False, noclose = False, pidfile = None):
old_sighup_action = signal.signal(signal.SIGHUP, signal.SIG_IGN)
- try:
- pid = os.fork()
- except OSError, e:
+ try:
+ pid = os.fork()
+ except OSError, e:
sys.exit("fork() failed: %d (%s)" % (e.errno, e.strerror))
else:
if pid > 0:
os._exit(0)
-
+
if not nochdir:
- os.chdir("/")
+ os.chdir("/")
- os.setsid()
+ os.setsid()
if not noclose:
sys.stdout.flush()
@@ -133,4 +132,4 @@ def daemon(nochdir = False, noclose = False, pidfile = None):
f.write("%d\n" % os.getpid())
f.close()
except IOError, e:
- logger.warning("Couldn't write PID file %s: %s" % (pidfile, e.strerror))
+ logger.warning("Couldn't write PID file %s: %s", pidfile, e.strerror)
diff --git a/rpki/exceptions.py b/rpki/exceptions.py
index d8d3774e..504c6f28 100644
--- a/rpki/exceptions.py
+++ b/rpki/exceptions.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2013 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -172,7 +172,7 @@ class WrongEContentType(RPKI_Exception):
"""
Received wrong CMS eContentType.
"""
-
+
class EmptyPEM(RPKI_Exception):
"""
Couldn't find PEM block to convert.
diff --git a/rpki/gui/app/check_expired.py b/rpki/gui/app/check_expired.py
index e869f31b..eda21c0c 100644
--- a/rpki/gui/app/check_expired.py
+++ b/rpki/gui/app/check_expired.py
@@ -111,7 +111,7 @@ def check_child_certs(conf, errs):
pdus = z.call_rpkid(req)
for pdu in pdus:
if isinstance(pdu, report_error_elt):
- logger.error("rpkid reported an error: %s" % pdu.error_code)
+ logger.error("rpkid reported an error: %s", pdu.error_code)
elif isinstance(pdu, list_published_objects_elt):
if pdu.uri.endswith('.cer'):
cert = X509()
diff --git a/rpki/gui/app/urls.py b/rpki/gui/app/urls.py
index f70667df..be5cb346 100644
--- a/rpki/gui/app/urls.py
+++ b/rpki/gui/app/urls.py
@@ -79,17 +79,17 @@ urlpatterns = patterns(
(r'^user/(?P<pk>\d+)/delete$', views.user_delete),
(r'^user/(?P<pk>\d+)/edit$', views.user_edit),
- url(r'^user/password/reset/$',
- 'django.contrib.auth.views.password_reset',
+ url(r'^user/password/reset/$',
+ 'django.contrib.auth.views.password_reset',
#{'post_reset_redirect' : '/user/password/reset/done/'},
{'extra_context': {'form_title': 'Password Reset'}},
name="password_reset"),
(r'^user/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'),
- url(r'^user/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
- 'django.contrib.auth.views.password_reset_confirm',
+ url(r'^user/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
+ 'django.contrib.auth.views.password_reset_confirm',
#{'post_reset_redirect' : '/user/password/done/'},
name="password_reset_confirm"),
- (r'^user/password/done/$',
+ (r'^user/password/done/$',
'django.contrib.auth.views.password_reset_complete'),
)
diff --git a/rpki/gui/cacheview/misc.py b/rpki/gui/cacheview/misc.py
index 9a69645c..54431224 100644
--- a/rpki/gui/cacheview/misc.py
+++ b/rpki/gui/cacheview/misc.py
@@ -1,9 +1,9 @@
# Copyright (C) 2011 SPARTA, Inc. dba Cobham Analytic Solutions
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/http.py b/rpki/http.py
index 2d53511b..4b9d1eca 100644
--- a/rpki/http.py
+++ b/rpki/http.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -251,7 +251,7 @@ class http_request(http_message):
def __repr__(self):
return rpki.log.log_repr(self, self.cmd, self.path)
-
+
class http_response(http_message):
"""
HTTP response message.
@@ -331,7 +331,7 @@ class http_stream(asynchat.async_chat):
it.
"""
if self.timeout is not None:
- self.logger.debug("Setting timeout %s" % self.timeout)
+ self.logger.debug("Setting timeout %s", self.timeout)
self.timer.set(self.timeout)
else:
self.logger.debug("Clearing timeout")
@@ -384,7 +384,7 @@ class http_stream(asynchat.async_chat):
self.set_terminator(int(self.msg.headers["Content-Length"]))
else:
self.handle_no_content_length()
-
+
def chunk_header(self):
"""
Asynchat just handed us what should be the header of one chunk of
@@ -393,7 +393,7 @@ class http_stream(asynchat.async_chat):
the process of exiting the chunk decoder.
"""
n = int(self.get_buffer().partition(";")[0], 16)
- self.logger.debug("Chunk length %s" % n)
+ self.logger.debug("Chunk length %s", n)
if n:
self.chunk_handler = self.chunk_body
self.set_terminator(n)
@@ -514,7 +514,7 @@ class http_server(http_stream):
Content-Type, look for a handler, and if everything looks right,
pass the message body, path, and a reply callback to the handler.
"""
- self.logger.debug("Received request %r" % self.msg)
+ self.logger.debug("Received request %r", self.msg)
if not self.msg.persistent:
self.expect_close = True
handler = self.find_handler(self.msg.path)
@@ -566,7 +566,7 @@ class http_server(http_stream):
self.logger.debug("Closing")
self.timer.cancel()
self.close_when_done()
- else:
+ else:
self.logger.debug("Listening for next message")
self.restart()
@@ -598,11 +598,11 @@ class http_listener(asyncore.dispatcher):
self.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
self.bind(sockaddr)
self.listen(5)
- except Exception, e:
+ except Exception:
self.logger.exception("Couldn't set up HTTP listener")
self.close()
for h in handlers:
- self.logger.debug("Handling %s" % h[0])
+ self.logger.debug("Handling %s", h[0])
def handle_accept(self):
"""
@@ -611,12 +611,12 @@ class http_listener(asyncore.dispatcher):
"""
try:
s, c = self.accept()
- self.logger.debug("Accepting connection from %s" % addr_to_string(c))
+ self.logger.debug("Accepting connection from %s", addr_to_string(c))
http_server(sock = s, handlers = self.handlers)
except (rpki.async.ExitNow, SystemExit):
raise
- except Exception, e:
- self.logger.debug("Unable to accept connection: %s" % e)
+ except Exception:
+ self.logger.exception("Unable to accept connection: %s")
self.handle_error()
def handle_error(self):
@@ -646,7 +646,7 @@ class http_client(http_stream):
def __init__(self, queue, hostport):
http_stream.__init__(self)
- self.logger.debug("Creating new connection to %s" % addr_to_string(hostport))
+ self.logger.debug("Creating new connection to %s", addr_to_string(hostport))
self.queue = queue
self.host = hostport[0]
self.port = hostport[1]
@@ -721,7 +721,7 @@ class http_client(http_stream):
"""
Queue up request message and kickstart connection.
"""
- self.logger.debug("Sending request %r" % msg)
+ self.logger.debug("Sending request %r", msg)
assert self.state == "idle", "%r: state should be idle, is %s" % (self, self.state)
self.set_state("request-sent")
msg.headers["Connection"] = "Close" if self.expect_close else "Keep-Alive"
@@ -738,7 +738,7 @@ class http_client(http_stream):
arrange for the stream to shut down.
"""
- self.logger.debug("Message received, state %s" % self.state)
+ self.logger.debug("Message received, state %s", self.state)
if not self.msg.persistent:
self.expect_close = True
@@ -778,7 +778,7 @@ class http_client(http_stream):
sent, signal the error.
"""
http_stream.handle_close(self)
- self.logger.debug("State %s" % self.state)
+ self.logger.debug("State %s", self.state)
if self.get_terminator() is None:
self.handle_body()
elif self.state == "request-sent":
@@ -793,7 +793,7 @@ class http_client(http_stream):
"""
bad = self.state not in ("idle", "closing")
if bad:
- self.logger.warning("Timeout while in state %s" % self.state)
+ self.logger.warning("Timeout while in state %s", self.state)
http_stream.handle_timeout(self)
if bad:
try:
@@ -834,7 +834,7 @@ class http_queue(object):
"""
Append http_request object(s) to this queue.
"""
- self.logger.debug("Adding requests %r" % requests)
+ self.logger.debug("Adding requests %r", requests)
self.queue.extend(requests)
def restart(self):
@@ -849,10 +849,10 @@ class http_queue(object):
try:
if self.client is None:
self.client = http_client(self, self.hostport)
- self.logger.debug("Attached client %r" % self.client)
+ self.logger.debug("Attached client %r", self.client)
self.client.start()
elif self.client.state == "idle":
- self.logger.debug("Sending request to existing client %r" % self.client)
+ self.logger.debug("Sending request to existing client %r", self.client)
self.send_request()
else:
self.logger.debug("Client %r exists in state %r" % (self.client, self.client.state))
@@ -876,7 +876,7 @@ class http_queue(object):
conditions.
"""
if client_ is self.client:
- self.logger.debug("Detaching client %r" % client_)
+ self.logger.debug("Detaching client %r", client_)
self.client = None
def return_result(self, client, result, detach = False): # pylint: disable=W0621
@@ -888,7 +888,7 @@ class http_queue(object):
"""
if client is not self.client:
- self.logger.warning("Wrong client trying to return result. THIS SHOULD NOT HAPPEN. Dropping result %r" % result)
+ self.logger.warning("Wrong client trying to return result. THIS SHOULD NOT HAPPEN. Dropping result %r", result)
return
if detach:
@@ -896,16 +896,16 @@ class http_queue(object):
try:
req = self.queue.pop(0)
- self.logger.debug("Dequeuing request %r" % req)
+ self.logger.debug("Dequeuing request %r", req)
except IndexError:
- self.logger.warning("No caller. THIS SHOULD NOT HAPPEN. Dropping result %r" % result)
+ self.logger.warning("No caller. THIS SHOULD NOT HAPPEN. Dropping result %r", result)
return
assert isinstance(result, http_response) or isinstance(result, Exception)
if isinstance(result, http_response):
try:
- self.logger.debug("Returning result %r to caller" % result)
+ self.logger.debug("Returning result %r to caller", result)
req.callback(result.body)
except (rpki.async.ExitNow, SystemExit):
raise
@@ -921,7 +921,7 @@ class http_queue(object):
except Exception:
self.logger.exception("Exception in exception callback, may have lost event chain")
- self.logger.debug("Queue: %r" % self.queue)
+ self.logger.debug("Queue: %r", self.queue)
if self.queue:
self.restart()
@@ -947,7 +947,7 @@ def client(msg, url, callback, errback):
raise rpki.exceptions.BadClientURL("Unusable URL %s" % url)
if debug_http:
- logger.debug("Contacting %s" % url)
+ logger.debug("Contacting %s", url)
request = http_request(
cmd = "POST",
@@ -961,7 +961,7 @@ def client(msg, url, callback, errback):
hostport = (u.hostname or "localhost", u.port or default_tcp_port)
if debug_http:
- logger.debug("Created request %r for %s" % (request, addr_to_string(hostport)))
+ logger.debug("Created request %r for %s", request, addr_to_string(hostport))
if hostport not in client_queues:
client_queues[hostport] = http_queue(hostport)
client_queues[hostport].request(request)
@@ -970,7 +970,7 @@ def client(msg, url, callback, errback):
# pending I/O events, in case connections have closed.
if debug_http:
- logger.debug("Scheduling connection startup for %r" % request)
+ logger.debug("Scheduling connection startup for %r", request)
rpki.async.event_defer(client_queues[hostport].restart)
def server(handlers, port, host = ""):
diff --git a/rpki/ipaddrs.py b/rpki/ipaddrs.py
index c1855302..68b2d27d 100644
--- a/rpki/ipaddrs.py
+++ b/rpki/ipaddrs.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -56,7 +56,7 @@ class v4addr(long):
bits = 32
ipversion = 4
-
+
def __new__(cls, x):
"""
Construct a v4addr object.
diff --git a/rpki/irdb/__init__.py b/rpki/irdb/__init__.py
index cc83387e..7f3b880e 100644
--- a/rpki/irdb/__init__.py
+++ b/rpki/irdb/__init__.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/irdb/models.py b/rpki/irdb/models.py
index 1ad9b4e3..6fa48c59 100644
--- a/rpki/irdb/models.py
+++ b/rpki/irdb/models.py
@@ -1,12 +1,12 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions 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
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR
@@ -24,7 +24,7 @@ to be usable by command line programs and other scripts, not just
Django GUI code, so be careful.
"""
-# pylint: disable=W0232
+# pylint: disable=W0232,C1001
import django.db.models
import rpki.x509
@@ -389,7 +389,7 @@ class ServerRevocation(Revocation):
class ResourceHolderRevocation(Revocation):
issuer = django.db.models.ForeignKey(ResourceHolderCA, related_name = "revocations")
-
+
class EECertificate(Certificate):
private_key = RSAKeyField()
@@ -637,10 +637,10 @@ class Client(CrossCertification):
# for Django South -- these are just simple subclasses
add_introspection_rules([],
- ('^rpki\.irdb\.models\.CertificateField',
- '^rpki\.irdb\.models\.CRLField',
- '^rpki\.irdb\.models\.EnumField',
- '^rpki\.irdb\.models\.HandleField',
- '^rpki\.irdb\.models\.RSAKeyField',
- '^rpki\.irdb\.models\.SignedReferralField',
- '^rpki\.irdb\.models\.SundialField'))
+ (r'^rpki\.irdb\.models\.CertificateField',
+ r'^rpki\.irdb\.models\.CRLField',
+ r'^rpki\.irdb\.models\.EnumField',
+ r'^rpki\.irdb\.models\.HandleField',
+ r'^rpki\.irdb\.models\.RSAKeyField',
+ r'^rpki\.irdb\.models\.SignedReferralField',
+ r'^rpki\.irdb\.models\.SundialField'))
diff --git a/rpki/irdb/router.py b/rpki/irdb/router.py
index 1f27d0c9..97e3d0b7 100644
--- a/rpki/irdb/router.py
+++ b/rpki/irdb/router.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# Copyright (C) 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/irdb/zookeeper.py b/rpki/irdb/zookeeper.py
index 78783e6b..cd996c7e 100644
--- a/rpki/irdb/zookeeper.py
+++ b/rpki/irdb/zookeeper.py
@@ -1,12 +1,12 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions 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
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR
@@ -20,7 +20,7 @@
Management code for the IRDB.
"""
-# pylint: disable=W0612
+# pylint: disable=W0612,C0325
import os
import copy
@@ -45,8 +45,6 @@ from lxml.etree import (Element, SubElement, ElementTree,
from rpki.csv_utils import csv_reader
-
-
# XML namespace and protocol version for OOB setup protocol. The name
# is historical and may change before we propose this as the basis for
# a standard.
@@ -80,7 +78,6 @@ class BadXMLMessage(Exception): "Bad XML message."
class PastExpiration(Exception): "Expiration date has already passed."
class CantRunRootd(Exception): "Can't run rootd."
-
def B64Element(e, tag, obj, **kwargs):
"""
@@ -135,8 +132,6 @@ class PEM_writer(object):
os.rename(tempname, filename)
self.wrote.add(filename)
-
-
def etree_read(filename):
"""
@@ -192,10 +187,9 @@ class etree_wrapper(object):
@property
def file(self):
- from cStringIO import StringIO
+ from cStringIO import StringIO
return StringIO(ElementToString(self.etree))
-
class Zookeeper(object):
@@ -464,7 +458,7 @@ class Zookeeper(object):
self.log("Regenerating Server BPKI CRL")
self.server_ca.generate_crl()
self.server_ca.save()
-
+
for ca in rpki.irdb.ResourceHolderCA.objects.all():
self.log("Regenerating BPKI CRL for Resource Holder %s" % ca.handle)
ca.generate_crl()
@@ -519,7 +513,7 @@ class Zookeeper(object):
parent_handle = parent.handle,
bpki_cms_cert = parent.certificate)
for parent in rpki.irdb.Parent.objects.all())
-
+
updates.extend(
rpki.left_right.parent_elt.make_pdu(
action = "set",
@@ -786,7 +780,7 @@ class Zookeeper(object):
if sia_base is None:
self.log("Don't know where to nest this client, defaulting to top-level")
sia_base = "rsync://%s/%s/%s/" % (self.rsync_server, self.rsync_module, client.get("handle"))
-
+
if not sia_base.startswith("rsync://"):
raise BadXMLMessage("Malformed sia_base parameter %r, should start with 'rsync://'" % sia_base)
@@ -1219,7 +1213,7 @@ class Zookeeper(object):
to whack everything into sync should call this when they're done,
but be warned that this can be slow with a lot of CAs.
- Any arguments given are handles of CAs which should be poked with a
+ Any arguments given are handles of CAs which should be poked with a
<self run_now="yes"/> operation.
"""
@@ -1617,12 +1611,12 @@ class Zookeeper(object):
pkcs10 = pkcs10,
gski = pkcs10.gSKI(),
valid_until = resources.valid_until)
- for range in resources.asn:
- ee_request.asns.create(start_as = str(range.min), end_as = str(range.max))
- for range in resources.v4:
- ee_request.address_ranges.create(start_ip = str(range.min), end_ip = str(range.max), version = 4)
- for range in resources.v6:
- ee_request.address_ranges.create(start_ip = str(range.min), end_ip = str(range.max), version = 6)
+ for r in resources.asn:
+ ee_request.asns.create(start_as = str(r.min), end_as = str(r.max))
+ for r in resources.v4:
+ ee_request.address_ranges.create(start_ip = str(r.min), end_ip = str(r.max), version = 4)
+ for r in resources.v6:
+ ee_request.address_ranges.create(start_ip = str(r.min), end_ip = str(r.max), version = 6)
@django.db.transaction.commit_on_success
@@ -1669,8 +1663,8 @@ class Zookeeper(object):
sn = sn,
eku = rpki.oids.id_kp_bgpsec_router)
- for range in asns:
- ee_request.asns.create(start_as = str(range.min), end_as = str(range.max))
+ for r in asns:
+ ee_request.asns.create(start_as = str(r.min), end_as = str(r.max))
@django.db.transaction.commit_on_success
diff --git a/rpki/irdbd.py b/rpki/irdbd.py
index 430da4c2..d53ae67c 100644
--- a/rpki/irdbd.py
+++ b/rpki/irdbd.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -21,7 +21,6 @@
IR database daemon.
"""
-import sys
import os
import time
import logging
@@ -180,7 +179,7 @@ class main(object):
prof.runcall(self.main)
finally:
prof.dump_stats(args.profile)
- logger.info("Dumped profile data to %s" % args.profile)
+ logger.info("Dumped profile data to %s", args.profile)
else:
self.main()
@@ -215,9 +214,9 @@ class main(object):
INSTALLED_APPS = ("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
# http://devblog.resolversystems.com/?p=439
# http://groups.google.com/group/django-users/browse_thread/thread/e25cec400598c06d
@@ -247,7 +246,7 @@ class main(object):
try:
self.http_server_host = self.cfg.get("server-host", "")
self.http_server_port = self.cfg.getint("server-port")
- except:
+ except: # pylint: disable=W0702
#
# Backwards compatibility, remove this eventually.
#
diff --git a/rpki/left_right.py b/rpki/left_right.py
index d85756ce..12c69521 100644
--- a/rpki/left_right.py
+++ b/rpki/left_right.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -114,7 +114,7 @@ class data_elt(rpki.xml_utils.data_elt, rpki.sql.sql_persistent, left_right_name
"""
where = "%s.self_id = self.self_id and self.self_handle = %%s" % self.element_name
return self.sql_fetch_where(self.gctx, where, (self.self_handle,), "self")
-
+
def serve_pre_save_hook(self, q_pdu, r_pdu, cb, eb):
"""
Hook to do _handle => _id translation before saving.
@@ -330,8 +330,8 @@ class self_elt(data_elt):
"""
Handle a left-right run_now action for this self.
"""
- logger.debug("Forced immediate run of periodic actions for self %s[%d]" % (
- self.self_handle, self.self_id))
+ logger.debug("Forced immediate run of periodic actions for self %s[%d]",
+ self.self_handle, self.self_id)
completion = rpki.rpkid_tasks.CompletionHandler(cb)
self.schedule_cron_tasks(completion)
assert completion.count > 0
@@ -391,12 +391,12 @@ class self_elt(data_elt):
results.add(ca_detail)
return results
-
+
class bsc_elt(data_elt):
"""
<bsc/> (Business Signing Context) element.
"""
-
+
element_name = "bsc"
attributes = ("action", "tag", "self_handle", "bsc_handle", "key_type", "hash_alg", "key_length")
elements = ("signing_cert", "signing_cert_crl", "pkcs10_request")
@@ -544,7 +544,7 @@ class repository_elt(data_elt):
handlers = {}
for q_pdu in q_msg:
- logger.info("Sending %s %s to pubd" % (q_pdu.action, q_pdu.uri))
+ logger.info("Sending %s %s to pubd", q_pdu.action, q_pdu.uri)
bsc = self.bsc
q_der = rpki.publication.cms_msg().wrap(q_msg, bsc.private_key_id, bsc.signing_cert, bsc.signing_cert_crl)
@@ -559,7 +559,7 @@ class repository_elt(data_elt):
for r_pdu in r_msg:
handler = handlers.get(r_pdu.tag, self.default_pubd_handler)
if handler:
- logger.debug("Calling pubd handler %r" % handler)
+ logger.debug("Calling pubd handler %r", handler)
handler(r_pdu)
if len(q_msg) != len(r_msg):
raise rpki.exceptions.BadPublicationReply("Wrong number of response PDUs from pubd: sent %r, got %r" % (q_msg, r_msg))
@@ -708,7 +708,7 @@ class parent_elt(data_elt):
"""
def loop(iterator, ski):
- logger.debug("Asking parent %r to revoke class %r, SKI %s" % (self, rc_name, ski))
+ logger.debug("Asking parent %r to revoke class %r, SKI %s", self, rc_name, ski)
q_pdu = rpki.up_down.revoke_pdu()
q_pdu.class_name = rc_name
q_pdu.ski = ski
@@ -761,7 +761,7 @@ class parent_elt(data_elt):
self.serve_revoke_forgotten(done, fail)
def fail(e):
- logger.warning("Trouble getting parent to revoke certificates, blundering onwards: %s" % e)
+ logger.warning("Trouble getting parent to revoke certificates, blundering onwards: %s", e)
done()
def done():
@@ -1139,7 +1139,7 @@ class list_published_objects_elt(rpki.xml_utils.text_elt, left_right_namespace):
r_msg.extend(self.make_reply(r.uri, r.roa)
for r in ca_detail.roas if r.roa is not None)
r_msg.extend(self.make_reply(g.uri, g.ghostbuster)
- for g in ca_detail.ghostbusters)
+ for g in ca_detail.ghostbusters)
r_msg.extend(self.make_reply(c.uri, c.cert)
for c in ca_detail.ee_certificates)
cb()
diff --git a/rpki/log.py b/rpki/log.py
index 77749c5a..9d837858 100644
--- a/rpki/log.py
+++ b/rpki/log.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -163,6 +163,8 @@ def init(ident = "rpki", args = argparse.Namespace(log_level = logging.WARNING,
assert isinstance(args, argparse.Namespace)
+ # pylint: disable=E1103
+
if args.log_stream:
handler = logging.StreamHandler(stream = args.log_stream)
@@ -222,8 +224,7 @@ def log_repr(obj, *tokens):
s = str(token)
except:
s = "???"
- logger.debug("Failed to generate repr() string for object of type %r" % type(token))
- traceback(logger)
+ logger.exception("Failed to generate repr() string for object of type %r", type(token))
if s:
words.append(s)
diff --git a/rpki/myrpki.py b/rpki/myrpki.py
index c5c7990f..2ae912f0 100644
--- a/rpki/myrpki.py
+++ b/rpki/myrpki.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# Copyright (C) 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/mysql_import.py b/rpki/mysql_import.py
index 88d30357..538e1916 100644
--- a/rpki/mysql_import.py
+++ b/rpki/mysql_import.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/oids.py b/rpki/oids.py
index a97df6a7..9fa30a04 100644
--- a/rpki/oids.py
+++ b/rpki/oids.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -87,6 +87,7 @@ for _sym in dir():
raise ValueError("Bad OID definition: %s = %r" % (_sym, _val))
_oid2name[_val] = _sym.replace("_", "-")
+# pylint: disable=W0631
del _sym
del _val
diff --git a/rpki/old_irdbd.py b/rpki/old_irdbd.py
index bdeb4f7d..6c026a31 100644
--- a/rpki/old_irdbd.py
+++ b/rpki/old_irdbd.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -25,7 +25,6 @@ and perhaps still useful as a minimal example. This does NOT work with
the GUI, rpkic, or any of the other more recent tools.
"""
-import sys
import os
import time
import logging
diff --git a/rpki/pubd.py b/rpki/pubd.py
index 8e45aff7..79315a78 100644
--- a/rpki/pubd.py
+++ b/rpki/pubd.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -22,11 +22,10 @@ RPKI publication engine.
"""
import os
+import re
import time
import logging
import argparse
-import sys
-import re
import rpki.resource_set
import rpki.up_down
import rpki.x509
@@ -82,14 +81,14 @@ class main(object):
prof.runcall(self.main)
finally:
prof.dump_stats(self.profile)
- logger.info("Dumped profile data to %s" % self.profile)
+ logger.info("Dumped profile data to %s", self.profile)
else:
self.main()
def main(self):
if self.profile:
- logger.info("Running in profile mode with output to %s" % self.profile)
+ logger.info("Running in profile mode with output to %s", self.profile)
self.sql = rpki.sql.session(self.cfg)
diff --git a/rpki/publication.py b/rpki/publication.py
index a3278564..95f4f314 100644
--- a/rpki/publication.py
+++ b/rpki/publication.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -250,7 +250,7 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace):
"""
Publish an object.
"""
- logger.info("Publishing %s" % self.payload.tracking_data(self.uri))
+ logger.info("Publishing %s", self.payload.tracking_data(self.uri))
filename = self.uri_to_filename()
filename_tmp = filename + ".tmp"
dirname = os.path.dirname(filename)
@@ -265,7 +265,7 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace):
"""
Withdraw an object, then recursively delete empty directories.
"""
- logger.info("Withdrawing %s" % self.uri)
+ logger.info("Withdrawing %s", self.uri)
filename = self.uri_to_filename()
try:
os.remove(filename)
@@ -305,7 +305,7 @@ class publication_object_elt(rpki.xml_utils.base_elt, publication_namespace):
Construct a publication PDU.
"""
assert cls.payload_type is not None and type(obj) is cls.payload_type
- return cls.make_pdu(action = "publish", uri = uri, payload = obj, tag = tag)
+ return cls.make_pdu(action = "publish", uri = uri, payload = obj, tag = tag)
@classmethod
def make_withdraw(cls, uri, obj, tag = None):
@@ -336,7 +336,7 @@ class crl_elt(publication_object_elt):
element_name = "crl"
payload_type = rpki.x509.CRL
-
+
class manifest_elt(publication_object_elt):
"""
<manifest/> element.
diff --git a/rpki/rcynic.py b/rpki/rcynic.py
index 3e8bc085..10ad7516 100644
--- a/rpki/rcynic.py
+++ b/rpki/rcynic.py
@@ -1,9 +1,9 @@
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rpki/resource_set.py b/rpki/resource_set.py
index 8642710e..fea6ad2d 100644
--- a/rpki/resource_set.py
+++ b/rpki/resource_set.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -712,7 +712,7 @@ class resource_bag(object):
self.valid_until == other.valid_until
def __ne__(self, other):
- return not (self == other)
+ return not (self == other) # pylint: disable=C0325
def intersection(self, other):
"""
@@ -1044,7 +1044,7 @@ class roa_prefix_bag(object):
return self.v4 == other.v4 and self.v6 == other.v6
def __ne__(self, other):
- return not (self == other)
+ return not (self == other) # pylint: disable=C0325
# Test suite for set operations.
diff --git a/rpki/rootd.py b/rpki/rootd.py
index 818f09c7..fb445213 100644
--- a/rpki/rootd.py
+++ b/rpki/rootd.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -27,7 +27,6 @@ import os
import time
import logging
import argparse
-import sys
import rpki.resource_set
import rpki.up_down
import rpki.left_right
@@ -59,15 +58,15 @@ class issue_pdu(rpki.up_down.issue_pdu):
class revoke_pdu(rpki.up_down.revoke_pdu):
def serve_pdu(self, q_msg, r_msg, ignored, callback, errback):
- logger.debug("Revocation requested for SKI %s" % self.ski)
+ logger.debug("Revocation requested for SKI %s", self.ski)
subject_cert = rootd.get_subject_cert()
if subject_cert is None:
logger.debug("No subject certificate, nothing to revoke")
raise rpki.exceptions.NotInDatabase
if subject_cert.gSKI() != self.ski:
- logger.debug("Subject certificate has different SKI %s, not revoking" % subject_cert.gSKI())
+ logger.debug("Subject certificate has different SKI %s, not revoking", subject_cert.gSKI())
raise rpki.exceptions.NotInDatabase
- logger.debug("Revoking certificate %s" % self.ski)
+ logger.debug("Revoking certificate %s", self.ski)
now = rpki.sundial.now()
rootd.revoke_subject_cert(now)
rootd.del_subject_cert()
@@ -102,7 +101,7 @@ class message_pdu(rpki.up_down.message_pdu):
"""
Log query we're handling.
"""
- logger.info("Serving %s query" % self.type)
+ logger.info("Serving %s query", self.type)
class sax_handler(rpki.up_down.sax_handler):
pdu = message_pdu
@@ -113,7 +112,7 @@ class cms_msg(rpki.up_down.cms_msg):
class main(object):
def get_root_cert(self):
- logger.debug("Read root cert %s" % self.rpki_root_cert_file)
+ logger.debug("Read root cert %s", self.rpki_root_cert_file)
self.rpki_root_cert = rpki.x509.X509(Auto_file = self.rpki_root_cert_file)
def root_newer_than_subject(self):
@@ -124,39 +123,39 @@ class main(object):
filename = os.path.join(self.rpki_root_dir, self.rpki_subject_cert)
try:
x = rpki.x509.X509(Auto_file = filename)
- logger.debug("Read subject cert %s" % filename)
+ logger.debug("Read subject cert %s", filename)
return x
except IOError:
return None
def set_subject_cert(self, cert):
filename = os.path.join(self.rpki_root_dir, self.rpki_subject_cert)
- logger.debug("Writing subject cert %s, SKI %s" % (filename, cert.hSKI()))
+ logger.debug("Writing subject cert %s, SKI %s", filename, cert.hSKI())
f = open(filename, "wb")
f.write(cert.get_DER())
f.close()
def del_subject_cert(self):
filename = os.path.join(self.rpki_root_dir, self.rpki_subject_cert)
- logger.debug("Deleting subject cert %s" % filename)
+ logger.debug("Deleting subject cert %s", filename)
os.remove(filename)
def get_subject_pkcs10(self):
try:
x = rpki.x509.PKCS10(Auto_file = self.rpki_subject_pkcs10)
- logger.debug("Read subject PKCS #10 %s" % self.rpki_subject_pkcs10)
+ logger.debug("Read subject PKCS #10 %s", self.rpki_subject_pkcs10)
return x
except IOError:
return None
def set_subject_pkcs10(self, pkcs10):
- logger.debug("Writing subject PKCS #10 %s" % self.rpki_subject_pkcs10)
+ logger.debug("Writing subject PKCS #10 %s", self.rpki_subject_pkcs10)
f = open(self.rpki_subject_pkcs10, "wb")
f.write(pkcs10.get_DER())
f.close()
def del_subject_pkcs10(self):
- logger.debug("Deleting subject PKCS #10 %s" % self.rpki_subject_pkcs10)
+ logger.debug("Deleting subject PKCS #10 %s", self.rpki_subject_pkcs10)
try:
os.remove(self.rpki_subject_pkcs10)
except OSError:
@@ -189,8 +188,8 @@ class main(object):
return None
resources = self.rpki_root_cert.get_3779resources()
notAfter = now + self.rpki_subject_lifetime
- logger.info("Generating subject cert %s with resources %s, expires %s" % (
- self.rpki_base_uri + self.rpki_subject_cert, resources, notAfter))
+ logger.info("Generating subject cert %s with resources %s, expires %s",
+ self.rpki_base_uri + self.rpki_subject_cert, resources, notAfter)
req_key = pkcs10.getPublicKey()
req_sia = pkcs10.get_SIA()
self.next_serial_number()
@@ -221,8 +220,9 @@ class main(object):
thisUpdate = now,
nextUpdate = now + self.rpki_subject_regen,
revokedCertificates = self.revoked)
- logger.debug("Writing CRL %s" % os.path.join(self.rpki_root_dir, self.rpki_root_crl))
- f = open(os.path.join(self.rpki_root_dir, self.rpki_root_crl), "wb")
+ fn = os.path.join(self.rpki_root_dir, self.rpki_root_crl)
+ logger.debug("Writing CRL %s", fn)
+ f = open(fn, "wb")
f.write(crl.get_DER())
f.close()
manifest_content = [(self.rpki_root_crl, crl)]
@@ -248,8 +248,9 @@ class main(object):
names_and_objs = manifest_content,
keypair = manifest_keypair,
certs = manifest_cert)
- logger.debug("Writing manifest %s" % os.path.join(self.rpki_root_dir, self.rpki_root_manifest))
- f = open(os.path.join(self.rpki_root_dir, self.rpki_root_manifest), "wb")
+ fn = os.path.join(self.rpki_root_dir, self.rpki_root_manifest)
+ logger.debug("Writing manifest %s", fn)
+ f = open(fn, "wb")
f.write(manifest.get_DER())
f.close()
diff --git a/rpki/rpkic.py b/rpki/rpkic.py
index e01eeae2..d37021a8 100644
--- a/rpki/rpkic.py
+++ b/rpki/rpkic.py
@@ -1,12 +1,12 @@
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2013 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
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR
@@ -47,7 +47,7 @@ import rpki.x509
import rpki.async
import rpki.version
-from rpki.cli import Cmd, BadCommandSyntax, parsecmd, cmdarg
+from rpki.cli import Cmd, parsecmd, cmdarg
class BadPrefixSyntax(Exception): "Bad prefix syntax."
class CouldntTalkToDaemon(Exception): "Couldn't talk to daemon."
@@ -64,7 +64,7 @@ class main(Cmd):
completedefault = Cmd.filename_complete
# Top-level argparser, for stuff that one might want when starting
- # up the interactive command loop. Not sure -i belongs here, but
+ # up the interactive command loop. Not sure -i belongs here, but
# it's harmless so leave it here for the moment.
top_argparser = argparse.ArgumentParser(add_help = False)
@@ -82,6 +82,7 @@ class main(Cmd):
argsubparsers = full_argparser.add_subparsers(title = "Commands", metavar = "")
def __init__(self):
+
os.environ["TZ"] = "UTC"
time.tzset()
@@ -597,7 +598,7 @@ class main(Cmd):
"""
Show resources received by this entity from its parent(s).
"""
-
+
for pdu in self.zoo.call_rpkid(
rpki.left_right.list_received_resources_elt.make_pdu(self_handle = self.zoo.handle)):
diff --git a/rpki/rpkid.py b/rpki/rpkid.py
index 228e52a1..5e7d2a79 100644
--- a/rpki/rpkid.py
+++ b/rpki/rpkid.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -22,13 +22,12 @@ RPKI CA engine.
"""
import os
-import time
-import logging
-import argparse
-import sys
import re
+import time
import random
import base64
+import logging
+import argparse
import rpki.resource_set
import rpki.up_down
import rpki.left_right
@@ -89,7 +88,7 @@ class main(object):
prof.runcall(self.main)
finally:
prof.dump_stats(self.profile)
- logger.info("Dumped profile data to %s" % self.profile)
+ logger.info("Dumped profile data to %s", self.profile)
else:
self.main()
@@ -100,7 +99,7 @@ class main(object):
logger.info(startup_msg)
if self.profile:
- logger.info("Running in profile mode with output to %s" % self.profile)
+ logger.info("Running in profile mode with output to %s", self.profile)
self.sql = rpki.sql.session(self.cfg)
@@ -158,7 +157,7 @@ class main(object):
if self.use_internal_cron:
self.cron_timer = rpki.async.timer(handler = self.cron)
when = rpki.sundial.now() + rpki.sundial.timedelta(seconds = self.initial_delay)
- logger.debug("Scheduling initial cron pass at %s" % when)
+ logger.debug("Scheduling initial cron pass at %s", when)
self.cron_timer.set(when)
else:
logger.debug("Not using internal clock, start_cron() call ignored")
@@ -327,11 +326,11 @@ class main(object):
Add a task to the scheduler task queue, unless it's already queued.
"""
if task not in self.task_queue:
- logger.debug("Adding %r to task queue" % task)
+ logger.debug("Adding %r to task queue", task)
self.task_queue.append(task)
return True
else:
- logger.debug("Task %r was already in the task queue" % task)
+ logger.debug("Task %r was already in the task queue", task)
return False
def task_next(self):
@@ -366,15 +365,15 @@ class main(object):
def done():
self.sql.sweep()
self.cron_timeout = None
- logger.info("Finished cron run started at %s" % now)
+ logger.info("Finished cron run started at %s", now)
if cb is not None:
cb()
completion = rpki.rpkid_tasks.CompletionHandler(done)
try:
selves = rpki.left_right.self_elt.sql_fetch_all(self)
- except Exception, e:
- logger.warning("Error pulling self_elts from SQL, maybe SQL server is down? (%s)" % e)
+ except Exception:
+ logger.exception("Error pulling self_elts from SQL, maybe SQL server is down?")
else:
for s in selves:
s.schedule_cron_tasks(completion)
@@ -383,12 +382,12 @@ class main(object):
assert self.use_internal_cron or self.cron_timeout is None
if self.cron_timeout is not None and self.cron_timeout < now:
- logger.warning("cron keepalive threshold %s has expired, breaking lock" % self.cron_timeout)
+ logger.warning("cron keepalive threshold %s has expired, breaking lock", self.cron_timeout)
self.cron_timeout = None
if self.use_internal_cron:
when = now + self.cron_period
- logger.debug("Scheduling next cron run at %s" % when)
+ logger.debug("Scheduling next cron run at %s", when)
self.cron_timer.set(when)
if self.cron_timeout is None:
@@ -396,7 +395,7 @@ class main(object):
self.task_run()
elif self.use_internal_cron:
- logger.warning("cron already running, keepalive will expire at %s" % self.cron_timeout)
+ logger.warning("cron already running, keepalive will expire at %s", self.cron_timeout)
if nothing_queued:
done()
@@ -528,7 +527,7 @@ class ca_obj(rpki.sql.sql_persistent):
sia_uri = self.construct_sia_uri(parent, rc)
sia_uri_changed = self.sia_uri != sia_uri
if sia_uri_changed:
- logger.debug("SIA changed: was %s now %s" % (self.sia_uri, sia_uri))
+ logger.debug("SIA changed: was %s now %s", self.sia_uri, sia_uri)
self.sia_uri = sia_uri
self.sql_mark_dirty()
@@ -543,8 +542,8 @@ class ca_obj(rpki.sql.sql_persistent):
if rc_cert is None:
- logger.warning("SKI %s in resource class %s is in database but missing from list_response to %s from %s, maybe parent certificate went away?"
- % (ca_detail.public_key.gSKI(), rc.class_name, parent.self.self_handle, parent.parent_handle))
+ logger.warning("SKI %s in resource class %s is in database but missing from list_response to %s from %s, maybe parent certificate went away?",
+ ca_detail.public_key.gSKI(), rc.class_name, parent.self.self_handle, parent.parent_handle)
publisher = publication_queue()
ca_detail.delete(ca = ca_detail.ca, publisher = publisher)
return publisher.call_pubd(iterator, eb)
@@ -552,7 +551,7 @@ class ca_obj(rpki.sql.sql_persistent):
else:
if ca_detail.state == "active" and ca_detail.ca_cert_uri != rc_cert.cert_url.rsync():
- logger.debug("AIA changed: was %s now %s" % (ca_detail.ca_cert_uri, rc_cert.cert_url.rsync()))
+ logger.debug("AIA changed: was %s now %s", ca_detail.ca_cert_uri, rc_cert.cert_url.rsync())
ca_detail.ca_cert_uri = rc_cert.cert_url.rsync()
ca_detail.sql_mark_dirty()
@@ -582,11 +581,10 @@ class ca_obj(rpki.sql.sql_persistent):
def done():
if cert_map:
- logger.warning("Unknown certificate SKI%s %s in resource class %s in list_response "
- "to %s from %s, maybe you want to \"revoke_forgotten\"?"
- % ("" if len(cert_map) == 1 else "s",
- ", ".join(c.cert.gSKI() for c in cert_map.values()),
- rc.class_name, parent.self.self_handle, parent.parent_handle))
+ logger.warning("Unknown certificate SKI%s %s in resource class %s in list_response to %s from %s, maybe you want to \"revoke_forgotten\"?",
+ "" if len(cert_map) == 1 else "s",
+ ", ".join(c.cert.gSKI() for c in cert_map.values()),
+ rc.class_name, parent.self.self_handle, parent.parent_handle)
self.gctx.sql.sweep()
self.gctx.checkpoint()
cb()
@@ -600,20 +598,20 @@ class ca_obj(rpki.sql.sql_persistent):
for x in ca_details
if x.latest_ca_cert is not None)
for ski in skis_parent & skis_me:
- logger.debug("Parent %s agrees that %s has SKI %s in resource class %s"
- % (parent.parent_handle, parent.self.self_handle, ski, rc.class_name))
+ logger.debug("Parent %s agrees that %s has SKI %s in resource class %s",
+ parent.parent_handle, parent.self.self_handle, ski, rc.class_name)
for ski in skis_parent - skis_me:
- logger.debug("Parent %s thinks %s has SKI %s in resource class %s but I don't think so"
- % (parent.parent_handle, parent.self.self_handle, ski, rc.class_name))
+ logger.debug("Parent %s thinks %s has SKI %s in resource class %s but I don't think so",
+ parent.parent_handle, parent.self.self_handle, ski, rc.class_name)
for ski in skis_me - skis_parent:
- logger.debug("I think %s has SKI %s in resource class %s but parent %s doesn't think so"
- % (parent.self.self_handle, ski, rc.class_name, parent.parent_handle))
+ logger.debug("I think %s has SKI %s in resource class %s but parent %s doesn't think so",
+ parent.self.self_handle, ski, rc.class_name, parent.parent_handle)
if ca_details:
rpki.async.iterator(ca_details, loop, done)
else:
- logger.warning("Existing resource class %s to %s from %s with no certificates, rekeying" %
- (rc.class_name, parent.self.self_handle, parent.parent_handle))
+ logger.warning("Existing resource class %s to %s from %s with no certificates, rekeying",
+ rc.class_name, parent.self.self_handle, parent.parent_handle)
self.gctx.checkpoint()
self.rekey(cb, eb)
@@ -638,7 +636,7 @@ class ca_obj(rpki.sql.sql_persistent):
def done(issue_response):
c = issue_response.payload.classes[0].certs[0]
- logger.debug("CA %r received certificate %s" % (self, c.cert_url))
+ logger.debug("CA %r received certificate %s", self, c.cert_url)
ca_detail.activate(
ca = self,
cert = c.cert,
@@ -646,7 +644,7 @@ class ca_obj(rpki.sql.sql_persistent):
callback = cb,
errback = eb)
- logger.debug("Sending issue request to %r from %r" % (parent, self.create))
+ logger.debug("Sending issue request to %r from %r", parent, self.create)
rpki.up_down.issue_pdu.query(parent, self, ca_detail, done, eb)
def delete(self, parent, callback):
@@ -666,8 +664,8 @@ class ca_obj(rpki.sql.sql_persistent):
callback()
def done():
- logger.debug("Deleting %r" % self)
- self.sql_delete()
+ logger.debug("Deleting %r", self)
+ self.sql_delete()
callback()
publisher = publication_queue()
@@ -713,7 +711,7 @@ class ca_obj(rpki.sql.sql_persistent):
def done(issue_response):
c = issue_response.payload.classes[0].certs[0]
- logger.debug("CA %r received certificate %s" % (self, c.cert_url))
+ logger.debug("CA %r received certificate %s", self, c.cert_url)
new_detail.activate(
ca = self,
cert = c.cert,
@@ -722,7 +720,7 @@ class ca_obj(rpki.sql.sql_persistent):
callback = cb,
errback = eb)
- logger.debug("Sending issue request to %r from %r" % (parent, self.rekey))
+ logger.debug("Sending issue request to %r from %r", parent, self.rekey)
rpki.up_down.issue_pdu.query(parent, self, new_detail, done, eb)
def revoke(self, cb, eb, revoke_all = False):
@@ -770,7 +768,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
"state",
"ca_cert_uri",
"ca_id")
-
+
crl_published = None
manifest_published = None
latest_ca_cert = None
@@ -942,7 +940,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
handler = handler)
child_cert.sql_mark_deleted()
for roa in self.roas:
- roa.revoke(publisher = publisher, allow_failure = allow_failure, fast = True)
+ roa.revoke(publisher = publisher, allow_failure = allow_failure, fast = True)
for ghostbuster in self.ghostbusters:
ghostbuster.revoke(publisher = publisher, allow_failure = allow_failure, fast = True)
try:
@@ -967,9 +965,9 @@ class ca_detail_obj(rpki.sql.sql_persistent):
handler = handler)
self.gctx.sql.sweep()
for cert in self.revoked_certs: # + self.child_certs
- logger.debug("Deleting %r" % cert)
+ logger.debug("Deleting %r", cert)
cert.sql_delete()
- logger.debug("Deleting %r" % self)
+ logger.debug("Deleting %r", self)
self.sql_delete()
def revoke(self, cb, eb):
@@ -1003,7 +1001,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
if r_msg.payload.ski != self.latest_ca_cert.gSKI():
raise rpki.exceptions.SKIMismatch
- logger.debug("Parent revoked %s, starting cleanup" % self.latest_ca_cert.gSKI())
+ logger.debug("Parent revoked %s, starting cleanup", self.latest_ca_cert.gSKI())
crl_interval = rpki.sundial.timedelta(seconds = parent.self.crl_interval)
@@ -1041,7 +1039,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
self.sql_mark_dirty()
publisher.call_pubd(cb, eb)
- logger.debug("Asking parent to revoke CA certificate %s" % self.latest_ca_cert.gSKI())
+ logger.debug("Asking parent to revoke CA certificate %s", self.latest_ca_cert.gSKI())
rpki.up_down.revoke_pdu.query(ca, self.latest_ca_cert.gSKI(), parent_revoked, eb)
def update(self, parent, ca, rc, sia_uri_changed, old_resources, callback, errback):
@@ -1052,7 +1050,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
def issued(issue_response):
c = issue_response.payload.classes[0].certs[0]
- logger.debug("CA %r received certificate %s" % (self, c.cert_url))
+ logger.debug("CA %r received certificate %s", self, c.cert_url)
if self.state == "pending":
return self.activate(
@@ -1094,7 +1092,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
publisher.call_pubd(callback, errback)
- logger.debug("Sending issue request to %r from %r" % (parent, self.update))
+ logger.debug("Sending issue request to %r from %r", parent, self.update)
rpki.up_down.issue_pdu.query(parent, ca, self, issued, errback)
@classmethod
@@ -1179,12 +1177,12 @@ class ca_detail_obj(rpki.sql.sql_persistent):
child_id = child.child_id,
ca_detail_id = self.ca_detail_id,
cert = cert)
- logger.debug("Created new child_cert %r" % child_cert)
+ logger.debug("Created new child_cert %r", child_cert)
else:
child_cert.cert = cert
del child_cert.ca_detail
child_cert.ca_detail_id = self.ca_detail_id
- logger.debug("Reusing existing child_cert %r" % child_cert)
+ logger.debug("Reusing existing child_cert %r", child_cert)
child_cert.ski = cert.get_SKI()
child_cert.published = rpki.sundial.now()
@@ -1265,19 +1263,19 @@ class ca_detail_obj(rpki.sql.sql_persistent):
nextUpdate = now + crl_interval
if self.latest_manifest_cert is None or self.latest_manifest_cert.getNotAfter() < nextUpdate:
- logger.debug("Generating EE certificate for %s" % uri)
+ logger.debug("Generating EE certificate for %s", uri)
self.generate_manifest_cert()
- logger.debug("Latest CA cert notAfter %s, new %s EE notAfter %s" % (
- self.latest_ca_cert.getNotAfter(), uri, self.latest_manifest_cert.getNotAfter()))
+ logger.debug("Latest CA cert notAfter %s, new %s EE notAfter %s",
+ self.latest_ca_cert.getNotAfter(), uri, self.latest_manifest_cert.getNotAfter())
- logger.debug("Constructing manifest object list for %s" % uri)
+ logger.debug("Constructing manifest object list for %s", uri)
objs = [(self.crl_uri_tail, self.latest_crl)]
objs.extend((c.uri_tail, c.cert) for c in self.child_certs)
objs.extend((r.uri_tail, r.roa) for r in self.roas if r.roa is not None)
objs.extend((g.uri_tail, g.ghostbuster) for g in self.ghostbusters)
objs.extend((e.uri_tail, e.cert) for e in self.ee_certificates)
- logger.debug("Building manifest object %s" % uri)
+ logger.debug("Building manifest object %s", uri)
self.latest_manifest = rpki.x509.SignedManifest.build(
serial = ca.next_manifest_number(),
thisUpdate = now,
@@ -1286,7 +1284,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
keypair = self.manifest_private_key_id,
certs = self.latest_manifest_cert)
- logger.debug("Manifest generation took %s" % (rpki.sundial.now() - now))
+ logger.debug("Manifest generation took %s", rpki.sundial.now() - now)
self.manifest_published = rpki.sundial.now()
self.sql_mark_dirty()
@@ -1352,7 +1350,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
should become configurable.
"""
- logger.debug("Checking for failed publication for %r" % self)
+ logger.debug("Checking for failed publication for %r", self)
stale = rpki.sundial.now() - rpki.sundial.timedelta(seconds = 60)
repository = self.ca.parent.repository
@@ -1360,7 +1358,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
if self.latest_crl is not None and \
self.crl_published is not None and \
self.crl_published < stale:
- logger.debug("Retrying publication for %s" % self.crl_uri)
+ logger.debug("Retrying publication for %s", self.crl_uri)
publisher.publish(cls = rpki.publication.crl_elt,
uri = self.crl_uri,
obj = self.latest_crl,
@@ -1370,7 +1368,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
if self.latest_manifest is not None and \
self.manifest_published is not None and \
self.manifest_published < stale:
- logger.debug("Retrying publication for %s" % self.manifest_uri)
+ logger.debug("Retrying publication for %s", self.manifest_uri)
publisher.publish(cls = rpki.publication.manifest_elt,
uri = self.manifest_uri,
obj = self.latest_manifest,
@@ -1384,7 +1382,7 @@ class ca_detail_obj(rpki.sql.sql_persistent):
# date, but let's avoid premature optimization
for child_cert in self.unpublished_child_certs(stale):
- logger.debug("Retrying publication for %s" % child_cert)
+ logger.debug("Retrying publication for %s", child_cert)
publisher.publish(
cls = rpki.publication.certificate_elt,
uri = child_cert.uri,
@@ -1393,16 +1391,16 @@ class ca_detail_obj(rpki.sql.sql_persistent):
handler = child_cert.published_callback)
for roa in self.unpublished_roas(stale):
- logger.debug("Retrying publication for %s" % roa)
+ logger.debug("Retrying publication for %s", roa)
publisher.publish(
cls = rpki.publication.roa_elt,
uri = roa.uri,
obj = roa.roa,
repository = repository,
handler = roa.published_callback)
-
+
for ghostbuster in self.unpublished_ghostbusters(stale):
- logger.debug("Retrying publication for %s" % ghostbuster)
+ logger.debug("Retrying publication for %s", ghostbuster)
publisher.publish(
cls = rpki.publication.ghostbuster_elt,
uri = ghostbuster.uri,
@@ -1428,7 +1426,7 @@ class child_cert_obj(rpki.sql.sql_persistent):
args = [self]
try:
args.append(self.uri)
- except:
+ except: # pylint: disable=W0702
pass
return rpki.log.log_repr(*args)
@@ -1452,7 +1450,7 @@ class child_cert_obj(rpki.sql.sql_persistent):
Fetch child object to which this child_cert object links.
"""
return rpki.left_right.child_elt.sql_fetch(self.gctx, self.child_id)
-
+
@property
@rpki.sql.cache_reference
def ca_detail(self):
@@ -1489,7 +1487,7 @@ class child_cert_obj(rpki.sql.sql_persistent):
ca_detail = self.ca_detail
ca = ca_detail.ca
- logger.debug("Revoking %r %r" % (self, self.uri))
+ logger.debug("Revoking %r %r", self, self.uri)
revoked_cert_obj.revoke(cert = self.cert, ca_detail = ca_detail)
publisher.withdraw(
cls = rpki.publication.certificate_elt,
@@ -1531,42 +1529,42 @@ class child_cert_obj(rpki.sql.sql_persistent):
assert resources.valid_until is not None and old_resources.valid_until is not None
if resources.asn != old_resources.asn or resources.v4 != old_resources.v4 or resources.v6 != old_resources.v6:
- logger.debug("Resources changed for %r: old %s new %s" % (self, old_resources, resources))
+ logger.debug("Resources changed for %r: old %s new %s", self, old_resources, resources)
needed = True
if resources.valid_until != old_resources.valid_until:
- logger.debug("Validity changed for %r: old %s new %s" % (
- self, old_resources.valid_until, resources.valid_until))
+ logger.debug("Validity changed for %r: old %s new %s",
+ self, old_resources.valid_until, resources.valid_until)
needed = True
if sia != old_sia:
- logger.debug("SIA changed for %r: old %r new %r" % (self, old_sia, sia))
+ logger.debug("SIA changed for %r: old %r new %r", self, old_sia, sia)
needed = True
if ca_detail != old_ca_detail:
- logger.debug("Issuer changed for %r: old %r new %r" % (self, old_ca_detail, ca_detail))
+ logger.debug("Issuer changed for %r: old %r new %r", self, old_ca_detail, ca_detail)
needed = True
if ca_detail.ca_cert_uri != old_aia:
- logger.debug("AIA changed for %r: old %r new %r" % (self, old_aia, ca_detail.ca_cert_uri))
+ logger.debug("AIA changed for %r: old %r new %r", self, old_aia, ca_detail.ca_cert_uri)
needed = True
must_revoke = old_resources.oversized(resources) or old_resources.valid_until > resources.valid_until
if must_revoke:
- logger.debug("Must revoke any existing cert(s) for %r" % self)
+ logger.debug("Must revoke any existing cert(s) for %r", self)
needed = True
if not needed and force:
- logger.debug("No change needed for %r, forcing reissuance anyway" % self)
+ logger.debug("No change needed for %r, forcing reissuance anyway", self)
needed = True
if not needed:
- logger.debug("No change to %r" % self)
+ logger.debug("No change to %r", self)
return self
if must_revoke:
for x in child.fetch_child_certs(ca_detail = ca_detail, ski = self.ski):
- logger.debug("Revoking child_cert %r" % x)
+ logger.debug("Revoking child_cert %r", x)
x.revoke(publisher = publisher)
ca_detail.generate_crl(publisher = publisher)
ca_detail.generate_manifest(publisher = publisher)
@@ -1580,7 +1578,7 @@ class child_cert_obj(rpki.sql.sql_persistent):
child_cert = None if must_revoke else self,
publisher = publisher)
- logger.debug("New child_cert %r uri %s" % (child_cert, child_cert.uri))
+ logger.debug("New child_cert %r uri %s", child_cert, child_cert.uri)
return child_cert
@@ -1759,7 +1757,7 @@ class roa_obj(rpki.sql.sql_persistent):
args = [self, self.asn, self.ipv4, self.ipv6]
try:
args.append(self.uri)
- except:
+ except: # pylint: disable=W0702
pass
return rpki.log.log_repr(*args)
@@ -1785,38 +1783,38 @@ class roa_obj(rpki.sql.sql_persistent):
v6 = self.ipv6.to_resource_set() if self.ipv6 is not None else rpki.resource_set.resource_set_ipv6()
if self.roa is None:
- logger.debug("%r doesn't exist, generating" % self)
+ logger.debug("%r doesn't exist, generating", self)
return self.generate(publisher = publisher, fast = fast)
ca_detail = self.ca_detail
if ca_detail is None:
- logger.debug("%r has no associated ca_detail, generating" % self)
+ logger.debug("%r has no associated ca_detail, generating", self)
return self.generate(publisher = publisher, fast = fast)
if ca_detail.state != "active":
- logger.debug("ca_detail associated with %r not active (state %s), regenerating" % (self, ca_detail.state))
+ logger.debug("ca_detail associated with %r not active (state %s), regenerating", self, ca_detail.state)
return self.regenerate(publisher = publisher, fast = fast)
regen_time = self.cert.getNotAfter() - rpki.sundial.timedelta(seconds = self.self.regen_margin)
if rpki.sundial.now() > regen_time:
- logger.debug("%r past threshold %s, regenerating" % (self, regen_time))
+ logger.debug("%r past threshold %s, regenerating", self, regen_time)
return self.regenerate(publisher = publisher, fast = fast)
ca_resources = ca_detail.latest_ca_cert.get_3779resources()
ee_resources = self.cert.get_3779resources()
if ee_resources.oversized(ca_resources):
- logger.debug("%r oversized with respect to CA, regenerating" % self)
+ logger.debug("%r oversized with respect to CA, regenerating", self)
return self.regenerate(publisher = publisher, fast = fast)
if ee_resources.v4 != v4 or ee_resources.v6 != v6:
- logger.debug("%r resources do not match EE, regenerating" % self)
+ logger.debug("%r resources do not match EE, regenerating", self)
return self.regenerate(publisher = publisher, fast = fast)
if self.cert.get_AIA()[0] != ca_detail.ca_cert_uri:
- logger.debug("%r AIA changed, regenerating" % self)
+ logger.debug("%r AIA changed, regenerating", self)
return self.regenerate(publisher = publisher, fast = fast)
def generate(self, publisher, fast = False):
@@ -1852,7 +1850,7 @@ class roa_obj(rpki.sql.sql_persistent):
ca_detail = self.ca_detail
if ca_detail is None or ca_detail.state != "active" or ca_detail.has_expired():
- logger.debug("Searching for new ca_detail for ROA %r" % self)
+ logger.debug("Searching for new ca_detail for ROA %r", self)
ca_detail = None
for parent in self.self.parents:
for ca in parent.cas:
@@ -1866,13 +1864,13 @@ class roa_obj(rpki.sql.sql_persistent):
if ca_detail is not None:
break
else:
- logger.debug("Keeping old ca_detail for ROA %r" % self)
+ logger.debug("Keeping old ca_detail for ROA %r", self)
if ca_detail is None:
raise rpki.exceptions.NoCoveringCertForROA("Could not find a certificate covering %r" % self)
- logger.debug("Using new ca_detail %r for ROA %r, ca_detail_state %s" % (
- ca_detail, self, ca_detail.state))
+ logger.debug("Using new ca_detail %r for ROA %r, ca_detail_state %s",
+ ca_detail, self, ca_detail.state)
ca = ca_detail.ca
resources = rpki.resource_set.resource_bag(v4 = v4, v6 = v6)
@@ -1889,7 +1887,7 @@ class roa_obj(rpki.sql.sql_persistent):
self.published = rpki.sundial.now()
self.sql_store()
- logger.debug("Generating %r URI %s" % (self, self.uri))
+ logger.debug("Generating %r URI %s", self, self.uri)
publisher.publish(
cls = rpki.publication.roa_elt,
uri = self.uri,
@@ -1929,14 +1927,14 @@ class roa_obj(rpki.sql.sql_persistent):
roa = self.roa
uri = self.uri
- logger.debug("%s %r, ca_detail %r state is %s" % (
- "Regenerating" if regenerate else "Not regenerating",
- self, ca_detail, ca_detail.state))
+ logger.debug("%s %r, ca_detail %r state is %s",
+ "Regenerating" if regenerate else "Not regenerating",
+ self, ca_detail, ca_detail.state)
if regenerate:
self.generate(publisher = publisher, fast = fast)
- logger.debug("Withdrawing %r %s and revoking its EE cert" % (self, uri))
+ logger.debug("Withdrawing %r %s and revoking its EE cert", self, uri)
rpki.rpkid.revoked_cert_obj.revoke(cert = cert, ca_detail = ca_detail)
publisher.withdraw(cls = rpki.publication.roa_elt, uri = uri, obj = roa,
repository = ca_detail.ca.parent.repository,
@@ -2006,11 +2004,11 @@ class ghostbuster_obj(rpki.sql.sql_persistent):
args = [self]
try:
args.extend(self.vcard.splitlines()[2:-1])
- except:
+ except: # pylint: disable=W0702
pass
try:
args.append(self.uri)
- except:
+ except: # pylint: disable=W0702
pass
return rpki.log.log_repr(*args)
@@ -2052,11 +2050,11 @@ class ghostbuster_obj(rpki.sql.sql_persistent):
regen_time = self.cert.getNotAfter() - rpki.sundial.timedelta(seconds = self.self.regen_margin)
if rpki.sundial.now() > regen_time:
- logger.debug("%r past threshold %s, regenerating" % (self, regen_time))
+ logger.debug("%r past threshold %s, regenerating", self, regen_time)
return self.regenerate(publisher = publisher, fast = fast)
if self.cert.get_AIA()[0] != self.ca_detail.ca_cert_uri:
- logger.debug("%r AIA changed, regenerating" % self)
+ logger.debug("%r AIA changed, regenerating", self)
return self.regenerate(publisher = publisher, fast = fast)
def generate(self, publisher, fast = False):
@@ -2088,7 +2086,7 @@ class ghostbuster_obj(rpki.sql.sql_persistent):
self.published = rpki.sundial.now()
self.sql_store()
- logger.debug("Generating Ghostbuster record %r" % self.uri)
+ logger.debug("Generating Ghostbuster record %r", self.uri)
publisher.publish(
cls = rpki.publication.ghostbuster_elt,
uri = self.uri,
@@ -2127,14 +2125,14 @@ class ghostbuster_obj(rpki.sql.sql_persistent):
ghostbuster = self.ghostbuster
uri = self.uri
- logger.debug("%s %r, ca_detail %r state is %s" % (
- "Regenerating" if regenerate else "Not regenerating",
- self, ca_detail, ca_detail.state))
+ logger.debug("%s %r, ca_detail %r state is %s",
+ "Regenerating" if regenerate else "Not regenerating",
+ self, ca_detail, ca_detail.state)
if regenerate:
self.generate(publisher = publisher, fast = fast)
- logger.debug("Withdrawing %r %s and revoking its EE cert" % (self, uri))
+ logger.debug("Withdrawing %r %s and revoking its EE cert", self, uri)
rpki.rpkid.revoked_cert_obj.revoke(cert = cert, ca_detail = ca_detail)
publisher.withdraw(cls = rpki.publication.ghostbuster_elt, uri = uri, obj = ghostbuster,
repository = ca_detail.ca.parent.repository,
@@ -2242,7 +2240,7 @@ class ee_cert_obj(rpki.sql.sql_persistent):
@gski.setter
def gski(self, val):
- self.ski = base64.urlsafe_b64decode(s + ("=" * ((4 - len(s)) % 4)))
+ self.ski = base64.urlsafe_b64decode(val + ("=" * ((4 - len(val)) % 4)))
@property
def uri(self):
@@ -2295,7 +2293,7 @@ class ee_cert_obj(rpki.sql.sql_persistent):
ca_detail.generate_manifest(publisher = publisher)
- logger.debug("New ee_cert %r" % self)
+ logger.debug("New ee_cert %r", self)
return self
@@ -2306,7 +2304,7 @@ class ee_cert_obj(rpki.sql.sql_persistent):
ca_detail = self.ca_detail
ca = ca_detail.ca
- logger.debug("Revoking %r %r" % (self, self.uri))
+ logger.debug("Revoking %r %r", self, self.uri)
revoked_cert_obj.revoke(cert = self.cert, ca_detail = ca_detail)
publisher.withdraw(cls = rpki.publication.certificate_elt,
uri = self.uri,
@@ -2346,37 +2344,37 @@ class ee_cert_obj(rpki.sql.sql_persistent):
assert ca_detail.covers(resources)
if ca_detail != self.ca_detail:
- logger.debug("ca_detail changed for %r: old %r new %r" % (
- self, self.ca_detail, ca_detail))
+ logger.debug("ca_detail changed for %r: old %r new %r",
+ self, self.ca_detail, ca_detail)
needed = True
if ca_detail.ca_cert_uri != old_cert.get_AIA()[0]:
- logger.debug("AIA changed for %r: old %s new %s" % (
- self, old_cert.get_AIA()[0], ca_detail.ca_cert_uri))
+ logger.debug("AIA changed for %r: old %s new %s",
+ self, old_cert.get_AIA()[0], ca_detail.ca_cert_uri)
needed = True
if resources.valid_until != old_resources.valid_until:
- logger.debug("Validity changed for %r: old %s new %s" % (
- self, old_resources.valid_until, resources.valid_until))
+ logger.debug("Validity changed for %r: old %s new %s",
+ self, old_resources.valid_until, resources.valid_until)
needed = True
if resources.asn != old_resources.asn or resources.v4 != old_resources.v4 or resources.v6 != old_resources.v6:
- logger.debug("Resources changed for %r: old %s new %s" % (
- self, old_resources, resources))
+ logger.debug("Resources changed for %r: old %s new %s",
+ self, old_resources, resources)
needed = True
must_revoke = (old_resources.oversized(resources) or
old_resources.valid_until > resources.valid_until)
if must_revoke:
- logger.debug("Must revoke existing cert(s) for %r" % self)
+ logger.debug("Must revoke existing cert(s) for %r", self)
needed = True
if not needed and force:
- logger.debug("No change needed for %r, forcing reissuance anyway" % self)
+ logger.debug("No change needed for %r, forcing reissuance anyway", self)
needed = True
if not needed:
- logger.debug("No change to %r" % self)
+ logger.debug("No change to %r", self)
return
cn, sn = self.cert.getSubject().extract_cn_and_sn()
@@ -2449,7 +2447,8 @@ class publication_queue(object):
self.repositories[rid] = repository
self.msgs[rid] = rpki.publication.msg.query()
if self.replace and uri in self.uris:
- logger.debug("Removing publication duplicate <%s %r %r>" % (self.uris[uri].action, self.uris[uri].uri, self.uris[uri].payload))
+ logger.debug("Removing publication duplicate <%s %r %r>",
+ self.uris[uri].action, self.uris[uri].uri, self.uris[uri].payload)
self.msgs[rid].remove(self.uris.pop(uri))
pdu = make_pdu(uri = uri, obj = obj)
if handler is not None:
@@ -2467,7 +2466,7 @@ class publication_queue(object):
def call_pubd(self, cb, eb):
def loop(iterator, rid):
- logger.debug("Calling pubd[%r]" % self.repositories[rid])
+ logger.debug("Calling pubd[%r]", self.repositories[rid])
self.repositories[rid].call_pubd(iterator, eb, self.msgs[rid], self.handlers)
def done():
self.clear()
diff --git a/rpki/rpkid_tasks.py b/rpki/rpkid_tasks.py
index 8a948dd1..e0bb6904 100644
--- a/rpki/rpkid_tasks.py
+++ b/rpki/rpkid_tasks.py
@@ -1,12 +1,12 @@
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2012--2013 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
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR
@@ -61,7 +61,7 @@ class CompletionHandler(object):
def register(self, task):
if self.debug:
- logger.debug("Completion handler %r registering task %r" % (self, task))
+ logger.debug("Completion handler %r registering task %r", self, task)
self.tasks.add(task)
task.register_completion(self.done)
@@ -69,13 +69,13 @@ class CompletionHandler(object):
try:
self.tasks.remove(task)
except KeyError:
- logger.warning("Completion handler %r called with unregistered task %r, blundering onwards" % (self, task))
+ logger.warning("Completion handler %r called with unregistered task %r, blundering onwards", self, task)
else:
if self.debug:
- logger.debug("Completion handler %r called with registered task %r" % (self, task))
+ logger.debug("Completion handler %r called with registered task %r", self, task)
if not self.tasks:
if self.debug:
- logger.debug("Completion handler %r finished, calling %r" % (self, self.cb))
+ logger.debug("Completion handler %r finished, calling %r", self, self.cb)
self.cb()
@property
@@ -130,11 +130,11 @@ class AbstractTask(object):
def __call__(self):
self.due_date = rpki.sundial.now() + self.timeslice
if self.continuation is None:
- logger.debug("Running task %r" % self)
+ logger.debug("Running task %r", self)
self.clear()
self.start()
else:
- logger.debug("Restarting task %r at %r" % (self, self.continuation))
+ logger.debug("Restarting task %r at %r", self, self.continuation)
continuation = self.continuation
self.continuation = None
continuation()
@@ -168,7 +168,7 @@ class PollParentTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
- logger.debug("Self %s[%d] polling parents" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] polling parents", self.self_handle, self.self_id)
rpki.async.iterator(self.parents, self.parent_loop, self.exit)
def parent_loop(self, parent_iterator, parent):
@@ -234,7 +234,7 @@ class UpdateChildrenTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
- logger.debug("Self %s[%d] updating children" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] updating children", self.self_handle, self.self_id)
self.now = rpki.sundial.now()
self.rsn = self.now + rpki.sundial.timedelta(seconds = self.regen_margin)
self.publisher = rpki.rpkid.publication_queue()
@@ -274,9 +274,8 @@ class UpdateChildrenTask(AbstractTask):
new_aia = ca_detail.ca_cert_uri
if new_resources.empty():
- logger.debug("Resources shrank to the null set, "
- "revoking and withdrawing child %s certificate SKI %s" % (
- self.child.child_handle, child_cert.cert.gSKI()))
+ logger.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)
@@ -287,15 +286,16 @@ class UpdateChildrenTask(AbstractTask):
irdb_resources.valid_until > self.now and
old_resources.valid_until != irdb_resources.valid_until)):
- logger.debug("Need to reissue child %s certificate SKI %s" % (
- self.child.child_handle, child_cert.cert.gSKI()))
+ logger.debug("Need to reissue child %s certificate SKI %s",
+ self.child.child_handle, child_cert.cert.gSKI())
if old_resources != new_resources:
- logger.debug("Child %s SKI %s resources changed: old %s new %s" % (
- self.child.child_handle, child_cert.cert.gSKI(), old_resources, new_resources))
+ logger.debug("Child %s SKI %s resources changed: old %s new %s",
+ self.child.child_handle, child_cert.cert.gSKI(),
+ old_resources, new_resources)
if old_resources.valid_until != irdb_resources.valid_until:
- logger.debug("Child %s SKI %s validity changed: old %s new %s" % (
- self.child.child_handle, child_cert.cert.gSKI(),
- old_resources.valid_until, irdb_resources.valid_until))
+ logger.debug("Child %s SKI %s validity changed: old %s new %s",
+ self.child.child_handle, child_cert.cert.gSKI(),
+ old_resources.valid_until, irdb_resources.valid_until)
new_resources.valid_until = irdb_resources.valid_until
child_cert.reissue(
@@ -304,9 +304,9 @@ class UpdateChildrenTask(AbstractTask):
publisher = self.publisher)
elif old_resources.valid_until < self.now:
- logger.debug("Child %s certificate SKI %s has expired: cert.valid_until %s, irdb.valid_until %s"
- % (self.child.child_handle, child_cert.cert.gSKI(),
- old_resources.valid_until, irdb_resources.valid_until))
+ logger.debug("Child %s certificate SKI %s has expired: cert.valid_until %s, irdb.valid_until %s",
+ self.child.child_handle, child_cert.cert.gSKI(),
+ old_resources.valid_until, irdb_resources.valid_until)
child_cert.sql_delete()
self.publisher.withdraw(
cls = rpki.publication.certificate_elt,
@@ -352,7 +352,7 @@ class UpdateROAsTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
self.gctx.sql.sweep()
- logger.debug("Self %s[%d] updating ROAs" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] updating ROAs", self.self_handle, self.self_id)
logger.debug("Issuing query for ROA requests")
self.gctx.irdb_query_roa_requests(self.self_handle, self.got_roa_requests, self.roa_requests_failed)
@@ -386,15 +386,15 @@ class UpdateROAsTask(AbstractTask):
for roa_request in roa_requests:
k = (roa_request.asn, str(roa_request.ipv4), str(roa_request.ipv6))
if k in seen:
- logger.warning("Skipping duplicate ROA request %r" % roa_request)
+ logger.warning("Skipping duplicate ROA request %r", roa_request)
else:
seen.add(k)
roa = roas.pop(k, None)
if roa is None:
roa = rpki.rpkid.roa_obj(self.gctx, self.self_id, roa_request.asn, roa_request.ipv4, roa_request.ipv6)
- logger.debug("Created new %r" % roa)
+ logger.debug("Created new %r", roa)
else:
- logger.debug("Found existing %r" % roa)
+ logger.debug("Found existing %r", roa)
self.updates.append(roa)
self.orphans.extend(roas.itervalues())
@@ -417,8 +417,8 @@ class UpdateROAsTask(AbstractTask):
except (SystemExit, rpki.async.ExitNow):
raise
except rpki.exceptions.NoCoveringCertForROA:
- logger.warning("No covering certificate for %r, skipping" % roa)
- except Exception, e:
+ logger.warning("No covering certificate for %r, skipping", roa)
+ except Exception:
logger.exception("Could not update %r, skipping", roa)
self.count += 1
if self.overdue:
@@ -429,9 +429,9 @@ class UpdateROAsTask(AbstractTask):
def publish(self, done):
if not self.publisher.empty():
for ca_detail in self.ca_details:
- logger.debug("Generating new CRL for %r" % ca_detail)
+ logger.debug("Generating new CRL for %r", ca_detail)
ca_detail.generate_crl(publisher = self.publisher)
- logger.debug("Generating new manifest for %r" % ca_detail)
+ logger.debug("Generating new manifest for %r", ca_detail)
ca_detail.generate_manifest(publisher = self.publisher)
self.ca_details.clear()
self.gctx.sql.sweep()
@@ -450,7 +450,7 @@ class UpdateROAsTask(AbstractTask):
roa.revoke(publisher = self.publisher, fast = True)
except (SystemExit, rpki.async.ExitNow):
raise
- except Exception, e:
+ except Exception:
logger.exception("Could not revoke %r", roa)
self.gctx.sql.sweep()
self.gctx.checkpoint()
@@ -475,12 +475,13 @@ class UpdateGhostbustersTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
- logger.debug("Self %s[%d] updating Ghostbuster records" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] updating Ghostbuster records",
+ self.self_handle, self.self_id)
self.gctx.irdb_query_ghostbuster_requests(self.self_handle,
- (p.parent_handle for p in self.parents),
- self.got_ghostbuster_requests,
- self.ghostbuster_requests_failed)
+ (p.parent_handle for p in self.parents),
+ self.got_ghostbuster_requests,
+ self.ghostbuster_requests_failed)
def got_ghostbuster_requests(self, ghostbuster_requests):
@@ -507,11 +508,11 @@ class UpdateGhostbustersTask(AbstractTask):
for ghostbuster_request in ghostbuster_requests:
if ghostbuster_request.parent_handle not in parents:
- logger.warning("Unknown parent_handle %r in Ghostbuster request, skipping" % ghostbuster_request.parent_handle)
+ logger.warning("Unknown parent_handle %r in Ghostbuster request, skipping", ghostbuster_request.parent_handle)
continue
k = (ghostbuster_request.parent_handle, ghostbuster_request.vcard)
if k in seen:
- logger.warning("Skipping duplicate Ghostbuster request %r" % ghostbuster_request)
+ logger.warning("Skipping duplicate Ghostbuster request %r", ghostbuster_request)
continue
seen.add(k)
for ca in parents[ghostbuster_request.parent_handle].cas:
@@ -520,9 +521,9 @@ class UpdateGhostbustersTask(AbstractTask):
ghostbuster = ghostbusters.pop((ca_detail.ca_detail_id, ghostbuster_request.vcard), None)
if ghostbuster is None:
ghostbuster = rpki.rpkid.ghostbuster_obj(self.gctx, self.self_id, ca_detail.ca_detail_id, ghostbuster_request.vcard)
- logger.debug("Created new %r for %r" % (ghostbuster, ghostbuster_request.parent_handle))
+ logger.debug("Created new %r for %r", ghostbuster, ghostbuster_request.parent_handle)
else:
- logger.debug("Found existing %r for %s" % (ghostbuster, ghostbuster_request.parent_handle))
+ logger.debug("Found existing %r for %s", ghostbuster, ghostbuster_request.parent_handle)
ghostbuster.update(publisher = publisher, fast = True)
ca_details.add(ca_detail)
@@ -542,7 +543,7 @@ class UpdateGhostbustersTask(AbstractTask):
except (SystemExit, rpki.async.ExitNow):
raise
- except Exception, e:
+ except Exception:
logger.exception("Could not update Ghostbuster records for %s, skipping", self.self_handle)
self.exit()
@@ -567,7 +568,7 @@ class UpdateEECertificatesTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
- logger.debug("Self %s[%d] updating EE certificates" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] updating EE certificates", self.self_handle, self.self_id)
self.gctx.irdb_query_ee_certificate_requests(self.self_handle,
self.got_requests,
@@ -604,17 +605,20 @@ class UpdateEECertificatesTask(AbstractTask):
for ee in ees:
if ee.ca_detail in covering:
- logger.debug("Updating existing EE certificate for %s %s" % (req.gski, resources))
+ logger.debug("Updating existing EE certificate for %s %s",
+ req.gski, resources)
ee.reissue(
resources = resources,
publisher = publisher)
covering.remove(ee.ca_detail)
else:
- logger.debug("Existing EE certificate for %s %s is no longer covered" % (req.gski, resources))
+ logger.debug("Existing EE certificate for %s %s is no longer covered",
+ req.gski, resources)
ee.revoke(publisher = publisher)
for ca_detail in covering:
- logger.debug("No existing EE certificate for %s %s" % (req.gski, resources))
+ logger.debug("No existing EE certificate for %s %s",
+ req.gski, resources)
rpki.rpkid.ee_cert_obj.create(
ca_detail = ca_detail,
subject_name = rpki.x509.X501DN.from_cn(req.cn, req.sn),
@@ -642,7 +646,7 @@ class UpdateEECertificatesTask(AbstractTask):
except (SystemExit, rpki.async.ExitNow):
raise
- except Exception, e:
+ except Exception:
logger.exception("Could not update EE certificates for %s, skipping", self.self_handle)
self.exit()
@@ -671,7 +675,8 @@ class RegenerateCRLsAndManifestsTask(AbstractTask):
def start(self):
self.gctx.checkpoint()
- logger.debug("Self %s[%d] regenerating CRLs and manifests" % (self.self_handle, self.self_id))
+ logger.debug("Self %s[%d] regenerating CRLs and manifests",
+ self.self_handle, self.self_id)
now = rpki.sundial.now()
crl_interval = rpki.sundial.timedelta(seconds = self.crl_interval)
@@ -690,7 +695,7 @@ class RegenerateCRLsAndManifestsTask(AbstractTask):
ca_detail.generate_manifest(publisher = publisher)
except (SystemExit, rpki.async.ExitNow):
raise
- except Exception, e:
+ except Exception:
logger.exception("Couldn't regenerate CRLs and manifests for CA %r, skipping", ca)
self.gctx.checkpoint()
diff --git a/rpki/rtr/client.py b/rpki/rtr/client.py
index d6000e04..c1d9a8a7 100644
--- a/rpki/rtr/client.py
+++ b/rpki/rtr/client.py
@@ -22,7 +22,6 @@ Client implementation for the RPKI-RTR protocol (RFC 6810 et sequalia).
import os
import sys
-import time
import base64
import socket
import signal
diff --git a/rpki/sql.py b/rpki/sql.py
index adcc78f6..31ed40ee 100644
--- a/rpki/sql.py
+++ b/rpki/sql.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# Copyright (C) 2009-2013 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -134,7 +134,7 @@ class session(object):
"""
for s in self.dirty.copy():
#if s.sql_cache_debug:
- logger.debug("Sweeping (%s) %r" % ("deleting" if s.sql_deleted else "storing", s))
+ logger.debug("Sweeping (%s) %r", "deleting" if s.sql_deleted else "storing", s)
if s.sql_deleted:
s.sql_delete()
else:
@@ -245,7 +245,7 @@ class sql_persistent(object):
if where is None:
assert args is None and also_from is None
if cls.sql_debug:
- logger.debug("sql_fetch_where(%r)" % cls.sql_template.select)
+ logger.debug("sql_fetch_where(%r)", cls.sql_template.select)
gctx.sql.execute(cls.sql_template.select)
else:
query = cls.sql_template.select
@@ -253,7 +253,7 @@ class sql_persistent(object):
query += "," + also_from
query += " WHERE " + where
if cls.sql_debug:
- logger.debug("sql_fetch_where(%r, %r)" % (query, args))
+ logger.debug("sql_fetch_where(%r, %r)", query, args)
gctx.sql.execute(query, args)
results = []
for row in gctx.sql.fetchall():
@@ -282,7 +282,7 @@ class sql_persistent(object):
Mark this object as needing to be written back to SQL.
"""
if self.sql_cache_debug and not self.sql_is_dirty:
- logger.debug("Marking %r SQL dirty" % self)
+ logger.debug("Marking %r SQL dirty", self)
self.gctx.sql.dirty.add(self)
def sql_mark_clean(self):
@@ -290,7 +290,7 @@ class sql_persistent(object):
Mark this object as not needing to be written back to SQL.
"""
if self.sql_cache_debug and self.sql_is_dirty:
- logger.debug("Marking %r SQL clean" % self)
+ logger.debug("Marking %r SQL clean", self)
self.gctx.sql.dirty.discard(self)
@property
@@ -314,14 +314,14 @@ class sql_persistent(object):
args = self.sql_encode()
if not self.sql_in_db:
if self.sql_debug:
- logger.debug("sql_store(%r, %r)" % (self.sql_template.insert, args))
+ logger.debug("sql_store(%r, %r)", self.sql_template.insert, args)
self.gctx.sql.execute(self.sql_template.insert, args)
setattr(self, self.sql_template.index, self.gctx.sql.lastrowid())
self.gctx.sql.cache[(self.__class__, self.gctx.sql.lastrowid())] = self
self.sql_insert_hook()
else:
if self.sql_debug:
- logger.debug("sql_store(%r, %r)" % (self.sql_template.update, args))
+ logger.debug("sql_store(%r, %r)", self.sql_template.update, args)
self.gctx.sql.execute(self.sql_template.update, args)
self.sql_update_hook()
key = (self.__class__, getattr(self, self.sql_template.index))
@@ -336,7 +336,7 @@ class sql_persistent(object):
if self.sql_in_db:
id = getattr(self, self.sql_template.index) # pylint: disable=W0622
if self.sql_debug:
- logger.debug("sql_delete(%r, %r)" % (self.sql_template.delete, id))
+ logger.debug("sql_delete(%r, %r)", self.sql_template.delete, id)
self.sql_delete_hook()
self.gctx.sql.execute(self.sql_template.delete, (id,))
key = (self.__class__, id)
@@ -382,7 +382,7 @@ class sql_persistent(object):
Customization hook.
"""
pass
-
+
def sql_update_hook(self):
"""
Customization hook.
diff --git a/rpki/sql_schemas.py b/rpki/sql_schemas.py
index 0ac6016e..cdec8dfc 100644
--- a/rpki/sql_schemas.py
+++ b/rpki/sql_schemas.py
@@ -162,7 +162,7 @@ CREATE TABLE child (
self_id BIGINT UNSIGNED NOT NULL,
bsc_id BIGINT UNSIGNED NOT NULL,
PRIMARY KEY (child_id),
- CONSTRAINT child_bsc_id
+ CONSTRAINT child_bsc_id
FOREIGN KEY (bsc_id) REFERENCES bsc (bsc_id) ON DELETE CASCADE,
CONSTRAINT child_self_id
FOREIGN KEY (self_id) REFERENCES self (self_id) ON DELETE CASCADE,
diff --git a/rpki/sundial.py b/rpki/sundial.py
index 1a7b3501..7be122c8 100644
--- a/rpki/sundial.py
+++ b/rpki/sundial.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -157,11 +157,11 @@ class datetime(pydatetime.datetime):
"""
for sep in " T":
- d, _, t = s.partition(sep)
+ d, _, t = s.partition(sep) # pylint: disable=W0612
if t:
try:
return cls(*[int(x) for x in d.split("-") + t.split(":")])
- except:
+ except: # pylint: disable=W0702
break
from rpki.mysql_import import MySQLdb
diff --git a/rpki/up_down.py b/rpki/up_down.py
index 5d4ea7e6..262003a2 100644
--- a/rpki/up_down.py
+++ b/rpki/up_down.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2013--2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2012 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -249,17 +249,18 @@ class list_pdu(base_elt):
r_msg.payload = list_response_pdu()
if irdb_resources.valid_until < rpki.sundial.now():
- logger.debug("Child %s's resources expired %s" % (child.child_handle, irdb_resources.valid_until))
+ logger.debug("Child %s's resources expired %s", child.child_handle, irdb_resources.valid_until)
else:
for parent in child.parents:
for ca in parent.cas:
ca_detail = ca.active_ca_detail
if not ca_detail:
- logger.debug("No active ca_detail, can't issue to %s" % child.child_handle)
+ logger.debug("No active ca_detail, can't issue to %s", child.child_handle)
continue
resources = ca_detail.latest_ca_cert.get_3779resources() & irdb_resources
if resources.empty():
- logger.debug("No overlap between received resources and what child %s should get ([%s], [%s])" % (child.child_handle, ca_detail.latest_ca_cert.get_3779resources(), irdb_resources))
+ logger.debug("No overlap between received resources and what child %s should get ([%s], [%s])",
+ child.child_handle, ca_detail.latest_ca_cert.get_3779resources(), irdb_resources)
continue
rc = class_elt()
rc.class_name = str(ca.ca_id)
@@ -283,7 +284,7 @@ class list_pdu(base_elt):
Send a "list" query to parent.
"""
try:
- logger.info('Sending "list" request to parent %s' % parent.parent_handle)
+ logger.info('Sending "list" request to parent %s', parent.parent_handle)
parent.query_up_down(cls(), cb, eb)
except (rpki.async.ExitNow, SystemExit):
raise
@@ -311,7 +312,7 @@ class class_response_syntax(base_elt):
self.classes.append(c)
stack.append(c)
c.startElement(stack, name, attrs)
-
+
def toXML(self):
"""Generate payload of "list_response" and "issue_response" PDUs."""
return [c.toXML() for c in self.classes]
@@ -440,7 +441,7 @@ class issue_pdu(base_elt):
is_ca = True,
caRepository = ca.sia_uri,
rpkiManifest = ca_detail.manifest_uri)
- logger.info('Sending "issue" request to parent %s' % parent.parent_handle)
+ logger.info('Sending "issue" request to parent %s', parent.parent_handle)
parent.query_up_down(self, callback, errback)
class issue_response_pdu(class_response_syntax):
@@ -474,7 +475,7 @@ class revoke_pdu(revoke_syntax):
"""
Up-Down protocol "revoke" PDU.
"""
-
+
def get_SKI(self):
"""
Convert g(SKI) encoding from PDU back to raw SKI.
@@ -509,7 +510,7 @@ class revoke_pdu(revoke_syntax):
self = cls()
self.class_name = ca.parent_resource_class
self.ski = gski
- logger.info('Sending "revoke" request for SKI %s to parent %s' % (gski, parent.parent_handle))
+ logger.info('Sending "revoke" request for SKI %s to parent %s', gski, parent.parent_handle)
parent.query_up_down(self, cb, eb)
class revoke_response_pdu(revoke_syntax):
@@ -547,15 +548,14 @@ class error_response_pdu(base_elt):
"""
base_elt.__init__(self)
if exception is not None:
- logger.debug("Constructing up-down error response from exception %s" % exception)
+ logger.debug("Constructing up-down error response from exception %s", exception)
exception_type = type(exception)
request_type = None if request_payload is None else type(request_payload)
- logger.debug("Constructing up-down error response: exception_type %s, request_type %s" % (
- exception_type, request_type))
+ logger.debug("Constructing up-down error response: exception_type %s, request_type %s",
+ exception_type, request_type)
if False:
self.status = self.exceptions.get((exception_type, request_type),
- self.exceptions.get(exception_type,
- 2001))
+ self.exceptions.get(exception_type, 2001))
else:
self.status = self.exceptions.get((exception_type, request_type))
if self.status is None:
@@ -565,7 +565,7 @@ class error_response_pdu(base_elt):
logger.debug("No exception match either, defaulting")
self.status = 2001
self.description = str(exception)
- logger.debug("Chosen status code: %s" % self.status)
+ logger.debug("Chosen status code: %s", self.status)
def endElement(self, stack, name, text):
"""
@@ -684,7 +684,7 @@ class message_pdu(base_elt):
"""
Log query we're handling. Separate method so rootd can override.
"""
- logger.info("Serving %s query from child %s [sender %s, recipient %s]" % (self.type, child.child_handle, self.sender, self.recipient))
+ logger.info("Serving %s query from child %s [sender %s, recipient %s]", self.type, child.child_handle, self.sender, self.recipient)
def serve_error(self, exception):
"""
diff --git a/rpki/x509.py b/rpki/x509.py
index c9a8f9c1..a7e4d17a 100644
--- a/rpki/x509.py
+++ b/rpki/x509.py
@@ -1,13 +1,13 @@
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2009--2013 Internet Systems Consortium ("ISC")
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notices and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND DRL, ISC, AND ARIN DISCLAIM ALL
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL,
@@ -126,13 +126,8 @@ class X501DN(object):
return rpki.log.log_repr(self, str(self))
def _debug(self):
- if False:
- import traceback
- for chunk in traceback.format_stack(limit = 5):
- for line in chunk.splitlines():
- logger.debug("== %s" % line)
- logger.debug("++ %r %r" % (self, self.dn))
-
+ logger.debug("++ %r %r", self, self.dn)
+
@classmethod
def from_cn(cls, cn, sn = None):
assert isinstance(cn, (str, unicode))
@@ -271,7 +266,7 @@ class DER_object(object):
self.DER = value
return
raise rpki.exceptions.DERObjectConversionError("Can't honor conversion request %r" % (kw,))
-
+
def check_auto_update(self):
"""
Check for updates to a DER object that auto-updates from a file.
@@ -282,7 +277,8 @@ class DER_object(object):
filename = self.filename
timestamp = os.stat(self.filename).st_mtime
if self.timestamp is None or self.timestamp < timestamp:
- logger.debug("Updating %s, timestamp %s" % (filename, rpki.sundial.datetime.fromtimestamp(timestamp)))
+ logger.debug("Updating %s, timestamp %s",
+ filename, rpki.sundial.datetime.fromtimestamp(timestamp))
f = open(filename, "rb")
value = f.read()
f.close()
@@ -296,7 +292,7 @@ class DER_object(object):
except (IOError, OSError), e:
now = rpki.sundial.now()
if self.lastfail is None or now > self.lastfail + self.failure_threshold:
- logger.warning("Could not auto_update %r (last failure %s): %s" % (self, self.lastfail, e))
+ logger.warning("Could not auto_update %r (last failure %s): %s", self, self.lastfail, e)
self.lastfail = now
else:
self.lastfail = None
@@ -1051,7 +1047,7 @@ class PKCS10(DER_object):
But draft-ietf-sidr-bgpsec-pki-profiles also says that router
certificates don't get SIA, while RFC 6487 requires SIA. So what
do we do with SIA in PKCS #10 for router certificates?
-
+
For the moment, ignore it, but make sure we don't include it in
the certificate when we get to the code that generates that.
"""
@@ -1147,7 +1143,7 @@ class PrivateKey(DER_object):
"""
Class to hold a Public/Private key pair.
"""
-
+
POW_class = rpki.POW.Asymmetric
def get_DER(self):
@@ -1206,7 +1202,7 @@ class PublicKey(DER_object):
"""
Class to hold a public key.
"""
-
+
POW_class = rpki.POW.Asymmetric
def get_DER(self):
@@ -1271,7 +1267,7 @@ class RSA(PrivateKey):
Generate a new keypair.
"""
if not quiet:
- logger.debug("Generating new %d-bit RSA key" % keylength)
+ logger.debug("Generating new %d-bit RSA key", keylength)
if generate_insecure_debug_only_rsa_key is not None:
return cls(POW = generate_insecure_debug_only_rsa_key())
else:
@@ -1331,17 +1327,17 @@ class CMS_object(DER_object):
# and CRLs should be uncondtionally mandatory in such cases.
require_crls = False
-
+
## @var allow_extra_certs
# Set this to True to allow CMS messages to contain CA certificates.
allow_extra_certs = False
-
+
## @var allow_extra_crls
# Set this to True to allow CMS messages to contain multiple CRLs.
allow_extra_crls = False
-
+
## @var print_on_der_error
# Set this to True to log alleged DER when we have trouble parsing
# it, in case it's really a Perl backtrace or something.
@@ -1386,8 +1382,8 @@ class CMS_object(DER_object):
raise
except Exception:
if self.print_on_der_error:
- logger.debug("Problem parsing DER CMS message, might not really be DER: %r" %
- self.get_DER())
+ logger.debug("Problem parsing DER CMS message, might not really be DER: %r",
+ self.get_DER())
raise rpki.exceptions.UnparsableCMSDER
if cms.eContentType() != self.econtent_oid:
@@ -1399,10 +1395,10 @@ class CMS_object(DER_object):
if self.debug_cms_certs:
for x in certs:
- logger.debug("Received CMS cert issuer %s subject %s SKI %s" % (
- x.getIssuer(), x.getSubject(), x.hSKI()))
+ logger.debug("Received CMS cert issuer %s subject %s SKI %s",
+ x.getIssuer(), x.getSubject(), x.hSKI())
for c in crls:
- logger.debug("Received CMS CRL issuer %r" % (c.getIssuer(),))
+ logger.debug("Received CMS CRL issuer %r", c.getIssuer())
store = rpki.POW.X509Store()
@@ -1412,8 +1408,8 @@ class CMS_object(DER_object):
for x in X509.normalize_chain(ta):
if self.debug_cms_certs:
- logger.debug("CMS trusted cert issuer %s subject %s SKI %s" % (
- x.getIssuer(), x.getSubject(), x.hSKI()))
+ logger.debug("CMS trusted cert issuer %s subject %s SKI %s",
+ x.getIssuer(), x.getSubject(), x.hSKI())
if x.getNotAfter() < now:
raise rpki.exceptions.TrustedCMSCertHasExpired("Trusted CMS certificate has expired",
"%s (%s)" % (x.getSubject(), x.hSKI()))
@@ -1427,8 +1423,8 @@ class CMS_object(DER_object):
if trusted_ee:
if self.debug_cms_certs:
- logger.debug("Trusted CMS EE cert issuer %s subject %s SKI %s" % (
- trusted_ee.getIssuer(), trusted_ee.getSubject(), trusted_ee.hSKI()))
+ logger.debug("Trusted CMS EE cert issuer %s subject %s SKI %s",
+ trusted_ee.getIssuer(), trusted_ee.getSubject(), trusted_ee.hSKI())
if len(certs) > 1 or (len(certs) == 1 and
(certs[0].getSubject() != trusted_ee.getSubject() or
certs[0].getPublicKey() != trusted_ee.getPublicKey())):
@@ -1461,7 +1457,7 @@ class CMS_object(DER_object):
for c in crls:
if c.getNextUpdate() < now:
- logger.warning("Stale BPKI CMS CRL (%s %s %s)" % (c.getNextUpdate(), c.getIssuer(), c.hAKI()))
+ logger.warning("Stale BPKI CMS CRL (%s %s %s)", c.getNextUpdate(), c.getIssuer(), c.hAKI())
try:
content = cms.verify(store)
@@ -1473,7 +1469,7 @@ class CMS_object(DER_object):
dbg = self.dumpasn1()
else:
dbg = cms.pprint()
- logger.warning("CMS verification failed, dumping ASN.1 (%d octets):" % len(self.get_DER()))
+ logger.warning("CMS verification failed, dumping ASN.1 (%d octets):", len(self.get_DER()))
for line in dbg.splitlines():
logger.warning(line)
raise rpki.exceptions.CMSVerificationFailed("CMS verification failed")
@@ -1527,11 +1523,11 @@ class CMS_object(DER_object):
crls = (crls,)
if self.debug_cms_certs:
- logger.debug("Signing with cert issuer %s subject %s SKI %s" % (
- cert.getIssuer(), cert.getSubject(), cert.hSKI()))
+ logger.debug("Signing with cert issuer %s subject %s SKI %s",
+ cert.getIssuer(), cert.getSubject(), cert.hSKI())
for i, c in enumerate(certs):
- logger.debug("Additional cert %d issuer %s subject %s SKI %s" % (
- i, c.getIssuer(), c.getSubject(), c.hSKI()))
+ logger.debug("Additional cert %d issuer %s subject %s SKI %s",
+ i, c.getIssuer(), c.getSubject(), c.hSKI())
self._sign(cert.get_POW(),
keypair.get_POW(),
@@ -1619,7 +1615,7 @@ class Wrapped_CMS_object(CMS_object):
cms = self.POW_class()
cms.sign(cert, keypair, self.encode(), certs, crls, self.econtent_oid, flags)
self.POW = cms
-
+
class DER_CMS_object(CMS_object):
"""
@@ -1650,7 +1646,7 @@ class SignedManifest(DER_CMS_object):
econtent_oid = rpki.oids.id_ct_rpkiManifest
POW_class = rpki.POW.Manifest
-
+
def getThisUpdate(self):
"""
Get thisUpdate value from this manifest.
@@ -1762,7 +1758,7 @@ class DeadDrop(object):
self.warned = False
except Exception, e:
if not self.warned:
- logger.warning("Could not write to mailbox %s: %s" % (self.name, e))
+ logger.warning("Could not write to mailbox %s: %s", self.name, e)
self.warned = True
class XML_CMS_object(Wrapped_CMS_object):
@@ -1885,7 +1881,7 @@ class XML_CMS_object(Wrapped_CMS_object):
def check_replay_sql(self, obj, *context):
"""
Like .check_replay() but gets recorded timestamp from
- "last_cms_timestamp" field of an SQL object and stores the new
+ "last_cms_timestamp" field of an SQL object and stores the new
timestamp back in that same field.
"""
obj.last_cms_timestamp = self.check_replay(obj.last_cms_timestamp, *context)
@@ -1941,7 +1937,7 @@ class CRL(DER_object):
"""
Class to hold a Certificate Revocation List.
"""
-
+
POW_class = rpki.POW.CRL
def get_DER(self):
diff --git a/rpki/xml_utils.py b/rpki/xml_utils.py
index 54cfac6d..e940d127 100644
--- a/rpki/xml_utils.py
+++ b/rpki/xml_utils.py
@@ -1,11 +1,11 @@
# $Id$
-#
+#
# 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
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -13,13 +13,13 @@
# 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.
-#
+#
# Portions copyright (C) 2007--2008 American Registry for Internet Numbers ("ARIN")
-#
+#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS" AND ARIN DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL ARIN BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -414,7 +414,7 @@ class data_elt(base_elt):
if self.action not in dispatch:
raise rpki.exceptions.BadQuery("Unexpected query: action %s" % self.action)
dispatch[self.action](r_msg, cb, eb)
-
+
def unimplemented_control(self, *controls):
"""
Uniform handling for unimplemented control operations.