diff options
-rw-r--r-- | rpkid/Makefile | 8 | ||||
-rw-r--r-- | rpkid/cronjob.py | 4 | ||||
-rw-r--r-- | rpkid/cross_certify.py | 6 | ||||
-rw-r--r-- | rpkid/extract-key.py | 6 | ||||
-rw-r--r-- | rpkid/irbe-setup.py | 8 | ||||
-rwxr-xr-x | rpkid/irbe_cli.py | 2 | ||||
-rwxr-xr-x | rpkid/irdbd.py | 4 | ||||
-rw-r--r-- | rpkid/missing-oids.py | 2 | ||||
-rwxr-xr-x | rpkid/pubd.py | 4 | ||||
-rwxr-xr-x | rpkid/rootd.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/config.py | 6 | ||||
-rw-r--r-- | rpkid/rpki/https.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/oids.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/resource_set.py | 4 | ||||
-rw-r--r-- | rpkid/rpki/sql.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/up_down.py | 2 | ||||
-rw-r--r-- | rpkid/rpki/xml_utils.py | 4 | ||||
-rwxr-xr-x | rpkid/rpkid.py | 4 | ||||
-rw-r--r-- | rpkid/testbed.py | 6 | ||||
-rw-r--r-- | rpkid/testpoke.py | 4 | ||||
-rw-r--r-- | rtr-origin/rtr-origin.py | 10 | ||||
-rw-r--r-- | scripts/pylint.rc | 201 |
22 files changed, 247 insertions, 52 deletions
diff --git a/rpkid/Makefile b/rpkid/Makefile index 981085c7..04059c84 100644 --- a/rpkid/Makefile +++ b/rpkid/Makefile @@ -135,11 +135,5 @@ dox doxygen: irbe_cli.usage doc/irdbd.dot doc/pubd.dot doc/rpkid.dot doc:: dox -# Preliminary experiment with pylint. Its default coding style -# differs enough from mine that it's not really usable without -# customization. In the long run this should be use a pylint config -# file rather than attempting to do it inline here. Useful options -# which lead to the others: --help, --rcfile, --generate-rcfile. - lint: - find * -name .svn -prune -o -type f -name '*.py' -print0 | xargs -0 pylint --output-format parseable --indent-string ' ' + pylint --rcfile ../scripts/pylint.rc rpki/[a-z]*.py cronjob.py cross_certify.py irbe_cli.py irdbd.py pubd.py rootd.py rpkid.py testbed.py testpoke.py diff --git a/rpkid/cronjob.py b/rpkid/cronjob.py index 12765ba1..22cadd2c 100644 --- a/rpkid/cronjob.py +++ b/rpkid/cronjob.py @@ -29,8 +29,8 @@ import rpki.config, rpki.https, getopt, sys cfg_file = "cronjob.conf" debug = False -opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/rpkid/cross_certify.py b/rpkid/cross_certify.py index 88c5718f..97d436af 100644 --- a/rpkid/cross_certify.py +++ b/rpkid/cross_certify.py @@ -46,9 +46,9 @@ def usage(code): output = None lifetime = rpki.sundial.timedelta(days = 30) -opts,argv = getopt.getopt(sys.argv[1:], "h?i:o:c:k:s:l:", - ["help", "in=", "out=", "ca=", "key=", "serial=", "lifetime="]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "h?i:o:c:k:s:l:", + ["help", "in=", "out=", "ca=", "key=", "serial=", "lifetime="]) +for o, a in opts: if o in ("-h", "--help", "-?"): usage(0) elif o in ("-i", "--in"): diff --git a/rpkid/extract-key.py b/rpkid/extract-key.py index dabca32a..74db1c02 100644 --- a/rpkid/extract-key.py +++ b/rpkid/extract-key.py @@ -53,9 +53,9 @@ user = "rpki" passwd = "fnord" db = "rpki" -opts,argv = getopt.getopt(sys.argv[1:], "s:b:u:p:d:h?", - ["self=", "bsc=", "user=", "password=", "db=", "help"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "s:b:u:p:d:h?", + ["self=", "bsc=", "user=", "password=", "db=", "help"]) +for o, a in opts: if o in ("-h", "--help", "-?"): usage(0) elif o in ("-s", "--self"): diff --git a/rpkid/irbe-setup.py b/rpkid/irbe-setup.py index 15b0d346..e04f4abe 100644 --- a/rpkid/irbe-setup.py +++ b/rpkid/irbe-setup.py @@ -66,10 +66,10 @@ pdu = call_rpkid(pdu) bsc_id = pdu.bsc_id print "Issue the business cert" -i,o = os.popen2(("openssl", "x509", "-req", - "-CA", "biz-certs/Bob-CA.cer", - "-CAkey", "biz-certs/Bob-CA.key", - "-CAserial", "biz-certs/Bob-CA.srl")) +i, o = os.popen2(("openssl", "x509", "-req", + "-CA", "biz-certs/Bob-CA.cer", + "-CAkey", "biz-certs/Bob-CA.key", + "-CAserial", "biz-certs/Bob-CA.srl")) i.write(pdu.pkcs10_request.get_PEM()) i.close() cer = rpki.x509.X509(PEM = o.read()) diff --git a/rpkid/irbe_cli.py b/rpkid/irbe_cli.py index 8c2b3d81..af18d591 100755 --- a/rpkid/irbe_cli.py +++ b/rpkid/irbe_cli.py @@ -106,7 +106,7 @@ class cmd_msg_mixin(object): @classmethod def usage(cls): """Generate usage message for this PDU.""" - for k,v in cls.pdus.items(): + for k, v in cls.pdus.items(): print usage_fill(k, v.usage()) # left-right protcol diff --git a/rpkid/irdbd.py b/rpkid/irdbd.py index 46669049..5274926f 100755 --- a/rpkid/irdbd.py +++ b/rpkid/irdbd.py @@ -88,8 +88,8 @@ rpki.log.init("irdbd") cfg_file = "irdbd.conf" -opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/rpkid/missing-oids.py b/rpkid/missing-oids.py index c9597531..f5571753 100644 --- a/rpkid/missing-oids.py +++ b/rpkid/missing-oids.py @@ -22,7 +22,7 @@ import POW.pkix, rpki.oids need_header = True -for oid,name in rpki.oids.oid2name.items(): +for oid, name in rpki.oids.oid2name.items(): try: POW.pkix.oid2obj(oid) except: diff --git a/rpkid/pubd.py b/rpkid/pubd.py index 5fbfcb9a..1fb2bace 100755 --- a/rpkid/pubd.py +++ b/rpkid/pubd.py @@ -115,8 +115,8 @@ rpki.log.init("pubd") cfg_file = "pubd.conf" profile = False -opts,argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help"]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/rpkid/rootd.py b/rpkid/rootd.py index 74157281..65af010b 100755 --- a/rpkid/rootd.py +++ b/rpkid/rootd.py @@ -177,7 +177,7 @@ class message_pdu(rpki.up_down.message_pdu): "revoke" : revoke_pdu, "revoke_response" : rpki.up_down.revoke_response_pdu, "error_response" : rpki.up_down.error_response_pdu } - type2name = dict((v,k) for k,v in name2type.items()) + type2name = dict((v, k) for k, v in name2type.items()) class sax_handler(rpki.up_down.sax_handler): pdu = message_pdu @@ -213,8 +213,8 @@ rpki.log.init("rootd") cfg_file = "rootd.conf" -opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/rpkid/rpki/config.py b/rpkid/rpki/config.py index df856311..72bbc589 100644 --- a/rpkid/rpki/config.py +++ b/rpkid/rpki/config.py @@ -22,11 +22,11 @@ import ConfigParser class parser(ConfigParser.RawConfigParser): - def __init__(self, file = None, section = None): + def __init__(self, filename = None, section = None): """Initialize this parser.""" ConfigParser.RawConfigParser.__init__(self) - if file: - self.read(file) + if filename: + self.read(filename) self.default_section = section def multiget(self, option, section = None): diff --git a/rpkid/rpki/https.py b/rpkid/rpki/https.py index 0e51cec9..b461f0cf 100644 --- a/rpkid/rpki/https.py +++ b/rpkid/rpki/https.py @@ -216,7 +216,7 @@ class requestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def rpki_find_handler(self): """Helper method to search self.rpki_handlers.""" - for s,h in self.rpki_handlers: + for s, h in self.rpki_handlers: if self.path.startswith(s): return h return None @@ -321,5 +321,5 @@ def server(handlers, server_key, server_cert, port = 4433, host ="", client_ta = except rpki.exceptions.ServerShuttingDown: pass finally: - for sig,handler in old_signal_handlers: + for sig, handler in old_signal_handlers: signal.signal(sig, handler) diff --git a/rpkid/rpki/oids.py b/rpkid/rpki/oids.py index 5824ad17..59c36cf8 100644 --- a/rpkid/rpki/oids.py +++ b/rpkid/rpki/oids.py @@ -54,4 +54,4 @@ oid2name = { ## @var name2oid # Mapping table of string names to OIDs -name2oid = dict((v,k) for k,v in oid2name.items()) +name2oid = dict((v, k) for k, v in oid2name.items()) diff --git a/rpkid/rpki/resource_set.py b/rpkid/rpki/resource_set.py index baaccfc4..10736812 100644 --- a/rpkid/rpki/resource_set.py +++ b/rpkid/rpki/resource_set.py @@ -307,7 +307,7 @@ class resource_set(list): sql.execute(query, args) return cls(ini = [cls.range_type(cls.range_type.datum_type(b), cls.range_type.datum_type(e)) - for (b,e) in sql.fetchall()]) + for (b, e) in sql.fetchall()]) class resource_set_as(resource_set): """ASN resource set.""" @@ -690,7 +690,7 @@ class roa_prefix_set(list): sql.execute(query, args) return cls([cls.prefix_type(cls.prefix_type.range_type.datum_type(x), int(y), int(z)) - for (x,y,z) in sql.fetchall()]) + for (x, y, z) in sql.fetchall()]) def to_roa_tuple(self): """Convert ROA prefix set into tuple format used by ROA ASN.1 encoder. diff --git a/rpkid/rpki/sql.py b/rpkid/rpki/sql.py index 6705e53b..61c1ed8f 100644 --- a/rpkid/rpki/sql.py +++ b/rpkid/rpki/sql.py @@ -97,7 +97,7 @@ class template(object): """SQL template generator.""" def __init__(self, table_name, index_column, *data_columns): """Build a SQL template.""" - type_map = dict((x[0],x[1]) for x in data_columns if isinstance(x, tuple)) + type_map = dict((x[0], x[1]) for x in data_columns if isinstance(x, tuple)) data_columns = tuple(isinstance(x, tuple) and x[0] or x for x in data_columns) columns = (index_column,) + data_columns self.table = table_name diff --git a/rpkid/rpki/up_down.py b/rpkid/rpki/up_down.py index 2d087b0d..e5031c00 100644 --- a/rpkid/rpki/up_down.py +++ b/rpkid/rpki/up_down.py @@ -476,7 +476,7 @@ class message_pdu(base_elt): "revoke_response" : revoke_response_pdu, "error_response" : error_response_pdu } - type2name = dict((v,k) for k,v in name2type.items()) + type2name = dict((v, k) for k, v in name2type.items()) def toXML(self): """Generate payload of message PDU.""" diff --git a/rpkid/rpki/xml_utils.py b/rpkid/rpki/xml_utils.py index 2f29b312..566c9a50 100644 --- a/rpkid/rpki/xml_utils.py +++ b/rpkid/rpki/xml_utils.py @@ -62,7 +62,7 @@ class sax_handler(xml.sax.handler.ContentHandler): that's the object we'll be returning as our final result. """ a = dict() - for k,v in attrs.items(): + for k, v in attrs.items(): if isinstance(k, tuple): if k == ("http://www.w3.org/XML/1998/namespace", "lang"): k = "xml:lang" @@ -168,7 +168,7 @@ class base_elt(object): def make_pdu(cls, **kargs): """Generic PDU constructor.""" self = cls() - for k,v in kargs.items(): + for k, v in kargs.items(): if isinstance(v, bool): v = 1 if v else 0 setattr(self, k, v) diff --git a/rpkid/rpkid.py b/rpkid/rpkid.py index e9f16941..0990c39d 100755 --- a/rpkid/rpkid.py +++ b/rpkid/rpkid.py @@ -37,8 +37,8 @@ rpki.log.init("rpkid") cfg_file = "rpkid.conf" profile = None -opts,argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help", "profile="]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:hp:?", ["config=", "help", "profile="]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/rpkid/testbed.py b/rpkid/testbed.py index 6df60086..f47f71c3 100644 --- a/rpkid/testbed.py +++ b/rpkid/testbed.py @@ -63,8 +63,8 @@ profile = False # Debugging hack whiel converting to event-driven I/O rpki.https.trace_synchronous_calls = True -opts,argv = getopt.getopt(sys.argv[1:], "c:hpy:?", ["config=", "help", "profile", "yaml="]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:hpy:?", ["config=", "help", "profile", "yaml="]) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) @@ -242,7 +242,7 @@ class main(object): rpki.log.info("Shutting down") for a in self.db.engines: a.kill_daemons() - for p,n in ((self.rootd_process, "rootd"), (self.pubd_process, "pubd"), (self.rsyncd_process, "rsyncd")): + for p, n in ((self.rootd_process, "rootd"), (self.pubd_process, "pubd"), (self.rsyncd_process, "rsyncd")): if p is not None: rpki.log.info("Killing %s" % n) os.kill(p.pid, signal.SIGTERM) diff --git a/rpkid/testpoke.py b/rpkid/testpoke.py index e1c583e4..86e7aaef 100644 --- a/rpkid/testpoke.py +++ b/rpkid/testpoke.py @@ -43,8 +43,8 @@ yaml_file = "testpoke.yaml" yaml_cmd = None debug = False -opts,argv = getopt.getopt(sys.argv[1:], "y:r:h?d", ["yaml=", "request=", "help", "debug"]) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "y:r:h?d", ["yaml=", "request=", "help", "debug"]) +for o, a in opts: if o in ("-h", "--help", "-?"): usage(0) elif o in ("-y", "--yaml"): diff --git a/rtr-origin/rtr-origin.py b/rtr-origin/rtr-origin.py index bab00a20..61c161de 100644 --- a/rtr-origin/rtr-origin.py +++ b/rtr-origin/rtr-origin.py @@ -237,7 +237,8 @@ class reset_query(pdu_empty): self.send_nodata(server) else: try: - self.send_file(server, "%s.ax" % server.current_serial) + fn = "%s.ax" % server.current_serial + self.send_file(server, fn) except IOError: server.push_pdu(error_report(errno = error_report.codes["Internal Error"], errpdu = self, errmsg = "Couldn't open %s" % fn)) @@ -369,7 +370,7 @@ class error_report(pdu): 1 : "Internal Error", 2 : "No Data Available" } - codes = dict((v,k) for k,v in msgs.items()) + codes = dict((v, k) for k, v in msgs.items()) def __init__(self, errno = None, errpdu = None, errmsg = None): assert errno is None or errno in self.msgs @@ -844,7 +845,6 @@ def client_main(argv): if argv: raise RuntimeError, "Unexpected arguments: %s" % argv client = None - timer = None try: client = client_channel("ssh", "-p", "2222", "-s", "localhost", "rpki-rtr") client.push_pdu(reset_query()) @@ -872,8 +872,8 @@ main_dispatch = { "server" : server_main, "show" : show_main } -opts,argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"] + main_dispatch.keys()) -for o,a in opts: +opts, argv = getopt.getopt(sys.argv[1:], "c:h?", ["config=", "help"] + main_dispatch.keys()) +for o, a in opts: if o in ("-h", "--help", "-?"): print __doc__ sys.exit(0) diff --git a/scripts/pylint.rc b/scripts/pylint.rc new file mode 100644 index 00000000..08f76fbb --- /dev/null +++ b/scripts/pylint.rc @@ -0,0 +1,201 @@ +# $Id$ +# +# Preliminary experiment with pylint. Its default coding style +# differs enough from mine that it's not really usable without +# customization. Useful options: --help, --generate-rcfile. + +[MASTER] + +profile=no +ignore=.svn +persistent=yes +cache-size=500 +load-plugins= + +[MESSAGES CONTROL] + +# Enable only checker(s) with the given id(s). This option conflicts with the +# disable-checker option +#enable-checker= + +# Enable all checker(s) except those with the given id(s). This option +# conflicts with the enable-checker option +#disable-checker= + +# Enable all messages in the listed categories (IRCWEF). +#enable-msg-cat= + +# Disable all messages in the listed categories (IRCWEF). +disable-msg-cat= + +# Enable the message(s) with the given id(s). +#enable-msg= + +# Disable the message(s) with the given id(s). +disable-msg=R0801,R0903,R0913,C0321,R0904,W0201,E1101,W0614,C0301,R0901,C0302,R0902,R0201,W0613,R0912,R0915,W0703,W0212 + +[REPORTS] + +output-format=parseable +include-ids=yes +files-output=no +reports=no +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) +comment=no + +[VARIABLES] + +# Tells wether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching names used for dummy variables (i.e. not used). +dummy-variables-rgx=ignored + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + +[TYPECHECK] + +# Tells wether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=no + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamicaly set). +ignored-classes=SQLObject + +# When zope mode is activated, add a predefined set of Zope acquired attributes +# to generated-members. +zope=no + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. +generated-members= + +[BASIC] + +# Required attributes for module, separated by a comma +required-attributes= + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__|usage + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([a-zA-Z_][a-zA-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[a-zA-Z_][a-zA-Z0-9_]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-zA-Z_][a-zA-Z0-9_]+$ + +# Regular expression which should only match correct method names +method-rgx=[a-zA-Z_][a-zA-Z0-9_]+$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[a-zA-Z_][a-zA-Z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names= + +# Bad variable names which should always be refused, separated by a comma +bad-names= + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,string,TERMIOS,Bastion,rexec + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report R0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report R0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report R0402 must +# not be disabled) +int-import-graph= + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. +ignore-iface-methods= + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=80 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. +indent-string=' ' + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO |