From 7342b1fd2b457a39f6c3479ebd9a14d357ba50de Mon Sep 17 00:00:00 2001 From: Christophe Vu-Brugier Date: Fri, 11 Oct 2013 21:02:02 +0200 Subject: Comply with PEP 3310 "Catching Exceptions in Python 3000" Generated with `2to3 -f except`. Signed-off-by: Christophe Vu-Brugier --- rtslib/node.py | 4 ++-- rtslib/target.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rtslib/node.py b/rtslib/node.py index 5ea23cd..8f5aa15 100644 --- a/rtslib/node.py +++ b/rtslib/node.py @@ -138,7 +138,7 @@ class CFSNode(object): else: try: fwrite(path, "%s" % str(value)) - except IOError, msg: + except IOError as msg: msg = msg[1] raise RTSLibError("Cannot set attribute %s: %s" % (str(attribute), str(msg))) @@ -173,7 +173,7 @@ class CFSNode(object): else: try: fwrite(path, "%s\n" % str(value)) - except IOError, msg: + except IOError as msg: msg = msg[1] raise RTSLibError("Cannot set parameter %s: %s" % (str(parameter), str(msg))) diff --git a/rtslib/target.py b/rtslib/target.py index 7a1e799..2a5591a 100644 --- a/rtslib/target.py +++ b/rtslib/target.py @@ -238,7 +238,7 @@ class TPG(CFSNode): if os.path.isfile(path) and (boolean != self._get_enable()): try: fwrite(path, str(int(boolean))) - except IOError, e: + except IOError as e: raise RTSLibError("Cannot change enable state: %s" % e) def _get_nexus(self): @@ -696,7 +696,7 @@ class NetworkPortal(CFSNode): try: self._create_in_cfs_ine(mode) - except OSError, msg: + except OSError as msg: raise RTSLibError(msg[1]) def _get_ip_address(self): @@ -818,7 +818,7 @@ class NodeACL(CFSNode): path = "%s/cmdsn_depth" % self.path try: fwrite(path, "%s" % depth) - except IOError, msg: + except IOError as msg: msg = msg[1] raise RTSLibError("Cannot set tcq_depth: %s" % str(msg)) -- cgit v1.2.1 From a899c2ce7a3528e4c52c9d9c8c084e082d0e51fd Mon Sep 17 00:00:00 2001 From: Christophe Vu-Brugier Date: Fri, 11 Oct 2013 21:02:27 +0200 Subject: Use set literals to better comply with Python 3 Generated with `2to3 -f set_literal`. Signed-off-by: Christophe Vu-Brugier --- rtslib/fabric.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtslib/fabric.py b/rtslib/fabric.py index 45d694d..170ea3f 100644 --- a/rtslib/fabric.py +++ b/rtslib/fabric.py @@ -117,8 +117,8 @@ from target import Target from utils import _get_auth_attr, _set_auth_attr from functools import partial -version_attributes = set(["lio_version", "version"]) -discovery_auth_attributes = set(["discovery_auth"]) +version_attributes = {"lio_version", "version"} +discovery_auth_attributes = {"discovery_auth"} target_names_excludes = version_attributes | discovery_auth_attributes -- cgit v1.2.1 From 55b4354a0408beb898e51b4725b3c64d33aefd7b Mon Sep 17 00:00:00 2001 From: Christophe Vu-Brugier Date: Fri, 11 Oct 2013 21:02:37 +0200 Subject: Fix whitespace in comma separated items Generated with `2to3 -f ws_comma`. Signed-off-by: Christophe Vu-Brugier --- rtslib/utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/rtslib/utils.py b/rtslib/utils.py index b6b4162..cf362f5 100644 --- a/rtslib/utils.py +++ b/rtslib/utils.py @@ -262,7 +262,7 @@ def generate_wwn(wwn_type): return str(uuid.uuid4()) elif wwn_type == 'iqn': localname = socket.gethostname().split(".")[0] - localarch = os.uname()[4].replace("_","") + localarch = os.uname()[4].replace("_", "") prefix = "iqn.2003-01.org.linux-iscsi.%s.%s" % (localname, localarch) prefix = prefix.strip().lower() serial = "sn.%s" % str(uuid.uuid4())[24:] @@ -311,15 +311,15 @@ def normalize_wwn(wwn_types, wwn, possible_wwns=None): Returns (normalized_wwn, wwn_type), or exception if invalid wwn. ''' wwn_test = { - 'free' : lambda wwn: True, - 'iqn' : lambda wwn: \ + 'free': lambda wwn: True, + 'iqn': lambda wwn: \ re.match("iqn\.[0-9]{4}-[0-1][0-9]\..*\..*", wwn) \ and not re.search(' ', wwn) \ and not re.search('_', wwn), - 'naa' : lambda wwn: re.match("naa\.[125][0-9a-fA-F]{15}$", wwn), - 'eui' : lambda wwn: re.match("eui\.[0-9a-f]{16}$", wwn), - 'ib' : lambda wwn: re.match("ib\.[0-9a-f]{32}$", wwn), - 'unit_serial' : lambda wwn: \ + 'naa': lambda wwn: re.match("naa\.[125][0-9a-fA-F]{15}$", wwn), + 'eui': lambda wwn: re.match("eui\.[0-9a-f]{16}$", wwn), + 'ib': lambda wwn: re.match("ib\.[0-9a-f]{32}$", wwn), + 'unit_serial': lambda wwn: \ re.match("[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$", wwn), } -- cgit v1.2.1