From 21bf2e2e19f9a02a813645678ffa14b926e25e7c Mon Sep 17 00:00:00 2001
From: Andrea Spadaccini <spadaccio@google.com>
Date: Fri, 26 Aug 2011 16:31:12 +0100
Subject: [PATCH] PEP8 for QA

- Makefile.am: added QA directory to the paths checked by pep8
- qa/: fixed the reported errors
- Makefile.am: also, added qa_group.py to qa_scripts

Signed-off-by: Andrea Spadaccini <spadaccio@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
---
 Makefile.am      | 14 +++++++++++++-
 qa/ganeti-qa.py  |  2 +-
 qa/qa_cluster.py | 14 ++++++++------
 qa/qa_env.py     |  4 ++--
 qa/qa_error.py   |  1 +
 qa/qa_node.py    |  5 ++---
 6 files changed, 27 insertions(+), 13 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3f67337ab..48a6f5cfe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -454,6 +454,7 @@ qa_scripts = \
 	qa/qa_daemon.py \
 	qa/qa_env.py \
 	qa/qa_error.py \
+	qa/qa_group.py \
 	qa/qa_instance.py \
 	qa/qa_node.py \
 	qa/qa_os.py \
@@ -767,6 +768,17 @@ lint_python_code = \
 	$(DOCPP) \
 	$(PYTHON_BOOTSTRAP)
 
+pep8_python_code = \
+	ganeti \
+	ganeti/http/server.py \
+	$(dist_sbin_SCRIPTS) \
+	$(dist_tools_PYTHON) \
+	$(pkglib_python_scripts) \
+	$(BUILD_BASH_COMPLETION) \
+	$(DOCPP) \
+	$(PYTHON_BOOTSTRAP) \
+	qa
+
 test/daemon-util_unittest.bash: daemons/daemon-util
 
 test/ganeti-cleaner_unittest.bash: daemons/ganeti-cleaner
@@ -1087,7 +1099,7 @@ lint: $(BUILT_SOURCES)
 		echo '"pep8" not found during configure' >&2; \
 	else \
 		$(PEP8) --repeat --ignore='$(PEP8_IGNORE)' --exclude='$(PEP8_EXCLUDE)' \
-			$(lint_python_code); \
+			$(pep8_python_code); \
 	fi
 	$(PYLINT) $(LINT_OPTS) $(lint_python_code)
 	cd $(top_srcdir)/qa && \
diff --git a/qa/ganeti-qa.py b/qa/ganeti-qa.py
index 0cb88ff02..fc7abbcfa 100755
--- a/qa/ganeti-qa.py
+++ b/qa/ganeti-qa.py
@@ -54,7 +54,7 @@ def _FormatHeader(line, end=72):
 
   """
   line = "---- " + line + " "
-  line += "-" * (end-len(line))
+  line += "-" * (end - len(line))
   line = line.rstrip()
   return line
 
diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py
index bfda23674..bd3d737d5 100644
--- a/qa/qa_cluster.py
+++ b/qa/qa_cluster.py
@@ -40,6 +40,7 @@ from qa_utils import AssertEqual, AssertCommand, GetCommandOutput
 #: cluster verify command
 _CLUSTER_VERIFY = ["gnt-cluster", "verify"]
 
+
 def _RemoveFileFromAllNodes(filename):
   """Removes a file from all nodes.
 
@@ -231,14 +232,14 @@ def TestClusterReservedLvs():
     (False, _CLUSTER_VERIFY),
     (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
     (False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]),
-    (True,  _CLUSTER_VERIFY),
+    (True, _CLUSTER_VERIFY),
     (False, ["gnt-cluster", "modify", "--reserved-lvs",
              "xenvg/qa-test,.*/other-test"]),
     (False, _CLUSTER_VERIFY),
     (False, ["gnt-cluster", "modify", "--reserved-lvs", ".*/qa-.*"]),
     (False, _CLUSTER_VERIFY),
     (False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
-    (True,  _CLUSTER_VERIFY),
+    (True, _CLUSTER_VERIFY),
     (False, ["lvremove", "-f", "xenvg/qa-test"]),
     (False, _CLUSTER_VERIFY),
     ]:
