mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-04 03:53:36 +03:00
Reformat with Black
This commit is contained in:
parent
dc49b12307
commit
d601fb9c9a
@ -12,6 +12,7 @@
|
|||||||
# All configuration values have a default; values that are commented out
|
# All configuration values have a default; values that are commented out
|
||||||
# serve to show the default.
|
# serve to show the default.
|
||||||
|
|
||||||
|
from glances import __version__
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@ -25,7 +26,6 @@ from datetime import datetime
|
|||||||
sys.path.insert(0, os.path.abspath('..'))
|
sys.path.insert(0, os.path.abspath('..'))
|
||||||
|
|
||||||
# WARNING: Do not move this import before the sys.path.insert() call.
|
# WARNING: Do not move this import before the sys.path.insert() call.
|
||||||
from glances import __version__
|
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ------------------------------------------------
|
# -- General configuration ------------------------------------------------
|
||||||
|
@ -142,9 +142,9 @@ class AmpsList(object):
|
|||||||
# Search in both cmdline and name (for kernel thread, see #1261)
|
# Search in both cmdline and name (for kernel thread, see #1261)
|
||||||
for p in processlist:
|
for p in processlist:
|
||||||
if (re.search(amp_value.regex(), p['name']) is not None) or (
|
if (re.search(amp_value.regex(), p['name']) is not None) or (
|
||||||
p['cmdline'] is not None and
|
p['cmdline'] is not None
|
||||||
p['cmdline'] != [] and
|
and p['cmdline'] != []
|
||||||
re.search(amp_value.regex(), ' '.join(p['cmdline'])) is not None
|
and re.search(amp_value.regex(), ' '.join(p['cmdline'])) is not None
|
||||||
):
|
):
|
||||||
ret.append(
|
ret.append(
|
||||||
{'pid': p['pid'], 'cpu_percent': p['cpu_percent'], 'memory_percent': p['memory_percent']}
|
{'pid': p['pid'], 'cpu_percent': p['cpu_percent'], 'memory_percent': p['memory_percent']}
|
||||||
|
@ -35,7 +35,6 @@ if PY3:
|
|||||||
from urllib.error import HTTPError, URLError
|
from urllib.error import HTTPError, URLError
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
||||||
# Correct issue #1025 by monkey path the xmlrpc lib
|
# Correct issue #1025 by monkey path the xmlrpc lib
|
||||||
from defusedxml.xmlrpc import monkey_patch
|
from defusedxml.xmlrpc import monkey_patch
|
||||||
|
|
||||||
|
@ -550,6 +550,7 @@ Examples of use:
|
|||||||
logger.setLevel(DEBUG)
|
logger.setLevel(DEBUG)
|
||||||
else:
|
else:
|
||||||
from warnings import simplefilter
|
from warnings import simplefilter
|
||||||
|
|
||||||
simplefilter("ignore")
|
simplefilter("ignore")
|
||||||
|
|
||||||
# Plugins refresh rate
|
# Plugins refresh rate
|
||||||
|
@ -330,7 +330,7 @@ class _GlancesCurses(object):
|
|||||||
'CRITICAL_LOG': self.ifCRITICAL_color,
|
'CRITICAL_LOG': self.ifCRITICAL_color,
|
||||||
'PASSWORD': curses.A_PROTECT,
|
'PASSWORD': curses.A_PROTECT,
|
||||||
'SELECTED': self.selected_color,
|
'SELECTED': self.selected_color,
|
||||||
'INFO': self.ifINFO_color
|
'INFO': self.ifINFO_color,
|
||||||
}
|
}
|
||||||
|
|
||||||
def set_cursor(self, value):
|
def set_cursor(self, value):
|
||||||
|
@ -111,9 +111,7 @@ class Plugin(GlancesPlugin):
|
|||||||
msg = self.stats.get('platform', 'Unknown')
|
msg = self.stats.get('platform', 'Unknown')
|
||||||
ret.append(self.curse_add_line(msg, "TITLE"))
|
ret.append(self.curse_add_line(msg, "TITLE"))
|
||||||
msg = ' {} instance {} ({})'.format(
|
msg = ' {} instance {} ({})'.format(
|
||||||
self.stats.get('type', 'Unknown'),
|
self.stats.get('type', 'Unknown'), self.stats.get('name', 'Unknown'), self.stats.get('region', 'Unknown')
|
||||||
self.stats.get('name', 'Unknown'),
|
|
||||||
self.stats.get('region', 'Unknown')
|
|
||||||
)
|
)
|
||||||
ret.append(self.curse_add_line(msg))
|
ret.append(self.curse_add_line(msg))
|
||||||
|
|
||||||
|
@ -325,8 +325,8 @@ class Plugin(GlancesPlugin):
|
|||||||
# Display rate if stats is available and io_tag ([4]) == 1
|
# Display rate if stats is available and io_tag ([4]) == 1
|
||||||
# IO
|
# IO
|
||||||
io = int(
|
io = int(
|
||||||
(p['io_counters'][0 if rorw == 'ior' else 1] - p['io_counters'][2 if rorw == 'ior' else 3]) /
|
(p['io_counters'][0 if rorw == 'ior' else 1] - p['io_counters'][2 if rorw == 'ior' else 3])
|
||||||
p['time_since_update']
|
/ p['time_since_update']
|
||||||
)
|
)
|
||||||
if io == 0:
|
if io == 0:
|
||||||
msg = self.layout_stat[rorw].format("0")
|
msg = self.layout_stat[rorw].format("0")
|
||||||
@ -357,8 +357,11 @@ class Plugin(GlancesPlugin):
|
|||||||
# When a process is selected:
|
# When a process is selected:
|
||||||
# * display a special character at the beginning of the line
|
# * display a special character at the beginning of the line
|
||||||
# * underline the command name
|
# * underline the command name
|
||||||
ret.append(self.curse_add_line(unicode_message('PROCESS_SELECTOR') if (selected and not args.disable_cursor)
|
ret.append(
|
||||||
else ' ', 'SELECTED'))
|
self.curse_add_line(
|
||||||
|
unicode_message('PROCESS_SELECTOR') if (selected and not args.disable_cursor) else ' ', 'SELECTED'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# CPU
|
# CPU
|
||||||
ret.append(self._get_process_curses_cpu(p, selected, args))
|
ret.append(self._get_process_curses_cpu(p, selected, args))
|
||||||
@ -433,10 +436,12 @@ class Plugin(GlancesPlugin):
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def is_selected_process(self, args):
|
def is_selected_process(self, args):
|
||||||
return args.is_standalone and \
|
return (
|
||||||
self.args.enable_process_extended and \
|
args.is_standalone
|
||||||
args.cursor_position is not None and \
|
and self.args.enable_process_extended
|
||||||
glances_processes.extended_process is not None
|
and args.cursor_position is not None
|
||||||
|
and glances_processes.extended_process is not None
|
||||||
|
)
|
||||||
|
|
||||||
def msg_curse(self, args=None, max_width=None):
|
def msg_curse(self, args=None, max_width=None):
|
||||||
"""Return the dict to display in the curse interface."""
|
"""Return the dict to display in the curse interface."""
|
||||||
@ -468,9 +473,7 @@ class Plugin(GlancesPlugin):
|
|||||||
# This is a Glances bottleneck (see flame graph),
|
# This is a Glances bottleneck (see flame graph),
|
||||||
# get_process_curses_data should be optimzed
|
# get_process_curses_data should be optimzed
|
||||||
for position, process in enumerate(processes_list_sorted):
|
for position, process in enumerate(processes_list_sorted):
|
||||||
ret.extend(self.get_process_curses_data(process,
|
ret.extend(self.get_process_curses_data(process, position == args.cursor_position, args))
|
||||||
position == args.cursor_position,
|
|
||||||
args))
|
|
||||||
|
|
||||||
# A filter is set Display the stats summaries
|
# A filter is set Display the stats summaries
|
||||||
if glances_processes.process_filter is not None:
|
if glances_processes.process_filter is not None:
|
||||||
@ -578,12 +581,20 @@ class Plugin(GlancesPlugin):
|
|||||||
if 'memory_info' in p and p['memory_info'] is not None:
|
if 'memory_info' in p and p['memory_info'] is not None:
|
||||||
ret.append(self.curse_add_line(' Memory info: '))
|
ret.append(self.curse_add_line(' Memory info: '))
|
||||||
for k in p['memory_info']._asdict():
|
for k in p['memory_info']._asdict():
|
||||||
ret.append(self.curse_add_line(self.auto_unit(p['memory_info']._asdict()[k], low_precision=False),
|
ret.append(
|
||||||
decoration='INFO', splittable=True))
|
self.curse_add_line(
|
||||||
|
self.auto_unit(p['memory_info']._asdict()[k], low_precision=False),
|
||||||
|
decoration='INFO',
|
||||||
|
splittable=True,
|
||||||
|
)
|
||||||
|
)
|
||||||
ret.append(self.curse_add_line(' ' + k + ' ', splittable=True))
|
ret.append(self.curse_add_line(' ' + k + ' ', splittable=True))
|
||||||
if 'memory_swap' in p and p['memory_swap'] is not None:
|
if 'memory_swap' in p and p['memory_swap'] is not None:
|
||||||
ret.append(self.curse_add_line(self.auto_unit(p['memory_swap'], low_precision=False),
|
ret.append(
|
||||||
decoration='INFO', splittable=True))
|
self.curse_add_line(
|
||||||
|
self.auto_unit(p['memory_swap'], low_precision=False), decoration='INFO', splittable=True
|
||||||
|
)
|
||||||
|
)
|
||||||
ret.append(self.curse_add_line(' swap ', splittable=True))
|
ret.append(self.curse_add_line(' swap ', splittable=True))
|
||||||
|
|
||||||
# Third line is for open files/network sessions
|
# Third line is for open files/network sessions
|
||||||
@ -650,8 +661,7 @@ class Plugin(GlancesPlugin):
|
|||||||
shortkey = "('e' to pin | 'k' to kill)"
|
shortkey = "('e' to pin | 'k' to kill)"
|
||||||
else:
|
else:
|
||||||
shortkey = ""
|
shortkey = ""
|
||||||
msg = self.layout_header['command'].format("Programs" if self.args.programs else "Command",
|
msg = self.layout_header['command'].format("Programs" if self.args.programs else "Command", shortkey)
|
||||||
shortkey)
|
|
||||||
ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'name' else 'DEFAULT'))
|
ret.append(self.curse_add_line(msg, sort_style if process_sort_key == 'name' else 'DEFAULT'))
|
||||||
|
|
||||||
def __msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
|
def __msg_curse_sum(self, ret, sep_char='_', mmm=None, args=None):
|
||||||
@ -675,9 +685,9 @@ class Plugin(GlancesPlugin):
|
|||||||
ret.append(self.curse_add_line(msg, decoration=self.__mmm_deco(mmm)))
|
ret.append(self.curse_add_line(msg, decoration=self.__mmm_deco(mmm)))
|
||||||
# VIRT and RES memory sum
|
# VIRT and RES memory sum
|
||||||
if (
|
if (
|
||||||
'memory_info' in self.stats[0] and
|
'memory_info' in self.stats[0]
|
||||||
self.stats[0]['memory_info'] is not None and
|
and self.stats[0]['memory_info'] is not None
|
||||||
self.stats[0]['memory_info'] != ''
|
and self.stats[0]['memory_info'] != ''
|
||||||
):
|
):
|
||||||
# VMS
|
# VMS
|
||||||
msg = self.layout_stat['virt'].format(
|
msg = self.layout_stat['virt'].format(
|
||||||
|
@ -188,7 +188,9 @@ class Plugin(GlancesPlugin):
|
|||||||
# Add the new hotspot to the message
|
# Add the new hotspot to the message
|
||||||
msg = '{:{width}}'.format(nativestr(hotspot_name), width=if_name_max_width)
|
msg = '{:{width}}'.format(nativestr(hotspot_name), width=if_name_max_width)
|
||||||
ret.append(self.curse_add_line(msg))
|
ret.append(self.curse_add_line(msg))
|
||||||
msg = '{:>7}'.format(i['signal'], )
|
msg = '{:>7}'.format(
|
||||||
|
i['signal'],
|
||||||
|
)
|
||||||
ret.append(
|
ret.append(
|
||||||
self.curse_add_line(msg, self.get_views(item=i[self.get_key()], key='signal', option='decoration'))
|
self.curse_add_line(msg, self.get_views(item=i[self.get_key()], key='signal', option='decoration'))
|
||||||
)
|
)
|
||||||
|
@ -313,15 +313,19 @@ class GlancesProcesses(object):
|
|||||||
if stat_prefix + '_min' not in self.extended_process:
|
if stat_prefix + '_min' not in self.extended_process:
|
||||||
ret[stat_prefix + '_min'] = proc[stat_prefix + '_percent']
|
ret[stat_prefix + '_min'] = proc[stat_prefix + '_percent']
|
||||||
else:
|
else:
|
||||||
ret[stat_prefix + '_min'] = \
|
ret[stat_prefix + '_min'] = (
|
||||||
proc[stat_prefix + '_percent'] if proc[stat_prefix + '_min'] > proc[stat_prefix + '_percent'] \
|
proc[stat_prefix + '_percent']
|
||||||
|
if proc[stat_prefix + '_min'] > proc[stat_prefix + '_percent']
|
||||||
else proc[stat_prefix + '_min']
|
else proc[stat_prefix + '_min']
|
||||||
|
)
|
||||||
if stat_prefix + '_max' not in self.extended_process:
|
if stat_prefix + '_max' not in self.extended_process:
|
||||||
ret[stat_prefix + '_max'] = proc[stat_prefix + '_percent']
|
ret[stat_prefix + '_max'] = proc[stat_prefix + '_percent']
|
||||||
else:
|
else:
|
||||||
ret[stat_prefix + '_max'] = \
|
ret[stat_prefix + '_max'] = (
|
||||||
proc[stat_prefix + '_percent'] if proc[stat_prefix + '_max'] < proc[stat_prefix + '_percent'] \
|
proc[stat_prefix + '_percent']
|
||||||
|
if proc[stat_prefix + '_max'] < proc[stat_prefix + '_percent']
|
||||||
else proc[stat_prefix + '_max']
|
else proc[stat_prefix + '_max']
|
||||||
|
)
|
||||||
if stat_prefix + '_mean_sum' not in self.extended_process:
|
if stat_prefix + '_mean_sum' not in self.extended_process:
|
||||||
ret[stat_prefix + '_mean_sum'] = proc[stat_prefix + '_percent']
|
ret[stat_prefix + '_mean_sum'] = proc[stat_prefix + '_percent']
|
||||||
else:
|
else:
|
||||||
@ -337,14 +341,16 @@ class GlancesProcesses(object):
|
|||||||
|
|
||||||
def is_selected_extended_process(self, position):
|
def is_selected_extended_process(self, position):
|
||||||
"""Return True if the process is the selected one for extended stats."""
|
"""Return True if the process is the selected one for extended stats."""
|
||||||
return hasattr(self.args, 'programs') and \
|
return (
|
||||||
not self.args.programs and \
|
hasattr(self.args, 'programs')
|
||||||
hasattr(self.args, 'enable_process_extended') and \
|
and not self.args.programs
|
||||||
self.args.enable_process_extended and \
|
and hasattr(self.args, 'enable_process_extended')
|
||||||
not self.disable_extended_tag and \
|
and self.args.enable_process_extended
|
||||||
hasattr(self.args, 'cursor_position') and \
|
and not self.disable_extended_tag
|
||||||
position == self.args.cursor_position and \
|
and hasattr(self.args, 'cursor_position')
|
||||||
not self.args.disable_cursor
|
and position == self.args.cursor_position
|
||||||
|
and not self.args.disable_cursor
|
||||||
|
)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the processes stats."""
|
"""Update the processes stats."""
|
||||||
@ -416,8 +422,7 @@ class GlancesProcesses(object):
|
|||||||
self.extended_process = proc
|
self.extended_process = proc
|
||||||
|
|
||||||
# Grab extended stats only for the selected process (see issue #2225)
|
# Grab extended stats only for the selected process (see issue #2225)
|
||||||
if self.extended_process is not None and \
|
if self.extended_process is not None and proc['pid'] == self.extended_process['pid']:
|
||||||
proc['pid'] == self.extended_process['pid']:
|
|
||||||
proc.update(self.get_extended_stats(self.extended_process))
|
proc.update(self.get_extended_stats(self.extended_process))
|
||||||
self.extended_process = proc
|
self.extended_process = proc
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user