[PATCH V4 0/4] check the python code with pyflakes

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> V3 -> V4 address Rodrigo's comment. add delete the cloned template in rollback. V2 -> V3 address zhengsheng's comment. improve the SKIP_PYFLAKES_ERR list. V1 -> V2 address Crístian'comment: remove the whole statement "info = self._get_vm(name).inf" address ming's comment: break down the patch into small patches by the pyflakes error. Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster. This is important to improve the code quality. ShaoHe Feng (4): make pyflakes happly, remove the unused import module make pyflakes happly, remove unused availables add template_delete to rollback after create a template run pyflakes when make check Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- src/kimchi/control/plugins.py | 2 +- src/kimchi/featuretests.py | 2 -- src/kimchi/mockmodel.py | 5 ++--- src/kimchi/model/storagepools.py | 2 +- src/kimchi/screenshot.py | 1 - src/kimchi/template.py | 1 - tests/test_model.py | 2 ++ tests/test_server.py | 1 - ui/pages/help/gen-index.py | 1 - 14 files changed, 25 insertions(+), 14 deletions(-) -- 1.8.5.3

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> remove the unused import module. make pyflakes happly before introduce pyflakes. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- src/kimchi/control/plugins.py | 2 +- src/kimchi/featuretests.py | 2 -- src/kimchi/mockmodel.py | 2 +- src/kimchi/screenshot.py | 1 - src/kimchi/template.py | 1 - tests/test_server.py | 1 - ui/pages/help/gen-index.py | 1 - 7 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py index 8dc2273..12c621e 100644 --- a/src/kimchi/control/plugins.py +++ b/src/kimchi/control/plugins.py @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA import kimchi.template -from kimchi.control.base import Collection, Resource +from kimchi.control.base import Collection from kimchi.control.utils import get_class_name, model_fn from kimchi.control.utils import UrlSubNode diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index a6a28fa..07d5676 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -20,7 +20,6 @@ import cherrypy import libvirt import lxml.etree as ET -import os import socket import subprocess import threading @@ -29,7 +28,6 @@ import threading from lxml.builder import E -from kimchi import config from kimchi.utils import kimchi_log diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index d40f61a..8ff3dbf 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -51,7 +51,7 @@ from kimchi.model.utils import get_vm_name from kimchi.model.vms import VM_STATIC_UPDATE_PARAMS from kimchi.objectstore import ObjectStore from kimchi.screenshot import VMScreenshot -from kimchi.utils import pool_name_from_uri, run_command +from kimchi.utils import pool_name_from_uri from kimchi.utils import template_name_from_uri from kimchi.vmtemplate import VMTemplate diff --git a/src/kimchi/screenshot.py b/src/kimchi/screenshot.py index 6c8a599..0040d7c 100644 --- a/src/kimchi/screenshot.py +++ b/src/kimchi/screenshot.py @@ -20,7 +20,6 @@ import glob import os -import random import signal import tempfile import time diff --git a/src/kimchi/template.py b/src/kimchi/template.py index 5707121..9bb2da5 100644 --- a/src/kimchi/template.py +++ b/src/kimchi/template.py @@ -20,7 +20,6 @@ import cherrypy import errno import json -import os from kimchi.config import paths diff --git a/tests/test_server.py b/tests/test_server.py index d7b93ad..d06e17a 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -17,7 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -import json import os import unittest diff --git a/ui/pages/help/gen-index.py b/ui/pages/help/gen-index.py index 56cbf47..cf7c5d7 100755 --- a/ui/pages/help/gen-index.py +++ b/ui/pages/help/gen-index.py @@ -18,7 +18,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -import glob import libxml2 import sys -- 1.8.5.3

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014-03-21Fri的 07:34 +0800,shaohef@linux.vnet.ibm.com:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
remove the unused import module. make pyflakes happly before introduce pyflakes.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- src/kimchi/control/plugins.py | 2 +- src/kimchi/featuretests.py | 2 -- src/kimchi/mockmodel.py | 2 +- src/kimchi/screenshot.py | 1 - src/kimchi/template.py | 1 - tests/test_server.py | 1 - ui/pages/help/gen-index.py | 1 - 7 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py index 8dc2273..12c621e 100644 --- a/src/kimchi/control/plugins.py +++ b/src/kimchi/control/plugins.py @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import kimchi.template -from kimchi.control.base import Collection, Resource +from kimchi.control.base import Collection from kimchi.control.utils import get_class_name, model_fn from kimchi.control.utils import UrlSubNode
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index a6a28fa..07d5676 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -20,7 +20,6 @@ import cherrypy import libvirt import lxml.etree as ET -import os import socket import subprocess import threading @@ -29,7 +28,6 @@ import threading from lxml.builder import E
-from kimchi import config from kimchi.utils import kimchi_log
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index d40f61a..8ff3dbf 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -51,7 +51,7 @@ from kimchi.model.utils import get_vm_name from kimchi.model.vms import VM_STATIC_UPDATE_PARAMS from kimchi.objectstore import ObjectStore from kimchi.screenshot import VMScreenshot -from kimchi.utils import pool_name_from_uri, run_command +from kimchi.utils import pool_name_from_uri from kimchi.utils import template_name_from_uri from kimchi.vmtemplate import VMTemplate
diff --git a/src/kimchi/screenshot.py b/src/kimchi/screenshot.py index 6c8a599..0040d7c 100644 --- a/src/kimchi/screenshot.py +++ b/src/kimchi/screenshot.py @@ -20,7 +20,6 @@
import glob import os -import random import signal import tempfile import time diff --git a/src/kimchi/template.py b/src/kimchi/template.py index 5707121..9bb2da5 100644 --- a/src/kimchi/template.py +++ b/src/kimchi/template.py @@ -20,7 +20,6 @@ import cherrypy import errno import json -import os
from kimchi.config import paths diff --git a/tests/test_server.py b/tests/test_server.py index d7b93ad..d06e17a 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -17,7 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import json import os import unittest
diff --git a/ui/pages/help/gen-index.py b/ui/pages/help/gen-index.py index 56cbf47..cf7c5d7 100755 --- a/ui/pages/help/gen-index.py +++ b/ui/pages/help/gen-index.py @@ -18,7 +18,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import glob import libxml2 import sys

Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> On 03/20/2014 08:34 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
remove the unused import module. make pyflakes happly before introduce pyflakes.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- src/kimchi/control/plugins.py | 2 +- src/kimchi/featuretests.py | 2 -- src/kimchi/mockmodel.py | 2 +- src/kimchi/screenshot.py | 1 - src/kimchi/template.py | 1 - tests/test_server.py | 1 - ui/pages/help/gen-index.py | 1 - 7 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py index 8dc2273..12c621e 100644 --- a/src/kimchi/control/plugins.py +++ b/src/kimchi/control/plugins.py @@ -18,7 +18,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import kimchi.template -from kimchi.control.base import Collection, Resource +from kimchi.control.base import Collection from kimchi.control.utils import get_class_name, model_fn from kimchi.control.utils import UrlSubNode
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index a6a28fa..07d5676 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -20,7 +20,6 @@ import cherrypy import libvirt import lxml.etree as ET -import os import socket import subprocess import threading @@ -29,7 +28,6 @@ import threading from lxml.builder import E
-from kimchi import config from kimchi.utils import kimchi_log
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index d40f61a..8ff3dbf 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -51,7 +51,7 @@ from kimchi.model.utils import get_vm_name from kimchi.model.vms import VM_STATIC_UPDATE_PARAMS from kimchi.objectstore import ObjectStore from kimchi.screenshot import VMScreenshot -from kimchi.utils import pool_name_from_uri, run_command +from kimchi.utils import pool_name_from_uri from kimchi.utils import template_name_from_uri from kimchi.vmtemplate import VMTemplate
diff --git a/src/kimchi/screenshot.py b/src/kimchi/screenshot.py index 6c8a599..0040d7c 100644 --- a/src/kimchi/screenshot.py +++ b/src/kimchi/screenshot.py @@ -20,7 +20,6 @@
import glob import os -import random import signal import tempfile import time diff --git a/src/kimchi/template.py b/src/kimchi/template.py index 5707121..9bb2da5 100644 --- a/src/kimchi/template.py +++ b/src/kimchi/template.py @@ -20,7 +20,6 @@ import cherrypy import errno import json -import os
from kimchi.config import paths diff --git a/tests/test_server.py b/tests/test_server.py index d7b93ad..d06e17a 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -17,7 +17,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import json import os import unittest
diff --git a/ui/pages/help/gen-index.py b/ui/pages/help/gen-index.py index 56cbf47..cf7c5d7 100755 --- a/ui/pages/help/gen-index.py +++ b/ui/pages/help/gen-index.py @@ -18,7 +18,6 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-import glob import libxml2 import sys

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> remove unused availables make pyflakes happly before introduce pyflakes. 1. the info is unused when start the vm, remove the statement. 2. the AsyncTask, we use it to create a task and run the task. 3. the Exception, we just catch it and do not use it. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/mockmodel.py | 3 +-- src/kimchi/model/storagepools.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index 8ff3dbf..b6f1eb8 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -127,7 +127,6 @@ class MockModel(object): def vm_start(self, name): self._get_vm(name).info['state'] = 'running' - info = self._get_vm(name).info def vm_stop(self, name): self._get_vm(name).info['state'] = 'shutoff' @@ -729,7 +728,7 @@ class MockModel(object): def add_task(self, target_uri, fn, opaque=None): id = self.next_taskid self.next_taskid = self.next_taskid + 1 - task = AsyncTask(id, target_uri, fn, self.objstore, opaque) + AsyncTask(id, target_uri, fn, self.objstore, opaque) return id diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py index fea19f6..92b2496 100644 --- a/src/kimchi/model/storagepools.py +++ b/src/kimchi/model/storagepools.py @@ -222,7 +222,7 @@ class StoragePoolModel(object): try: poolDef.prepare(conn) return True - except Exception as e: + except Exception: return False def lookup(self, name): -- 1.8.5.3

Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> On 03/20/2014 08:34 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
remove unused availables make pyflakes happly before introduce pyflakes.
1. the info is unused when start the vm, remove the statement. 2. the AsyncTask, we use it to create a task and run the task. 3. the Exception, we just catch it and do not use it.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/mockmodel.py | 3 +-- src/kimchi/model/storagepools.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index 8ff3dbf..b6f1eb8 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -127,7 +127,6 @@ class MockModel(object):
def vm_start(self, name): self._get_vm(name).info['state'] = 'running' - info = self._get_vm(name).info
def vm_stop(self, name): self._get_vm(name).info['state'] = 'shutoff' @@ -729,7 +728,7 @@ class MockModel(object): def add_task(self, target_uri, fn, opaque=None): id = self.next_taskid self.next_taskid = self.next_taskid + 1 - task = AsyncTask(id, target_uri, fn, self.objstore, opaque) + AsyncTask(id, target_uri, fn, self.objstore, opaque)
return id
diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py index fea19f6..92b2496 100644 --- a/src/kimchi/model/storagepools.py +++ b/src/kimchi/model/storagepools.py @@ -222,7 +222,7 @@ class StoragePoolModel(object): try: poolDef.prepare(conn) return True - except Exception as e: + except Exception: return False
def lookup(self, name):

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> We know ModelTests will tear down the template datebase. But it is better to delete the template explicitly. In this way, the test case also can test the template_delete. Also this can make pyflakes happy. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- tests/test_model.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_model.py b/tests/test_model.py index c8c54c0..69f9b5b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -513,9 +513,11 @@ class ModelTests(unittest.TestCase): orig_params = {'name': 'test-template', 'memory': 1024, 'cpus': 1, 'cdrom': self.kimchi_iso} inst.templates_create(orig_params) + rollback.prependDefer(inst.template_delete, 'test-template') orig_temp = inst.template_lookup(orig_params['name']) ident = inst.template_clone('test-template') + rollback.prependDefer(inst.template_delete, ident) clone_temp = inst.template_lookup(ident) clone_temp['name'] = orig_temp['name'] -- 1.8.5.3

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014-03-21Fri的 07:34 +0800,shaohef@linux.vnet.ibm.com:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
We know ModelTests will tear down the template datebase. But it is better to delete the template explicitly. In this way, the test case also can test the template_delete.
Also this can make pyflakes happy.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- tests/test_model.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py index c8c54c0..69f9b5b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -513,9 +513,11 @@ class ModelTests(unittest.TestCase): orig_params = {'name': 'test-template', 'memory': 1024, 'cpus': 1, 'cdrom': self.kimchi_iso} inst.templates_create(orig_params) + rollback.prependDefer(inst.template_delete, 'test-template') orig_temp = inst.template_lookup(orig_params['name'])
ident = inst.template_clone('test-template') + rollback.prependDefer(inst.template_delete, ident) clone_temp = inst.template_lookup(ident)
clone_temp['name'] = orig_temp['name']

Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> On 03/20/2014 08:34 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
We know ModelTests will tear down the template datebase. But it is better to delete the template explicitly. In this way, the test case also can test the template_delete.
Also this can make pyflakes happy.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- tests/test_model.py | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/tests/test_model.py b/tests/test_model.py index c8c54c0..69f9b5b 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -513,9 +513,11 @@ class ModelTests(unittest.TestCase): orig_params = {'name': 'test-template', 'memory': 1024, 'cpus': 1, 'cdrom': self.kimchi_iso} inst.templates_create(orig_params) + rollback.prependDefer(inst.template_delete, 'test-template') orig_temp = inst.template_lookup(orig_params['name'])
ident = inst.template_clone('test-template') + rollback.prependDefer(inst.template_delete, ident) clone_temp = inst.template_lookup(ident)
clone_temp['name'] = orig_temp['name']

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster. This is important to improve the code quality. Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2fdafb1..c68f050 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,14 @@ PEP8_WHITELIST = \ tests/utils.py \ $(NULL) +SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py" + check-local: + find . -path './.git' -prune -type f -o \ + -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \ + grep -w -v $(SKIP_PYFLAKES_ERR) | \ + while read LINE; do echo "$$LINE"; false; done + $(PEP8) --version $(PEP8) --filename '*.py,*.py.in' $(PEP8_WHITELIST) diff --git a/configure.ac b/configure.ac index 365348f..a625f35 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,13 @@ AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.10]) AC_PATH_PROG([CHEETAH], [cheetah], [/usr/bin/cheetah]) +# Checking for pyflakes +AC_PATH_PROG([PYFLAKES], [pyflakes]) +if test "x$PYFLAKES" = "x"; then + AC_MSG_WARN([pyflakes not found]) +fi + + AC_CONFIG_FILES([ po/Makefile.in po/gen-pot diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in index c2b2a40..75c42a6 100644 --- a/contrib/DEBIAN/control.in +++ b/contrib/DEBIAN/control.in @@ -24,6 +24,7 @@ Depends: python-cherrypy3 (>= 3.2.0), open-iscsi, firewalld Build-Depends: libxslt, + pyflakes, python-libxml2 Maintainer: Aline Manera <alinefm@br.ibm.com> Description: Kimchi web server diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index bf80104..1d51c87 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -31,6 +31,7 @@ Requires: nfs-utils Requires: iscsi-initiator-utils BuildRequires: libxslt BuildRequires: libxml2-python +BuildRequires: pyflakes %if 0%{?rhel} == 6 Requires: python-ordereddict diff --git a/docs/README.md b/docs/README.md index 8b8b181..f853c4d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,7 +53,7 @@ Install Dependencies PyPAM m2crypto python-jsonschema rpm-build \ qemu-kvm python-psutil python-ethtool sos \ python-ipaddr python-lxml nfs-utils \ - iscsi-initiator-utils libxslt pyparted + iscsi-initiator-utils libxslt pyparted pyflakes # If using RHEL6, install the following additional packages: $ sudo yum install python-unittest2 python-ordereddict # Restart libvirt to allow configuration changes to take effect @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository. python-pam python-m2crypto python-jsonschema \ qemu-kvm libtool python-psutil python-ethtool \ sosreport python-ipaddr python-lxml nfs-common \ - open-iscsi lvm2 xsltproc python-parted + open-iscsi lvm2 xsltproc python-parted pyflakes Packages version requirement: python-jsonschema >= 1.3.0 @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository. python-pam python-M2Crypto python-jsonschema \ rpm-build kvm python-psutil python-ethtool \ python-ipaddr python-lxml nfs-client open-iscsi \ - libxslt-tools python-xml python-parted + libxslt-tools python-xml python-parted pyflakes Packages version requirement: python-psutil >= 0.6.0 -- 1.8.5.3

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014-03-21Fri 07:34 +0800,shaohef@linux.vnet.ibm.com:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster.
This is important to improve the code quality.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- 5 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 2fdafb1..c68f050 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,14 @@ PEP8_WHITELIST = \ tests/utils.py \ $(NULL)
+SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py" + check-local: + find . -path './.git' -prune -type f -o \ + -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \ + grep -w -v $(SKIP_PYFLAKES_ERR) | \ + while read LINE; do echo "$$LINE"; false; done + $(PEP8) --version $(PEP8) --filename '*.py,*.py.in' $(PEP8_WHITELIST)
diff --git a/configure.ac b/configure.ac index 365348f..a625f35 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,13 @@ AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.10]) AC_PATH_PROG([CHEETAH], [cheetah], [/usr/bin/cheetah])
+# Checking for pyflakes +AC_PATH_PROG([PYFLAKES], [pyflakes]) +if test "x$PYFLAKES" = "x"; then + AC_MSG_WARN([pyflakes not found]) +fi + + AC_CONFIG_FILES([ po/Makefile.in po/gen-pot diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in index c2b2a40..75c42a6 100644 --- a/contrib/DEBIAN/control.in +++ b/contrib/DEBIAN/control.in @@ -24,6 +24,7 @@ Depends: python-cherrypy3 (>= 3.2.0), open-iscsi, firewalld Build-Depends: libxslt, + pyflakes, python-libxml2 Maintainer: Aline Manera <alinefm@br.ibm.com> Description: Kimchi web server diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index bf80104..1d51c87 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -31,6 +31,7 @@ Requires: nfs-utils Requires: iscsi-initiator-utils BuildRequires: libxslt BuildRequires: libxml2-python +BuildRequires: pyflakes
%if 0%{?rhel} == 6 Requires: python-ordereddict diff --git a/docs/README.md b/docs/README.md index 8b8b181..f853c4d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,7 +53,7 @@ Install Dependencies PyPAM m2crypto python-jsonschema rpm-build \ qemu-kvm python-psutil python-ethtool sos \ python-ipaddr python-lxml nfs-utils \ - iscsi-initiator-utils libxslt pyparted + iscsi-initiator-utils libxslt pyparted pyflakes # If using RHEL6, install the following additional packages: $ sudo yum install python-unittest2 python-ordereddict # Restart libvirt to allow configuration changes to take effect @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository. python-pam python-m2crypto python-jsonschema \ qemu-kvm libtool python-psutil python-ethtool \ sosreport python-ipaddr python-lxml nfs-common \ - open-iscsi lvm2 xsltproc python-parted + open-iscsi lvm2 xsltproc python-parted pyflakes
Packages version requirement: python-jsonschema >= 1.3.0 @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository. python-pam python-M2Crypto python-jsonschema \ rpm-build kvm python-psutil python-ethtool \ python-ipaddr python-lxml nfs-client open-iscsi \ - libxslt-tools python-xml python-parted + libxslt-tools python-xml python-parted pyflakes
Packages version requirement: python-psutil >= 0.6.0