@@ -251,19 +252,19 @@ def TestClusterModifyBe():
     # mem
     (False, ["gnt-cluster", "modify", "-B", "memory=256"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]),
-    (True,  ["gnt-cluster", "modify", "-B", "memory=a"]),
+    (True, ["gnt-cluster", "modify", "-B", "memory=a"]),
     (False, ["gnt-cluster", "modify", "-B", "memory=128"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]),
     # vcpus
     (False, ["gnt-cluster", "modify", "-B", "vcpus=4"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]),
-    (True,  ["gnt-cluster", "modify", "-B", "vcpus=a"]),
+    (True, ["gnt-cluster", "modify", "-B", "vcpus=a"]),
     (False, ["gnt-cluster", "modify", "-B", "vcpus=1"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]),
     # auto_balance
     (False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]),
-    (True,  ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
+    (True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
     (False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]),
     (False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]),
     ]:
@@ -274,6 +275,7 @@ def TestClusterModifyBe():
   if bep:
     AssertCommand(["gnt-cluster", "modify", "-B", bep])
 
+
 def TestClusterInfo():
   """gnt-cluster info"""
   AssertCommand(["gnt-cluster", "info"])
@@ -306,7 +308,7 @@ def TestClusterRenewCrypto():
     ["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"],
     ]
   for i in conflicting:
-    AssertCommand(cmd+i, fail=True)
+    AssertCommand(cmd + i, fail=True)
 
   # Invalid RAPI certificate
   cmd = ["gnt-cluster", "renew-crypto", "--force",
diff --git a/qa/qa_env.py b/qa/qa_env.py
index e9293b076..986128b2f 100644
--- a/qa/qa_env.py
+++ b/qa/qa_env.py
@@ -42,7 +42,7 @@ def TestGanetiCommands():
   """Test availibility of Ganeti commands.
 
   """
-  cmds = ( ["gnt-backup", "--version"],
+  cmds = (["gnt-backup", "--version"],
            ["gnt-cluster", "--version"],
            ["gnt-debug", "--version"],
            ["gnt-instance", "--version"],
@@ -76,7 +76,7 @@ def TestIcmpPing():
   seccmd = [pingsecondary, "-e"]
   for i in nodes:
     pricmd.append(i["primary"])
-    if i.has_key("secondary"):
+    if "secondary" in i:
       seccmd.append(i["secondary"])
 
   pristr = utils.ShellQuoteArgs(pricmd)
diff --git a/qa/qa_error.py b/qa/qa_error.py
index 131b69bc8..8b5d4b903 100644
--- a/qa/qa_error.py
+++ b/qa/qa_error.py
@@ -23,6 +23,7 @@
 
 """
 
+
 class Error(Exception):
   """An error occurred during Q&A testing.
 
diff --git a/qa/qa_node.py b/qa/qa_node.py
index 434de3832..8b2d406f3 100644
--- a/qa/qa_node.py
+++ b/qa/qa_node.py
@@ -275,7 +275,7 @@ def TestOutOfBand():
     # Power off on master without options should fail
     AssertCommand(["gnt-node", "power", "-f", "off", master_name], fail=True)
     # With force master it should still fail
-    AssertCommand(["gnt-node", "power", "-f",  "--ignore-status", "off",
+    AssertCommand(["gnt-node", "power", "-f", "--ignore-status", "off",
                    master_name],
                   fail=True)
 
@@ -302,7 +302,7 @@ def TestOutOfBand():
     AssertCommand(["gnt-node", "health"], fail=True)
 
     # Correct Data, exit 0
-    _UpdateOobFile(data_path, serializer.DumpJson({ "powered": True }))
+    _UpdateOobFile(data_path, serializer.DumpJson({"powered": True}))
 
     AssertCommand(["gnt-node", "power", "status", node_name])
     _AssertOobCall(verify_path, "power-status %s" % full_node_name)
@@ -315,7 +315,6 @@ def TestOutOfBand():
 
     AssertCommand(["gnt-node", "health"])
 
-
     # Those commands should fail as they expect no data regardless of exit 0
     AssertCommand(["gnt-node", "power", "on", node_name], fail=True)
     _AssertOobCall(verify_path, "power-on %s" % full_node_name)
-- 
GitLab