[CRIU] [PATCH 3/4] fix various linter errors

Tycho Andersen tycho.andersen at canonical.com
Thu Oct 22 10:50:56 PDT 2015


p.haul:41:40: E231 missing whitespace after ','
phaul/fs_haul_ploop.py:54:4: F841 local variable 'receiver' is assigned to but never used
phaul/criu_api.py:52:6: E713 test for membership should be 'not in'
phaul/criu_req.py:126:1: W391 blank line at end of file
phaul/images.py:10:1: F811 redefinition of unused 'time' from line 8
phaul/p_haul_service.py:6:1: F401 'xem_rpc' imported but unused
phaul/p_haul_lxc.py:11:1: F401 'fs_haul_subtree' imported but unused
phaul/p_haul_lxc.py:83:11: E703 statement ends with a semicolon
phaul/p_haul_type.py:18:23: W601 .has_key() is deprecated, use 'in'
phaul/p_haul_iters.py:85:14: E231 missing whitespace after ','
phaul/p_haul_iters.py:171:10: E703 statement ends with a semicolon
phaul/util.py:54:2: F841 local variable 'fd' is assigned to but never used
phaul/xem_rpc_client.py:5:1: F401 'socket' imported but unused
phaul/xem_rpc_client.py:7:1: F401 'util' imported but unused
phaul/xem_rpc.py:10:1: F401 'util' imported but unused
phaul/p_haul_vz.py:9:1: F401 'p_haul_module' imported but unused
Makefile:3: recipe for target 'lint' failed

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 p.haul                  | 2 +-
 phaul/criu_api.py       | 2 +-
 phaul/criu_req.py       | 1 -
 phaul/fs_haul_ploop.py  | 2 +-
 phaul/images.py         | 1 -
 phaul/p_haul_iters.py   | 4 ++--
 phaul/p_haul_lxc.py     | 3 +--
 phaul/p_haul_service.py | 1 -
 phaul/p_haul_type.py    | 2 +-
 phaul/p_haul_vz.py      | 1 -
 phaul/util.py           | 1 -
 phaul/xem_rpc.py        | 1 -
 phaul/xem_rpc_client.py | 2 --
 13 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/p.haul b/p.haul