Reviewed-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> On 03/20/2014 08:34 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster.
This is important to improve the code quality.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- 5 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 2fdafb1..c68f050 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,14 @@ PEP8_WHITELIST = \ tests/utils.py \ $(NULL)
+SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py" + check-local: + find . -path './.git' -prune -type f -o \ + -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \ + grep -w -v $(SKIP_PYFLAKES_ERR) | \ + while read LINE; do echo "$$LINE"; false; done + $(PEP8) --version $(PEP8) --filename '*.py,*.py.in' $(PEP8_WHITELIST)
diff --git a/configure.ac b/configure.ac index 365348f..a625f35 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,13 @@ AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.10]) AC_PATH_PROG([CHEETAH], [cheetah], [/usr/bin/cheetah])
+# Checking for pyflakes +AC_PATH_PROG([PYFLAKES], [pyflakes]) +if test "x$PYFLAKES" = "x"; then + AC_MSG_WARN([pyflakes not found]) +fi + + AC_CONFIG_FILES([ po/Makefile.in po/gen-pot diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in index c2b2a40..75c42a6 100644 --- a/contrib/DEBIAN/control.in +++ b/contrib/DEBIAN/control.in @@ -24,6 +24,7 @@ Depends: python-cherrypy3 (>= 3.2.0), open-iscsi, firewalld Build-Depends: libxslt, + pyflakes, python-libxml2 Maintainer: Aline Manera <alinefm@br.ibm.com> Description: Kimchi web server diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index bf80104..1d51c87 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -31,6 +31,7 @@ Requires: nfs-utils Requires: iscsi-initiator-utils BuildRequires: libxslt BuildRequires: libxml2-python +BuildRequires: pyflakes
%if 0%{?rhel} == 6 Requires: python-ordereddict diff --git a/docs/README.md b/docs/README.md index 8b8b181..f853c4d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,7 +53,7 @@ Install Dependencies PyPAM m2crypto python-jsonschema rpm-build \ qemu-kvm python-psutil python-ethtool sos \ python-ipaddr python-lxml nfs-utils \ - iscsi-initiator-utils libxslt pyparted + iscsi-initiator-utils libxslt pyparted pyflakes # If using RHEL6, install the following additional packages: $ sudo yum install python-unittest2 python-ordereddict # Restart libvirt to allow configuration changes to take effect @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository. python-pam python-m2crypto python-jsonschema \ qemu-kvm libtool python-psutil python-ethtool \ sosreport python-ipaddr python-lxml nfs-common \ - open-iscsi lvm2 xsltproc python-parted + open-iscsi lvm2 xsltproc python-parted pyflakes
Packages version requirement: python-jsonschema >= 1.3.0 @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository. python-pam python-M2Crypto python-jsonschema \ rpm-build kvm python-psutil python-ethtool \ python-ipaddr python-lxml nfs-client open-iscsi \ - libxslt-tools python-xml python-parted + libxslt-tools python-xml python-parted pyflakes
Packages version requirement: python-psutil >= 0.6.0

