Hi there,
Your patch failed the 'make check-local' we usually do when testing new
contributions*. I
don't know if Aline talked about it in this ML, but we usually refuse
patches that fails
this sanity check and encourage people to always run this command before
submitting
patches to Kimchi. It was just a small pep8 fix though, so I've fixed
and amended the patch.
Patch applied to the 'next' branch of
https://github.com/danielhb/kimchi
repo.
Thanks!
* this was the output of make check-local:
$ make check-local
PYTHONPATH=src contrib/check_i18n.py plugins/*/i18n.py src/kimchi/i18n.py
Checking for invalid i18n string...
Checking for invalid i18n string successfully
find . -path './.git' -prune -type f -o \
-name '*.py' -o -name '*.py.in' | xargs /usr/bin/pyflakes | \
grep -w -v "\./src/kimchi/websocket\.py" | \
while read LINE; do echo "$LINE"; false; done
/usr/bin/pep8 --version
1.6.2
/usr/bin/pep8 --filename '*.py,*.py.in'
--exclude="*src/kimchi/config.py,*src/kimchi/i18n.py,*tests/test_config.py"
.
./src/kimchi/model/host.py:124:26: E231 missing whitespace after ','
Makefile:927: recipe for target 'check-local' failed
make: *** [check-local] Error 1
On 07/09/2015 04:49 PM, stephan.conrad(a)gmail.com wrote:
From: Stephan Conrad <stephan.conrad(a)gmail.com>
Signed-off-by: Stephan Conrad <stephan.conrad(a)gmail.com>
---
src/kimchi/model/host.py | 17 ++++++++++++++---
src/kimchi/osinfo.py | 6 ++++--
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index b2fa379..03aa974 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -102,13 +102,16 @@ class HostModel(object):
return res
def lookup(self, *name):
- cpus = psutil.NUM_CPUS
+ cpus = 0
# psutil is unstable on how to get the number of
# cpus, different versions call it differently
if hasattr(psutil, 'cpu_count'):
cpus = psutil.cpu_count()
+ elif hasattr(psutil, 'NUM_CPUS'):
+ cpus = psutil.NUM_CPUS
+
elif hasattr(psutil, '_psplatform'):
for method_name in ['_get_num_cpus', 'get_num_cpus']:
@@ -118,7 +121,10 @@ class HostModel(object):
break
self.host_info['cpus'] = cpus
- self.host_info['memory'] = psutil.phymem_usage().total
+ if hasattr(psutil,'phymem_usage'):
+ self.host_info['memory'] = psutil.phymem_usage().total
+ elif hasattr(psutil, 'virtual_memory'):
+ self.host_info['memory'] = psutil.virtual_memory().total
return self.host_info
def swupdate(self, *name):
@@ -248,7 +254,12 @@ class HostStatsModel(object):
prev_recv_bytes = net_recv_bytes[-1] if net_recv_bytes else 0
prev_sent_bytes = net_sent_bytes[-1] if net_sent_bytes else 0
- net_ios = psutil.network_io_counters(True)
+ net_ios = None
+ if hasattr(psutil, 'net_io_counters'):
+ net_ios = psutil.net_io_counters(True)
+ elif hasattr(psutil, 'network_io_counters'):
+ net_ios = psutil.network_io_counters(True)
+
recv_bytes = 0
sent_bytes = 0
for key in set(netinfo.nics() +
diff --git a/src/kimchi/osinfo.py b/src/kimchi/osinfo.py
index 78eb828..df10910 100644
--- a/src/kimchi/osinfo.py
+++ b/src/kimchi/osinfo.py
@@ -186,8 +186,10 @@ def lookup(distro, version):
arch = _get_arch()
# Setting maxMemory of the VM, which will be equal total Host memory in Kib
- params['max_memory'] = psutil.TOTAL_PHYMEM >> 10
-
+ if hasattr(psutil, 'virtual_memory'):
+ params['max_memory'] = psutil.virtual_memory().total >> 10
+ else:
+ params['max_memory'] = psutil.TOTAL_PHYMEM >> 10
# set up arch to ppc64 instead of ppc64le due to libvirt compatibility
if params["arch"] == "ppc64le":
params["arch"] = "ppc64"