---
storage/deviceaction.py | 7 ++-----
storage/devicelibs/crypto.py | 1 -
storage/devicelibs/mdraid.py | 2 +-
storage/devicelibs/swap.py | 5 +++--
storage/devicetree.py | 1 -
storage/errors.py | 3 ---
storage/formats/__init__.py | 1 -
storage/formats/dmraid.py | 2 --
storage/formats/fs.py | 7 +++----
storage/formats/lvmpv.py | 7 +++----
storage/iscsi.py | 37 ++++++++++++++++---------------------
storage/miscutils.py | 1 -
storage/partitioning.py | 1 -
storage/udev.py | 8 +++-----
storage/zfcp.py | 7 ++-----
15 files changed, 33 insertions(+), 57 deletions(-)
diff --git a/storage/deviceaction.py b/storage/deviceaction.py
index ba4456a..b462108 100644
--- a/storage/deviceaction.py
+++ b/storage/deviceaction.py
@@ -22,7 +22,6 @@
#
import copy
-from parted import PARTITION_BOOT
from udev import *
@@ -37,10 +36,8 @@ import logging
log = logging.getLogger("storage")
-""" The values are just hints as to the ordering.
-
- Eg: fsmod and devmod ordering depends on the mod (shrink -v- grow)
-"""
+# The values are just hints as to the ordering.
+# Eg: fsmod and devmod ordering depends on the mod (shrink -v- grow)
ACTION_TYPE_NONE = 0
ACTION_TYPE_DESTROY = 1000
ACTION_TYPE_RESIZE = 500
diff --git a/storage/devicelibs/crypto.py b/storage/devicelibs/crypto.py
index 28da47c..771798a 100644
--- a/storage/devicelibs/crypto.py
+++ b/storage/devicelibs/crypto.py
@@ -23,7 +23,6 @@
import os
from pycryptsetup import CryptSetup
-import iutil
from ..errors import *
import gettext
diff --git a/storage/devicelibs/mdraid.py b/storage/devicelibs/mdraid.py
index dec5f2d..185aa14 100644
--- a/storage/devicelibs/mdraid.py
+++ b/storage/devicelibs/mdraid.py
@@ -42,7 +42,7 @@ def getRaidLevels():
avail = []
try:
f = open("/proc/mdstat", "r")
- except:
+ except IOError:
pass
else:
for l in f.readlines():
diff --git a/storage/devicelibs/swap.py b/storage/devicelibs/swap.py
index 090c92e..dadeb0a 100644
--- a/storage/devicelibs/swap.py
+++ b/storage/devicelibs/swap.py
@@ -52,15 +52,16 @@ def swapon(device, priority=None):
num = pagesize
else:
num = 2048
+
try:
fd = os.open(device, os.O_RDONLY)
buf = os.read(fd, num)
- except:
+ except OSError:
pass
finally:
try:
os.close(fd)
- except:
+ except (OSError, UnboundLocalError):
pass
if buf is not None and len(buf) == pagesize:
diff --git a/storage/devicetree.py b/storage/devicetree.py
index b9552bd..2025c20 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1381,7 +1381,6 @@ class DeviceTree(object):
except DeviceError:
# the pvremoves will finish the job.
log.debug("There was an error destroying the VG %s." % vg.name)
- pass
# remove VG device from list.
self._removeDevice(vg)
diff --git a/storage/errors.py b/storage/errors.py
index 8fb57b1..d2d35ee 100644
--- a/storage/errors.py
+++ b/storage/errors.py
@@ -18,9 +18,6 @@ class DeviceSetupError(DeviceError):
class DeviceTeardownError(DeviceError):
pass
-class DeviceResizeError(DeviceError):
- pass
-
class DeviceUserDeniedFormatError(DeviceError):
pass
diff --git a/storage/formats/__init__.py b/storage/formats/__init__.py
index 9ec0999..784bb1c 100644
--- a/storage/formats/__init__.py
+++ b/storage/formats/__init__.py
@@ -284,7 +284,6 @@ class DeviceFormat(object):
def teardown(self, *args, **kwargs):
log_method_call(self, device=self.device,
type=self.type, status=self.status)
- pass
@property
def status(self):
diff --git a/storage/formats/dmraid.py b/storage/formats/dmraid.py
index f5f2808..4ebd41c 100644
--- a/storage/formats/dmraid.py
+++ b/storage/formats/dmraid.py
@@ -20,8 +20,6 @@
# Red Hat Author(s): Dave Lehman<dlehman@xxxxxxxxxx>
#
-import block
-
from iutil import log_method_call
from ..errors import *
from . import DeviceFormat, register_device_format
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 8864b3a..36e3691 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -663,10 +663,9 @@ class FS(DeviceFormat):
return _type
- """ These methods just wrap filesystem-specific methods in more
- generically named methods so filesystems and formatted devices
- like swap and LVM physical volumes can have a common API.
- """
+ # These methods just wrap filesystem-specific methods in more
+ # generically named methods so filesystems and formatted devices
+ # like swap and LVM physical volumes can have a common API.
def create(self, *args, **kwargs):
if self.exists:
raise FSError("filesystem already exists")
diff --git a/storage/formats/lvmpv.py b/storage/formats/lvmpv.py
index c9cbe29..a111635 100644
--- a/storage/formats/lvmpv.py
+++ b/storage/formats/lvmpv.py
@@ -74,7 +74,6 @@ class LVMPhysicalVolume(DeviceFormat):
if not self.exists:
raise PhysicalVolumeError("format has not been created")
- pass
#info = lvm.pvinfo(self.device)
#self.vgName = info['vg_name']
#self.vgUuid = info['vg_uuid']
@@ -84,9 +83,9 @@ class LVMPhysicalVolume(DeviceFormat):
log_method_call(self, device=self.device,
type=self.type, status=self.status)
DeviceFormat.create(self, *args, **kwargs)
- """ Consider use of -Z|--zero
- -f|--force or -y|--yes may be required
- """
+ # Consider use of -Z|--zero
+ # -f|--force or -y|--yes may be required
+
# lvm has issues with persistence of metadata, so here comes the
# hammer...
DeviceFormat.destroy(self, *args, **kwargs)
diff --git a/storage/iscsi.py b/storage/iscsi.py
index 29d8983..3e6dc0a 100644
--- a/storage/iscsi.py
+++ b/storage/iscsi.py
@@ -20,11 +20,7 @@
from constants import *
import os
-import errno
-import string
-import signal
import iutil
-import isys
from flags import flags
import logging
import shutil
@@ -39,11 +35,10 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
has_libiscsi = True
try:
import libiscsi
-except:
+except ImportError:
has_libiscsi = False
# Note that stage2 copies all files under /sbin to /usr/sbin
-global ISCSID
ISCSID=""
INITIATOR_FILE="/etc/iscsi/initiatorname.iscsi"
@@ -141,19 +136,19 @@ class iscsi(object):
return
try:
- found_nodes = libiscsi.discover_firmware()
+ found_nodes = libiscsi.discover_firmware()
except:
- # an exception here means there is no ibft firmware, just return
- return
+ # an exception here means there is no ibft firmware, just return
+ return
for node in found_nodes:
try:
- node.login()
- self.nodes.append(node)
+ node.login()
+ self.nodes.append(node)
except:
- # FIXME, what to do when we cannot log in to a firmware
- # provided node ??
- pass
+ # FIXME, what to do when we cannot log in to a firmware
+ # provided node ??
+ pass
stabilize(intf)
@@ -234,14 +229,14 @@ class iscsi(object):
found = found + 1
try:
- if (authinfo):
- node.setAuth(authinfo)
- node.login()
- self.nodes.append(node)
- logged_in = logged_in + 1
+ if (authinfo):
+ node.setAuth(authinfo)
+ node.login()
+ self.nodes.append(node)
+ logged_in = logged_in + 1
except:
- # some nodes may require different credentials
- pass
+ # some nodes may require different credentials
+ pass
if intf:
w.pop()
diff --git a/storage/miscutils.py b/storage/miscutils.py
index b9c9740..e577497 100644
--- a/storage/miscutils.py
+++ b/storage/miscutils.py
@@ -1,5 +1,4 @@
# iutil.py stubs
-import sys
import os
import logging
diff --git a/storage/partitioning.py b/storage/partitioning.py
index a71ba91..12d5c29 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -22,7 +22,6 @@
import sys
import os
-import copy
from operator import add, sub
import parted
diff --git a/storage/udev.py b/storage/udev.py
index 11df629..a1b2e1f 100644
--- a/storage/udev.py
+++ b/storage/udev.py
@@ -21,7 +21,6 @@
#
import os
-import re
import stat
import iutil
@@ -170,9 +169,8 @@ def udev_trigger(subsystem=None):
iutil.execWithRedirect("udevadm", argv, stderr="/dev/null", searchPath=1)
-""" These are functions for retrieving specific pieces of information from
- udev database entries.
-"""
+# These are functions for retrieving specific pieces of information from
+# udev database entries.
def udev_device_get_name(udev_info):
""" Return the best name for a device based on the udev db data. """
return udev_info.get("DM_NAME", udev_info["name"])
@@ -313,7 +311,7 @@ def udev_device_is_dmraid(info):
def udev_device_get_dmraid_partition_disk(info):
try:
p_index = info["DM_NAME"].rindex("p")
- except:
+ except (KeyError, AttributeError, ValueError):
return None
if not info["DM_NAME"][p_index+1:].isdigit():
diff --git a/storage/zfcp.py b/storage/zfcp.py
index e38b818..2584268 100644
--- a/storage/zfcp.py
+++ b/storage/zfcp.py
@@ -21,9 +21,6 @@
import string
import os
-import iutil
-import isys
-import shutil
from constants import *
import gettext
@@ -94,7 +91,7 @@ class ZFCPDevice:
try:
int(hex, 16)
return True
- except:
+ except TypeError:
return False
def checkValidDevice(self, id):
@@ -184,7 +181,7 @@ class ZFCP:
def readConfig(self):
try:
f = open("/tmp/fcpconfig", "r")
- except:
+ except IOError:
log.info("no /tmp/fcpconfig; not configuring zfcp")
return