Skip to content

Commit 31ff0f7

Browse files
Refactoring: random cleanup while viewing code with @nick-carbonsoft. (#141)
1 parent 3be4091 commit 31ff0f7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

netutils_linux_monitoring/base_top.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from abc import abstractmethod
12
import argparse
23
from os import system
34
from random import randint
@@ -101,14 +102,14 @@ def __repr_table__(self, table):
101102
return BaseTop.header + str(table)
102103
return str(table)
103104

105+
@abstractmethod
104106
def parse(self):
105107
""" Should read some file(s) into python structure (dict/list) """
106-
raise NotImplementedError
107108

109+
@abstractmethod
108110
def eval(self):
109111
""" Should evaluate self.diff using self.previous / self.current """
110-
raise NotImplementedError
111112

113+
@abstractmethod
112114
def __repr__(self):
113115
""" Should return string, representing self.diff """
114-
raise NotImplementedError

netutils_linux_monitoring/topology.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def detect_layout_lscpu(self, lscpu_output=None):
4848
return lscpu_output
4949
stdout, return_code = self.__detect_layout_lscpu()
5050
if return_code != 0:
51-
return self.detect_layouts_fallback()
51+
self.detect_layouts_fallback()
52+
return
5253
if isinstance(stdout, bytes):
5354
stdout = str(stdout)
5455
return stdout
@@ -59,10 +60,9 @@ def detect_layouts_fallback(self):
5960
"""
6061
process = Popen(['nproc'], stdout=PIPE, stderr=PIPE)
6162
stdout, _ = process.communicate()
62-
if process.returncode != 0:
63-
return None
64-
cpu_count = int(stdout.strip())
65-
self.socket_layout = self.numa_layout = dict(enumerate([0] * cpu_count))
63+
if process.returncode == 0:
64+
cpu_count = int(stdout.strip())
65+
self.socket_layout = self.numa_layout = dict(enumerate([0] * cpu_count))
6666

6767
@staticmethod
6868
def __detect_layout_lscpu():

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def read(*paths):
1616

1717
setuptools.setup(
1818
name='netutils-linux',
19-
version='2.2.8',
19+
version='2.2.10',
2020
author='Oleg Strizhechenko',
2121
author_email='[email protected]',
2222
license='MIT',

0 commit comments

Comments
 (0)