From 68acdc03a0a7a6893df5360995098c40ec54e92c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 9 May 2014 12:48:31 +0100 Subject: [PATCH] build: Add 'make lint' rule and fix some problems found by pylint. --- Makefile.am | 5 +++++ mclu.py | 7 ++++--- node.py | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 1d9c8bc..abdbe83 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,3 +57,8 @@ CLEANFILES = \ config.py \ mclu \ mclu.spec + +# Run pylint. + +lint: + pylint -E $(pkgdata_SCRIPTS) diff --git a/mclu.py b/mclu.py index 0d1c72d..c0ab197 100755 --- a/mclu.py +++ b/mclu.py @@ -16,10 +16,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -import os -import re import argparse import ConfigParser +import os +import re +import sys import config from node import Node @@ -103,7 +104,7 @@ nodes = {} for node_name in node_names: host = conf.get (node_name, "host") if not host: - host = node + host = node_name mac = conf.get (node_name, "mac") uri = conf.get (node_name, "uri") node = Node (node_name, host, mac, uri) diff --git a/node.py b/node.py index 345c4c2..613a456 100644 --- a/node.py +++ b/node.py @@ -17,6 +17,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os +import sys import subprocess import libvirt @@ -28,11 +29,13 @@ class Node: self.host = host self.mac = mac self.uri = uri + self.conn = None + self.up = None def ping (self, force = False): """Test if node is up.""" if not force: - if hasattr (self, 'up'): + if self.up is not None: return self.up devnull = open (os.devnull, "w") @@ -90,7 +93,7 @@ class Node: """Return cached libvirt connection, fail if not possible.""" if not self.ping (): sys.exit ("error: node %s is not awake" % self.name) - if hasattr (self, 'conn'): + if self.conn is not None: return self.conn conn = libvirt.open (self.uri) if conn == None: -- 1.8.3.1