test suite reviews and discussions
 help / color / mirror / Atom feed
* [PATCH v1] ics/net_device: fix pylama errors
@ 2021-12-06 12:18 Juraj Linkeš
  2021-12-06 12:18 ` [PATCH v1] nics/net_device: " Juraj Linkeš
  0 siblings, 1 reply; 4+ messages in thread
From: Juraj Linkeš @ 2021-12-06 12:18 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
nics/net_device.py:104: [E] E0213 Method should have "self" as first argument [pylint]
nics/net_device.py:114: [E] E1102 func is not callable [pylint]
nics/net_device.py:206: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:297: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:309: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:321: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:401: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:441: [E] E0602 Undefined variable 'bus_id' [pylint]
nics/net_device.py:461: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:490: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:516: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:519: [E] E0102 method already defined line 510 [pylint]
nics/net_device.py:525: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:622: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:696: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
Lijuan, please add additional people to review if needed.
---
Lijuan, please add additional people to review if needed.
---
 nics/net_device.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/nics/net_device.py b/nics/net_device.py
index 96f31327..e7c6b770 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -73,6 +73,7 @@ class NetDevice(object):
         self.driver_version = ''
         self.firmware = ''
         self.pkg = None
+        self.current_driver = None
 
     def stop(self):
         pass
@@ -101,6 +102,7 @@ class NetDevice(object):
         """
         return True
 
+    @staticmethod
     def nic_has_driver(func):
         """
         Check if the NIC has a driver.
@@ -438,7 +440,7 @@ class NetDevice(object):
                 'get_ipv4_addr_freebsd_%s' %
                 generic_driver)
 
-        return get_ipv4_addr_freebsd(intf, bus_id, devfun_id)
+        return get_ipv4_addr_freebsd(intf)
 
     def get_ipv4_addr_freebsd_generic(self, intf):
         """
@@ -515,15 +517,6 @@ class NetDevice(object):
             self, 'get_ipv6_addr_%s' % self.__get_os_type())
         return get_ipv6_addr(self.intf_name, self.current_driver)
 
-    @nic_has_driver
-    def get_ipv6_addr(self):
-        """
-        Get ipv6 address of specified pci device.
-        """
-        get_ipv6_addr = getattr(
-            self, 'get_ipv6_addr_%s' % self.__get_os_type())
-        return get_ipv6_addr(self.intf_name, self.current_driver)
-
     def get_ipv6_addr_linux(self, intf, driver):
         """
         Get ipv6 address of specified pci device on linux.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1] nics/net_device: fix pylama errors
  2021-12-06 12:18 [PATCH v1] ics/net_device: fix pylama errors Juraj Linkeš
@ 2021-12-06 12:18 ` Juraj Linkeš
  2021-12-15 15:28   ` [PATCH v2] " Juraj Linkeš
  0 siblings, 1 reply; 4+ messages in thread
From: Juraj Linkeš @ 2021-12-06 12:18 UTC (permalink / raw)
  To: lijuan.tu, ohilyard; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
nics/net_device.py:104: [E] E0213 Method should have "self" as first argument [pylint]
nics/net_device.py:114: [E] E1102 func is not callable [pylint]
nics/net_device.py:206: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:297: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:309: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:321: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:401: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:441: [E] E0602 Undefined variable 'bus_id' [pylint]
nics/net_device.py:461: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:490: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:516: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:519: [E] E0102 method already defined line 510 [pylint]
nics/net_device.py:525: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:622: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:696: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 nics/net_device.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/nics/net_device.py b/nics/net_device.py
index 96f31327..e7c6b770 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -73,6 +73,7 @@ class NetDevice(object):
         self.driver_version = ''
         self.firmware = ''
         self.pkg = None
+        self.current_driver = None
 
     def stop(self):
         pass
@@ -101,6 +102,7 @@ class NetDevice(object):
         """
         return True
 
+    @staticmethod
     def nic_has_driver(func):
         """
         Check if the NIC has a driver.
@@ -438,7 +440,7 @@ class NetDevice(object):
                 'get_ipv4_addr_freebsd_%s' %
                 generic_driver)
 
-        return get_ipv4_addr_freebsd(intf, bus_id, devfun_id)
+        return get_ipv4_addr_freebsd(intf)
 
     def get_ipv4_addr_freebsd_generic(self, intf):
         """
@@ -515,15 +517,6 @@ class NetDevice(object):
             self, 'get_ipv6_addr_%s' % self.__get_os_type())
         return get_ipv6_addr(self.intf_name, self.current_driver)
 
-    @nic_has_driver
-    def get_ipv6_addr(self):
-        """
-        Get ipv6 address of specified pci device.
-        """
-        get_ipv6_addr = getattr(
-            self, 'get_ipv6_addr_%s' % self.__get_os_type())
-        return get_ipv6_addr(self.intf_name, self.current_driver)
-
     def get_ipv6_addr_linux(self, intf, driver):
         """
         Get ipv6 address of specified pci device on linux.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] nics/net_device: fix pylama errors
  2021-12-06 12:18 ` [PATCH v1] nics/net_device: " Juraj Linkeš
@ 2021-12-15 15:28   ` Juraj Linkeš
  2022-01-14  8:55     ` Tu, Lijuan
  0 siblings, 1 reply; 4+ messages in thread
From: Juraj Linkeš @ 2021-12-15 15:28 UTC (permalink / raw)
  To: lijuan.tu, ohilyard, junx.dong; +Cc: dts, Juraj Linkeš

