aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2014-05-31 18:32:19 +0000
committerRob Austein <sra@hactrn.net>2014-05-31 18:32:19 +0000
commita7cad7f4aab21d48eb783935dfabb9859bcc4f37 (patch)
treefa8ec4816cfbef4bb3edf01319fe4b7db9b3a73b
parent61309aa7e3c4d8abb6b7e78c979c851f59a70fc4 (diff)
Still more PyLint.
svn path=/trunk/; revision=5856
-rw-r--r--Makefile.in5
-rw-r--r--buildtools/pylint.rc2
-rwxr-xr-xca/irbe_cli2
-rwxr-xr-xca/rpki-confgen10
-rwxr-xr-xca/rpki-sql-backup4
-rwxr-xr-xca/rpki-sql-setup24
-rwxr-xr-xca/rpki-start-servers6
-rwxr-xr-xca/rpkigui-apache-conf-gen12
-rwxr-xr-xca/rpkigui-import-routes2
-rwxr-xr-xca/rpkigui-rcynic2
-rw-r--r--ca/tests/smoketest.py32
-rw-r--r--ca/tests/xml-parse-test.py2
-rw-r--r--ca/tests/yamlconf.py1
-rw-r--r--ca/tests/yamltest.py1
-rw-r--r--ca/upgrade-scripts/upgrade-rpkid-to-0.5709.py2
-rwxr-xr-xrp/rcynic/rcynic-cron8
-rwxr-xr-xrp/rcynic/rcynic-html53
-rwxr-xr-xrp/rcynic/rcynic-svn27
-rwxr-xr-xrp/rcynic/rcynic-text8
-rw-r--r--rp/rcynic/rpki-torrent.py48
-rwxr-xr-xrp/rcynic/validation_status6
-rwxr-xr-xrp/utils/find_roa10
-rwxr-xr-xrp/utils/hashdir6
-rwxr-xr-xrp/utils/print_roa8
-rwxr-xr-xrp/utils/print_rpki_manifest8
-rwxr-xr-xrp/utils/scan_roas6
-rwxr-xr-xrp/utils/scan_routercerts6
-rwxr-xr-xrp/utils/uri9
28 files changed, 158 insertions, 152 deletions
diff --git a/Makefile.in b/Makefile.in
index dcc92349..8908ae32 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -202,8 +202,11 @@ schemas/relaxng/myrpki.rng: schemas/relaxng/myrpki.rnc
schemas/relaxng/router-certificate-schema.rng: schemas/relaxng/router-certificate-schema.rnc
${TRANG} schemas/relaxng/router-certificate-schema.rnc schemas/relaxng/router-certificate-schema.rng
+# Eg: PYLINT_FLAGS='--disable=W0311'
+
lint:
- find rpki -name '*.py' | xargs pylint --rcfile ${abs_top_srcdir}/buildtools/pylint.rc
+ { find rpki rp ca -name '*.py' -print; find rp ca -type f -perm -1 -print | xargs grep -El '^#!.+python'; } | \
+ sort -u | xargs pylint --rcfile ${abs_top_srcdir}/buildtools/pylint.rc ${PYLINT_FLAGS}
tags: Makefile
find rpki rp ca schemas -type f \
diff --git a/buildtools/pylint.rc b/buildtools/pylint.rc
index 7236e09a..ed296108 100644
--- a/buildtools/pylint.rc
+++ b/buildtools/pylint.rc
@@ -44,7 +44,7 @@ disable-msg-cat=
#enable-msg=
# Disable the message(s) with the given id(s).
-disable=R0801,R0903,R0913,C0321,R0904,W0201,E1101,W0614,C0301,R0901,C0302,R0902,R0201,W0613,R0912,R0915,W0703,W0212,R0914,W0603,W0142,I0011,C0111,C0103,R0401,C0326,R0911
+disable=R0801,R0903,R0913,C0321,R0904,W0201,E1101,W0614,C0301,R0901,C0302,R0902,R0201,W0613,R0912,R0915,W0703,W0212,R0914,W0603,W0142,I0011,C0111,C0103,R0401,C0326,R0911,C0325
[REPORTS]
diff --git a/ca/irbe_cli b/ca/irbe_cli
index 9deac6d6..1becd403 100755
--- a/ca/irbe_cli
+++ b/ca/irbe_cli
@@ -30,7 +30,7 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-__doc__ = """
+"""
Command line IR back-end control program for rpkid and pubd.
"""
diff --git a/ca/rpki-confgen b/ca/rpki-confgen
index f531bee8..07c87f0f 100755
--- a/ca/rpki-confgen
+++ b/ca/rpki-confgen
@@ -4,11 +4,11 @@
#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 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
@@ -155,7 +155,7 @@ class CustomAction(argparse.Action):
class CustomFlagAction(argparse.Action):
def __init__(self, option_strings, dest, default = None,
- required = False, help = None):
+ required = False, help = None): # pylint: disable=W0622
super(CustomFlagAction, self).__init__(
option_strings = option_strings, dest = dest, nargs = 0,
const = None, default = default, required = required, help = help)
@@ -221,7 +221,7 @@ class main(object):
name, value = arg.split("=", 1)
section, option = name.split("::")
except ValueError:
- sys.exit("Couldn't parse --set specification \"%s\"" % a)
+ sys.exit("Couldn't parse --set specification \"%s\"" % arg)
name = (section, option)
if name not in self.option_map:
sys.exit("Couldn't find option %s::%s" % name)
@@ -232,7 +232,7 @@ class main(object):
try:
section, option = arg.split("::")
except ValueError:
- sys.exit("Couldn't parse --pwgen specification \"%s\"" % a)
+ sys.exit("Couldn't parse --pwgen specification \"%s\"" % arg)
name = (section, option)
if name not in self.option_map:
sys.exit("Couldn't find option %s::%s" % name)
diff --git a/ca/rpki-sql-backup b/ca/rpki-sql-backup
index 0b2d079d..e60f9ae3 100755
--- a/ca/rpki-sql-backup
+++ b/ca/rpki-sql-backup
@@ -4,11 +4,11 @@
#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 2010-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
diff --git a/ca/rpki-sql-setup b/ca/rpki-sql-setup
index 40a78532..edc2c242 100755
--- a/ca/rpki-sql-setup
+++ b/ca/rpki-sql-setup
@@ -4,11 +4,11 @@
#
# 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
@@ -116,7 +116,7 @@ class UserDB(object):
def exists_and_accessible(self):
try:
MySQLdb.connect(db = self.database, user = self.username, passwd = self.password).close()
- except:
+ except: # pylint: disable=W0702
return False
else:
return True
@@ -179,13 +179,13 @@ class Upgrade(object):
"""
@classmethod
- def load_all(cls, name, dir):
- g = os.path.join(dir, "upgrade-%s-to-*.py" % name)
+ def load_all(cls, name, dn):
+ g = os.path.join(dn, "upgrade-%s-to-*.py" % name)
for fn in glob.iglob(g):
yield cls(g, fn)
def __init__(self, g, fn):
- head, sep, tail = g.partition("*")
+ head, sep, tail = g.partition("*") # pylint: disable=W0612
self.fn = fn
self.version = Version(fn[len(head):-len(tail)])
@@ -196,7 +196,7 @@ class Upgrade(object):
# db is an argument here primarily so the script we exec can get at it
log("Applying %s to %s" % (self.fn, db.name))
with open(self.fn, "r") as f:
- exec f
+ exec f # pylint: disable=W0122
def do_drop(name):
@@ -302,10 +302,10 @@ try:
cfg = rpki.config.parser(args.config, "myrpki")
root = RootDB(args.mysql_defaults)
current_version = Version(rpki.version.VERSION)
- for name in ("irdbd", "rpkid", "pubd"):
- if cfg.getboolean("start_" + name, False):
- args.dispatch(name)
+ for program_name in ("irdbd", "rpkid", "pubd"):
+ if cfg.getboolean("start_" + program_name, False):
+ args.dispatch(program_name)
root.close()
except Exception, e:
- #sys.exit(str(e))
- raise
+ #raise
+ sys.exit(str(e))
diff --git a/ca/rpki-start-servers b/ca/rpki-start-servers
index f867fefa..8a745896 100755
--- a/ca/rpki-start-servers
+++ b/ca/rpki-start-servers
@@ -1,15 +1,15 @@
#!/usr/bin/env python
# $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,
diff --git a/ca/rpkigui-apache-conf-gen b/ca/rpkigui-apache-conf-gen
index 6201c364..0f56342f 100755
--- a/ca/rpkigui-apache-conf-gen
+++ b/ca/rpkigui-apache-conf-gen
@@ -17,7 +17,6 @@
# PERFORMANCE OF THIS SOFTWARE.
import os
-import re
import sys
import socket
import urllib2
@@ -168,7 +167,7 @@ class Platform(object):
apache_key = os.path.join(rpki.autoconf.sysconfdir, "rpki", "apache.key")
apache_conf = os.path.join(rpki.autoconf.sysconfdir, "rpki", "apache.conf")
- apache_conf_sample = apache_conf + ".sample"
+ apache_conf_sample = apache_conf + ".sample"
apache_conf_preface = ""
@@ -305,7 +304,7 @@ class Platform(object):
def remove(self):
try:
same = open(self.apache_conf, "r").read() == open(self.apache_conf_sample, "r").read()
- except:
+ except: # pylint: disable=W0702
same = False
self.unlink(self.apache_conf_sample)
if same:
@@ -334,7 +333,7 @@ class Platform(object):
addrinfo = socket.getaddrinfo(host, port, family, proto)
except socket.error:
return False
- for af, socktype, proto, canon, sa in addrinfo:
+ for af, socktype, proto, canon, sa in addrinfo: # pylint: disable=W0612
try:
s = socket.socket(af, socktype, proto)
s.connect(sa)
@@ -344,7 +343,7 @@ class Platform(object):
else:
return True
return False
-
+
class FreeBSD(Platform):
"""
FreeBSD.
@@ -353,7 +352,7 @@ class FreeBSD(Platform):
# On FreeBSD we have to ask httpd what version it is before we know
# where to put files or what to call the service. In FreeBSD's makefiles,
# this value is called APACHE_VERSION, and is calculated thusly:
- #
+ #
# httpd -V | sed -ne 's/^Server version: Apache\/\([0-9]\)\.\([0-9]*\).*/\1\2/p'
_apache_name = None
@@ -417,6 +416,7 @@ class Debian(Platform):
class NIY(Platform):
def __init__(self, args):
+ super(NIY, self).__init__(args)
raise NotImplementedError("Platform %s not implemented yet, sorry" % self.__class__.__name__)
class Redhat(NIY):
diff --git a/ca/rpkigui-import-routes b/ca/rpkigui-import-routes
index 234a865b..3dce26b3 100755
--- a/ca/rpkigui-import-routes
+++ b/ca/rpkigui-import-routes
@@ -81,7 +81,7 @@ automatically.""")
delay = random.SystemRandom().randint(0, options.jitter)
except NotImplementedError:
delay = random.randint(0, options.jitter)
- logging.info('jitter active, delaying startup for %d seconds' % delay)
+ logging.info('jitter active, delaying startup for %d seconds', delay)
time.sleep(delay)
if options.lockfile:
diff --git a/ca/rpkigui-rcynic b/ca/rpkigui-rcynic
index 8fb91a70..79afb15f 100755
--- a/ca/rpkigui-rcynic
+++ b/ca/rpkigui-rcynic
@@ -47,7 +47,7 @@ if __name__ == '__main__':
v = getattr(logging, options.log_level.upper())
logging.basicConfig(level=v)
- logging.info('log level set to %s' % logging.getLevelName(v))
+ logging.info('log level set to %s', logging.getLevelName(v))
import_rcynic_xml(options.root, options.logfile)
diff --git a/ca/tests/smoketest.py b/ca/tests/smoketest.py
index 04b43f07..7f56843f 100644
--- a/ca/tests/smoketest.py
+++ b/ca/tests/smoketest.py
@@ -35,7 +35,6 @@ things that don't belong in yaml_file.
import os
import yaml
import subprocess
-import signal
import time
import logging
import argparse
@@ -311,13 +310,13 @@ def main():
(rsyncd_process, "rsyncd")):
# pylint: disable=E1103
if proc is not None and proc.poll() is None:
- logger.info("Killing %s, pid %s" % (name, proc.pid))
+ logger.info("Killing %s, pid %s", name, proc.pid)
try:
proc.terminate()
except OSError:
pass
if proc is not None:
- logger.info("Daemon %s, pid %s exited with code %s" % (name, proc.pid, proc.wait()))
+ logger.info("Daemon %s, pid %s exited with code %s", name, proc.pid, proc.wait())
def cmd_sleep(cb, interval):
"""
@@ -405,11 +404,10 @@ class router_cert(object):
return self.asn == other.asn and self.sn == other.sn and self.gski == other.gski
def __hash__(self):
- v6 = tuple(self.v6) if self.v6 is not None else None
- return tuple(self.asn).__hash__() + sn.__hash__() + self.gski.__hash__()
+ return tuple(self.asn).__hash__() + self.cn.__hash__() + self.sn.__hash__() + self.gski.__hash__()
def __str__(self):
- return "%s: %s: %s" % (self.asn, self.cn, self.sn, self.gski)
+ return "%s: %s,%s: %s" % (self.asn, self.cn, self.sn, self.gski)
@classmethod
def parse(cls, yaml):
@@ -638,7 +636,7 @@ class allocation(object):
self.call_rpkid([rpki.left_right.self_elt.make_pdu(
action = "set", self_handle = self.name, rekey = "yes")], cb = done)
else:
- logger.info("Rekeying <parent/> %s %s" % (self.name, target))
+ logger.info("Rekeying <parent/> %s %s", self.name, target)
self.call_rpkid([rpki.left_right.parent_elt.make_pdu(
action = "set", self_handle = self.name, parent_handle = target, rekey = "yes")], cb = done)
@@ -655,7 +653,7 @@ class allocation(object):
self.call_rpkid([rpki.left_right.self_elt.make_pdu(
action = "set", self_handle = self.name, revoke = "yes")], cb = done)
else:
- logger.info("Revoking <parent/> %s %s" % (self.name, target))
+ logger.info("Revoking <parent/> %s %s", self.name, target)
self.call_rpkid([rpki.left_right.parent_elt.make_pdu(
action = "set", self_handle = self.name, parent_handle = target, revoke = "yes")], cb = done)
@@ -842,14 +840,14 @@ class allocation(object):
for proc, name in ((self.rpkid_process, "rpkid"),
(self.irdbd_process, "irdbd")):
if proc is not None and proc.poll() is None:
- logger.info("Killing daemon %s pid %s for %s" % (name, proc.pid, self.name))
+ logger.info("Killing daemon %s pid %s for %s", name, proc.pid, self.name)
try:
proc.terminate()
except OSError:
pass
if proc is not None:
- logger.info("Daemon %s pid %s for %s exited with code %s" % (
- name, proc.pid, self.name, proc.wait()))
+ logger.info("Daemon %s pid %s for %s exited with code %s",
+ name, proc.pid, self.name, proc.wait())
def call_rpkid(self, pdus, cb):
"""
@@ -863,7 +861,7 @@ class allocation(object):
logger.info("Calling rpkid for %s", self.name)
if self.is_hosted:
- logger.info("rpkid %s is hosted by rpkid %s, switching" % (self.name, self.hosted_by.name))
+ logger.info("rpkid %s is hosted by rpkid %s, switching", self.name, self.hosted_by.name)
self = self.hosted_by
assert not self.is_hosted
@@ -909,7 +907,7 @@ class allocation(object):
certifier = self.name + "-SELF"
certfile = certifier + "-" + certificant + ".cer"
- logger.info("Cross certifying %s into %s's BPKI (%s)" % (certificant, certifier, certfile))
+ logger.info("Cross certifying %s into %s's BPKI (%s)", certificant, certifier, certfile)
child = rpki.x509.X509(Auto_file = certificant + ".cer")
parent = rpki.x509.X509(Auto_file = certifier + ".cer")
@@ -943,8 +941,8 @@ class allocation(object):
f.close()
logger.debug("Cross certified %s:", certfile)
- logger.debug(" Issuer %s [%s]" % (x.getIssuer(), x.hAKI()))
- logger.debug(" Subject %s [%s]" % (x.getSubject(), x.hSKI()))
+ logger.debug(" Issuer %s [%s]", x.getIssuer(), x.hAKI())
+ logger.debug(" Subject %s [%s]", x.getSubject(), x.hSKI())
return x
def create_rpki_objects(self, cb):
@@ -965,7 +963,7 @@ class allocation(object):
selves = [self] + self.hosts
for i, s in enumerate(selves):
- logger.info("Creating RPKI objects for [%d] %s" % (i, s.name))
+ logger.info("Creating RPKI objects for [%d] %s", i, s.name)
rpkid_pdus = []
pubd_pdus = []
@@ -1062,7 +1060,7 @@ class allocation(object):
raise CouldntIssueBSCEECertificate("Couldn't issue BSC EE certificate")
s.bsc_ee = rpki.x509.X509(PEM = signed[0])
s.bsc_crl = rpki.x509.CRL(PEM_file = s.name + "-SELF.crl")
- logger.info("BSC EE cert for %s SKI %s" % (s.name, s.bsc_ee.hSKI()))
+ logger.info("BSC EE cert for %s SKI %s", s.name, s.bsc_ee.hSKI())
bsc_pdus.append(rpki.left_right.bsc_elt.make_pdu(
action = "set",
diff --git a/ca/tests/xml-parse-test.py b/ca/tests/xml-parse-test.py
index 3647a82a..5ea25492 100644
--- a/ca/tests/xml-parse-test.py
+++ b/ca/tests/xml-parse-test.py
@@ -50,7 +50,7 @@ def test(fileglob, rng, sax_handler, encoding, tester = None):
print "<!-- Output -->"
print lxml.etree.tostring(elt_out, pretty_print = True, encoding = encoding, xml_declaration = True)
rng.assertValid(elt_out)
- if (tester):
+ if tester:
tester(elt_in, elt_out, handler.result)
if verbose:
print
diff --git a/ca/tests/yamlconf.py b/ca/tests/yamlconf.py
index e9b6e391..acc56497 100644
--- a/ca/tests/yamlconf.py
+++ b/ca/tests/yamlconf.py
@@ -133,7 +133,6 @@ class router_cert(object):
return self.asn == other.asn and self.router_id == other.router_id and self.gski == other.gski
def __hash__(self):
- v6 = tuple(self.v6) if self.v6 is not None else None
return tuple(self.asn).__hash__() + self.router_id.__hash__() + self.gski.__hash__()
def __str__(self):
diff --git a/ca/tests/yamltest.py b/ca/tests/yamltest.py
index a2390aff..1482c4e2 100644
--- a/ca/tests/yamltest.py
+++ b/ca/tests/yamltest.py
@@ -137,7 +137,6 @@ class router_cert(object):
return self.asn == other.asn and self.router_id == other.router_id and self.gski == other.gski
def __hash__(self):
- v6 = tuple(self.v6) if self.v6 is not None else None
return tuple(self.asn).__hash__() + self.router_id.__hash__() + self.gski.__hash__()
def __str__(self):
diff --git a/ca/upgrade-scripts/upgrade-rpkid-to-0.5709.py b/ca/upgrade-scripts/upgrade-rpkid-to-0.5709.py
index aa8e3ec1..0cea5671 100644
--- a/ca/upgrade-scripts/upgrade-rpkid-to-0.5709.py
+++ b/ca/upgrade-scripts/upgrade-rpkid-to-0.5709.py
@@ -14,6 +14,8 @@
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
+# pylint: disable=E0602
+
"""
Upgrade RPKI SQL databases to schema expected by 0.5709.
diff --git a/rp/rcynic/rcynic-cron b/rp/rcynic/rcynic-cron
index d56d706f..53bfea9f 100755
--- a/rp/rcynic/rcynic-cron
+++ b/rp/rcynic/rcynic-cron
@@ -1,14 +1,14 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
# Portions copyright (C) 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
@@ -96,7 +96,7 @@ else:
run(os.path.join(rpki.autoconf.bindir, "rcynic"), "-c", os.path.join(rpki.autoconf.sysconfdir, "rcynic.conf"))
run(os.path.join(rpki.autoconf.bindir, "rpki-rtr"),
- "cronjob",
+ "cronjob",
os.path.join(rpki.autoconf.RCYNIC_DIR, "data/authenticated"),
cwd = os.path.join(rpki.autoconf.RCYNIC_DIR, "rpki-rtr"))
diff --git a/rp/rcynic/rcynic-html b/rp/rcynic/rcynic-html
index f0a3b574..ef566440 100755
--- a/rp/rcynic/rcynic-html
+++ b/rp/rcynic/rcynic-html
@@ -1,14 +1,14 @@
#!/usr/bin/env python
#
# $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
@@ -134,7 +134,7 @@ class Validation_Status(object):
@property
def is_backup(self):
return self.generation == "backup"
-
+
@property
def is_problem(self):
return self.label.mood != "good"
@@ -156,7 +156,7 @@ class Validation_Status(object):
return not self.label.code.startswith("rsync_transfer_")
class Problem_Mixin(object):
-
+
@property
def connection_problems(self):
result = [v for v in self.validation_status if v.is_connection_problem]
@@ -246,9 +246,9 @@ class Host(Problem_Mixin):
# differently to indicate how succesful transfer was. Intent is
# that exactly one of these be defined for every value in elapsed.
- "CDEF:success=failed,UNKN,elapsed,IF",
- "CDEF:failure=connections,1,EQ,failed,*,elapsed,UNKN,IF",
- "CDEF:partial=connections,1,NE,failed,*,elapsed,UNKN,IF",
+ r"CDEF:success=failed,UNKN,elapsed,IF",
+ r"CDEF:failure=connections,1,EQ,failed,*,elapsed,UNKN,IF",
+ r"CDEF:partial=connections,1,NE,failed,*,elapsed,UNKN,IF",
# Show connection timing first, as color-coded semi-transparent
# areas with opaque borders. Intent is to make the colors stand
@@ -256,27 +256,27 @@ class Host(Problem_Mixin):
# handled via an alpha channel (fourth octet of color code). We
# draw this stuff first so that later lines can overwrite it.
- "AREA:success#00FF0080:Sync time (success)",
- "AREA:partial#FFA50080:Sync time (partial failure)",
- "AREA:failure#FF000080:Sync time (total failure)",
+ r"AREA:success#00FF0080:Sync time (success)",
+ r"AREA:partial#FFA50080:Sync time (partial failure)",
+ r"AREA:failure#FF000080:Sync time (total failure)",
- "LINE1:success#00FF00", # Green
- "LINE1:partial#FFA500", # Orange
- "LINE1:failure#FF0000", # Red
+ r"LINE1:success#00FF00", # Green
+ r"LINE1:partial#FFA500", # Orange
+ r"LINE1:failure#FF0000", # Red
# Now show object counts, as a simple black line.
- "LINE1:objects#000000:Objects", # Black
+ r"LINE1:objects#000000:Objects", # Black
# Add averages over period to chart legend.
- "VDEF:avg_elapsed=elapsed,AVERAGE",
- "VDEF:avg_connections=connections,AVERAGE",
- "VDEF:avg_objects=objects,AVERAGE",
- "COMMENT:\j",
- "GPRINT:avg_elapsed:Average sync time (seconds)\: %5.2lf",
- "GPRINT:avg_connections:Average connection count\: %5.2lf",
- "GPRINT:avg_objects:Average object count\: %5.2lf" )
+ r"VDEF:avg_elapsed=elapsed,AVERAGE",
+ r"VDEF:avg_connections=connections,AVERAGE",
+ r"VDEF:avg_objects=objects,AVERAGE",
+ r"COMMENT:\j",
+ r"GPRINT:avg_elapsed:Average sync time (seconds)\: %5.2lf",
+ r"GPRINT:avg_connections:Average connection count\: %5.2lf",
+ r"GPRINT:avg_objects:Average object count\: %5.2lf" )
graph_periods = (("week", "-1w"),
("month", "-31d"),
@@ -303,6 +303,7 @@ class Host(Problem_Mixin):
"%s:%s" % (self.timestamp, ":".join(str(v) for v in self.field_values))])
def rrd_graph(self, html):
+ # pylint: disable=W0622
filebase = os.path.join(args.output_directory, self.hostname)
formats = [format for format in ("png", "svg", "eps")
if getattr(args, format + "_width") and getattr(args, format + "_height")]
@@ -331,7 +332,7 @@ class Host(Problem_Mixin):
svg_html.BodyElement("img", src = "%s_%s.svg" % (self.hostname, period))
svg_html.close()
-
+
class Session(Problem_Mixin):
def __init__(self):
@@ -479,7 +480,7 @@ class HTML(object):
self.filename = os.path.join(args.output_directory, filebase + ".html")
self.html = Element("html")
- self.html.append(Comment(" Generators:\n" +
+ self.html.append(Comment(" Generators:\n" +
" " + session.rcynic_version + "\n" +
" $Id$\n"))
self.head = SubElement(self.html, "head")
@@ -546,7 +547,7 @@ class HTML(object):
td.text = str(count)
return table
- def object_count_table(self, session):
+ def object_count_table(self, session): # pylint: disable=W0621
table = self.BodyElement("table", rules = "all", border = "1")
thead = SubElement(table, "thead")
tbody = SubElement(table, "tbody")
@@ -595,7 +596,7 @@ class HTML(object):
def main():
global session
-
+
os.putenv("TZ", "UTC")
time.tzset()
diff --git a/rp/rcynic/rcynic-svn b/rp/rcynic/rcynic-svn
index c667ec4a..28b24672 100755
--- a/rp/rcynic/rcynic-svn
+++ b/rp/rcynic/rcynic-svn
@@ -24,7 +24,6 @@ import subprocess
import argparse
import datetime
import fcntl
-import glob
import os
try:
@@ -43,34 +42,34 @@ mime_types = (
("gbr", "application/rpki-ghostbusters"))
-def run(*cmd, **kwargs):
+def run(*argv, **kwargs):
"""
Run a program, displaying timing data when appropriate.
"""
- t = datetime.datetime.utcnow()
- subprocess.check_call(cmd, **kwargs)
+ _t0 = datetime.datetime.utcnow()
+ subprocess.check_call(argv, **kwargs)
if args.show_timing:
- now = datetime.datetime.utcnow()
- print now, (now - t), " ".join(cmd)
+ _t1 = datetime.datetime.utcnow()
+ print _t1, (_t1 - _t0), " ".join(argv)
-def runxml(*cmd):
+def runxml(*argv):
"""
Run a program which produces XML output, displaying timing data when
appropriate and returning an ElementTree constructed from the
program's output.
"""
- t = datetime.datetime.utcnow()
- p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
+ _t0 = datetime.datetime.utcnow()
+ p = subprocess.Popen(argv, stdout = subprocess.PIPE)
x = ElementTree(file = p.stdout)
s = p.wait()
if s:
- raise subprocess.CalledProcessError(s, cmd[0])
+ raise subprocess.CalledProcessError(s, argv[0])
if args.show_timing:
- now = datetime.datetime.utcnow()
- print now, (now - t), " ".join(cmd)
+ _t1 = datetime.datetime.utcnow()
+ print _t1, (_t1 - _t0), " ".join(argv)
return x
@@ -188,5 +187,5 @@ run("svn", "commit", "--quiet", "--message", "Auto update.", args.working_direct
run("svn", "update", "--quiet", args.working_directory)
if args.show_timing:
- now = datetime.datetime.utcnow()
- print now, now - t0, "total runtime"
+ t1 = datetime.datetime.utcnow()
+ print t1, t1 - t0, "total runtime"
diff --git a/rp/rcynic/rcynic-text b/rp/rcynic/rcynic-text
index c837e88b..db4126ce 100755
--- a/rp/rcynic/rcynic-text
+++ b/rp/rcynic/rcynic-text
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
-#
+#
# Permission to use, copy, modify, and/or 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,
@@ -88,7 +88,7 @@ class Session(object):
hostnames = sorted(hostname for hostname in self.hosts if hostname is not None)
hostwidth = max(len(hostname) for hostname in hostnames + ["Hostname"])
separator = "+-%s-+-%s-+" % (
- "-" * hostwidth,
+ "-" * hostwidth,
"-+-".join("-" * label.width for label in visible))
print separator
for i in xrange(max(len(label.lines) for label in visible)):
diff --git a/rp/rcynic/rpki-torrent.py b/rp/rcynic/rpki-torrent.py
index c823aad9..2c6aa64d 100644
--- a/rp/rcynic/rpki-torrent.py
+++ b/rp/rcynic/rpki-torrent.py
@@ -75,16 +75,29 @@ class CouldNotFindTorrents(Exception):
class UseTheSourceLuke(Exception):
"Use The Source, Luke."
+cfg = None
+
def main():
try:
- syslog_flags = syslog.LOG_PID;
+ syslog_flags = syslog.LOG_PID
if os.isatty(sys.stderr.fileno()):
syslog_flags |= syslog.LOG_PERROR
syslog.openlog("rpki-torrent", syslog_flags)
+ # If I seriously expected this script to get a lot of further use,
+ # I might rewrite this using subparsers, but it'd be a bit tricky
+ # as argparse doesn't support making the subparser argument
+ # optional and transmission gives no sane way to provide arguments
+ # when running a completion script. So, for the moment, let's
+ # just fix the bugs accidently introduced while converting the
+ # universe to argparse without making any radical changes to the
+ # program structure here, even if the result looks kind of klunky.
+
parser = argparse.ArgumentParser(description = __doc__)
parser.add_argument("-c", "--config",
help = "configuration file")
+ parser.add_argument("action", choices = ("poll", "generate", "mirror"), nargs = "?",
+ help = "action to take")
args = parser.parse_args()
global cfg
@@ -95,22 +108,21 @@ def main():
for dn in ("/var/rcynic/etc", "/usr/local/etc", "/etc")])
if cfg.act_as_generator:
- if len(argv) == 1 and argv[0] == "generate":
+ if args.action == "generate":
generator_main()
- elif len(argv) == 1 and argv[0] == "mirror":
+ elif args.action == "mirror":
mirror_main()
else:
raise UseTheSourceLuke
-
else:
- if len(argv) == 0 and all(v in os.environ for v in tr_env_vars):
+ if args.action is None and all(v in os.environ for v in tr_env_vars):
torrent_completion_main()
- elif len(argv) == 1 and argv[0] == "poll":
+ elif args.action == "poll":
poll_main()
else:
raise UseTheSourceLuke
- except Exception, e:
+ except:
for line in traceback.format_exc().splitlines():
syslog.syslog(line)
sys.exit(1)
@@ -126,7 +138,7 @@ def generator_main():
self._log(paramiko.common.DEBUG, 'atomic_rename(%r, %r)' % (oldpath, newpath))
self._request(paramiko.sftp.CMD_EXTENDED, "posix-rename@openssh.com", oldpath, newpath)
- z = ZipFile(url = cfg.generate_url, dir = cfg.zip_dir)
+ z = ZipFile(url = cfg.generate_url, dn = cfg.zip_dir)
client = TransmissionClient()
client.remove_torrents(z.torrent_name)
@@ -147,7 +159,7 @@ def generator_main():
except OSError, e:
if e.errno != errno.ENOENT:
raise
- ignore_output_for_now = subprocess.check_output(
+ ignore_output_for_now = subprocess.check_output( # pylint: disable=W0612
(cfg.mktorrent_prog,
"-a", cfg.tracker_url,
"-c", "RPKI unauthenticated data snapshot generated by rpki-torrent",
@@ -212,7 +224,7 @@ def mirror_main():
for zip_url in cfg.zip_urls:
if zip_url != cfg.generate_url:
- z = ZipFile(url = zip_url, dir = cfg.zip_dir, ta = cfg.zip_ta)
+ z = ZipFile(url = zip_url, dn = cfg.zip_dir, ta = cfg.zip_ta)
if z.fetch():
client.remove_torrents(z.torrent_name)
syslog.syslog("Mirroring torrent %s" % z.torrent_name)
@@ -226,7 +238,7 @@ def mirror_main():
def poll_main():
for zip_url in cfg.zip_urls:
- z = ZipFile(url = zip_url, dir = cfg.zip_dir, ta = cfg.zip_ta)
+ z = ZipFile(url = zip_url, dn = cfg.zip_dir, ta = cfg.zip_ta)
client = TransmissionClient()
if z.fetch():
@@ -242,7 +254,7 @@ def torrent_completion_main():
torrent_name = os.getenv("TR_TORRENT_NAME")
torrent_id = int(os.getenv("TR_TORRENT_ID"))
- z = ZipFile(url = cfg.find_url(torrent_name), dir = cfg.zip_dir, ta = cfg.zip_ta)
+ z = ZipFile(url = cfg.find_url(torrent_name), dn = cfg.zip_dir, ta = cfg.zip_ta)
client = TransmissionClient()
torrent = client.info([torrent_id]).popitem()[1]
@@ -324,12 +336,12 @@ class ZipFile(object):
may first need to be fetched via HTTPS.
"""
- def __init__(self, url, dir, ta = None, verbose = True):
+ def __init__(self, url, dn, ta = None, verbose = True):
self.url = url
- self.dir = dir
+ self.dir = dn
self.ta = ta
self.verbose = verbose
- self.filename = os.path.join(dir, os.path.basename(url))
+ self.filename = os.path.join(dn, os.path.basename(url))
self.changed = False
self.zf = None
self.peercert = None
@@ -401,7 +413,7 @@ class ZipFile(object):
tempname = self.filename + ".new"
f = open(tempname, "wb")
n = int(r.info()["Content-Length"])
- for i in xrange(0, n - bufsize, bufsize):
+ for i in xrange(0, n - bufsize, bufsize): # pylint: disable=W0612
f.write(r.read(bufsize))
f.write(r.read())
f.close()
@@ -510,7 +522,7 @@ def create_manifest(topdir, torrent_name):
result = {}
topdir = os.path.abspath(topdir)
- for dirpath, dirnames, filenames in os.walk(os.path.join(topdir, torrent_name)):
+ for dirpath, dirnames, filenames in os.walk(os.path.join(topdir, torrent_name)): # pylint: disable=W0612
for filename in filenames:
filename = os.path.join(dirpath, filename)
f = open(filename, "rb")
@@ -697,7 +709,7 @@ class MyConfigParser(ConfigParser.RawConfigParser):
yield getter(self.rpki_torrent_section, name)
name += "."
names = [i for i in self.options(self.rpki_torrent_section) if i.startswith(name) and i[len(name):].isdigit()]
- names.sort(key = lambda s: int(s[len(name):]))
+ names.sort(key = lambda s: int(s[len(name):])) # pylint: disable=W0631
for name in names:
yield getter(self.rpki_torrent_section, name)
diff --git a/rp/rcynic/validation_status b/rp/rcynic/validation_status
index 1ff17e75..a3ee36f1 100755
--- a/rp/rcynic/validation_status
+++ b/rp/rcynic/validation_status
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
-#
+#
# Permission to use, copy, modify, and/or 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/rp/utils/find_roa b/rp/utils/find_roa
index 1fc0af3d..4cfcccac 100755
--- a/rp/utils/find_roa
+++ b/rp/utils/find_roa
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -22,8 +22,6 @@ matching specified prefixes.
"""
import os
-import sys
-import base64
import argparse
import rpki.POW
import rpki.oids
@@ -54,7 +52,7 @@ class Prefix(object):
def __init__(self, val):
addr, length = val.split("/")
- length, sep, maxlength = length.partition("-")
+ length, sep, maxlength = length.partition("-") # pylint: disable=W0612
self.prefix = rpki.POW.IPAddress(addr)
self.length = int(length)
self.maxlength = int(maxlength) if maxlength else self.length
diff --git a/rp/utils/hashdir b/rp/utils/hashdir
index 2f02cd3b..d3fe393c 100755
--- a/rp/utils/hashdir
+++ b/rp/utils/hashdir
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rp/utils/print_roa b/rp/utils/print_roa
index fd7308d1..d5db0c3c 100755
--- a/rp/utils/print_roa
+++ b/rp/utils/print_roa
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -21,8 +21,6 @@ Pretty-print the content of a ROA. Does NOT attempt to verify the
signature.
"""
-import os
-import sys
import argparse
import rpki.POW
diff --git a/rp/utils/print_rpki_manifest b/rp/utils/print_rpki_manifest
index 778b4310..5ebc6356 100755
--- a/rp/utils/print_rpki_manifest
+++ b/rp/utils/print_rpki_manifest
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -21,8 +21,6 @@ Pretty-print the content of a manifest. Does NOT attempt to verify the
signature.
"""
-import os
-import sys
import argparse
import rpki.POW
import rpki.oids
diff --git a/rp/utils/scan_roas b/rp/utils/scan_roas
index 1f5746b1..a1b64f01 100755
--- a/rp/utils/scan_roas
+++ b/rp/utils/scan_roas
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rp/utils/scan_routercerts b/rp/utils/scan_routercerts
index aa3ed9e6..081a6293 100755
--- a/rp/utils/scan_routercerts
+++ b/rp/utils/scan_routercerts
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
diff --git a/rp/utils/uri b/rp/utils/uri
index e095eb30..e72d5e0d 100755
--- a/rp/utils/uri
+++ b/rp/utils/uri
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
# $Id$
-#
+#
# Copyright (C) 2014 Dragon Research Labs ("DRL")
-#
+#
# Permission to use, copy, modify, and/or 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 DRL DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL DRL BE LIABLE FOR ANY SPECIAL, DIRECT,
@@ -24,7 +24,6 @@ Input files must be in DER format and may be either X.509v3 certificates
or CMS objects which contain X.509v3 certificates in the CMS wrapper.
"""
-import os
import argparse
import rpki.POW
@@ -41,7 +40,7 @@ class Certificate(object):
def __init__(self, fn):
try:
x = rpki.POW.X509.derReadFile(fn)
- except:
+ except: # pylint: disable=W0702
try:
cms = rpki.POW.CMS.derReadFile(fn)
cms.extractWithoutVerifying()