index 9b64864..107d5d2 100755
--- a/p.haul
+++ b/p.haul
@@ -38,7 +38,7 @@ parser.add_argument("--img-path", help="Directory where to put images",
 parser.add_argument("--pid-root", help="Path to tree's FS root")
 parser.add_argument("--force", help="Don't do any sanity (CPU compat) checks", default=False, action='store_true')
 parser.add_argument("--log-file", help="Write logging messages to specified file")
-parser.add_argument("-j", "--shell-job",help ="Allow migration of shell jobs",
+parser.add_argument("-j", "--shell-job", help="Allow migration of shell jobs",
 	default=False, action='store_true')
 
 
diff --git a/phaul/criu_api.py b/phaul/criu_api.py
index 9d35eb9..0fcc618 100644
--- a/phaul/criu_api.py
+++ b/phaul/criu_api.py
@@ -49,7 +49,7 @@ class criu_conn:
 	def _recv_resp(self):
 		resp = pycriu.rpc.criu_resp()
 		resp.ParseFromString(self._cs.recv(1024))
-		if not resp.type in (pycriu.rpc.NOTIFY, self._last_req):
+		if resp.type not in (pycriu.rpc.NOTIFY, self._last_req):
 			raise Exception("CRIU RPC error (%d/%d)" % (resp.type, self._last_req))
 
 		return resp
diff --git a/phaul/criu_req.py b/phaul/criu_req.py
index 3cc1721..8109edd 100644
--- a/phaul/criu_req.py
+++ b/phaul/criu_req.py
@@ -123,4 +123,3 @@ def make_dirty_tracking_req(htype, img):
 	req.keep_open = True
 	req.opts.images_dir_fd = img.work_dir_fd()
 	return req
-
diff --git a/phaul/fs_haul_ploop.py b/phaul/fs_haul_ploop.py
index e430ed5..b70edff 100644
--- a/phaul/fs_haul_ploop.py
+++ b/phaul/fs_haul_ploop.py
@@ -51,7 +51,7 @@ class p_haul_fs_receiver(threading.Thread):
 	def run(self):
 		try:
 			logging.info("Started fs receiver")
-			receiver = libploop.ploopcopy_receiver(self.__fname_path,
+			libploop.ploopcopy_receiver(self.__fname_path,
 				self.__fs_sk.fileno())
 		except:
 			logging.exception("Exception in p_haul_fs_receiver")
diff --git a/phaul/images.py b/phaul/images.py
index 11b3dbb..57dca59 100644
--- a/phaul/images.py
+++ b/phaul/images.py
@@ -7,7 +7,6 @@ import tempfile
 import tarfile
 import time
 import shutil
-import time
 import threading
 import logging
 import util
diff --git a/phaul/p_haul_iters.py b/phaul/p_haul_iters.py
index b2c76e3..b220662 100644
--- a/phaul/p_haul_iters.py
+++ b/phaul/p_haul_iters.py
@@ -82,7 +82,7 @@ class phaul_iter_worker:
 	def pre_dump_check(self):
 		# pre-dump auto-detection
 		req = criu_req.make_dirty_tracking_req(
-			self.htype,self.img)
+			self.htype, self.img)
 		resp = self.criu_connection.send_req(req)
 		if not resp.success:
 			# Not able to do auto-detection, disable memory tracking
@@ -168,7 +168,7 @@ class phaul_iter_worker:
 
 			if dstats.pages_written <= phaul_iter_min_size:
 				logging.info("\t> Small dump")
-				break;
+				break
 
 			if prev_dstats:
 				w_add = dstats.pages_written - prev_dstats.pages_written
diff --git a/phaul/p_haul_lxc.py b/phaul/p_haul_lxc.py
index f5770e8..53d63f9 100644
--- a/phaul/p_haul_lxc.py
+++ b/phaul/p_haul_lxc.py
@@ -8,7 +8,6 @@ import logging
 import p_haul_module
 import util
 import fs_haul_shared
-import fs_haul_subtree
 from subprocess import Popen, PIPE
 
 lxc_dir = "/var/lib/lxc/"
@@ -80,7 +79,7 @@ class p_haul_type:
 		pass
 
 	def root_task_pid(self):
-		pid = -1;
+		pid = -1
 
 		pd = Popen(["lxc-info", "-n", self._ctname], stdout = PIPE)
 		for l in pd.stdout:
diff --git a/phaul/p_haul_service.py b/phaul/p_haul_service.py
index 11883a6..776d490 100644
--- a/phaul/p_haul_service.py
+++ b/phaul/p_haul_service.py
@@ -3,7 +3,6 @@
 #
 
 import logging
-import xem_rpc
 import images
 import criu_api
 import criu_req
diff --git a/phaul/p_haul_type.py b/phaul/p_haul_type.py
index 7e05a7b..f3a4774 100644
--- a/phaul/p_haul_type.py
+++ b/phaul/p_haul_type.py
@@ -15,7 +15,7 @@ __haul_modules = {
 
 def __get(id):
 	hauler_name, haulee_id = id[0], id[1]
-	if not __haul_modules.has_key(hauler_name):
+	if hauler_name not in __haul_modules:
 		logging.error("Unknown type. Try one of %s", str(get_haul_names()))
 		return None
 
diff --git a/phaul/p_haul_vz.py b/phaul/p_haul_vz.py
index 13f3fd1..47d9c64 100644
--- a/phaul/p_haul_vz.py
+++ b/phaul/p_haul_vz.py
@@ -6,7 +6,6 @@ import os
 import subprocess
 import shlex
 import logging
-import p_haul_module
 import util
 import fs_haul_shared
 import fs_haul_ploop
diff --git a/phaul/util.py b/phaul/util.py
index 0a08f8d..2a66de4 100644
--- a/phaul/util.py
+++ b/phaul/util.py
@@ -51,7 +51,6 @@ def bridge_add(ifname, brname):
 	os.system("brctl addif %s %s" % (brname, ifname))
 
 def set_cloexec(sk):
-	fd = sk.fileno()
 	flags = fcntl.fcntl(sk, fcntl.F_GETFD)
 	fcntl.fcntl(sk, fcntl.F_SETFD, flags | fcntl.FD_CLOEXEC)
 
diff --git a/phaul/xem_rpc.py b/phaul/xem_rpc.py
index 345e250..97c3daf 100644
--- a/phaul/xem_rpc.py
+++ b/phaul/xem_rpc.py
@@ -7,7 +7,6 @@ import select
 import threading
 import traceback
 import logging
-import util
 
 rpc_sk_buf = 16384
 
diff --git a/phaul/xem_rpc_client.py b/phaul/xem_rpc_client.py
index c6fe8c3..073521f 100644
--- a/phaul/xem_rpc_client.py
+++ b/phaul/xem_rpc_client.py
@@ -2,9 +2,7 @@
 # RPC client implementation
 #
 
-import socket
 import logging
-import util
 import xem_rpc
 
 class _rpc_proxy_caller:
-- 
2.5.0



More information about the CRIU mailing list