Pylama found the following errors:
nics/net_device.py:104: [E] E0213 Method should have "self" as first argument [pylint]
nics/net_device.py:114: [E] E1102 func is not callable [pylint]
- moved the decorator outside class definition, which is the standard
way to define decorators
nics/net_device.py:206: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:297: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:309: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:321: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:401: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:441: [E] E0602 Undefined variable 'bus_id' [pylint]
nics/net_device.py:461: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:490: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:516: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:519: [E] E0102 method already defined line 510 [pylint]
nics/net_device.py:525: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:622: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]
nics/net_device.py:696: [E] E1101 Instance of 'NetDevice' has no 'current_driver' member [pylint]

Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
---
Lijuan, please add additional people to review if needed.
---
 nics/net_device.py | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/nics/net_device.py b/nics/net_device.py
index 96f31327..19e239e4 100644
--- a/nics/net_device.py
+++ b/nics/net_device.py
@@ -45,6 +45,22 @@ NICS_LIST = []      # global list for save nic objects
 MIN_MTU = 68
 
 
+def nic_has_driver(func):
+    """
+    Check if the NIC has a driver.
+    """
+
+    @wraps(func)
+    def wrapper(*args, **kwargs):
+        nic_instance = args[0]
+        nic_instance.current_driver = nic_instance.get_nic_driver()
+        if not nic_instance.current_driver:
+            return ''
+        return func(*args, **kwargs)
+
+    return wrapper
+
+
 class NetDevice(object):
 
     """
@@ -73,6 +89,7 @@ class NetDevice(object):
         self.driver_version = ''
         self.firmware = ''
         self.pkg = None
+        self.current_driver = None
 
     def stop(self):
         pass
@@ -101,19 +118,6 @@ class NetDevice(object):
         """
         return True
 
-    def nic_has_driver(func):
-        """
-        Check if the NIC has a driver.
-        """
-        @wraps(func)
-        def wrapper(*args, **kwargs):
-            nic_instance = args[0]
-            nic_instance.current_driver = nic_instance.get_nic_driver()
-            if not nic_instance.current_driver:
-                return ''
-            return func(*args, **kwargs)
-        return wrapper
-
     def get_nic_driver(self):
         """
         Get the NIC driver.
@@ -273,7 +277,7 @@ class NetDevice(object):
         """
         Get the interface name by the default way on freebsd.
         """
-        pci_str = "%s:%s:%s" % (domain_id, bus_id, devfun_id) 
+        pci_str = "%s:%s:%s" % (domain_id, bus_id, devfun_id)
         out = self.__send_expect("pciconf -l", "# ")
         rexp = r"(\w*)@pci0:%s" % pci_str
         pattern = re.compile(rexp)
@@ -438,7 +442,7 @@ class NetDevice(object):
                 'get_ipv4_addr_freebsd_%s' %
                 generic_driver)
 
-        return get_ipv4_addr_freebsd(intf, bus_id, devfun_id)
+        return get_ipv4_addr_freebsd(intf)
 
     def get_ipv4_addr_freebsd_generic(self, intf):
         """
@@ -515,15 +519,6 @@ class NetDevice(object):
             self, 'get_ipv6_addr_%s' % self.__get_os_type())
         return get_ipv6_addr(self.intf_name, self.current_driver)
 
-    @nic_has_driver
-    def get_ipv6_addr(self):
-        """
-        Get ipv6 address of specified pci device.
-        """
-        get_ipv6_addr = getattr(
-            self, 'get_ipv6_addr_%s' % self.__get_os_type())
-        return get_ipv6_addr(self.intf_name, self.current_driver)
-
     def get_ipv6_addr_linux(self, intf, driver):
         """
         Get ipv6 address of specified pci device on linux.
-- 
2.20.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] nics/net_device: fix pylama errors
  2021-12-15 15:28   ` [PATCH v2] " Juraj Linkeš
@ 2022-01-14  8:55     ` Tu, Lijuan
  0 siblings, 0 replies; 4+ messages in thread
From: Tu, Lijuan @ 2022-01-14  8:55 UTC (permalink / raw)
  To: Juraj Linkeš, ohilyard, Dong, JunX; +Cc: dts

> -----Original Message-----
> From: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Sent: 2021年12月15日 23:29
> To: Tu, Lijuan <lijuan.tu@intel.com>; ohilyard@iol.unh.edu; Dong, JunX
> <junx.dong@intel.com>
> Cc: dts@dpdk.org; Juraj Linkeš <juraj.linkes@pantheon.tech>
> Subject: [PATCH v2] nics/net_device: fix pylama errors
> 
> Pylama found the following errors:
> nics/net_device.py:104: [E] E0213 Method should have "self" as first argument
> [pylint]
> nics/net_device.py:114: [E] E1102 func is not callable [pylint]
> - moved the decorator outside class definition, which is the standard way to
> define decorators
> nics/net_device.py:206: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:297: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:309: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:321: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:401: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:441: [E] E0602 Undefined variable 'bus_id' [pylint]
> nics/net_device.py:461: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:490: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:516: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:519: [E] E0102 method already defined line 510 [pylint]
> nics/net_device.py:525: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:622: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> nics/net_device.py:696: [E] E1101 Instance of 'NetDevice' has no
> 'current_driver' member [pylint]
> 
> Signed-off-by: Juraj Linkeš <juraj.linkes@pantheon.tech>

Applied

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-14  8:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06 12:18 [PATCH v1] ics/net_device: fix pylama errors Juraj Linkeš
2021-12-06 12:18 ` [PATCH v1] nics/net_device: " Juraj Linkeš
2021-12-15 15:28   ` [PATCH v2] " Juraj Linkeš
2022-01-14  8:55     ` Tu, Lijuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).