Reduce disabled pylint to address them not hide 18/21318/1
authorPeter Mikus <pmikus@cisco.com>
Thu, 15 Aug 2019 06:36:36 +0000 (06:36 +0000)
committerPeter Mikus <pmikus@cisco.com>
Thu, 15 Aug 2019 06:36:36 +0000 (06:36 +0000)
+ Fixed Qemu
- Broad Exception should be addressed
- Policer is about to be refactored
- Drop search to be refactored

Signed-off-by: Peter Mikus <pmikus@cisco.com>
Change-Id: I97eb992497ff6334057bf82a0f413387706e17fd

resources/libraries/python/DropRateSearch.py
resources/libraries/python/PapiExecutor.py
resources/libraries/python/Policer.py
resources/libraries/python/QemuUtils.py
resources/libraries/python/VatExecutor.py

index 0c4f2c6..e87ef95 100644 (file)
@@ -61,8 +61,6 @@ class SearchResultType(Enum):
 
 class DropRateSearch(object):
     """Abstract class with search algorithm implementation."""
-    #TODO DropRateSearch should be refactored as part of CSIT-1378
-    #pylint: disable=too-many-instance-attributes
 
     __metaclass__ = ABCMeta
 
index bfa538f..ef04787 100644 (file)
@@ -706,7 +706,7 @@ class PapiExecutor(object):
                          "\n{apis}".format(host=self._node["host"],
                                            apis=api_data))
             raise
-        except Exception as exc:  # pylint: disable=broad-except
+        except Exception as exc:
             raise_from(RuntimeError(
                 "PAPI command(s) execution on host {host} "
                 "failed: {apis}".format(
index 55429e7..9e14a4f 100644 (file)
@@ -109,7 +109,6 @@ class PolicerClassifyTableType(Enum):
         self.string = string
 
 
-# pylint: disable=too-many-instance-attributes
 class Policer(object):
     """Policer utilities."""
 
@@ -145,7 +144,6 @@ class Policer(object):
         # create policer
         color_aware = 'color-aware' if self._color_aware else ''
 
-        # pylint: disable=no-member
         conform_action = self._conform_action.value
 
         if PolicerAction.MARK_AND_TRANSMIT == self._conform_action:
@@ -213,7 +211,7 @@ class Policer(object):
             node,
             "policer/policer_classify_add_session.vat",
             policer_index=policer_index,
-            pre_color=self._classify_precolor.value, # pylint: disable=no-member
+            pre_color=self._classify_precolor.value,
             table_index=new_table_index,
             skip_n=skip_n_vectors,
             match_n=match_n_vectors,
@@ -228,7 +226,7 @@ class Policer(object):
             node,
             "policer/policer_classify_set_interface.vat",
             sw_if_index=self._sw_if_index,
-            table_type=table_type.value, # pylint: disable=no-member
+            table_type=table_type.value,
             table_index=new_table_index)
 
         VatJsonUtil.verify_vat_retval(
index a4d8533..17b5eab 100644 (file)
@@ -13,9 +13,6 @@
 
 """QEMU utilities library."""
 
-# Disable due to pylint bug
-# pylint: disable=no-name-in-module,import-error
-from distutils.version import StrictVersion
 import json
 from re import match
 from string import Template
@@ -159,13 +156,7 @@ class QemuUtils(object):
         self._params.add_with_value(
             'net', 'user,hostfwd=tcp::{info[port]}-:22'.format(
                 info=self._vm_info))
-        # TODO: Remove try except after fully migrated to Bionic or
-        # qemu_set_node is removed.
-        try:
-            locking = ',file.locking=off'\
-                if self.qemu_version(version='2.10') else ''
-        except AttributeError:
-            locking = ''
+        locking = ',file.locking=off'
         self._params.add_with_value(
             'drive', 'file={img},format=raw,cache=none,if=virtio{locking}'.
             format(img=self._opt.get('img'), locking=locking))
@@ -646,22 +637,18 @@ class QemuUtils(object):
             exec_cmd(self._node, 'cat {value}'.format(value=value), sudo=True)
             exec_cmd(self._node, 'rm -f {value}'.format(value=value), sudo=True)
 
-    def qemu_version(self, version=None):
-        """Return Qemu version or compare if version is higher than parameter.
+    def qemu_version(self):
+        """Return Qemu version.
 
-        :param version: Version to compare.
-        :type version: str
-        :returns: Qemu version or Boolean if version is higher than parameter.
-        :rtype: str or bool
+        :returns: Qemu version.
+        :rtype: str
         """
         command = ('{bin_path}/qemu-system-{arch} --version'.format(
             bin_path=Constants.QEMU_BIN_PATH,
             arch=self._arch))
         try:
             stdout, _ = exec_cmd_no_error(self._node, command, sudo=True)
-            ver = match(r'QEMU emulator version ([\d.]*)', stdout).group(1)
-            return StrictVersion(ver) > StrictVersion(version) \
-                if version else ver
+            return match(r'QEMU emulator version ([\d.]*)', stdout).group(1)
         except RuntimeError:
             self.qemu_kill_all()
             raise
index 1d0a213..4fe549e 100644 (file)
@@ -252,7 +252,7 @@ class VatTerminal(object):
                     self._tty,
                     'sudo -S {0}{1}'.format(Constants.VAT_BIN_NAME, json_text),
                     self.__VAT_PROMPT)
-            except Exception:  #pylint: disable=broad-except
+            except Exception:
                 continue
             else:
                 break