Reformat with Black

This commit is contained in:
nicolargo 2023-05-01 10:24:43 +02:00
parent dc49b12307
commit d601fb9c9a
12 changed files with 107 additions and 92 deletions

View File

@ -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
@ -19,24 +20,23 @@ from datetime import datetime
# If extensions (or modules to document with autodoc) are in another directory, # If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the # add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here. # documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.')) # sys.path.insert(0, os.path.abspath('.'))
# Insert Glances' path into the system. # Insert Glances' path into the system.
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 ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here. # If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0' # needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones. # ones.
#extensions = ['sphinxcontrib.autohttp.bottle'] # extensions = ['sphinxcontrib.autohttp.bottle']
extensions = ['sphinx.ext.intersphinx'] extensions = ['sphinx.ext.intersphinx']
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
@ -48,7 +48,7 @@ templates_path = ['_templates']
source_suffix = '.rst' source_suffix = '.rst'
# The encoding of source files. # The encoding of source files.
#source_encoding = 'utf-8-sig' # source_encoding = 'utf-8-sig'
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = 'index'
@ -76,13 +76,13 @@ release = version
# #
# This is also used if you do content translation via gettext catalogs. # This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases. # Usually you set "language" from the command line for these cases.
#language = None # language = None
# There are two options for replacing |today|: either, you set today to some # There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used: # non-false value, then it is used:
#today = '' # today = ''
# Else, today_fmt is used as the format for a strftime call. # Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y' # today_fmt = '%B %d, %Y'
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
@ -90,27 +90,27 @@ exclude_patterns = ['_build']
# The reST default role (used for this markup: `text`) to use for all # The reST default role (used for this markup: `text`) to use for all
# documents. # documents.
#default_role = None # default_role = None
# If true, '()' will be appended to :func: etc. cross-reference text. # If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True # add_function_parentheses = True
# If true, the current module name will be prepended to all description # If true, the current module name will be prepended to all description
# unit titles (such as .. function::). # unit titles (such as .. function::).
#add_module_names = True # add_module_names = True
# If true, sectionauthor and moduleauthor directives will be shown in the # If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default. # output. They are ignored by default.
#show_authors = False # show_authors = False
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# A list of ignored prefixes for module index sorting. # A list of ignored prefixes for module index sorting.
#modindex_common_prefix = [] # modindex_common_prefix = []
# If true, keep warnings as "system message" paragraphs in the built documents. # If true, keep warnings as "system message" paragraphs in the built documents.
#keep_warnings = False # keep_warnings = False
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False todo_include_todos = False
@ -129,23 +129,23 @@ html_theme_options = {
} }
# Add any paths that contain custom themes here, relative to this directory. # Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = [] # html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to # The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation". # "<project> v<release> documentation".
#html_title = None # html_title = None
# A shorter title for the navigation bar. Default is the same as html_title. # A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None # html_short_title = None
# The name of an image file (relative to this directory) to place at the top # The name of an image file (relative to this directory) to place at the top
# of the sidebar. # of the sidebar.
#html_logo = None # html_logo = None
# The name of an image file (relative to this directory) to use as a favicon of # The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large. # pixels large.
#html_favicon = None # html_favicon = None
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
@ -155,15 +155,15 @@ html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or # Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied # .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation. # directly to the root of the documentation.
#html_extra_path = [] # html_extra_path = []
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y' # html_last_updated_fmt = '%b %d, %Y'
# If true, SmartyPants will be used to convert quotes and dashes to # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.
#html_use_smartypants = True # html_use_smartypants = True
# Custom sidebar templates, maps document names to template names. # Custom sidebar templates, maps document names to template names.
html_sidebars = { html_sidebars = {
@ -177,47 +177,47 @@ html_sidebars = {
# Additional templates that should be rendered to pages, maps page names to # Additional templates that should be rendered to pages, maps page names to
# template names. # template names.
#html_additional_pages = {} # html_additional_pages = {}
# If false, no module index is generated. # If false, no module index is generated.
#html_domain_indices = True # html_domain_indices = True
# If false, no index is generated. # If false, no index is generated.
#html_use_index = True # html_use_index = True
# If true, the index is split into individual pages for each letter. # If true, the index is split into individual pages for each letter.
#html_split_index = False # html_split_index = False
# If true, links to the reST sources are added to the pages. # If true, links to the reST sources are added to the pages.
html_show_sourcelink = False html_show_sourcelink = False
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
#html_show_sphinx = True # html_show_sphinx = True
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
#html_show_copyright = True # html_show_copyright = True
# If true, an OpenSearch description file will be output, and all pages will # If true, an OpenSearch description file will be output, and all pages will
# contain a <link> tag referring to it. The value of this option must be the # contain a <link> tag referring to it. The value of this option must be the
# base URL from which the finished HTML is served. # base URL from which the finished HTML is served.
#html_use_opensearch = '' # html_use_opensearch = ''
# This is the file name suffix for HTML files (e.g. ".xhtml"). # This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None # html_file_suffix = None
# Language to be used for generating the HTML full-text search index. # Language to be used for generating the HTML full-text search index.
# Sphinx supports the following languages: # Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' # 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' # 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr'
#html_search_language = 'en' # html_search_language = 'en'
# A dictionary with options for the search language support, empty by default. # A dictionary with options for the search language support, empty by default.
# Now only 'ja' uses this config value # Now only 'ja' uses this config value
#html_search_options = {'type': 'default'} # html_search_options = {'type': 'default'}
# The name of a javascript file (relative to the configuration directory) that # The name of a javascript file (relative to the configuration directory) that
# implements a search results scorer. If empty, the default will be used. # implements a search results scorer. If empty, the default will be used.
#html_search_scorer = 'scorer.js' # html_search_scorer = 'scorer.js'
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'Glancesdoc' htmlhelp_basename = 'Glancesdoc'
@ -248,23 +248,23 @@ latex_documents = [
# The name of an image file (relative to this directory) to place at the top of # The name of an image file (relative to this directory) to place at the top of
# the title page. # the title page.
#latex_logo = None # latex_logo = None
# For "manual" documents, if this is true, then toplevel headings are parts, # For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters. # not chapters.
#latex_use_parts = False # latex_use_parts = False
# If true, show page references after internal links. # If true, show page references after internal links.
#latex_show_pagerefs = False # latex_show_pagerefs = False
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#latex_show_urls = False # latex_show_urls = False
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#latex_appendices = [] # latex_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#latex_domain_indices = True # latex_domain_indices = True
# -- Options for manual page output --------------------------------------- # -- Options for manual page output ---------------------------------------
@ -277,7 +277,7 @@ man_pages = [
] ]
# If true, show URL addresses after external links. # If true, show URL addresses after external links.
#man_show_urls = False # man_show_urls = False
# -- Options for Texinfo output ------------------------------------------- # -- Options for Texinfo output -------------------------------------------
@ -292,13 +292,13 @@ texinfo_documents = [
] ]
# Documents to append as an appendix to all manuals. # Documents to append as an appendix to all manuals.
#texinfo_appendices = [] # texinfo_appendices = []
# If false, no module index is generated. # If false, no module index is generated.
#texinfo_domain_indices = True # texinfo_domain_indices = True
# How to display URL addresses: 'footnote', 'no', or 'inline'. # How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote' # texinfo_show_urls = 'footnote'
# If true, do not generate a @detailmenu in the "Top" node's menu. # If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False # texinfo_no_detailmenu = False

View File

@ -42,7 +42,7 @@ class GlancesAmp(object):
# AMP name (= module name without glances_) # AMP name (= module name without glances_)
if name is None: if name is None:
self.amp_name = self.__class__.__module__[len('glances_'):] self.amp_name = self.__class__.__module__[len('glances_') :]
else: else:
self.amp_name = name self.amp_name = name

View File

@ -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']}

View File

@ -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

View File

@ -41,7 +41,7 @@ class GlancesExport(object):
def __init__(self, config=None, args=None): def __init__(self, config=None, args=None):
"""Init the export class.""" """Init the export class."""
# Export name (= module name without glances_) # Export name (= module name without glances_)
self.export_name = self.__class__.__module__[len('glances_'):] self.export_name = self.__class__.__module__[len('glances_') :]
logger.debug("Init export module %s" % self.export_name) logger.debug("Init export module %s" % self.export_name)
# Init the config & args # Init the config & args

View File

@ -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

View File

@ -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):

View File

@ -113,14 +113,14 @@ class GlancesStdoutIssue(object):
) )
if isinstance(stat, list) and len(stat) > 0 and 'key' in stat[0]: if isinstance(stat, list) and len(stat) > 0 and 'key' in stat[0]:
key = 'key={} '.format(stat[0]['key']) key = 'key={} '.format(stat[0]['key'])
message = colors.ORANGE + key + colors.NO + str(stat)[0: TERMINAL_WIDTH - 41 - len(key)] message = colors.ORANGE + key + colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41 - len(key)]
else: else:
message = colors.NO + str(stat)[0: TERMINAL_WIDTH - 41] message = colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41]
else: else:
result = (colors.RED + '[ERROR]' + colors.BLUE + ' {:.5f}s '.format(counter.get())).rjust( result = (colors.RED + '[ERROR]' + colors.BLUE + ' {:.5f}s '.format(counter.get())).rjust(
41 - len(plugin) 41 - len(plugin)
) )
message = colors.NO + str(stat_error)[0: TERMINAL_WIDTH - 41] message = colors.NO + str(stat_error)[0 : TERMINAL_WIDTH - 41]
self.print_issue(plugin, result, message) self.print_issue(plugin, result, message)
# Display total time need to update all plugins # Display total time need to update all plugins

View File

@ -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))

View File

@ -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(

View File

@ -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'))
) )

View File

@ -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