Ports plugin crashs on start with Python 3 (issue#918)

pull/923/head
nicolargo 2016-09-11 11:04:20 +02:00
parent 55346cd18d
commit cc9e7adbbf
2 changed files with 5 additions and 1 deletions

View File

@ -24,6 +24,7 @@
import operator
import sys
import unicodedata
import types
PY3 = sys.version_info[0] == 3
@ -47,6 +48,7 @@ if PY3:
text_type = str
binary_type = bytes
bool_type = bool
viewkeys = operator.methodcaller('keys')
viewvalues = operator.methodcaller('values')
@ -96,6 +98,7 @@ else:
text_type = unicode
binary_type = str
bool_type = types.BooleanType
viewkeys = operator.methodcaller('viewkeys')
viewvalues = operator.methodcaller('viewvalues')

View File

@ -29,6 +29,7 @@ import time
from glances.globals import WINDOWS
from glances.ports_list import GlancesPortsList
from glances.timer import Timer, Counter
from glances.compat import bool_type
from glances.logger import logger
from glances.plugins.glances_plugin import GlancesPlugin
@ -116,7 +117,7 @@ class Plugin(GlancesPlugin):
for p in self.stats:
if p['status'] is None:
status = 'Scanning'
elif isinstance(p['status'], types.BooleanType) and p['status'] is True:
elif isinstance(p['status'], bool_type) and p['status'] is True:
status = 'Open'
elif p['status'] == 0:
status = 'Timeout'