On 03/20/2014 08:34 PM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster.
This is important to improve the code quality.
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Signed-off-by: Zhou Zheng Sheng <zhshzhou@linux.vnet.ibm.com> --- Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- 5 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/Makefile.am b/Makefile.am index 2fdafb1..c68f050 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,14 @@ PEP8_WHITELIST = \ tests/utils.py \ $(NULL)
+SKIP_PYFLAKES_ERR = "\./src/kimchi/websocket\.py" + check-local: + find . -path './.git' -prune -type f -o \ + -name '*.py' -o -name '*.py.in' | xargs $(PYFLAKES) | \ + grep -w -v $(SKIP_PYFLAKES_ERR) | \ + while read LINE; do echo "$$LINE"; false; done + $(PEP8) --version $(PEP8) --filename '*.py,*.py.in' $(PEP8_WHITELIST)
diff --git a/configure.ac b/configure.ac index 365348f..a625f35 100644 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,13 @@ AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT_VERSION([0.10]) AC_PATH_PROG([CHEETAH], [cheetah], [/usr/bin/cheetah])
+# Checking for pyflakes +AC_PATH_PROG([PYFLAKES], [pyflakes]) +if test "x$PYFLAKES" = "x"; then + AC_MSG_WARN([pyflakes not found]) +fi + + AC_CONFIG_FILES([ po/Makefile.in po/gen-pot diff --git a/contrib/DEBIAN/control.in b/contrib/DEBIAN/control.in index c2b2a40..75c42a6 100644 --- a/contrib/DEBIAN/control.in +++ b/contrib/DEBIAN/control.in @@ -24,6 +24,7 @@ Depends: python-cherrypy3 (>= 3.2.0), open-iscsi, firewalld Build-Depends: libxslt, + pyflakes, python-libxml2 Maintainer: Aline Manera <alinefm@br.ibm.com> Description: Kimchi web server diff --git a/contrib/kimchi.spec.fedora.in b/contrib/kimchi.spec.fedora.in index bf80104..1d51c87 100644 --- a/contrib/kimchi.spec.fedora.in +++ b/contrib/kimchi.spec.fedora.in @@ -31,6 +31,7 @@ Requires: nfs-utils Requires: iscsi-initiator-utils BuildRequires: libxslt BuildRequires: libxml2-python +BuildRequires: pyflakes
The same I commented about pep8. We do not need pyflakes to run or build Kimchi. It is only used for developers to check code style.
%if 0%{?rhel} == 6 Requires: python-ordereddict diff --git a/docs/README.md b/docs/README.md index 8b8b181..f853c4d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -53,7 +53,7 @@ Install Dependencies PyPAM m2crypto python-jsonschema rpm-build \ qemu-kvm python-psutil python-ethtool sos \ python-ipaddr python-lxml nfs-utils \ - iscsi-initiator-utils libxslt pyparted + iscsi-initiator-utils libxslt pyparted pyflakes # If using RHEL6, install the following additional packages: $ sudo yum install python-unittest2 python-ordereddict # Restart libvirt to allow configuration changes to take effect @@ -75,7 +75,7 @@ for more information on how to configure your system to access this repository. python-pam python-m2crypto python-jsonschema \ qemu-kvm libtool python-psutil python-ethtool \ sosreport python-ipaddr python-lxml nfs-common \ - open-iscsi lvm2 xsltproc python-parted + open-iscsi lvm2 xsltproc python-parted pyflakes
Packages version requirement: python-jsonschema >= 1.3.0 @@ -89,7 +89,7 @@ for more information on how to configure your system to access this repository. python-pam python-M2Crypto python-jsonschema \ rpm-build kvm python-psutil python-ethtool \ python-ipaddr python-lxml nfs-client open-iscsi \ - libxslt-tools python-xml python-parted + libxslt-tools python-xml python-parted pyflakes
Packages version requirement: python-psutil >= 0.6.0

