summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2016-03-03 16:32:32 -0600
committerRyan Harper <ryan.harper@canonical.com>2016-03-03 16:32:32 -0600
commit3d9153d16b194e7a3139c290e723ef17518e617d (patch)
tree61b036f51d187f6c06d85936cad59a11e8e1dc94
parent8cb7c3f7b5339e686bfbf95996b51afafeaf9c9e (diff)
downloadvyos-cloud-init-3d9153d16b194e7a3139c290e723ef17518e617d.tar.gz
vyos-cloud-init-3d9153d16b194e7a3139c290e723ef17518e617d.zip
Fix pyflake/pyflake3 errors
Now we can run make check to assess pep8, pyflakes for python2 or 3 And execute unittests via nosetests (2 and 3).
-rw-r--r--Makefile1
-rw-r--r--cloudinit/util.py2
-rw-r--r--tests/unittests/test_datasource/test_azure_helper.py2
-rw-r--r--tests/unittests/test_datasource/test_smartos.py1
-rw-r--r--tests/unittests/test_handler/test_handler_power_state.py2
-rwxr-xr-xtools/run-pyflakes18
-rwxr-xr-xtools/run-pyflakes32
7 files changed, 22 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index fb65b70b..fc91f829 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,6 @@ pyflakes:
pyflakes3:
@$(CWD)/tools/run-pyflakes3
-
unittest:
nosetests $(noseopts) tests/unittests
nosetests3 $(noseopts) tests/unittests
diff --git a/cloudinit/util.py b/cloudinit/util.py
index de37b0f5..e7407ea4 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -2148,7 +2148,7 @@ def _read_dmi_syspath(key):
LOG.debug("dmi data %s returned %s", dmi_key_path, key_data)
return key_data.strip()
- except Exception as e:
+ except Exception:
logexc(LOG, "failed read of %s", dmi_key_path)
return None
diff --git a/tests/unittests/test_datasource/test_azure_helper.py b/tests/unittests/test_datasource/test_azure_helper.py
index 8dbdfb0b..1134199b 100644
--- a/tests/unittests/test_datasource/test_azure_helper.py
+++ b/tests/unittests/test_datasource/test_azure_helper.py
@@ -1,6 +1,4 @@
import os
-import struct
-import unittest
from cloudinit.sources.helpers import azure as azure_helper
from ..helpers import TestCase
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index 5e617b83..616e9f0e 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -31,7 +31,6 @@ import shutil
import stat
import tempfile
import uuid
-import unittest
from binascii import crc32
import serial
diff --git a/tests/unittests/test_handler/test_handler_power_state.py b/tests/unittests/test_handler/test_handler_power_state.py
index f9660ff6..04ce5687 100644
--- a/tests/unittests/test_handler/test_handler_power_state.py
+++ b/tests/unittests/test_handler/test_handler_power_state.py
@@ -106,7 +106,7 @@ def check_lps_ret(psc_return, mode=None):
if 'shutdown' not in psc_return[0][0]:
errs.append("string 'shutdown' not in cmd")
- if 'condition' is None:
+ if condition is None:
errs.append("condition was not returned")
if mode is not None:
diff --git a/tools/run-pyflakes b/tools/run-pyflakes
new file mode 100755
index 00000000..4bea17f4
--- /dev/null
+++ b/tools/run-pyflakes
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+PYTHON_VERSION=${PYTHON_VERSION:-2}
+CR="
+"
+pycheck_dirs=( "cloudinit/" "bin/" "tests/" "tools/" )
+
+set -f
+if [ $# -eq 0 ]; then
+ files=( "${pycheck_dirs[@]}" )
+else
+ files=( "$@" )
+fi
+
+cmd=( "python${PYTHON_VERSION}" -m "pyflakes" "${files[@]}" )
+
+echo "Running: " "${cmd[@]}" 1>&2
+exec "${cmd[@]}"
diff --git a/tools/run-pyflakes3 b/tools/run-pyflakes3
new file mode 100755
index 00000000..e9f0863d
--- /dev/null
+++ b/tools/run-pyflakes3
@@ -0,0 +1,2 @@
+#!/bin/sh
+PYTHON_VERSION=3 exec "${0%/*}/run-pyflakes" "$@"