提交 5e5c6817 编写于 作者: A Alessio Sergi

PEP 257

- First line should end with a period
- No blank lines allowed after function docstring
- 1 blank line required between summary line and description
- 1 blank line required before class docstring
- Multi-line docstring closing quotes should be on a separate line
- No whitespaces allowed surrounding docstring text
- One-line docstring should fit on one line with quotes
- Use r""" if any backslashes in a docstring
上级 49ecd401
......@@ -35,11 +35,10 @@ else:
class GlancesActions(object):
"""This class manage action if an alert is reached"""
"""This class manage action if an alert is reached."""
def __init__(self):
"""Init GlancesActions class"""
"""Init GlancesActions class."""
# Dict with the criticity status
# - key: stat_name
# - value: criticity
......@@ -47,25 +46,26 @@ class GlancesActions(object):
self.status = {}
def get(self, stat_name):
"""Get the stat_name criticity"""
"""Get the stat_name criticity."""
try:
return self.status[stat_name]
except KeyError:
return None
def set(self, stat_name, criticity):
"""Set the stat_name to criticity"""
"""Set the stat_name to criticity."""
self.status[stat_name] = criticity
def run(self, stat_name, criticity, commands, mustache_dict=None):
"""Run the commands (in background)
"""Run the commands (in background).
- stats_name: plugin_name (+ header)
- criticity: criticity of the trigger
- commands: a list of command line with optional {{mustache}}
- mustache_dict: Plugin stats (can be use within {{mustache}})
Return True if the commands have been ran"""
Return True if the commands have been ran.
"""
if self.get(stat_name) == criticity:
# Action already executed => Exit
return False
......
......@@ -53,7 +53,7 @@ zeroconf_type = "_%s._tcp." % appname
class AutoDiscovered(object):
"""Class to manage the auto discovered servers dict"""
"""Class to manage the auto discovered servers dict."""
def __init__(self):
# server_dict is a list of dict (JSON compliant)
......@@ -61,15 +61,15 @@ class AutoDiscovered(object):
self._server_list = []
def get_servers_list(self):
"""Return the current server list (list of dict)"""
"""Return the current server list (list of dict)."""
return self._server_list
def set_server(self, server_pos, key, value):
"""Set the key to the value for the server_pos (position in the list)"""
"""Set the key to the value for the server_pos (position in the list)."""
self._server_list[server_pos][key] = value
def add_server(self, name, ip, port):
"""Add a new server to the list"""
"""Add a new server to the list."""
new_server = {'key': name, # Zeroconf name with both hostname and port
'name': name.split(':')[0], # Short name
'ip': ip, # IP address seen by the client
......@@ -84,7 +84,7 @@ class AutoDiscovered(object):
(len(self._server_list), self._server_list))
def remove_server(self, name):
"""Remove a server from the dict"""
"""Remove a server from the dict."""
for i in self._server_list:
if i['key'] == name:
try:
......@@ -99,22 +99,23 @@ class AutoDiscovered(object):
class GlancesAutoDiscoverListener(object):
"""Zeroconf listener for Glances server"""
"""Zeroconf listener for Glances server."""
def __init__(self):
# Create an instance of the servers list
self.servers = AutoDiscovered()
def get_servers_list(self):
"""Return the current server list (list of dict)"""
"""Return the current server list (list of dict)."""
return self.servers.get_servers_list()
def set_server(self, server_pos, key, value):
"""Set the key to the value for the server_pos (position in the list)"""
"""Set the key to the value for the server_pos (position in the list)."""
self.servers.set_server(server_pos, key, value)
def add_service(self, zeroconf, srv_type, srv_name):
"""Method called when a new Zeroconf client is detected
"""Method called when a new Zeroconf client is detected.
Return True if the zeroconf client is a Glances server
Note: the return code will never be used
"""
......@@ -137,7 +138,7 @@ class GlancesAutoDiscoverListener(object):
return True
def remove_service(self, zeroconf, srv_type, srv_name):
# Remove the server from the list
"""Remove the server from the list."""
self.servers.remove_server(srv_name)
logger.info(
"Glances server %s removed from the autodetect list" % srv_name)
......@@ -145,7 +146,7 @@ class GlancesAutoDiscoverListener(object):
class GlancesAutoDiscoverServer(object):
"""Implementation of the Zeroconf protocol (server side for the Glances client)"""
"""Implementation of the Zeroconf protocol (server side for the Glances client)."""
def __init__(self, args=None):
if zeroconf_tag:
......@@ -165,14 +166,14 @@ class GlancesAutoDiscoverServer(object):
self.zeroconf_enable_tag = False
def get_servers_list(self):
"""Return the current server list (dict of dict)"""
"""Return the current server list (dict of dict)."""
if zeroconf_tag and self.zeroconf_enable_tag:
return self.listener.get_servers_list()
else:
return []
def set_server(self, server_pos, key, value):
"""Set the key to the value for the server_pos (position in the list)"""
"""Set the key to the value for the server_pos (position in the list)."""
if zeroconf_tag and self.zeroconf_enable_tag:
self.listener.set_server(server_pos, key, value)
......
......@@ -38,7 +38,7 @@ from glances.outputs.glances_curses import GlancesCursesClient
class GlancesClientTransport(Transport):
"""This class overwrite the default XML-RPC transport and manage timeout"""
"""This class overwrite the default XML-RPC transport and manage timeout."""
def set_timeout(self, timeout):
self.timeout = timeout
......@@ -77,7 +77,7 @@ class GlancesClient(object):
self.log_and_exit("Client couldn't create socket {0}: {1}".format(uri, e))
def log_and_exit(self, msg=''):
"""Log and (exit)"""
"""Log and exit."""
if not self.return_to_browser:
logger.critical(msg)
sys.exit(2)
......@@ -216,9 +216,7 @@ class GlancesClient(object):
def serve_forever(self):
"""Main client loop."""
exitkey = False
try:
while True and not exitkey:
# Update the stats
......
......@@ -38,7 +38,7 @@ from glances.outputs.glances_curses import GlancesCursesBrowser
class GlancesClientBrowser(object):
"""This class creates and manages the TCP client browser (servers' list)."""
"""This class creates and manages the TCP client browser (servers list)."""
def __init__(self, config=None, args=None):
# Store the arg/config
......@@ -58,9 +58,9 @@ class GlancesClientBrowser(object):
self.screen = GlancesCursesBrowser(args=self.args)
def get_servers_list(self):
"""
Return the current server list (list of dict)
Merge of static + autodiscover servers list
"""Return the current server list (list of dict).
Merge of static + autodiscover servers list.
"""
ret = []
......@@ -72,7 +72,7 @@ class GlancesClientBrowser(object):
return ret
def __get_uri(self, server):
"""Return the URI for the given server dict"""
"""Return the URI for the given server dict."""
# Select the connection mode (with or without password)
if server['password'] != "":
return 'http://{0}:{1}@{2}:{3}'.format(server['username'], server['password'],
......@@ -218,9 +218,11 @@ class GlancesClientBrowser(object):
self.screen.active_server = None
def serve_forever(self):
"""Wrapper to the serve_forever function
this function will restore the terminal to a sane state
before re-raising the exception and generating a traceback"""
"""Wrapper to the serve_forever function.
This function will restore the terminal to a sane state
before re-raising the exception and generating a traceback.
"""
try:
return self.__serve_forever()
finally:
......
......@@ -25,7 +25,8 @@ from glances.core.glances_timer import Timer
class CpuPercent(object):
"""Get and strore the CPU percent"""
"""Get and store the CPU percent."""
def __init__(self, cached_time=1):
self.cpu_percent = 0
......@@ -36,7 +37,7 @@ class CpuPercent(object):
self.cached_time = cached_time
def get(self):
"""Update and/or return the CPU using the PSUtil lib"""
"""Update and/or return the CPU using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer.finished():
self.cpu_percent = psutil.cpu_percent(interval=0.0)
......
......@@ -100,10 +100,10 @@ class GlancesLogs(object):
proc_list=None, proc_desc="", peak_time=6):
"""Add a new item to the logs list.
If 'item' is a 'new one', add the new item at the beginning of the logs
list.
If 'item' is a 'new one', add the new item at the beginning of
the logs list.
If 'item' is not a 'new one', update the existing item.
If event < peak_time the the alert is not setoff
If event < peak_time the the alert is not setoff.
"""
proc_list = proc_list or []
......@@ -186,8 +186,8 @@ class GlancesLogs(object):
def clean(self, critical=False):
"""Clean the logs list by deleting finished items.
By default, only delete WARNING message
If critical = True, also delete CRITICAL message
By default, only delete WARNING message.
If critical = True, also delete CRITICAL message.
"""
# Create a new clean list
clean_logs_list = []
......
......@@ -32,7 +32,7 @@ from glances.core.glances_timer import getTimeSinceLastUpdate, Timer
def is_kernel_thread(proc):
""" Return True if proc is a kernel thread, False instead. """
"""Return True if proc is a kernel thread, False instead."""
try:
return os.getpgid(proc.pid) == 0
# Python >= 3.3 raises ProcessLookupError, which inherits OSError
......@@ -43,10 +43,10 @@ def is_kernel_thread(proc):
class ProcessTreeNode(object):
"""
Represent a process tree.
"""Represent a process tree.
We avoid recursive algorithm to manipulate the tree because function calls are expensive with CPython.
We avoid recursive algorithm to manipulate the tree because function
calls are expensive with CPython.
"""
def __init__(self, process=None, stats=None, sort_key=None, sort_reverse=True, root=False):
......@@ -59,7 +59,7 @@ class ProcessTreeNode(object):
self.is_root = root
def __str__(self):
""" Return the tree as a string for debugging. """
"""Return the tree as a string for debugging."""
lines = []
nodes_to_print = collections.deque([collections.deque([("#", self)])])
while nodes_to_print:
......@@ -85,7 +85,10 @@ class ProcessTreeNode(object):
return "\n".join(lines)
def set_sorting(self, key, reverse):
""" Set sorting key or func for user with __iter__ (affects the whole tree from this node). """
"""Set sorting key or func for use with __iter__.
This affects the whole tree from this node.
"""
if self.sort_key != key or self.sort_reverse != reverse:
nodes_to_flag_unsorted = collections.deque([self])
while nodes_to_flag_unsorted:
......@@ -96,7 +99,7 @@ class ProcessTreeNode(object):
nodes_to_flag_unsorted.extend(current_node.children)
def get_weight(self):
""" Return "weight" of a process and all its children for sorting. """
"""Return 'weight' of a process and all its children for sorting."""
if self.sort_key == 'name' or self.sort_key == 'username':
return self.stats[self.sort_key]
......@@ -130,7 +133,7 @@ class ProcessTreeNode(object):
return total
def __iter__(self):
""" Iterator returning ProcessTreeNode in sorted order, recursively. """
"""Iterator returning ProcessTreeNode in sorted order, recursively."""
if not self.is_root:
yield self
if not self.children_sorted:
......@@ -144,12 +147,14 @@ class ProcessTreeNode(object):
yield n
def iter_children(self, exclude_incomplete_stats=True):
"""
Iterator returning ProcessTreeNode in sorted order (only children of this node, non recursive).
"""Iterator returning ProcessTreeNode in sorted order.
Return only children of this node, non recursive.
If exclude_incomplete_stats is True, exclude processes not having full statistics.
It can happen after a resort (change of sort key) because process stats are not grabbed immediately,
but only at next full update.
If exclude_incomplete_stats is True, exclude processes not
having full statistics. It can happen after a resort (change of
sort key) because process stats are not grabbed immediately, but
only at next full update.
"""
if not self.children_sorted:
# optimization to avoid sorting twice (once when limiting the maximum processes to grab stats for,
......@@ -162,7 +167,10 @@ class ProcessTreeNode(object):
yield child
def find_process(self, process):
""" Search in tree for the ProcessTreeNode owning process, return it or None if not found. """
"""Search in tree for the ProcessTreeNode owning process.
Return it or None if not found.
"""
nodes_to_search = collections.deque([self])
while nodes_to_search:
current_node = nodes_to_search.pop()
......@@ -172,7 +180,10 @@ class ProcessTreeNode(object):
@staticmethod
def build_tree(process_dict, sort_key, sort_reverse, hide_kernel_threads):
""" Build a process tree using using parent/child relationships, and return the tree root node. """
"""Build a process tree using using parent/child relationships.
Return the tree root node.
"""
tree_root = ProcessTreeNode(root=True)
nodes_to_add_last = collections.deque()
......@@ -326,7 +337,7 @@ class GlancesProcesses(object):
return self._process_filter_re
def is_filtered(self, value):
"""Return True if the value should be filtered"""
"""Return True if the value should be filtered."""
if self.process_filter is None:
# No filter => Not filtered
return False
......@@ -335,15 +346,15 @@ class GlancesProcesses(object):
return self.process_filter_re.match(value) is None
def disable_kernel_threads(self):
""" Ignore kernel threads in process list. """
"""Ignore kernel threads in process list."""
self.no_kernel_threads = True
def enable_tree(self):
""" Enable process tree. """
"""Enable process tree."""
self._enable_tree = True
def is_tree_enabled(self):
""" Return True if process tree is enabled, False instead. """
"""Return True if process tree is enabled, False instead."""
return self._enable_tree
@property
......@@ -356,7 +367,8 @@ class GlancesProcesses(object):
def __get_mandatory_stats(self, proc, procstat):
"""
Get mandatory_stats: need for the sorting/filter step
Get mandatory_stats: need for the sorting/filter step.
=> cpu_percent, memory_percent, io_counters, name, cmdline
"""
procstat['mandatory_stats'] = True
......@@ -419,7 +431,8 @@ class GlancesProcesses(object):
def __get_standard_stats(self, proc, procstat):
"""
Get standard_stats: for all the displayed processes
Get standard_stats: for all the displayed processes.
=> username, status, memory_info, cpu_times
"""
procstat['standard_stats'] = True
......@@ -452,7 +465,8 @@ class GlancesProcesses(object):
def __get_extended_stats(self, proc, procstat):
"""
Get extended_stats: only for top processes (see issue #403)
Get extended_stats: only for top processes (see issue #403).
=> connections (UDP/TCP), memory_swap...
"""
procstat['extended_stats'] = True
......@@ -540,10 +554,7 @@ class GlancesProcesses(object):
mandatory_stats=True,
standard_stats=True,
extended_stats=False):
"""
Get process stats of the proc processes (proc is returned psutil.process_iter())
"""
"""Get stats of running processes."""
# Process ID (always)
procstat = proc.as_dict(attrs=['pid'])
......@@ -559,9 +570,7 @@ class GlancesProcesses(object):
return procstat
def update(self):
"""
Update the processes stats
"""
"""Update the processes stats."""
# Reset the stats
self.processlist = []
self.processcount = {'total': 0, 'running': 0, 'sleeping': 0, 'thread': 0}
......
......@@ -50,7 +50,7 @@ class GlancesSNMPClient(object):
self.auth = auth
def __buid_result(self, varBinds):
"""Build the results"""
"""Build the results."""
ret = {}
for name, val in varBinds:
if str(val) == '':
......
......@@ -99,9 +99,11 @@ class GlancesStandalone(object):
self.stats.export(self.stats)
def serve_forever(self):
"""Wrapper to the serve_forever function
this function will restore the terminal to a sane state
before re-raising the exception and generating a traceback"""
"""Wrapper to the serve_forever function.
This function will restore the terminal to a sane state
before re-raising the exception and generating a traceback.
"""
try:
return self.__serve_forever()
finally:
......
......@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Manage the Glances server static list """
"""Manage the Glances server static list."""
# System lib
from socket import gaierror, gethostbyname
......@@ -28,7 +28,7 @@ from glances.core.glances_logging import logger
class GlancesStaticServer(object):
"""Manage the static servers list for the client browser"""
"""Manage the static servers list for the client browser."""
_section = "serverlist"
......@@ -39,8 +39,7 @@ class GlancesStaticServer(object):
self._server_list = self.load(config)
def load(self, config):
"""Load the server list from the configuration file"""
"""Load the server list from the configuration file."""
server_list = []
if config is None:
......@@ -85,9 +84,9 @@ class GlancesStaticServer(object):
return server_list
def get_servers_list(self):
"""Return the current server list (dict of dict)"""
"""Return the current server list (dict of dict)."""
return self._server_list
def set_server(self, server_pos, key, value):
"""Set the key to the value for the server_pos (position in the list)"""
"""Set the key to the value for the server_pos (position in the list)."""
self._server_list[server_pos][key] = value
......@@ -157,7 +157,9 @@ class GlancesStats(object):
def export(self, input_stats=None):
"""Export all the stats.
Each export module is ran in a dedicated thread."""
Each export module is ran in a dedicated thread.
"""
# threads = []
input_stats = input_stats or {}
......@@ -169,11 +171,11 @@ class GlancesStats(object):
thread.start()
def getAll(self):
"""Return all the stats (list)"""
"""Return all the stats (list)."""
return [self._plugins[p].get_raw() for p in self._plugins]
def getAllAsDict(self):
"""Return all the stats (dict)"""
"""Return all the stats (dict)."""
# Python > 2.6
# {p: self._plugins[p].get_raw() for p in self._plugins}
ret = {}
......@@ -186,18 +188,18 @@ class GlancesStats(object):
return [self._plugins[p].limits for p in self._plugins]
def getAllLimitsAsDict(self):
"""Return all the stats limits (dict)"""
"""Return all the stats limits (dict)."""
ret = {}
for p in self._plugins:
ret[p] = self._plugins[p].limits
return ret
def getAllViews(self):
"""Return the plugins views"""
"""Return the plugins views."""
return [self._plugins[p].get_views() for p in self._plugins]
def getAllViewsAsDict(self):
"""Return all the stats views (dict)"""
"""Return all the stats views (dict)."""
ret = {}
for p in self._plugins:
ret[p] = self._plugins[p].get_views()
......@@ -215,7 +217,7 @@ class GlancesStats(object):
return None
def end(self):
"""End of the Glances stats"""
"""End of the Glances stats."""
# Close the export module
for e in self._exports:
self._exports[e].exit()
......@@ -244,7 +246,7 @@ class GlancesStatsServer(GlancesStats):
self.all_stats = self._set_stats(input_stats)
def _set_stats(self, input_stats):
"""Set the stats to the input_stats one"""
"""Set the stats to the input_stats one."""
# Build the all_stats with the get_raw() method of the plugins
ret = collections.defaultdict(dict)
for p in self._plugins:
......@@ -252,11 +254,11 @@ class GlancesStatsServer(GlancesStats):
return ret
def getAll(self):
"""Return the stats as a list"""
"""Return the stats as a list."""
return self.all_stats
def getAllAsDict(self):
"""Return the stats as a dict"""
"""Return the stats as a dict."""
# Python > 2.6
# return {p: self.all_stats[p] for p in self._plugins}
ret = {}
......@@ -363,7 +365,7 @@ class GlancesStatsClientSNMP(GlancesStats):
return ret
def get_system_name(self, oid_system_name):
"""Get the short os name from the OS name OID string"""
"""Get the short os name from the OS name OID string."""
short_system_name = None
if oid_system_name == '':
......
......@@ -32,7 +32,7 @@ from glances.core.glances_logging import logger
class GlancesExport(object):
"""Main class for Glances' export IF."""
"""Main class for Glances export IF."""
def __init__(self, config=None, args=None):
"""Init the export class."""
......@@ -53,7 +53,7 @@ class GlancesExport(object):
logger.debug("Finalise export interface %s" % self.export_name)
def plugins_to_export(self):
"""Return the list of plugins to export"""
"""Return the list of plugins to export."""
return ['cpu',
'percpu',
'load',
......
......@@ -39,23 +39,21 @@ else:
class GlancesHistory(object):
"""This class define the object to manage stats history"""
"""This class define the object to manage stats history."""
def __init__(self, output_folder):
self.output_folder = output_folder
def get_output_folder(self):
"""Return the output folder where the graph are generated"""
"""Return the output folder where the graph are generated."""
return self.output_folder
def graph_enabled(self):
"""Return True if Glances can generaate history graphs"""
"""Return True if Glances can generate history graphs."""
return matplotlib_check
def reset(self, stats):
"""
Reset all the history
"""
"""Reset all the history."""
if not self.graph_enabled():
return False
for p in stats.getAllPlugins():
......@@ -65,9 +63,7 @@ class GlancesHistory(object):
return True
def get_graph_color(self, item):
"""
Get the item's color
"""
"""Get the item's color."""
try:
ret = item['color']
except KeyError:
......@@ -76,15 +72,11 @@ class GlancesHistory(object):
return ret
def get_graph_legend(self, item):
"""
Get the item's legend
"""
"""Get the item's legend."""
return item['name']
def get_graph_yunit(self, item, pre_label=''):
"""
Get the item's Y unit
"""
"""Get the item's Y unit."""
try:
unit = " (%s)" % item['y_unit']
except KeyError:
......@@ -96,9 +88,9 @@ class GlancesHistory(object):
return "%s%s" % (label, unit)
def generate_graph(self, stats):
"""
Generate graphs from plugins history
Return the number of output files generated by the function
"""Generate graphs from plugins history.
Return the number of output files generated by the function.
"""
if not self.graph_enabled():
return 0
......
......@@ -57,7 +57,7 @@ class Export(GlancesExport):
self.client = self.init()
def load_conf(self, section="influxdb"):
"""Load the InfluxDb configuration in the Glances configuration file"""
"""Load the InfluxDb configuration in the Glances configuration file."""
if self.config is None:
return False
try:
......@@ -82,7 +82,7 @@ class Export(GlancesExport):
return True
def init(self):
"""Init the connection to the InfluxDB server"""
"""Init the connection to the InfluxDB server."""
if not self.export_enable:
return None
......@@ -116,7 +116,7 @@ class Export(GlancesExport):
return db
def export(self, name, columns, points):
"""Write the points to the InfluxDB server"""
"""Write the points to the InfluxDB server."""
# Manage prefix
if self.prefix is not None:
name = self.prefix + '.' + name
......
......@@ -58,7 +58,7 @@ class Export(GlancesExport):
self.client = self.init()
def load_conf(self, section="rabbitmq"):
"""Load the rabbitmq configuration in the Glances configuration file"""
"""Load the rabbitmq configuration in the Glances configuration file."""
if self.config is None:
return False
try:
......@@ -78,7 +78,7 @@ class Export(GlancesExport):
return True
def init(self):
"""Init the connection to the rabbitmq server"""
"""Init the connection to the rabbitmq server."""
if not self.export_enable:
return None
try:
......@@ -91,7 +91,7 @@ class Export(GlancesExport):
return None
def export(self, name, columns, points):
"""Write the points in RabbitMQ"""
"""Write the points in RabbitMQ."""
data = "hostname="+self.hostname+", name="+name+", dateinfo="+datetime.datetime.utcnow().isoformat()
for i in range(0, len(columns)):
if not isinstance(points[i], Number):
......
......@@ -60,7 +60,7 @@ class Export(GlancesExport):
prefix=self.prefix)
def load_conf(self, section="statsd"):
"""Load the Statsd configuration in the Glances configuration file"""
"""Load the Statsd configuration in the Glances configuration file."""
if self.config is None:
return False
try:
......@@ -82,7 +82,7 @@ class Export(GlancesExport):
return True
def init(self, prefix='glances'):
"""Init the connection to the Statsd server"""
"""Init the connection to the Statsd server."""
if not self.export_enable:
return None
return StatsClient(self.host,
......@@ -90,7 +90,7 @@ class Export(GlancesExport):
prefix=prefix)
def export(self, name, columns, points):
"""Export the stats to the Statsd server"""
"""Export the stats to the Statsd server."""
for i in range(0, len(columns)):
if not isinstance(points[i], Number):
continue
......
......@@ -25,7 +25,8 @@ import locale
class Bar(object):
"""Manage bar (progression or status)
r"""Manage bar (progression or status).
import sys
import time
......@@ -35,7 +36,6 @@ class Bar(object):
print("\r%s" % b),
time.sleep(0.1)
sys.stdout.flush()
"""
def __init__(self, size,
......
......@@ -16,9 +16,8 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Web interface class."""
# Import Glances libs
# Import mandatory Bottle lib
import json
import os
......@@ -27,7 +26,6 @@ import sys
from glances.core.glances_globals import is_windows
from glances.core.glances_logging import logger
try:
from bottle import Bottle, static_file, abort, response, request
except ImportError:
......@@ -143,10 +141,9 @@ class GlancesBottle(object):
return static_file('favicon.ico', root=self.STATIC_PATH)
def _api_help(self):
"""
Glances API RESTFul implementation
Return the help data
or 404 error
"""Glances API RESTFul implementation.
Return the help data or 404 error.
"""
response.content_type = 'application/json'
......@@ -195,8 +192,8 @@ class GlancesBottle(object):
return plist
def _api_all(self):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON representation of all the plugins
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -224,8 +221,8 @@ class GlancesBottle(object):
return f.read()
def _api_all_limits(self):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON representation of all the plugins limits
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -241,8 +238,8 @@ class GlancesBottle(object):
return limits
def _api_all_views(self):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON representation of all the plugins views
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -258,8 +255,8 @@ class GlancesBottle(object):
return limits
def _api(self, plugin):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON representation of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -281,8 +278,8 @@ class GlancesBottle(object):
return statval
def _api_limits(self, plugin):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON limits of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -304,8 +301,8 @@ class GlancesBottle(object):
return ret
def _api_views(self, plugin):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON views of a given plugin
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -327,8 +324,8 @@ class GlancesBottle(object):
return ret
def _api_item(self, plugin, item):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the JSON represenation of the couple plugin/item
HTTP/200 if OK
HTTP/400 if plugin is not found
......@@ -351,8 +348,8 @@ class GlancesBottle(object):
return plist
def _api_value(self, plugin, item, value):
"""
Glances API RESTFul implementation
"""Glances API RESTFul implementation.
Return the process stats (dict) for the given item=value
HTTP/200 if OK
HTTP/400 if plugin is not found
......
......@@ -47,9 +47,9 @@ else:
class _GlancesCurses(object):
"""
This class manages the curses display (and key pressed).
Note: It is a private class, use GlancesCursesClient or GlancesCursesBrowser
"""This class manages the curses display (and key pressed).
Note: It is a private class, use GlancesCursesClient or GlancesCursesBrowser.
"""
def __init__(self, args=None):
......@@ -202,11 +202,12 @@ class _GlancesCurses(object):
'Stats history disabled because MatPlotLib is not installed')
def set_cursor(self, value):
"""Configure the curse cursor apparence
0: invisible
1: visible
2: very visible
"""
"""Configure the curse cursor apparence.
0: invisible
1: visible
2: very visible
"""
if hasattr(curses, 'curs_set'):
try:
curses.curs_set(value)
......@@ -369,26 +370,26 @@ class _GlancesCurses(object):
curses.endwin()
def init_line_column(self):
"""Init the line and column position for the curses inteface"""
"""Init the line and column position for the curses inteface."""
self.init_line()
self.init_column()
def init_line(self):
"""Init the line position for the curses inteface"""
"""Init the line position for the curses inteface."""
self.line = 0
self.next_line = 0
def init_column(self):
"""Init the column position for the curses inteface"""
"""Init the column position for the curses inteface."""
self.column = 0
self.next_column = 0
def new_line(self):
"""New line in the curses interface"""
"""New line in the curses interface."""
self.line = self.next_line
def new_column(self):
"""New column in the curses interface"""
"""New column in the curses interface."""
self.column = self.next_column
def display(self, stats, cs_status=None):
......@@ -656,18 +657,20 @@ class _GlancesCurses(object):
input_size=30,
input_value=None):
"""
Display a centered popup.
If is_input is False:
Display a centered popup with the given message during duration seconds
If size_x and size_y: set the popup size
else set it automatically
Return True if the popup could be displayed
If is_input is True:
Display a centered popup with the given message and a input field
If size_x and size_y: set the popup size
else set it automatically
Return the input string or None if the field is empty
"""
# Center the popup
sentence_list = message.split('\n')
if size_x is None:
......@@ -898,21 +901,21 @@ class _GlancesCurses(object):
class GlancesCursesStandalone(_GlancesCurses):
"""Class for the Glances' curse standalone"""
"""Class for the Glances curse standalone."""
pass
class GlancesCursesClient(_GlancesCurses):
"""Class for the Glances' curse client"""
"""Class for the Glances curse client."""
pass
class GlancesCursesBrowser(_GlancesCurses):
"""Class for the Glances' curse client browser"""
"""Class for the Glances curse client browser."""
def __init__(self, args=None):
# Init the father class
......@@ -961,14 +964,14 @@ class GlancesCursesBrowser(_GlancesCurses):
self.cursor_position = position
def cursor_up(self, servers_list):
"""Set the cursor to position N-1 in the list"""
"""Set the cursor to position N-1 in the list."""
if self.cursor_position > 0:
self.cursor_position -= 1
else:
self.cursor_position = len(servers_list) - 1
def cursor_down(self, servers_list):
"""Set the cursor to position N-1 in the list"""
"""Set the cursor to position N-1 in the list."""
if self.cursor_position < len(servers_list) - 1:
self.cursor_position += 1
else:
......@@ -1028,13 +1031,15 @@ class GlancesCursesBrowser(_GlancesCurses):
def flush(self, servers_list):
"""Update the servers' list screen.
servers_list: List of dict with servers stats
"""
self.erase()
self.display(servers_list)
def display(self, servers_list):
"""Display the servers list
"""Display the servers list.
Return:
True if the stats have been displayed
False if the stats have not been displayed (no server available)
......
......@@ -29,7 +29,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' alert plugin.
"""Glances alert plugin.
Only for display.
"""
......@@ -123,9 +123,7 @@ class Plugin(GlancesPlugin):
return ret
def approx_equal(self, a, b, tolerance=0.0):
"""
Compare a with b using the tolerance (if numerical)
"""
"""Compare a with b using the tolerance (if numerical)."""
if str(int(a)).isdigit() and str(int(b)).isdigit():
return abs(a - b) <= max(abs(a), abs(b)) * tolerance
else:
......
......@@ -32,7 +32,7 @@ except ImportError:
class Plugin(GlancesPlugin):
"""Glances' battery capacity plugin.
"""Glances battery capacity plugin.
stats is a list
"""
......
......@@ -26,7 +26,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' CPU core plugin.
"""Glances CPU core plugin.
Get stats about CPU core number.
......
......@@ -141,7 +141,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......@@ -160,7 +160,7 @@ class Plugin(GlancesPlugin):
self.views[key]['optional'] = True
def msg_curse(self, args=None):
"""Return the list to display in the UI"""
"""Return the list to display in the UI."""
# Init the return message
ret = []
......
......@@ -36,7 +36,7 @@ items_history_list = [{'name': 'read_bytes', 'color': '#00FF00', 'y_unit': 'B/s'
class Plugin(GlancesPlugin):
"""Glances' disks I/O plugin.
"""Glances disks I/O plugin.
stats is a list
"""
......@@ -53,7 +53,7 @@ class Plugin(GlancesPlugin):
self.reset()
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'disk_name'
def reset(self):
......@@ -127,7 +127,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -42,7 +42,7 @@ else:
class Plugin(GlancesPlugin):
"""Glances' Docker plugin.
"""Glances Docker plugin.
stats is a list
"""
......@@ -61,7 +61,7 @@ class Plugin(GlancesPlugin):
self.docker_client = False
def connect(self, version=None):
"""Connect to the Docker server"""
"""Connect to the Docker server."""
# Init connection to the Docker API
try:
if version is None:
......@@ -113,8 +113,7 @@ class Plugin(GlancesPlugin):
@GlancesPlugin._log_result_decorator
def update(self):
"""Update Docker stats using the input method.
"""
"""Update Docker stats using the input method."""
# Reset stats
self.reset()
......@@ -188,9 +187,11 @@ class Plugin(GlancesPlugin):
return self.stats
def get_docker_cpu_old(self, container_id):
"""Return the container CPU usage by reading /sys/fs/cgroup/...
"""Return the container CPU usage by reading /sys/fs/cgroup/.
Input: id is the full container id
Output: a dict {'total': 1.49, 'user': 0.65, 'system': 0.84}"""
Output: a dict {'total': 1.49, 'user': 0.65, 'system': 0.84}
"""
ret = {}
# Read the stats
try:
......@@ -208,11 +209,12 @@ class Plugin(GlancesPlugin):
return ret
def get_docker_cpu(self, container_id, all_stats):
"""Return the container CPU usage
"""Return the container CPU usage.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'total': 1.49}"""
Output: a dict {'total': 1.49}
"""
cpu_new = {}
ret = {'total': 0.0}
......@@ -263,9 +265,11 @@ class Plugin(GlancesPlugin):
return ret
def get_docker_memory_old(self, container_id):
"""Return the container MEMORY usage by reading /sys/fs/cgroup/...
"""Return the container MEMORY usage by reading /sys/fs/cgroup/.
Input: id is the full container id
Output: a dict {'rss': 1015808, 'cache': 356352}"""
Output: a dict {'rss': 1015808, 'cache': 356352}
"""
ret = {}
# Read the stats
try:
......@@ -281,10 +285,12 @@ class Plugin(GlancesPlugin):
return ret
def get_docker_memory(self, container_id, all_stats):
"""Return the container MEMORY
"""Return the container MEMORY.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'rss': 1015808, 'cache': 356352, 'usage': ..., 'max_usage': ...}"""
Output: a dict {'rss': 1015808, 'cache': 356352, 'usage': ..., 'max_usage': ...}
"""
ret = {}
# Read the stats
try:
......@@ -301,10 +307,11 @@ class Plugin(GlancesPlugin):
return ret
def get_docker_network(self, container_id, all_stats):
"""Return the container network usage using the Docker API (v1.0 or higher)
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'rx': 10, 'tx': 65}"""
"""Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'rx': 10, 'tx': 65}.
"""
# Init the returned dict
network_new = {}
......@@ -348,7 +355,7 @@ class Plugin(GlancesPlugin):
return network_new
def get_user_ticks(self):
"""return the user ticks by reading the environment variable"""
"""Return the user ticks by reading the environment variable."""
return os.sysconf(os.sysconf_names['SC_CLK_TCK'])
def msg_curse(self, args=None):
......@@ -434,7 +441,7 @@ class Plugin(GlancesPlugin):
return ret
def container_alert(self, status):
"""Analyse the container status"""
"""Analyse the container status."""
if "Paused" in status:
return 'CAREFUL'
else:
......
......@@ -63,7 +63,7 @@ items_history_list = [{'name': 'percent', 'color': '#00FF00'}]
class Plugin(GlancesPlugin):
"""Glances' file system plugin.
"""Glances file system plugin.
stats is a list
"""
......@@ -80,7 +80,7 @@ class Plugin(GlancesPlugin):
self.reset()
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'mnt_point'
def reset(self):
......@@ -183,7 +183,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -30,7 +30,7 @@ from glances.core.glances_logging import logger
class Plugin(GlancesPlugin):
"""Glances' HDD temperature sensors plugin.
"""Glances HDD temperature sensors plugin.
stats is a list
"""
......
......@@ -30,7 +30,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' help plugin."""
"""Glances help plugin."""
def __init__(self, args=None, config=None):
"""Init the plugin."""
......
......@@ -33,7 +33,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' IP Plugin.
"""Glances IP Plugin.
stats is a dict
"""
......@@ -86,7 +86,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......@@ -97,7 +97,6 @@ class Plugin(GlancesPlugin):
def msg_curse(self, args=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
......@@ -117,6 +116,8 @@ class Plugin(GlancesPlugin):
@staticmethod
def ip_to_cidr(ip):
# Convert IP address to CIDR
# Exemple: '255.255.255.0' will return 24
"""Convert IP address to CIDR.
Example: '255.255.255.0' will return 24
"""
return sum(map(lambda x: int(x) << 8, ip.split('.'))) // 8128
......@@ -44,7 +44,7 @@ items_history_list = [{'name': 'min1', 'color': '#0000FF'},
class Plugin(GlancesPlugin):
"""Glances' load plugin.
"""Glances load plugin.
stats is a dict
"""
......@@ -117,7 +117,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -161,7 +161,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -41,7 +41,7 @@ items_history_list = [{'name': 'percent', 'color': '#00FF00', 'y_unit': '%'}]
class Plugin(GlancesPlugin):
"""Glances' swap memory plugin.
"""Glances swap memory plugin.
stats is a dict
"""
......@@ -136,7 +136,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -27,7 +27,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' monitor plugin."""
"""Glances monitor plugin."""
def __init__(self, args=None):
"""Init the plugin."""
......
......@@ -43,7 +43,7 @@ items_history_list = [{'name': 'rx', 'color': '#00FF00', 'y_unit': 'bit/s'},
class Plugin(GlancesPlugin):
"""Glances' network Plugin.
"""Glances network plugin.
stats is a list
"""
......@@ -59,7 +59,7 @@ class Plugin(GlancesPlugin):
self.reset()
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'interface_name'
def reset(self):
......@@ -194,7 +194,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......@@ -209,7 +209,6 @@ class Plugin(GlancesPlugin):
def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
......
......@@ -43,7 +43,7 @@ class Plugin(GlancesPlugin):
self.reset()
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'cpu_number'
def reset(self):
......
......@@ -37,7 +37,7 @@ from glances.core.glances_actions import GlancesActions
class GlancesPlugin(object):
"""Main class for Glances' plugin."""
"""Main class for Glances plugin."""
def __init__(self, args=None, items_history_list=None):
"""Init the plugin of plugins class."""
......@@ -80,18 +80,18 @@ class GlancesPlugin(object):
return str(self.stats)
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return None
def add_item_history(self, key, value):
"""Add an new item (key, value) to the current history"""
"""Add an new item (key, value) to the current history."""
try:
self.stats_history[key].append(value)
except KeyError:
self.stats_history[key] = [value]
def init_stats_history(self):
"""Init the stats history (dict of list)"""
"""Init the stats history (dict of list)."""
ret = None
if self.args is not None and self.args.enable_history and self.get_items_history_list() is not None:
init_list = [i['name'] for i in self.get_items_history_list()]
......@@ -101,7 +101,7 @@ class GlancesPlugin(object):
return ret
def reset_stats_history(self):
"""Reset the stats history (dict of list)"""
"""Reset the stats history (dict of list)."""
if self.args is not None and self.args.enable_history and self.get_items_history_list() is not None:
reset_list = [i['name'] for i in self.get_items_history_list()]
logger.debug("Reset history for plugin {0} (items: {0})".format(
......@@ -109,7 +109,7 @@ class GlancesPlugin(object):
self.stats_history = {}
def update_stats_history(self, item_name=''):
"""Update stats history"""
"""Update stats history."""
if (self.stats and self.args is not None and
self.args.enable_history and
self.get_items_history_list() is not None):
......@@ -128,11 +128,11 @@ class GlancesPlugin(object):
self.add_item_history(i['name'], self.stats[i['name']])
def get_stats_history(self):
"""Return the stats history"""
"""Return the stats history."""
return self.stats_history
def get_items_history_list(self):
"""Return the items history list"""
"""Return the items history list."""
return self.items_history_list
@property
......@@ -224,12 +224,12 @@ class GlancesPlugin(object):
return self.stats
def get_stats(self):
"""Return the stats object in JSON format"""
"""Return the stats object in JSON format."""
return json.dumps(self.stats)
def get_stats_item(self, item):
"""
Return the stats object for a specific item (in JSON format)
"""Return the stats object for a specific item in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if type(self.stats) is not list:
......@@ -250,8 +250,8 @@ class GlancesPlugin(object):
return None
def get_stats_value(self, item, value):
"""
Return the stats object for a specific item=value (in JSON format)
"""Return the stats object for a specific item=value in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if type(self.stats) is not list:
......@@ -267,7 +267,8 @@ class GlancesPlugin(object):
return None
def update_views(self):
"""Default builder fo the stats views
"""Default builder fo the stats views.
The V of MVC
A dict of dict with the needed information to display the stats.
Example for the stat xxx:
......@@ -307,12 +308,13 @@ class GlancesPlugin(object):
def get_views(self, item=None, key=None, option=None):
"""Return the views object.
If key is None, return all the view for the current plugin
else if option is None return the view for the specific key (all option)
else return the view fo the specific key/option
Specify item if the stats are stored in a dict of dict (ex: NETWORK, FS...)"""
Specify item if the stats are stored in a dict of dict (ex: NETWORK, FS...)
"""
if item is None:
item_views = self.views
else:
......@@ -436,7 +438,7 @@ class GlancesPlugin(object):
return self.get_alert(current, minimum, maximum, header, log=True)
def __get_limit(self, criticity, stat_name=""):
"""Return the limit value for the alert"""
"""Return the limit value for the alert."""
# Get the limit for stat + header
# Exemple: network_wlan0_rx_careful
try:
......@@ -450,7 +452,7 @@ class GlancesPlugin(object):
return limit
def __get_limit_action(self, criticity, stat_name=""):
"""Return the action for the alert"""
"""Return the action for the alert."""
# Get the action for stat + header
# Exemple: network_wlan0_rx_careful_action
try:
......@@ -464,7 +466,7 @@ class GlancesPlugin(object):
return ret
def __get_limit_log(self, stat_name, default_action=False):
"""Return the log tag for the alert"""
"""Return the log tag for the alert."""
# Get the log tag for stat + header
# Exemple: network_wlan0_rx_log
try:
......@@ -482,7 +484,10 @@ class GlancesPlugin(object):
return log_tag[0].lower() == 'true'
def get_conf_value(self, value, header="", plugin_name=None):
"""Return the configuration (header_) value for the current plugin (or the one given by the plugin_name var)"""
"""Return the configuration (header_) value for the current plugin.
...or the one given by the plugin_name var.
"""
if plugin_name is None:
# If not default use the current plugin name
plugin_name = self.plugin_name
......@@ -501,7 +506,7 @@ class GlancesPlugin(object):
return value in self.get_conf_value('hide', header=header)
def has_alias(self, header):
"""Return the alias name for the relative header or None if nonexist"""
"""Return the alias name for the relative header or None if nonexist."""
try:
return self._limits[self.plugin_name + '_' + header + '_' + 'alias'][0]
except (KeyError, IndexError):
......@@ -541,7 +546,7 @@ class GlancesPlugin(object):
def curse_add_line(self, msg, decoration="DEFAULT",
optional=False, additional=False,
splittable=False):
"""Return a dict with
"""Return a dict with.
Where:
msg: string
......@@ -634,7 +639,7 @@ class GlancesPlugin(object):
return '{0!s}'.format(number)
def _log_result_decorator(fct):
"""Log (DEBUG) the result of the function fct"""
"""Log (DEBUG) the result of the function fct."""
def wrapper(*args, **kw):
ret = fct(*args, **kw)
if is_py3:
......
......@@ -29,7 +29,7 @@ from glances.plugins.glances_plugin import GlancesPlugin
class Plugin(GlancesPlugin):
"""Glances' processes plugin.
"""Glances process count plugin.
stats is a list
"""
......
......@@ -64,7 +64,7 @@ class Plugin(GlancesPlugin):
# Note: 'glances_processes' is already init in the glances_processes.py script
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'pid'
def reset(self):
......@@ -91,7 +91,7 @@ class Plugin(GlancesPlugin):
return self.stats
def get_process_tree_curses_data(self, node, args, first_level=True, max_node_count=None):
""" Get curses data to display for a process tree. """
"""Get curses data to display for a process tree."""
ret = []
node_count = 0
if not node.is_root and ((max_node_count is None) or (max_node_count > 0)):
......@@ -122,7 +122,7 @@ class Plugin(GlancesPlugin):
return ret
def add_tree_decoration(self, child_data, is_last_child, first_level):
""" Add tree curses decoration and indentation to a subtree. """
"""Add tree curses decoration and indentation to a subtree."""
# find process command indices in messages
pos = []
for i, m in enumerate(child_data):
......@@ -170,7 +170,7 @@ class Plugin(GlancesPlugin):
return child_data
def get_process_curses_data(self, p, first, args):
""" Get curses data to display for a process. """
"""Get curses data to display for a process."""
ret = [self.curse_new_line()]
# CPU
if 'cpu_percent' in p and p['cpu_percent'] is not None and p['cpu_percent'] != '':
......
......@@ -71,7 +71,7 @@ class Plugin(GlancesPlugin):
return self.stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......@@ -82,7 +82,7 @@ class Plugin(GlancesPlugin):
self.views[key]['decoration'] = self.get_alert(self.stats[key], header=key)
def msg_curse(self, args=None, max_width=10):
"""Return the list to display in the UI"""
"""Return the list to display in the UI."""
# Init the return message
ret = []
......
......@@ -32,7 +32,7 @@ except ImportError:
class Plugin(GlancesPlugin):
"""Glances' RAID plugin.
"""Glances RAID plugin.
stats is a dict (see pymdstat documentation)
"""
......@@ -139,8 +139,10 @@ class Plugin(GlancesPlugin):
return ret
def raid_alert(self, status, used, available):
"""
[available/used] means that ideally the array would have _available_ devices however, _used_ devices are in use.
"""RAID alert messages.
[available/used] means that ideally the array may have _available_
devices however, _used_ devices are in use.
Obviously when used >= available then things are good.
"""
if status == 'inactive':
......
......@@ -39,9 +39,10 @@ else:
SENSOR_TEMP_UNIT = '°C '
SENSOR_FAN_UNIT = 'RPM'
class Plugin(GlancesPlugin):
"""Glances' sensors plugin.
"""Glances sensors plugin.
The stats list includes both sensors and hard disks stats, if any.
The sensors are already grouped by chip type and then sorted by name.
......@@ -70,7 +71,7 @@ class Plugin(GlancesPlugin):
self.reset()
def get_key(self):
"""Return the key of the list"""
"""Return the key of the list."""
return 'label'
def reset(self):
......@@ -149,7 +150,7 @@ class Plugin(GlancesPlugin):
return stats
def update_views(self):
"""Update stats views"""
"""Update stats views."""
# Call the father's method
GlancesPlugin.update_views(self)
......
......@@ -69,7 +69,7 @@ class Plugin(GlancesPlugin):
self.stats = {}
def _linux_os_release(self):
"""This function tries to determine the name of a Linux distribution.
"""Try to determine the name of a Linux distribution.
It checks for the /etc/os-release file. It takes the name from the
'NAME' field and the version from 'VERSION_ID'.
......
......@@ -34,7 +34,7 @@ snmp_oid = {'_uptime': '1.3.6.1.2.1.1.3.0'}
class Plugin(GlancesPlugin):
"""Glances' uptime plugin.
"""Glances uptime plugin.
stats is date (string)
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册