Reviewed-by: Shu Ming <shuming@linux.vnet.ibm.com> 2014-03-21Fri的 07:34 +0800,shaohef@linux.vnet.ibm.com:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
V3 -> V4 address Rodrigo's comment. add delete the cloned template in rollback.
V2 -> V3 address zhengsheng's comment. improve the SKIP_PYFLAKES_ERR list.
V1 -> V2 address Crístian'comment: remove the whole statement "info = self._get_vm(name).inf" address ming's comment: break down the patch into small patches by the pyflakes error.
Pyflakes analyzes programs and detects various errors. It works by parsing the source file, not importing it, so it is safe to use on modules with side effects. It's also much faster.
This is important to improve the code quality.
ShaoHe Feng (4): make pyflakes happly, remove the unused import module make pyflakes happly, remove unused availables add template_delete to rollback after create a template run pyflakes when make check
Makefile.am | 7 +++++++ configure.ac | 7 +++++++ contrib/DEBIAN/control.in | 1 + contrib/kimchi.spec.fedora.in | 1 + docs/README.md | 6 +++--- src/kimchi/control/plugins.py | 2 +- src/kimchi/featuretests.py | 2 -- src/kimchi/mockmodel.py | 5 ++--- src/kimchi/model/storagepools.py | 2 +- src/kimchi/screenshot.py | 1 - src/kimchi/template.py | 1 - tests/test_model.py | 2 ++ tests/test_server.py | 1 - ui/pages/help/gen-index.py | 1 - 14 files changed, 25 insertions(+), 14 deletions(-)
participants (4)
-
Aline Manera
-
Rodrigo Trujillo
-
shaohef@linux.vnet.ibm.com
-
Shu Ming