repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.__sum_stats
def __sum_stats(self, key, indice=None, mmm=None): """Return the sum of the stats value for the given key. * indice: If indice is set, get the p[key][indice] * mmm: display min, max, mean or current (if mmm=None) """ # Compute stats summary ret = 0 for p in self....
python
def __sum_stats(self, key, indice=None, mmm=None): """Return the sum of the stats value for the given key. * indice: If indice is set, get the p[key][indice] * mmm: display min, max, mean or current (if mmm=None) """ # Compute stats summary ret = 0 for p in self....
[ "def", "__sum_stats", "(", "self", ",", "key", ",", "indice", "=", "None", ",", "mmm", "=", "None", ")", ":", "# Compute stats summary", "ret", "=", "0", "for", "p", "in", "self", ".", "stats", ":", "if", "key", "not", "in", "p", ":", "# Correct issu...
Return the sum of the stats value for the given key. * indice: If indice is set, get the p[key][indice] * mmm: display min, max, mean or current (if mmm=None)
[ "Return", "the", "sum", "of", "the", "stats", "value", "for", "the", "given", "key", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L579-L622
train
nicolargo/glances
glances/plugins/glances_processlist.py
Plugin.__sort_stats
def __sort_stats(self, sortedby=None): """Return the stats (dict) sorted by (sortedby).""" return sort_stats(self.stats, sortedby, reverse=glances_processes.sort_reverse)
python
def __sort_stats(self, sortedby=None): """Return the stats (dict) sorted by (sortedby).""" return sort_stats(self.stats, sortedby, reverse=glances_processes.sort_reverse)
[ "def", "__sort_stats", "(", "self", ",", "sortedby", "=", "None", ")", ":", "return", "sort_stats", "(", "self", ".", "stats", ",", "sortedby", ",", "reverse", "=", "glances_processes", ".", "sort_reverse", ")" ]
Return the stats (dict) sorted by (sortedby).
[ "Return", "the", "stats", "(", "dict", ")", "sorted", "by", "(", "sortedby", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processlist.py#L630-L633
train
nicolargo/glances
glances/outputs/glances_stdout_csv.py
GlancesStdoutCsv.build_header
def build_header(self, plugin, attribute, stat): """Build and return the header line""" line = '' if attribute is not None: line += '{}.{}{}'.format(plugin, attribute, self.separator) else: if isinstance(stat, dict): for k in stat.keys(): ...
python
def build_header(self, plugin, attribute, stat): """Build and return the header line""" line = '' if attribute is not None: line += '{}.{}{}'.format(plugin, attribute, self.separator) else: if isinstance(stat, dict): for k in stat.keys(): ...
[ "def", "build_header", "(", "self", ",", "plugin", ",", "attribute", ",", "stat", ")", ":", "line", "=", "''", "if", "attribute", "is", "not", "None", ":", "line", "+=", "'{}.{}{}'", ".", "format", "(", "plugin", ",", "attribute", ",", "self", ".", "...
Build and return the header line
[ "Build", "and", "return", "the", "header", "line" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L63-L86
train
nicolargo/glances
glances/outputs/glances_stdout_csv.py
GlancesStdoutCsv.build_data
def build_data(self, plugin, attribute, stat): """Build and return the data line""" line = '' if attribute is not None: line += '{}{}'.format(str(stat.get(attribute, self.na)), self.separator) else: if isinstance(stat, dict): ...
python
def build_data(self, plugin, attribute, stat): """Build and return the data line""" line = '' if attribute is not None: line += '{}{}'.format(str(stat.get(attribute, self.na)), self.separator) else: if isinstance(stat, dict): ...
[ "def", "build_data", "(", "self", ",", "plugin", ",", "attribute", ",", "stat", ")", ":", "line", "=", "''", "if", "attribute", "is", "not", "None", ":", "line", "+=", "'{}{}'", ".", "format", "(", "str", "(", "stat", ".", "get", "(", "attribute", ...
Build and return the data line
[ "Build", "and", "return", "the", "data", "line" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L88-L107
train
nicolargo/glances
glances/outputs/glances_stdout_csv.py
GlancesStdoutCsv.update
def update(self, stats, duration=3): """Display stats to stdout. Refresh every duration second. """ # Build the stats list line = '' for plugin, attribute in self.plugins_list: # Check if the plugin exist and is enable ...
python
def update(self, stats, duration=3): """Display stats to stdout. Refresh every duration second. """ # Build the stats list line = '' for plugin, attribute in self.plugins_list: # Check if the plugin exist and is enable ...
[ "def", "update", "(", "self", ",", "stats", ",", "duration", "=", "3", ")", ":", "# Build the stats list", "line", "=", "''", "for", "plugin", ",", "attribute", "in", "self", ".", "plugins_list", ":", "# Check if the plugin exist and is enable", "if", "plugin", ...
Display stats to stdout. Refresh every duration second.
[ "Display", "stats", "to", "stdout", ".", "Refresh", "every", "duration", "second", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout_csv.py#L109-L139
train
nicolargo/glances
glances/exports/glances_riemann.py
Export.init
def init(self): """Init the connection to the Riemann server.""" if not self.export_enable: return None try: client = bernhard.Client(host=self.host, port=self.port) return client except Exception as e: logger.critical("Connection to Rieman...
python
def init(self): """Init the connection to the Riemann server.""" if not self.export_enable: return None try: client = bernhard.Client(host=self.host, port=self.port) return client except Exception as e: logger.critical("Connection to Rieman...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "try", ":", "client", "=", "bernhard", ".", "Client", "(", "host", "=", "self", ".", "host", ",", "port", "=", "self", ".", "port", ")", "return...
Init the connection to the Riemann server.
[ "Init", "the", "connection", "to", "the", "Riemann", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_riemann.py#L61-L70
train
nicolargo/glances
glances/exports/glances_riemann.py
Export.export
def export(self, name, columns, points): """Write the points in Riemann.""" for i in range(len(columns)): if not isinstance(points[i], Number): continue else: data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]} ...
python
def export(self, name, columns, points): """Write the points in Riemann.""" for i in range(len(columns)): if not isinstance(points[i], Number): continue else: data = {'host': self.hostname, 'service': name + " " + columns[i], 'metric': points[i]} ...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "for", "i", "in", "range", "(", "len", "(", "columns", ")", ")", ":", "if", "not", "isinstance", "(", "points", "[", "i", "]", ",", "Number", ")", ":", "continue"...
Write the points in Riemann.
[ "Write", "the", "points", "in", "Riemann", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_riemann.py#L72-L83
train
nicolargo/glances
glances/timer.py
getTimeSinceLastUpdate
def getTimeSinceLastUpdate(IOType): """Return the elapsed time since last update.""" global last_update_times # assert(IOType in ['net', 'disk', 'process_disk']) current_time = time() last_time = last_update_times.get(IOType) if not last_time: time_since_update = 1 else: time...
python
def getTimeSinceLastUpdate(IOType): """Return the elapsed time since last update.""" global last_update_times # assert(IOType in ['net', 'disk', 'process_disk']) current_time = time() last_time = last_update_times.get(IOType) if not last_time: time_since_update = 1 else: time...
[ "def", "getTimeSinceLastUpdate", "(", "IOType", ")", ":", "global", "last_update_times", "# assert(IOType in ['net', 'disk', 'process_disk'])", "current_time", "=", "time", "(", ")", "last_time", "=", "last_update_times", ".", "get", "(", "IOType", ")", "if", "not", "...
Return the elapsed time since last update.
[ "Return", "the", "elapsed", "time", "since", "last", "update", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/timer.py#L29-L40
train
nicolargo/glances
glances/compat.py
subsample
def subsample(data, sampling): """Compute a simple mean subsampling. Data should be a list of numerical itervalues Return a subsampled list of sampling lenght """ if len(data) <= sampling: return data sampling_length = int(round(len(data) / float(sampling))) return [mean(data[s * s...
python
def subsample(data, sampling): """Compute a simple mean subsampling. Data should be a list of numerical itervalues Return a subsampled list of sampling lenght """ if len(data) <= sampling: return data sampling_length = int(round(len(data) / float(sampling))) return [mean(data[s * s...
[ "def", "subsample", "(", "data", ",", "sampling", ")", ":", "if", "len", "(", "data", ")", "<=", "sampling", ":", "return", "data", "sampling_length", "=", "int", "(", "round", "(", "len", "(", "data", ")", "/", "float", "(", "sampling", ")", ")", ...
Compute a simple mean subsampling. Data should be a list of numerical itervalues Return a subsampled list of sampling lenght
[ "Compute", "a", "simple", "mean", "subsampling", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/compat.py#L209-L219
train
nicolargo/glances
glances/compat.py
time_serie_subsample
def time_serie_subsample(data, sampling): """Compute a simple mean subsampling. Data should be a list of set (time, value) Return a subsampled list of sampling lenght """ if len(data) <= sampling: return data t = [t[0] for t in data] v = [t[1] for t in data] sampling_length = i...
python
def time_serie_subsample(data, sampling): """Compute a simple mean subsampling. Data should be a list of set (time, value) Return a subsampled list of sampling lenght """ if len(data) <= sampling: return data t = [t[0] for t in data] v = [t[1] for t in data] sampling_length = i...
[ "def", "time_serie_subsample", "(", "data", ",", "sampling", ")", ":", "if", "len", "(", "data", ")", "<=", "sampling", ":", "return", "data", "t", "=", "[", "t", "[", "0", "]", "for", "t", "in", "data", "]", "v", "=", "[", "t", "[", "1", "]", ...
Compute a simple mean subsampling. Data should be a list of set (time, value) Return a subsampled list of sampling lenght
[ "Compute", "a", "simple", "mean", "subsampling", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/compat.py#L222-L236
train
nicolargo/glances
glances/exports/glances_couchdb.py
Export.init
def init(self): """Init the connection to the CouchDB server.""" if not self.export_enable: return None if self.user is None: server_uri = 'http://{}:{}/'.format(self.host, self.port) else: server_uri = ...
python
def init(self): """Init the connection to the CouchDB server.""" if not self.export_enable: return None if self.user is None: server_uri = 'http://{}:{}/'.format(self.host, self.port) else: server_uri = ...
[ "def", "init", "(", "self", ")", ":", "if", "not", "self", ".", "export_enable", ":", "return", "None", "if", "self", ".", "user", "is", "None", ":", "server_uri", "=", "'http://{}:{}/'", ".", "format", "(", "self", ".", "host", ",", "self", ".", "po...
Init the connection to the CouchDB server.
[ "Init", "the", "connection", "to", "the", "CouchDB", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_couchdb.py#L57-L88
train
nicolargo/glances
glances/exports/glances_couchdb.py
Export.export
def export(self, name, columns, points): """Write the points to the CouchDB server.""" logger.debug("Export {} stats to CouchDB".format(name)) # Create DB input data = dict(zip(columns, points)) # Set the type to the current stat name data['type'] = name data['t...
python
def export(self, name, columns, points): """Write the points to the CouchDB server.""" logger.debug("Export {} stats to CouchDB".format(name)) # Create DB input data = dict(zip(columns, points)) # Set the type to the current stat name data['type'] = name data['t...
[ "def", "export", "(", "self", ",", "name", ",", "columns", ",", "points", ")", ":", "logger", ".", "debug", "(", "\"Export {} stats to CouchDB\"", ".", "format", "(", "name", ")", ")", "# Create DB input", "data", "=", "dict", "(", "zip", "(", "columns", ...
Write the points to the CouchDB server.
[ "Write", "the", "points", "to", "the", "CouchDB", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_couchdb.py#L94-L110
train
nicolargo/glances
glances/plugins/glances_core.py
Plugin.update
def update(self): """Update core stats. Stats is a dict (with both physical and log cpu number) instead of a integer. """ # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib ...
python
def update(self): """Update core stats. Stats is a dict (with both physical and log cpu number) instead of a integer. """ # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib ...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "# The psutil 2.0 include psutil.cpu_count() and psu...
Update core stats. Stats is a dict (with both physical and log cpu number) instead of a integer.
[ "Update", "core", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_core.py#L43-L73
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.is_theme
def is_theme(self, name): """Return True if the theme *name* should be used.""" return getattr(self.args, 'theme_' + name) or self.theme['name'] == name
python
def is_theme(self, name): """Return True if the theme *name* should be used.""" return getattr(self.args, 'theme_' + name) or self.theme['name'] == name
[ "def", "is_theme", "(", "self", ",", "name", ")", ":", "return", "getattr", "(", "self", ".", "args", ",", "'theme_'", "+", "name", ")", "or", "self", ".", "theme", "[", "'name'", "]", "==", "name" ]
Return True if the theme *name* should be used.
[ "Return", "True", "if", "the", "theme", "*", "name", "*", "should", "be", "used", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L164-L166
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses._init_cursor
def _init_cursor(self): """Init cursors.""" if hasattr(curses, 'noecho'): curses.noecho() if hasattr(curses, 'cbreak'): curses.cbreak() self.set_cursor(0)
python
def _init_cursor(self): """Init cursors.""" if hasattr(curses, 'noecho'): curses.noecho() if hasattr(curses, 'cbreak'): curses.cbreak() self.set_cursor(0)
[ "def", "_init_cursor", "(", "self", ")", ":", "if", "hasattr", "(", "curses", ",", "'noecho'", ")", ":", "curses", ".", "noecho", "(", ")", "if", "hasattr", "(", "curses", ",", "'cbreak'", ")", ":", "curses", ".", "cbreak", "(", ")", "self", ".", "...
Init cursors.
[ "Init", "cursors", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L173-L180
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses._init_colors
def _init_colors(self): """Init the Curses color layout.""" # Set curses options try: if hasattr(curses, 'start_color'): curses.start_color() if hasattr(curses, 'use_default_colors'): curses.use_default_colors() except Exception as...
python
def _init_colors(self): """Init the Curses color layout.""" # Set curses options try: if hasattr(curses, 'start_color'): curses.start_color() if hasattr(curses, 'use_default_colors'): curses.use_default_colors() except Exception as...
[ "def", "_init_colors", "(", "self", ")", ":", "# Set curses options", "try", ":", "if", "hasattr", "(", "curses", ",", "'start_color'", ")", ":", "curses", ".", "start_color", "(", ")", "if", "hasattr", "(", "curses", ",", "'use_default_colors'", ")", ":", ...
Init the Curses color layout.
[ "Init", "the", "Curses", "color", "layout", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L182-L295
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.loop_position
def loop_position(self): """Return the current sort in the loop""" for i, v in enumerate(self._sort_loop): if v == glances_processes.sort_key: return i return 0
python
def loop_position(self): """Return the current sort in the loop""" for i, v in enumerate(self._sort_loop): if v == glances_processes.sort_key: return i return 0
[ "def", "loop_position", "(", "self", ")", ":", "for", "i", ",", "v", "in", "enumerate", "(", "self", ".", "_sort_loop", ")", ":", "if", "v", "==", "glances_processes", ".", "sort_key", ":", "return", "i", "return", "0" ]
Return the current sort in the loop
[ "Return", "the", "current", "sort", "in", "the", "loop" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L414-L419
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.enable_fullquicklook
def enable_fullquicklook(self): """Disable the full quicklook mode""" self.args.disable_quicklook = False for p in ['cpu', 'gpu', 'mem', 'memswap']: setattr(self.args, 'disable_' + p, True)
python
def enable_fullquicklook(self): """Disable the full quicklook mode""" self.args.disable_quicklook = False for p in ['cpu', 'gpu', 'mem', 'memswap']: setattr(self.args, 'disable_' + p, True)
[ "def", "enable_fullquicklook", "(", "self", ")", ":", "self", ".", "args", ".", "disable_quicklook", "=", "False", "for", "p", "in", "[", "'cpu'", ",", "'gpu'", ",", "'mem'", ",", "'memswap'", "]", ":", "setattr", "(", "self", ".", "args", ",", "'disab...
Disable the full quicklook mode
[ "Disable", "the", "full", "quicklook", "mode" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L436-L440
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.end
def end(self): """Shutdown the curses window.""" if hasattr(curses, 'echo'): curses.echo() if hasattr(curses, 'nocbreak'): curses.nocbreak() if hasattr(curses, 'curs_set'): try: curses.curs_set(1) except Exception: ...
python
def end(self): """Shutdown the curses window.""" if hasattr(curses, 'echo'): curses.echo() if hasattr(curses, 'nocbreak'): curses.nocbreak() if hasattr(curses, 'curs_set'): try: curses.curs_set(1) except Exception: ...
[ "def", "end", "(", "self", ")", ":", "if", "hasattr", "(", "curses", ",", "'echo'", ")", ":", "curses", ".", "echo", "(", ")", "if", "hasattr", "(", "curses", ",", "'nocbreak'", ")", ":", "curses", ".", "nocbreak", "(", ")", "if", "hasattr", "(", ...
Shutdown the curses window.
[ "Shutdown", "the", "curses", "window", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L442-L453
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.__get_stat_display
def __get_stat_display(self, stats, layer): """Return a dict of dict with all the stats display. stats: Global stats dict layer: ~ cs_status "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a...
python
def __get_stat_display(self, stats, layer): """Return a dict of dict with all the stats display. stats: Global stats dict layer: ~ cs_status "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a...
[ "def", "__get_stat_display", "(", "self", ",", "stats", ",", "layer", ")", ":", "ret", "=", "{", "}", "for", "p", "in", "stats", ".", "getPluginsList", "(", "enable", "=", "False", ")", ":", "if", "p", "==", "'quicklook'", "or", "p", "==", "'processl...
Return a dict of dict with all the stats display. stats: Global stats dict layer: ~ cs_status "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a SNMP server "Disconnected": Client is disc...
[ "Return", "a", "dict", "of", "dict", "with", "all", "the", "stats", "display", ".", "stats", ":", "Global", "stats", "dict", "layer", ":", "~", "cs_status", "None", ":", "standalone", "or", "server", "mode", "Connected", ":", "Client", "is", "connected", ...
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L478-L511
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.display
def display(self, stats, cs_status=None): """Display stats on the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a SNMP server ...
python
def display(self, stats, cs_status=None): """Display stats on the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a SNMP server ...
[ "def", "display", "(", "self", ",", "stats", ",", "cs_status", "=", "None", ")", ":", "# Init the internal line/column for Glances Curses", "self", ".", "init_line_column", "(", ")", "# Update the stats messages", "###########################", "# Get all the plugins but quic...
Display stats on the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to a Glances server "SNMP": Client is connected to a SNMP server "Disconnected": Client is disconnected from the se...
[ "Display", "stats", "on", "the", "screen", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L513-L625
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.__display_header
def __display_header(self, stat_display): """Display the firsts lines (header) in the Curses interface. system + ip + uptime (cloud) """ # First line self.new_line() self.space_between_column = 0 l_uptime = (self.get_stats_display_width(stat_display["syst...
python
def __display_header(self, stat_display): """Display the firsts lines (header) in the Curses interface. system + ip + uptime (cloud) """ # First line self.new_line() self.space_between_column = 0 l_uptime = (self.get_stats_display_width(stat_display["syst...
[ "def", "__display_header", "(", "self", ",", "stat_display", ")", ":", "# First line", "self", ".", "new_line", "(", ")", "self", ".", "space_between_column", "=", "0", "l_uptime", "=", "(", "self", ".", "get_stats_display_width", "(", "stat_display", "[", "\"...
Display the firsts lines (header) in the Curses interface. system + ip + uptime (cloud)
[ "Display", "the", "firsts", "lines", "(", "header", ")", "in", "the", "Curses", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L627-L652
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.__display_top
def __display_top(self, stat_display, stats): """Display the second line in the Curses interface. <QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD """ self.init_column() self.new_line() # Init quicklook stat_display['quicklook'] = {'msgdict': []} # ...
python
def __display_top(self, stat_display, stats): """Display the second line in the Curses interface. <QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD """ self.init_column() self.new_line() # Init quicklook stat_display['quicklook'] = {'msgdict': []} # ...
[ "def", "__display_top", "(", "self", ",", "stat_display", ",", "stats", ")", ":", "self", ".", "init_column", "(", ")", "self", ".", "new_line", "(", ")", "# Init quicklook", "stat_display", "[", "'quicklook'", "]", "=", "{", "'msgdict'", ":", "[", "]", ...
Display the second line in the Curses interface. <QUICKLOOK> + CPU|PERCPU + <GPU> + MEM + SWAP + LOAD
[ "Display", "the", "second", "line", "in", "the", "Curses", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L654-L727
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.__display_left
def __display_left(self, stat_display): """Display the left sidebar in the Curses interface.""" self.init_column() if self.args.disable_left_sidebar: return for s in self._left_sidebar: if ((hasattr(self.args, 'enable_' + s) or hasattr(self.args...
python
def __display_left(self, stat_display): """Display the left sidebar in the Curses interface.""" self.init_column() if self.args.disable_left_sidebar: return for s in self._left_sidebar: if ((hasattr(self.args, 'enable_' + s) or hasattr(self.args...
[ "def", "__display_left", "(", "self", ",", "stat_display", ")", ":", "self", ".", "init_column", "(", ")", "if", "self", ".", "args", ".", "disable_left_sidebar", ":", "return", "for", "s", "in", "self", ".", "_left_sidebar", ":", "if", "(", "(", "hasatt...
Display the left sidebar in the Curses interface.
[ "Display", "the", "left", "sidebar", "in", "the", "Curses", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L729-L740
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.__display_right
def __display_right(self, stat_display): """Display the right sidebar in the Curses interface. docker + processcount + amps + processlist + alert """ # Do not display anything if space is not available... if self.screen.getmaxyx()[1] < self._left_sidebar_min_width: r...
python
def __display_right(self, stat_display): """Display the right sidebar in the Curses interface. docker + processcount + amps + processlist + alert """ # Do not display anything if space is not available... if self.screen.getmaxyx()[1] < self._left_sidebar_min_width: r...
[ "def", "__display_right", "(", "self", ",", "stat_display", ")", ":", "# Do not display anything if space is not available...", "if", "self", ".", "screen", ".", "getmaxyx", "(", ")", "[", "1", "]", "<", "self", ".", "_left_sidebar_min_width", ":", "return", "# Re...
Display the right sidebar in the Curses interface. docker + processcount + amps + processlist + alert
[ "Display", "the", "right", "sidebar", "in", "the", "Curses", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L742-L767
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.display_popup
def display_popup(self, message, size_x=None, size_y=None, duration=3, is_input=False, input_size=30, input_value=None): """ Display a centered popup. If is_input is False: Dis...
python
def display_popup(self, message, size_x=None, size_y=None, duration=3, is_input=False, input_size=30, input_value=None): """ Display a centered popup. If is_input is False: Dis...
[ "def", "display_popup", "(", "self", ",", "message", ",", "size_x", "=", "None", ",", "size_y", "=", "None", ",", "duration", "=", "3", ",", "is_input", "=", "False", ",", "input_size", "=", "30", ",", "input_value", "=", "None", ")", ":", "# Center th...
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: Displ...
[ "Display", "a", "centered", "popup", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L769-L845
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.display_plugin
def display_plugin(self, plugin_stats, display_optional=True, display_additional=True, max_y=65535, add_space=0): """Display the plugin_stats on the screen. If display_optional=True display the optional stats ...
python
def display_plugin(self, plugin_stats, display_optional=True, display_additional=True, max_y=65535, add_space=0): """Display the plugin_stats on the screen. If display_optional=True display the optional stats ...
[ "def", "display_plugin", "(", "self", ",", "plugin_stats", ",", "display_optional", "=", "True", ",", "display_additional", "=", "True", ",", "max_y", "=", "65535", ",", "add_space", "=", "0", ")", ":", "# Exit if:", "# - the plugin_stats message is empty", "# - t...
Display the plugin_stats on the screen. If display_optional=True display the optional stats If display_additional=True display additionnal stats max_y: do not display line > max_y add_space: add x space (line) after the plugin
[ "Display", "the", "plugin_stats", "on", "the", "screen", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L847-L937
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.flush
def flush(self, stats, cs_status=None): """Clear and update the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to the server "Disconnected": Client is disconnected from the server ...
python
def flush(self, stats, cs_status=None): """Clear and update the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to the server "Disconnected": Client is disconnected from the server ...
[ "def", "flush", "(", "self", ",", "stats", ",", "cs_status", "=", "None", ")", ":", "self", ".", "erase", "(", ")", "self", ".", "display", "(", "stats", ",", "cs_status", "=", "cs_status", ")" ]
Clear and update the screen. stats: Stats database to display cs_status: "None": standalone or server mode "Connected": Client is connected to the server "Disconnected": Client is disconnected from the server
[ "Clear", "and", "update", "the", "screen", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L943-L953
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.update
def update(self, stats, duration=3, cs_status=None, return_to_browser=False): """Update the screen. INPUT stats: Stats database to display duration: duration of the loop cs_status: "None": standalone or serv...
python
def update(self, stats, duration=3, cs_status=None, return_to_browser=False): """Update the screen. INPUT stats: Stats database to display duration: duration of the loop cs_status: "None": standalone or serv...
[ "def", "update", "(", "self", ",", "stats", ",", "duration", "=", "3", ",", "cs_status", "=", "None", ",", "return_to_browser", "=", "False", ")", ":", "# Flush display", "self", ".", "flush", "(", "stats", ",", "cs_status", "=", "cs_status", ")", "# If ...
Update the screen. INPUT stats: Stats database to display duration: duration of the loop cs_status: "None": standalone or server mode "Connected": Client is connected to the server "Disconnected": Client is disconnected from the server return_...
[ "Update", "the", "screen", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L955-L1002
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.get_stats_display_width
def get_stats_display_width(self, curse_msg, without_option=False): """Return the width of the formatted curses message.""" try: if without_option: # Size without options c = len(max(''.join([(u(u(nativestr(i['msg'])).encode('ascii', 'replace')) if not i['opti...
python
def get_stats_display_width(self, curse_msg, without_option=False): """Return the width of the formatted curses message.""" try: if without_option: # Size without options c = len(max(''.join([(u(u(nativestr(i['msg'])).encode('ascii', 'replace')) if not i['opti...
[ "def", "get_stats_display_width", "(", "self", ",", "curse_msg", ",", "without_option", "=", "False", ")", ":", "try", ":", "if", "without_option", ":", "# Size without options", "c", "=", "len", "(", "max", "(", "''", ".", "join", "(", "[", "(", "u", "(...
Return the width of the formatted curses message.
[ "Return", "the", "width", "of", "the", "formatted", "curses", "message", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L1008-L1023
train
nicolargo/glances
glances/outputs/glances_curses.py
_GlancesCurses.get_stats_display_height
def get_stats_display_height(self, curse_msg): r"""Return the height of the formatted curses message. The height is defined by the number of '\n' (new line). """ try: c = [i['msg'] for i in curse_msg['msgdict']].count('\n') except Exception as e: logger.d...
python
def get_stats_display_height(self, curse_msg): r"""Return the height of the formatted curses message. The height is defined by the number of '\n' (new line). """ try: c = [i['msg'] for i in curse_msg['msgdict']].count('\n') except Exception as e: logger.d...
[ "def", "get_stats_display_height", "(", "self", ",", "curse_msg", ")", ":", "try", ":", "c", "=", "[", "i", "[", "'msg'", "]", "for", "i", "in", "curse_msg", "[", "'msgdict'", "]", "]", ".", "count", "(", "'\\n'", ")", "except", "Exception", "as", "e...
r"""Return the height of the formatted curses message. The height is defined by the number of '\n' (new line).
[ "r", "Return", "the", "height", "of", "the", "formatted", "curses", "message", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L1025-L1036
train
nicolargo/glances
glances/snmp.py
GlancesSNMPClient.__buid_result
def __buid_result(self, varBinds): """Build the results.""" ret = {} for name, val in varBinds: if str(val) == '': ret[name.prettyPrint()] = '' else: ret[name.prettyPrint()] = val.prettyPrint() # In Python 3, prettyPrint() r...
python
def __buid_result(self, varBinds): """Build the results.""" ret = {} for name, val in varBinds: if str(val) == '': ret[name.prettyPrint()] = '' else: ret[name.prettyPrint()] = val.prettyPrint() # In Python 3, prettyPrint() r...
[ "def", "__buid_result", "(", "self", ",", "varBinds", ")", ":", "ret", "=", "{", "}", "for", "name", ",", "val", "in", "varBinds", ":", "if", "str", "(", "val", ")", "==", "''", ":", "ret", "[", "name", ".", "prettyPrint", "(", ")", "]", "=", "...
Build the results.
[ "Build", "the", "results", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L51-L62
train
nicolargo/glances
glances/snmp.py
GlancesSNMPClient.get_by_oid
def get_by_oid(self, *oid): """SNMP simple request (list of OID). One request per OID list. * oid: oid list > Return a dict """ if self.version == '3': errorIndication, errorStatus, errorIndex, varBinds = self.cmdGen.getCmd( cmdgen.UsmUserDat...
python
def get_by_oid(self, *oid): """SNMP simple request (list of OID). One request per OID list. * oid: oid list > Return a dict """ if self.version == '3': errorIndication, errorStatus, errorIndex, varBinds = self.cmdGen.getCmd( cmdgen.UsmUserDat...
[ "def", "get_by_oid", "(", "self", ",", "*", "oid", ")", ":", "if", "self", ".", "version", "==", "'3'", ":", "errorIndication", ",", "errorStatus", ",", "errorIndex", ",", "varBinds", "=", "self", ".", "cmdGen", ".", "getCmd", "(", "cmdgen", ".", "UsmU...
SNMP simple request (list of OID). One request per OID list. * oid: oid list > Return a dict
[ "SNMP", "simple", "request", "(", "list", "of", "OID", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L71-L91
train
nicolargo/glances
glances/snmp.py
GlancesSNMPClient.getbulk_by_oid
def getbulk_by_oid(self, non_repeaters, max_repetitions, *oid): """SNMP getbulk request. In contrast to snmpwalk, this information will typically be gathered in a single transaction with the agent, rather than one transaction per variable found. * non_repeaters: This specifies ...
python
def getbulk_by_oid(self, non_repeaters, max_repetitions, *oid): """SNMP getbulk request. In contrast to snmpwalk, this information will typically be gathered in a single transaction with the agent, rather than one transaction per variable found. * non_repeaters: This specifies ...
[ "def", "getbulk_by_oid", "(", "self", ",", "non_repeaters", ",", "max_repetitions", ",", "*", "oid", ")", ":", "if", "self", ".", "version", ".", "startswith", "(", "'3'", ")", ":", "errorIndication", ",", "errorStatus", ",", "errorIndex", ",", "varBinds", ...
SNMP getbulk request. In contrast to snmpwalk, this information will typically be gathered in a single transaction with the agent, rather than one transaction per variable found. * non_repeaters: This specifies the number of supplied variables that should not be iterated over...
[ "SNMP", "getbulk", "request", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L100-L133
train
nicolargo/glances
glances/static_list.py
GlancesStaticServer.load
def load(self, config): """Load the server list from the configuration file.""" server_list = [] if config is None: logger.debug("No configuration file available. Cannot load server list.") elif not config.has_section(self._section): logger.warning("No [%s] secti...
python
def load(self, config): """Load the server list from the configuration file.""" server_list = [] if config is None: logger.debug("No configuration file available. Cannot load server list.") elif not config.has_section(self._section): logger.warning("No [%s] secti...
[ "def", "load", "(", "self", ",", "config", ")", ":", "server_list", "=", "[", "]", "if", "config", "is", "None", ":", "logger", ".", "debug", "(", "\"No configuration file available. Cannot load server list.\"", ")", "elif", "not", "config", ".", "has_section", ...
Load the server list from the configuration file.
[ "Load", "the", "server", "list", "from", "the", "configuration", "file", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/static_list.py#L40-L84
train
nicolargo/glances
glances/static_list.py
GlancesStaticServer.set_server
def set_server(self, server_pos, key, value): """Set the key to the value for the server_pos (position in the list).""" self._server_list[server_pos][key] = value
python
def set_server(self, server_pos, key, value): """Set the key to the value for the server_pos (position in the list).""" self._server_list[server_pos][key] = value
[ "def", "set_server", "(", "self", ",", "server_pos", ",", "key", ",", "value", ")", ":", "self", ".", "_server_list", "[", "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", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/static_list.py#L90-L92
train
nicolargo/glances
glances/autodiscover.py
AutoDiscovered.add_server
def add_server(self, name, ip, port): """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 'port': port, # TCP por...
python
def add_server(self, name, ip, port): """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 'port': port, # TCP por...
[ "def", "add_server", "(", "self", ",", "name", ",", "ip", ",", "port", ")", ":", "new_server", "=", "{", "'key'", ":", "name", ",", "# Zeroconf name with both hostname and port", "'name'", ":", "name", ".", "split", "(", "':'", ")", "[", "0", "]", ",", ...
Add a new server to the list.
[ "Add", "a", "new", "server", "to", "the", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L71-L84
train
nicolargo/glances
glances/autodiscover.py
AutoDiscovered.remove_server
def remove_server(self, name): """Remove a server from the dict.""" for i in self._server_list: if i['key'] == name: try: self._server_list.remove(i) logger.debug("Remove server %s from the list" % name) logger.debug...
python
def remove_server(self, name): """Remove a server from the dict.""" for i in self._server_list: if i['key'] == name: try: self._server_list.remove(i) logger.debug("Remove server %s from the list" % name) logger.debug...
[ "def", "remove_server", "(", "self", ",", "name", ")", ":", "for", "i", "in", "self", ".", "_server_list", ":", "if", "i", "[", "'key'", "]", "==", "name", ":", "try", ":", "self", ".", "_server_list", ".", "remove", "(", "i", ")", "logger", ".", ...
Remove a server from the dict.
[ "Remove", "a", "server", "from", "the", "dict", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L86-L97
train
nicolargo/glances
glances/autodiscover.py
GlancesAutoDiscoverListener.set_server
def set_server(self, server_pos, key, value): """Set the key to the value for the server_pos (position in the list).""" self.servers.set_server(server_pos, key, value)
python
def set_server(self, server_pos, key, value): """Set the key to the value for the server_pos (position in the list).""" self.servers.set_server(server_pos, key, value)
[ "def", "set_server", "(", "self", ",", "server_pos", ",", "key", ",", "value", ")", ":", "self", ".", "servers", ".", "set_server", "(", "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", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L112-L114
train
nicolargo/glances
glances/autodiscover.py
GlancesAutoDiscoverListener.add_service
def add_service(self, zeroconf, srv_type, srv_name): """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 """ if srv_type != zeroconf_type: return False logger...
python
def add_service(self, zeroconf, srv_type, srv_name): """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 """ if srv_type != zeroconf_type: return False logger...
[ "def", "add_service", "(", "self", ",", "zeroconf", ",", "srv_type", ",", "srv_name", ")", ":", "if", "srv_type", "!=", "zeroconf_type", ":", "return", "False", "logger", ".", "debug", "(", "\"Check new Zeroconf server: %s / %s\"", "%", "(", "srv_type", ",", "...
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
[ "Method", "called", "when", "a", "new", "Zeroconf", "client", "is", "detected", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L116-L138
train
nicolargo/glances
glances/autodiscover.py
GlancesAutoDiscoverListener.remove_service
def remove_service(self, zeroconf, srv_type, srv_name): """Remove the server from the list.""" self.servers.remove_server(srv_name) logger.info( "Glances server %s removed from the autodetect list" % srv_name)
python
def remove_service(self, zeroconf, srv_type, srv_name): """Remove the server from the list.""" self.servers.remove_server(srv_name) logger.info( "Glances server %s removed from the autodetect list" % srv_name)
[ "def", "remove_service", "(", "self", ",", "zeroconf", ",", "srv_type", ",", "srv_name", ")", ":", "self", ".", "servers", ".", "remove_server", "(", "srv_name", ")", "logger", ".", "info", "(", "\"Glances server %s removed from the autodetect list\"", "%", "srv_n...
Remove the server from the list.
[ "Remove", "the", "server", "from", "the", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L140-L144
train
nicolargo/glances
glances/autodiscover.py
GlancesAutoDiscoverServer.set_server
def set_server(self, server_pos, key, value): """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)
python
def set_server(self, server_pos, key, value): """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)
[ "def", "set_server", "(", "self", ",", "server_pos", ",", "key", ",", "value", ")", ":", "if", "zeroconf_tag", "and", "self", ".", "zeroconf_enable_tag", ":", "self", ".", "listener", ".", "set_server", "(", "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", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L175-L178
train
nicolargo/glances
glances/autodiscover.py
GlancesAutoDiscoverClient.find_active_ip_address
def find_active_ip_address(): """Try to find the active IP addresses.""" import netifaces # Interface of the default gateway gateway_itf = netifaces.gateways()['default'][netifaces.AF_INET][1] # IP address for the interface return netifaces.ifaddresses(gateway_itf)[netifa...
python
def find_active_ip_address(): """Try to find the active IP addresses.""" import netifaces # Interface of the default gateway gateway_itf = netifaces.gateways()['default'][netifaces.AF_INET][1] # IP address for the interface return netifaces.ifaddresses(gateway_itf)[netifa...
[ "def", "find_active_ip_address", "(", ")", ":", "import", "netifaces", "# Interface of the default gateway", "gateway_itf", "=", "netifaces", ".", "gateways", "(", ")", "[", "'default'", "]", "[", "netifaces", ".", "AF_INET", "]", "[", "1", "]", "# IP address for ...
Try to find the active IP addresses.
[ "Try", "to", "find", "the", "active", "IP", "addresses", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L226-L232
train
nicolargo/glances
glances/outputs/glances_bottle.py
compress
def compress(func): """Compress result with deflate algorithm if the client ask for it.""" def wrapper(*args, **kwargs): """Wrapper that take one function and return the compressed result.""" ret = func(*args, **kwargs) logger.debug('Receive {} {} request with header: {}'.format( ...
python
def compress(func): """Compress result with deflate algorithm if the client ask for it.""" def wrapper(*args, **kwargs): """Wrapper that take one function and return the compressed result.""" ret = func(*args, **kwargs) logger.debug('Receive {} {} request with header: {}'.format( ...
[ "def", "compress", "(", "func", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapper that take one function and return the compressed result.\"\"\"", "ret", "=", "func", "(", "*", "args", ",", "*", "*", "kwargs", ")",...
Compress result with deflate algorithm if the client ask for it.
[ "Compress", "result", "with", "deflate", "algorithm", "if", "the", "client", "ask", "for", "it", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L41-L70
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle.load_config
def load_config(self, config): """Load the outputs section of the configuration file.""" # Limit the number of processes to display in the WebUI if config is not None and config.has_section('outputs'): logger.debug('Read number of processes to display in the WebUI') n = c...
python
def load_config(self, config): """Load the outputs section of the configuration file.""" # Limit the number of processes to display in the WebUI if config is not None and config.has_section('outputs'): logger.debug('Read number of processes to display in the WebUI') n = c...
[ "def", "load_config", "(", "self", ",", "config", ")", ":", "# Limit the number of processes to display in the WebUI", "if", "config", "is", "not", "None", "and", "config", ".", "has_section", "(", "'outputs'", ")", ":", "logger", ".", "debug", "(", "'Read number ...
Load the outputs section of the configuration file.
[ "Load", "the", "outputs", "section", "of", "the", "configuration", "file", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L117-L123
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle.check_auth
def check_auth(self, username, password): """Check if a username/password combination is valid.""" if username == self.args.username: from glances.password import GlancesPassword pwd = GlancesPassword() return pwd.check_password(self.args.password, pwd.sha256_hash(pas...
python
def check_auth(self, username, password): """Check if a username/password combination is valid.""" if username == self.args.username: from glances.password import GlancesPassword pwd = GlancesPassword() return pwd.check_password(self.args.password, pwd.sha256_hash(pas...
[ "def", "check_auth", "(", "self", ",", "username", ",", "password", ")", ":", "if", "username", "==", "self", ".", "args", ".", "username", ":", "from", "glances", ".", "password", "import", "GlancesPassword", "pwd", "=", "GlancesPassword", "(", ")", "retu...
Check if a username/password combination is valid.
[ "Check", "if", "a", "username", "/", "password", "combination", "is", "valid", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L134-L141
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._route
def _route(self): """Define route.""" # REST API self._app.route('/api/%s/config' % self.API_VERSION, method="GET", callback=self._api_config) self._app.route('/api/%s/config/<item>' % self.API_VERSION, method="GET", callback=self._api_conf...
python
def _route(self): """Define route.""" # REST API self._app.route('/api/%s/config' % self.API_VERSION, method="GET", callback=self._api_config) self._app.route('/api/%s/config/<item>' % self.API_VERSION, method="GET", callback=self._api_conf...
[ "def", "_route", "(", "self", ")", ":", "# REST API", "self", ".", "_app", ".", "route", "(", "'/api/%s/config'", "%", "self", ".", "API_VERSION", ",", "method", "=", "\"GET\"", ",", "callback", "=", "self", ".", "_api_config", ")", "self", ".", "_app", ...
Define route.
[ "Define", "route", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L143-L196
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle.start
def start(self, stats): """Start the bottle.""" # Init stats self.stats = stats # Init plugin list self.plugins_list = self.stats.getPluginsList() # Bind the Bottle TCP address/port if self.args.open_web_browser: # Implementation of the issue #946 ...
python
def start(self, stats): """Start the bottle.""" # Init stats self.stats = stats # Init plugin list self.plugins_list = self.stats.getPluginsList() # Bind the Bottle TCP address/port if self.args.open_web_browser: # Implementation of the issue #946 ...
[ "def", "start", "(", "self", ",", "stats", ")", ":", "# Init stats", "self", ".", "stats", "=", "stats", "# Init plugin list", "self", ".", "plugins_list", "=", "self", ".", "stats", ".", "getPluginsList", "(", ")", "# Bind the Bottle TCP address/port", "if", ...
Start the bottle.
[ "Start", "the", "bottle", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L198-L218
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._index
def _index(self, refresh_time=None): """Bottle callback for index.html (/) file.""" if refresh_time is None or refresh_time < 1: refresh_time = self.args.time # Update the stat self.__update__() # Display return template("index.html", refresh_time=refresh_t...
python
def _index(self, refresh_time=None): """Bottle callback for index.html (/) file.""" if refresh_time is None or refresh_time < 1: refresh_time = self.args.time # Update the stat self.__update__() # Display return template("index.html", refresh_time=refresh_t...
[ "def", "_index", "(", "self", ",", "refresh_time", "=", "None", ")", ":", "if", "refresh_time", "is", "None", "or", "refresh_time", "<", "1", ":", "refresh_time", "=", "self", ".", "args", ".", "time", "# Update the stat", "self", ".", "__update__", "(", ...
Bottle callback for index.html (/) file.
[ "Bottle", "callback", "for", "index", ".", "html", "(", "/", ")", "file", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L224-L234
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_help
def _api_help(self): """Glances API RESTful implementation. Return the help data or 404 error. """ response.content_type = 'application/json; charset=utf-8' # Update the stat view_data = self.stats.get_plugin("help").get_view_data() try: plist = json...
python
def _api_help(self): """Glances API RESTful implementation. Return the help data or 404 error. """ response.content_type = 'application/json; charset=utf-8' # Update the stat view_data = self.stats.get_plugin("help").get_view_data() try: plist = json...
[ "def", "_api_help", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "# Update the stat", "view_data", "=", "self", ".", "stats", ".", "get_plugin", "(", "\"help\"", ")", ".", "get_view_data", "(", ")", "try", ":"...
Glances API RESTful implementation. Return the help data or 404 error.
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L242-L255
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_plugins
def _api_plugins(self): """Glances API RESTFul implementation. @api {get} /api/%s/pluginslist Get plugins list @apiVersion 2.0 @apiName pluginslist @apiGroup plugin @apiSuccess {String[]} Plugins list. @apiSuccessExample Success-Response: HTTP/1.1 2...
python
def _api_plugins(self): """Glances API RESTFul implementation. @api {get} /api/%s/pluginslist Get plugins list @apiVersion 2.0 @apiName pluginslist @apiGroup plugin @apiSuccess {String[]} Plugins list. @apiSuccessExample Success-Response: HTTP/1.1 2...
[ "def", "_api_plugins", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "# Update the stat", "self", ".", "__update__", "(", ")", "try", ":", "plist", "=", "json", ".", "dumps", "(", "self", ".", "plugins_list", ...
Glances API RESTFul implementation. @api {get} /api/%s/pluginslist Get plugins list @apiVersion 2.0 @apiName pluginslist @apiGroup plugin @apiSuccess {String[]} Plugins list. @apiSuccessExample Success-Response: HTTP/1.1 200 OK [ ...
[ "Glances", "API", "RESTFul", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L258-L293
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_all
def _api_all(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if self.arg...
python
def _api_all(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if self.arg...
[ "def", "_api_all", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "self", ".", "args", ".", "debug", ":", "fname", "=", "os", ".", "path", ".", "join", "(", "tempfile", ".", "gettempdir", "(", ")", ...
Glances API RESTful implementation. Return the JSON representation of all the plugins HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L296-L323
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_all_limits
def _api_all_limits(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins limits HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' ...
python
def _api_all_limits(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins limits HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' ...
[ "def", "_api_all_limits", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "try", ":", "# Get the JSON value of the stat limits", "limits", "=", "json", ".", "dumps", "(", "self", ".", "stats", ".", "getAllLimitsAsDict"...
Glances API RESTful implementation. Return the JSON representation of all the plugins limits HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L326-L341
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_all_views
def _api_all_views(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins views HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' ...
python
def _api_all_views(self): """Glances API RESTful implementation. Return the JSON representation of all the plugins views HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' ...
[ "def", "_api_all_views", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "try", ":", "# Get the JSON value of the stat view", "limits", "=", "json", ".", "dumps", "(", "self", ".", "stats", ".", "getAllViewsAsDict", ...
Glances API RESTful implementation. Return the JSON representation of all the plugins views HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L344-L359
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api
def _api(self, plugin): """Glances API RESTful implementation. Return the JSON representation of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugi...
python
def _api(self, plugin): """Glances API RESTful implementation. Return the JSON representation of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugi...
[ "def", "_api", "(", "self", ",", "plugin", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "plugin", "not", "in", "self", ".", "plugins_list", ":", "abort", "(", "400", ",", "\"Unknown plugin %s (available plugins: %s)\"", ...
Glances API RESTful implementation. Return the JSON representation of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L362-L383
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_history
def _api_history(self, plugin, nb=0): """Glances API RESTful implementation. Return the JSON representation of a given plugin history Limit to the last nb items (all if nb=0) HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ resp...
python
def _api_history(self, plugin, nb=0): """Glances API RESTful implementation. Return the JSON representation of a given plugin history Limit to the last nb items (all if nb=0) HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ resp...
[ "def", "_api_history", "(", "self", ",", "plugin", ",", "nb", "=", "0", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "plugin", "not", "in", "self", ".", "plugins_list", ":", "abort", "(", "400", ",", "\"Unknown p...
Glances API RESTful implementation. Return the JSON representation of a given plugin history Limit to the last nb items (all if nb=0) HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L386-L408
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_limits
def _api_limits(self, plugin): """Glances API RESTful implementation. Return the JSON limits of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugin...
python
def _api_limits(self, plugin): """Glances API RESTful implementation. Return the JSON limits of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugin...
[ "def", "_api_limits", "(", "self", ",", "plugin", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "plugin", "not", "in", "self", ".", "plugins_list", ":", "abort", "(", "400", ",", "\"Unknown plugin %s (available plugins: %...
Glances API RESTful implementation. Return the JSON limits of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L411-L432
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_views
def _api_views(self, plugin): """Glances API RESTful implementation. Return the JSON views of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugin n...
python
def _api_views(self, plugin): """Glances API RESTful implementation. Return the JSON views of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' if plugin n...
[ "def", "_api_views", "(", "self", ",", "plugin", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "plugin", "not", "in", "self", ".", "plugins_list", ":", "abort", "(", "400", ",", "\"Unknown plugin %s (available plugins: %s...
Glances API RESTful implementation. Return the JSON views of a given plugin HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L435-L456
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_itemvalue
def _api_itemvalue(self, plugin, item, value=None, history=False, nb=0): """Father method for _api_item and _api_value.""" response.content_type = 'application/json; charset=utf-8' if plugin not in self.plugins_list: abort(400, "Unknown plugin %s (available plugins: %s)" % (plugin, ...
python
def _api_itemvalue(self, plugin, item, value=None, history=False, nb=0): """Father method for _api_item and _api_value.""" response.content_type = 'application/json; charset=utf-8' if plugin not in self.plugins_list: abort(400, "Unknown plugin %s (available plugins: %s)" % (plugin, ...
[ "def", "_api_itemvalue", "(", "self", ",", "plugin", ",", "item", ",", "value", "=", "None", ",", "history", "=", "False", ",", "nb", "=", "0", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "plugin", "not", "in"...
Father method for _api_item and _api_value.
[ "Father", "method", "for", "_api_item", "and", "_api_value", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L459-L487
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_item_history
def _api_item_history(self, plugin, item, nb=0): """Glances API RESTful implementation. Return the JSON representation of the couple plugin/history of item HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ return self._api_itemvalue(plu...
python
def _api_item_history(self, plugin, item, nb=0): """Glances API RESTful implementation. Return the JSON representation of the couple plugin/history of item HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error """ return self._api_itemvalue(plu...
[ "def", "_api_item_history", "(", "self", ",", "plugin", ",", "item", ",", "nb", "=", "0", ")", ":", "return", "self", ".", "_api_itemvalue", "(", "plugin", ",", "item", ",", "history", "=", "True", ",", "nb", "=", "int", "(", "nb", ")", ")" ]
Glances API RESTful implementation. Return the JSON representation of the couple plugin/history of item HTTP/200 if OK HTTP/400 if plugin is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L502-L511
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_value
def _api_value(self, plugin, item, value): """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 HTTP/404 if others error """ return self._api_itemvalue(plugin, item, value)
python
def _api_value(self, plugin, item, value): """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 HTTP/404 if others error """ return self._api_itemvalue(plugin, item, value)
[ "def", "_api_value", "(", "self", ",", "plugin", ",", "item", ",", "value", ")", ":", "return", "self", ".", "_api_itemvalue", "(", "plugin", ",", "item", ",", "value", ")" ]
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 HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L514-L522
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_config
def _api_config(self): """Glances API RESTful implementation. Return the JSON representation of the Glances configuration file HTTP/200 if OK HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' try: # Get the JSON v...
python
def _api_config(self): """Glances API RESTful implementation. Return the JSON representation of the Glances configuration file HTTP/200 if OK HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' try: # Get the JSON v...
[ "def", "_api_config", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "try", ":", "# Get the JSON value of the config' dict", "args_json", "=", "json", ".", "dumps", "(", "self", ".", "config", ".", "as_dict", "(", ...
Glances API RESTful implementation. Return the JSON representation of the Glances configuration file HTTP/200 if OK HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L525-L539
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_config_item
def _api_config_item(self, item): """Glances API RESTful implementation. Return the JSON representation of the Glances configuration item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=...
python
def _api_config_item(self, item): """Glances API RESTful implementation. Return the JSON representation of the Glances configuration item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error """ response.content_type = 'application/json; charset=...
[ "def", "_api_config_item", "(", "self", ",", "item", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "config_dict", "=", "self", ".", "config", ".", "as_dict", "(", ")", "if", "item", "not", "in", "config_dict", ":", "abort...
Glances API RESTful implementation. Return the JSON representation of the Glances configuration item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L542-L561
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_args
def _api_args(self): """Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments HTTP/200 if OK HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' try: # Get the JSON...
python
def _api_args(self): """Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments HTTP/200 if OK HTTP/404 if others error """ response.content_type = 'application/json; charset=utf-8' try: # Get the JSON...
[ "def", "_api_args", "(", "self", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "try", ":", "# Get the JSON value of the args' dict", "# Use vars to convert namespace to dict", "# Source: https://docs.python.org/%s/library/functions.html#vars", "...
Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments HTTP/200 if OK HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L564-L580
train
nicolargo/glances
glances/outputs/glances_bottle.py
GlancesBottle._api_args_item
def _api_args_item(self, item): """Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error """ response.content_type = 'application/json; c...
python
def _api_args_item(self, item): """Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error """ response.content_type = 'application/json; c...
[ "def", "_api_args_item", "(", "self", ",", "item", ")", ":", "response", ".", "content_type", "=", "'application/json; charset=utf-8'", "if", "item", "not", "in", "self", ".", "args", ":", "abort", "(", "400", ",", "\"Unknown argument item %s\"", "%", "item", ...
Glances API RESTful implementation. Return the JSON representation of the Glances command line arguments item HTTP/200 if OK HTTP/400 if item is not found HTTP/404 if others error
[ "Glances", "API", "RESTful", "implementation", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L583-L603
train
nicolargo/glances
glances/plugins/glances_diskio.py
Plugin.update
def update(self): """Update disk I/O stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Grab the stat using the psutil disk_io_counters method ...
python
def update(self): """Update disk I/O stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Grab the stat using the psutil disk_io_counters method ...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "# Grab the stat using the psutil disk_io_counters m...
Update disk I/O stats using the input method.
[ "Update", "disk", "I", "/", "O", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_diskio.py#L60-L138
train
nicolargo/glances
glances/plugins/glances_diskio.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message ret = [] # Only process if stats exist and display plugin enable... if not self.stats or self.is_disable(): return ret # Max si...
python
def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message ret = [] # Only process if stats exist and display plugin enable... if not self.stats or self.is_disable(): return ret # Max si...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist and display plugin enable...", "if", "not", "self", ".", "stats", "or", "self", ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_diskio.py#L154-L227
train
nicolargo/glances
glances/__init__.py
start
def start(config, args): """Start Glances.""" # Load mode global mode if core.is_standalone(): from glances.standalone import GlancesStandalone as GlancesMode elif core.is_client(): if core.is_client_browser(): from glances.client_browser import GlancesClientBrowser as ...
python
def start(config, args): """Start Glances.""" # Load mode global mode if core.is_standalone(): from glances.standalone import GlancesStandalone as GlancesMode elif core.is_client(): if core.is_client_browser(): from glances.client_browser import GlancesClientBrowser as ...
[ "def", "start", "(", "config", ",", "args", ")", ":", "# Load mode", "global", "mode", "if", "core", ".", "is_standalone", "(", ")", ":", "from", "glances", ".", "standalone", "import", "GlancesStandalone", "as", "GlancesMode", "elif", "core", ".", "is_clien...
Start Glances.
[ "Start", "Glances", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/__init__.py#L86-L112
train
nicolargo/glances
glances/__init__.py
main
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Log Glances and psutil version logger.info('Start Glances {}'.format(__version__)) logger.info('{} {}...
python
def main(): """Main entry point for Glances. Select the mode (standalone, client or server) Run it... """ # Catch the CTRL-C signal signal.signal(signal.SIGINT, __signal_handler) # Log Glances and psutil version logger.info('Start Glances {}'.format(__version__)) logger.info('{} {}...
[ "def", "main", "(", ")", ":", "# Catch the CTRL-C signal", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "__signal_handler", ")", "# Log Glances and psutil version", "logger", ".", "info", "(", "'Start Glances {}'", ".", "format", "(", "__version__", ...
Main entry point for Glances. Select the mode (standalone, client or server) Run it...
[ "Main", "entry", "point", "for", "Glances", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/__init__.py#L115-L140
train
nicolargo/glances
glances/config.py
user_config_dir
def user_config_dir(): r"""Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances """ if WINDOWS: path = os.environ.get('APPDATA') elif MACOS: path = os.path.expanduser('...
python
def user_config_dir(): r"""Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances """ if WINDOWS: path = os.environ.get('APPDATA') elif MACOS: path = os.path.expanduser('...
[ "def", "user_config_dir", "(", ")", ":", "if", "WINDOWS", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "'APPDATA'", ")", "elif", "MACOS", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "'~/Library/Application Support'", ")", "el...
r"""Return the per-user config dir (full path). - Linux, *BSD, SunOS: ~/.config/glances - macOS: ~/Library/Application Support/glances - Windows: %APPDATA%\glances
[ "r", "Return", "the", "per", "-", "user", "config", "dir", "(", "full", "path", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L33-L51
train
nicolargo/glances
glances/config.py
user_cache_dir
def user_cache_dir(): r"""Return the per-user cache dir (full path). - Linux, *BSD, SunOS: ~/.cache/glances - macOS: ~/Library/Caches/glances - Windows: {%LOCALAPPDATA%,%APPDATA%}\glances\cache """ if WINDOWS: path = os.path.join(os.environ.get('LOCALAPPDATA') or os.environ.get('APPDATA...
python
def user_cache_dir(): r"""Return the per-user cache dir (full path). - Linux, *BSD, SunOS: ~/.cache/glances - macOS: ~/Library/Caches/glances - Windows: {%LOCALAPPDATA%,%APPDATA%}\glances\cache """ if WINDOWS: path = os.path.join(os.environ.get('LOCALAPPDATA') or os.environ.get('APPDATA...
[ "def", "user_cache_dir", "(", ")", ":", "if", "WINDOWS", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", ".", "get", "(", "'LOCALAPPDATA'", ")", "or", "os", ".", "environ", ".", "get", "(", "'APPDATA'", ")", ",", "'glan...
r"""Return the per-user cache dir (full path). - Linux, *BSD, SunOS: ~/.cache/glances - macOS: ~/Library/Caches/glances - Windows: {%LOCALAPPDATA%,%APPDATA%}\glances\cache
[ "r", "Return", "the", "per", "-", "user", "cache", "dir", "(", "full", "path", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L54-L70
train
nicolargo/glances
glances/config.py
system_config_dir
def system_config_dir(): r"""Return the system-wide config dir (full path). - Linux, SunOS: /etc/glances - *BSD, macOS: /usr/local/etc/glances - Windows: %APPDATA%\glances """ if LINUX or SUNOS: path = '/etc' elif BSD or MACOS: path = '/usr/local/etc' else: path ...
python
def system_config_dir(): r"""Return the system-wide config dir (full path). - Linux, SunOS: /etc/glances - *BSD, macOS: /usr/local/etc/glances - Windows: %APPDATA%\glances """ if LINUX or SUNOS: path = '/etc' elif BSD or MACOS: path = '/usr/local/etc' else: path ...
[ "def", "system_config_dir", "(", ")", ":", "if", "LINUX", "or", "SUNOS", ":", "path", "=", "'/etc'", "elif", "BSD", "or", "MACOS", ":", "path", "=", "'/usr/local/etc'", "else", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "'APPDATA'", ")", ...
r"""Return the system-wide config dir (full path). - Linux, SunOS: /etc/glances - *BSD, macOS: /usr/local/etc/glances - Windows: %APPDATA%\glances
[ "r", "Return", "the", "system", "-", "wide", "config", "dir", "(", "full", "path", ")", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L73-L91
train
nicolargo/glances
glances/config.py
Config.config_file_paths
def config_file_paths(self): r"""Get a list of config file paths. The list is built taking into account of the OS, priority and location. * custom path: /path/to/glances * Linux, SunOS: ~/.config/glances, /etc/glances * *BSD: ~/.config/glances, /usr/local/etc/glances * ...
python
def config_file_paths(self): r"""Get a list of config file paths. The list is built taking into account of the OS, priority and location. * custom path: /path/to/glances * Linux, SunOS: ~/.config/glances, /etc/glances * *BSD: ~/.config/glances, /usr/local/etc/glances * ...
[ "def", "config_file_paths", "(", "self", ")", ":", "paths", "=", "[", "]", "if", "self", ".", "config_dir", ":", "paths", ".", "append", "(", "self", ".", "config_dir", ")", "paths", ".", "append", "(", "os", ".", "path", ".", "join", "(", "user_conf...
r"""Get a list of config file paths. The list is built taking into account of the OS, priority and location. * custom path: /path/to/glances * Linux, SunOS: ~/.config/glances, /etc/glances * *BSD: ~/.config/glances, /usr/local/etc/glances * macOS: ~/Library/Application Support/...
[ "r", "Get", "a", "list", "of", "config", "file", "paths", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L113-L137
train
nicolargo/glances
glances/config.py
Config.read
def read(self): """Read the config file, if it exists. Using defaults otherwise.""" for config_file in self.config_file_paths(): logger.info('Search glances.conf file in {}'.format(config_file)) if os.path.exists(config_file): try: with open(co...
python
def read(self): """Read the config file, if it exists. Using defaults otherwise.""" for config_file in self.config_file_paths(): logger.info('Search glances.conf file in {}'.format(config_file)) if os.path.exists(config_file): try: with open(co...
[ "def", "read", "(", "self", ")", ":", "for", "config_file", "in", "self", ".", "config_file_paths", "(", ")", ":", "logger", ".", "info", "(", "'Search glances.conf file in {}'", ".", "format", "(", "config_file", ")", ")", "if", "os", ".", "path", ".", ...
Read the config file, if it exists. Using defaults otherwise.
[ "Read", "the", "config", "file", "if", "it", "exists", ".", "Using", "defaults", "otherwise", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L139-L225
train
nicolargo/glances
glances/config.py
Config.as_dict
def as_dict(self): """Return the configuration as a dict""" dictionary = {} for section in self.parser.sections(): dictionary[section] = {} for option in self.parser.options(section): dictionary[section][option] = self.parser.get(section, option) r...
python
def as_dict(self): """Return the configuration as a dict""" dictionary = {} for section in self.parser.sections(): dictionary[section] = {} for option in self.parser.options(section): dictionary[section][option] = self.parser.get(section, option) r...
[ "def", "as_dict", "(", "self", ")", ":", "dictionary", "=", "{", "}", "for", "section", "in", "self", ".", "parser", ".", "sections", "(", ")", ":", "dictionary", "[", "section", "]", "=", "{", "}", "for", "option", "in", "self", ".", "parser", "."...
Return the configuration as a dict
[ "Return", "the", "configuration", "as", "a", "dict" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L232-L239
train
nicolargo/glances
glances/config.py
Config.set_default_cwc
def set_default_cwc(self, section, option_header=None, cwc=['50', '70', '90']): """Set default values for careful, warning and critical.""" if option_header is None: header = '' else: header = option_header + '_' sel...
python
def set_default_cwc(self, section, option_header=None, cwc=['50', '70', '90']): """Set default values for careful, warning and critical.""" if option_header is None: header = '' else: header = option_header + '_' sel...
[ "def", "set_default_cwc", "(", "self", ",", "section", ",", "option_header", "=", "None", ",", "cwc", "=", "[", "'50'", ",", "'70'", ",", "'90'", "]", ")", ":", "if", "option_header", "is", "None", ":", "header", "=", "''", "else", ":", "header", "="...
Set default values for careful, warning and critical.
[ "Set", "default", "values", "for", "careful", "warning", "and", "critical", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L253-L263
train
nicolargo/glances
glances/config.py
Config.set_default
def set_default(self, section, option, default): """If the option did not exist, create a default value.""" if not self.parser.has_option(section, option): self.parser.set(section, option, default)
python
def set_default(self, section, option, default): """If the option did not exist, create a default value.""" if not self.parser.has_option(section, option): self.parser.set(section, option, default)
[ "def", "set_default", "(", "self", ",", "section", ",", "option", ",", "default", ")", ":", "if", "not", "self", ".", "parser", ".", "has_option", "(", "section", ",", "option", ")", ":", "self", ".", "parser", ".", "set", "(", "section", ",", "optio...
If the option did not exist, create a default value.
[ "If", "the", "option", "did", "not", "exist", "create", "a", "default", "value", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L265-L269
train
nicolargo/glances
glances/config.py
Config.get_value
def get_value(self, section, option, default=None): """Get the value of an option, if it exists. If it did not exist, then return the default value. It allows user to define dynamic configuration key (see issue#1204) Dynamic vlaue should starts and end with the ` char...
python
def get_value(self, section, option, default=None): """Get the value of an option, if it exists. If it did not exist, then return the default value. It allows user to define dynamic configuration key (see issue#1204) Dynamic vlaue should starts and end with the ` char...
[ "def", "get_value", "(", "self", ",", "section", ",", "option", ",", "default", "=", "None", ")", ":", "ret", "=", "default", "try", ":", "ret", "=", "self", ".", "parser", ".", "get", "(", "section", ",", "option", ")", "except", "NoOptionError", ":...
Get the value of an option, if it exists. If it did not exist, then return the default value. It allows user to define dynamic configuration key (see issue#1204) Dynamic vlaue should starts and end with the ` char Example: prefix=`hostname`
[ "Get", "the", "value", "of", "an", "option", "if", "it", "exists", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L271-L295
train
nicolargo/glances
glances/config.py
Config.get_int_value
def get_int_value(self, section, option, default=0): """Get the int value of an option, if it exists.""" try: return self.parser.getint(section, option) except NoOptionError: return int(default)
python
def get_int_value(self, section, option, default=0): """Get the int value of an option, if it exists.""" try: return self.parser.getint(section, option) except NoOptionError: return int(default)
[ "def", "get_int_value", "(", "self", ",", "section", ",", "option", ",", "default", "=", "0", ")", ":", "try", ":", "return", "self", ".", "parser", ".", "getint", "(", "section", ",", "option", ")", "except", "NoOptionError", ":", "return", "int", "("...
Get the int value of an option, if it exists.
[ "Get", "the", "int", "value", "of", "an", "option", "if", "it", "exists", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L297-L302
train
nicolargo/glances
glances/config.py
Config.get_float_value
def get_float_value(self, section, option, default=0.0): """Get the float value of an option, if it exists.""" try: return self.parser.getfloat(section, option) except NoOptionError: return float(default)
python
def get_float_value(self, section, option, default=0.0): """Get the float value of an option, if it exists.""" try: return self.parser.getfloat(section, option) except NoOptionError: return float(default)
[ "def", "get_float_value", "(", "self", ",", "section", ",", "option", ",", "default", "=", "0.0", ")", ":", "try", ":", "return", "self", ".", "parser", ".", "getfloat", "(", "section", ",", "option", ")", "except", "NoOptionError", ":", "return", "float...
Get the float value of an option, if it exists.
[ "Get", "the", "float", "value", "of", "an", "option", "if", "it", "exists", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L304-L309
train
nicolargo/glances
glances/config.py
Config.get_bool_value
def get_bool_value(self, section, option, default=True): """Get the bool value of an option, if it exists.""" try: return self.parser.getboolean(section, option) except NoOptionError: return bool(default)
python
def get_bool_value(self, section, option, default=True): """Get the bool value of an option, if it exists.""" try: return self.parser.getboolean(section, option) except NoOptionError: return bool(default)
[ "def", "get_bool_value", "(", "self", ",", "section", ",", "option", ",", "default", "=", "True", ")", ":", "try", ":", "return", "self", ".", "parser", ".", "getboolean", "(", "section", ",", "option", ")", "except", "NoOptionError", ":", "return", "boo...
Get the bool value of an option, if it exists.
[ "Get", "the", "bool", "value", "of", "an", "option", "if", "it", "exists", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L311-L316
train
nicolargo/glances
glances/events.py
GlancesEvents.__event_exist
def __event_exist(self, event_type): """Return the event position, if it exists. An event exist if: * end is < 0 * event_type is matching Return -1 if the item is not found. """ for i in range(self.len()): if self.events_list[i][1] < 0 and self.events...
python
def __event_exist(self, event_type): """Return the event position, if it exists. An event exist if: * end is < 0 * event_type is matching Return -1 if the item is not found. """ for i in range(self.len()): if self.events_list[i][1] < 0 and self.events...
[ "def", "__event_exist", "(", "self", ",", "event_type", ")", ":", "for", "i", "in", "range", "(", "self", ".", "len", "(", ")", ")", ":", "if", "self", ".", "events_list", "[", "i", "]", "[", "1", "]", "<", "0", "and", "self", ".", "events_list",...
Return the event position, if it exists. An event exist if: * end is < 0 * event_type is matching Return -1 if the item is not found.
[ "Return", "the", "event", "position", "if", "it", "exists", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L65-L76
train
nicolargo/glances
glances/events.py
GlancesEvents.get_event_sort_key
def get_event_sort_key(self, event_type): """Return the process sort key""" # Process sort depending on alert type if event_type.startswith("MEM"): # Sort TOP process by memory_percent ret = 'memory_percent' elif event_type.startswith("CPU_IOWAIT"): # ...
python
def get_event_sort_key(self, event_type): """Return the process sort key""" # Process sort depending on alert type if event_type.startswith("MEM"): # Sort TOP process by memory_percent ret = 'memory_percent' elif event_type.startswith("CPU_IOWAIT"): # ...
[ "def", "get_event_sort_key", "(", "self", ",", "event_type", ")", ":", "# Process sort depending on alert type", "if", "event_type", ".", "startswith", "(", "\"MEM\"", ")", ":", "# Sort TOP process by memory_percent", "ret", "=", "'memory_percent'", "elif", "event_type", ...
Return the process sort key
[ "Return", "the", "process", "sort", "key" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L78-L90
train
nicolargo/glances
glances/events.py
GlancesEvents.set_process_sort
def set_process_sort(self, event_type): """Define the process auto sort key from the alert type.""" if glances_processes.auto_sort: glances_processes.sort_key = self.get_event_sort_key(event_type)
python
def set_process_sort(self, event_type): """Define the process auto sort key from the alert type.""" if glances_processes.auto_sort: glances_processes.sort_key = self.get_event_sort_key(event_type)
[ "def", "set_process_sort", "(", "self", ",", "event_type", ")", ":", "if", "glances_processes", ".", "auto_sort", ":", "glances_processes", ".", "sort_key", "=", "self", ".", "get_event_sort_key", "(", "event_type", ")" ]
Define the process auto sort key from the alert type.
[ "Define", "the", "process", "auto", "sort", "key", "from", "the", "alert", "type", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L92-L95
train
nicolargo/glances
glances/events.py
GlancesEvents.add
def add(self, event_state, event_type, event_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'event' is a 'new one', add it at the beginning of the list. If 'event' is not a 'new one', update the list . If event < peak_time then the ...
python
def add(self, event_state, event_type, event_value, proc_list=None, proc_desc="", peak_time=6): """Add a new item to the logs list. If 'event' is a 'new one', add it at the beginning of the list. If 'event' is not a 'new one', update the list . If event < peak_time then the ...
[ "def", "add", "(", "self", ",", "event_state", ",", "event_type", ",", "event_value", ",", "proc_list", "=", "None", ",", "proc_desc", "=", "\"\"", ",", "peak_time", "=", "6", ")", ":", "proc_list", "=", "proc_list", "or", "glances_processes", ".", "getlis...
Add a new item to the logs list. If 'event' is a 'new one', add it at the beginning of the list. If 'event' is not a 'new one', update the list . If event < peak_time then the alert is not set.
[ "Add", "a", "new", "item", "to", "the", "logs", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L102-L123
train
nicolargo/glances
glances/events.py
GlancesEvents._create_event
def _create_event(self, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Add a new item in the log list. Item is added only if the criticity (event_state) is WARNING or CRITICAL. """ if event_state == "WARNING" or event_state == "CRITICAL"...
python
def _create_event(self, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Add a new item in the log list. Item is added only if the criticity (event_state) is WARNING or CRITICAL. """ if event_state == "WARNING" or event_state == "CRITICAL"...
[ "def", "_create_event", "(", "self", ",", "event_state", ",", "event_type", ",", "event_value", ",", "proc_list", ",", "proc_desc", ",", "peak_time", ")", ":", "if", "event_state", "==", "\"WARNING\"", "or", "event_state", "==", "\"CRITICAL\"", ":", "# Define th...
Add a new item in the log list. Item is added only if the criticity (event_state) is WARNING or CRITICAL.
[ "Add", "a", "new", "item", "in", "the", "log", "list", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L125-L161
train
nicolargo/glances
glances/events.py
GlancesEvents._update_event
def _update_event(self, event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Update an event in the list""" if event_state == "OK" or event_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort(...
python
def _update_event(self, event_index, event_state, event_type, event_value, proc_list, proc_desc, peak_time): """Update an event in the list""" if event_state == "OK" or event_state == "CAREFUL": # Reset the automatic process sort key self.reset_process_sort(...
[ "def", "_update_event", "(", "self", ",", "event_index", ",", "event_state", ",", "event_type", ",", "event_value", ",", "proc_list", ",", "proc_desc", ",", "peak_time", ")", ":", "if", "event_state", "==", "\"OK\"", "or", "event_state", "==", "\"CAREFUL\"", "...
Update an event in the list
[ "Update", "an", "event", "in", "the", "list" ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L163-L208
train
nicolargo/glances
glances/events.py
GlancesEvents.clean
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. """ # Create a new clean list clean_events_list = [] while self.len() > 0: i...
python
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. """ # Create a new clean list clean_events_list = [] while self.len() > 0: i...
[ "def", "clean", "(", "self", ",", "critical", "=", "False", ")", ":", "# Create a new clean list", "clean_events_list", "=", "[", "]", "while", "self", ".", "len", "(", ")", ">", "0", ":", "item", "=", "self", ".", "events_list", ".", "pop", "(", ")", ...
Clean the logs list by deleting finished items. By default, only delete WARNING message. If critical = True, also delete CRITICAL message.
[ "Clean", "the", "logs", "list", "by", "deleting", "finished", "items", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L210-L224
train
nicolargo/glances
glances/stats_client_snmp.py
GlancesStatsClientSNMP.check_snmp
def check_snmp(self): """Chek if SNMP is available on the server.""" # Import the SNMP client class from glances.snmp import GlancesSNMPClient # Create an instance of the SNMP client clientsnmp = GlancesSNMPClient(host=self.args.client, por...
python
def check_snmp(self): """Chek if SNMP is available on the server.""" # Import the SNMP client class from glances.snmp import GlancesSNMPClient # Create an instance of the SNMP client clientsnmp = GlancesSNMPClient(host=self.args.client, por...
[ "def", "check_snmp", "(", "self", ")", ":", "# Import the SNMP client class", "from", "glances", ".", "snmp", "import", "GlancesSNMPClient", "# Create an instance of the SNMP client", "clientsnmp", "=", "GlancesSNMPClient", "(", "host", "=", "self", ".", "args", ".", ...
Chek if SNMP is available on the server.
[ "Chek", "if", "SNMP", "is", "available", "on", "the", "server", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L57-L82
train
nicolargo/glances
glances/stats_client_snmp.py
GlancesStatsClientSNMP.get_system_name
def get_system_name(self, oid_system_name): """Get the short os name from the OS name OID string.""" short_system_name = None if oid_system_name == '': return short_system_name # Find the short name in the oid_to_short_os_name dict for r, v in iteritems(oid_to_short...
python
def get_system_name(self, oid_system_name): """Get the short os name from the OS name OID string.""" short_system_name = None if oid_system_name == '': return short_system_name # Find the short name in the oid_to_short_os_name dict for r, v in iteritems(oid_to_short...
[ "def", "get_system_name", "(", "self", ",", "oid_system_name", ")", ":", "short_system_name", "=", "None", "if", "oid_system_name", "==", "''", ":", "return", "short_system_name", "# Find the short name in the oid_to_short_os_name dict", "for", "r", ",", "v", "in", "i...
Get the short os name from the OS name OID string.
[ "Get", "the", "short", "os", "name", "from", "the", "OS", "name", "OID", "string", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L84-L97
train
nicolargo/glances
glances/stats_client_snmp.py
GlancesStatsClientSNMP.update
def update(self): """Update the stats using SNMP.""" # For each plugins, call the update method for p in self._plugins: if self._plugins[p].is_disable(): # If current plugin is disable # then continue to next plugin continue ...
python
def update(self): """Update the stats using SNMP.""" # For each plugins, call the update method for p in self._plugins: if self._plugins[p].is_disable(): # If current plugin is disable # then continue to next plugin continue ...
[ "def", "update", "(", "self", ")", ":", "# For each plugins, call the update method", "for", "p", "in", "self", ".", "_plugins", ":", "if", "self", ".", "_plugins", "[", "p", "]", ".", "is_disable", "(", ")", ":", "# If current plugin is disable", "# then contin...
Update the stats using SNMP.
[ "Update", "the", "stats", "using", "SNMP", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L99-L121
train
nicolargo/glances
glances/plugins/glances_raid.py
Plugin.update
def update(self): """Update RAID stats using the input method.""" # Init new stats stats = self.get_init_value() if import_error_tag: return self.stats if self.input_method == 'local': # Update stats using the PyMDstat lib (https://github.com/nicolargo/p...
python
def update(self): """Update RAID stats using the input method.""" # Init new stats stats = self.get_init_value() if import_error_tag: return self.stats if self.input_method == 'local': # Update stats using the PyMDstat lib (https://github.com/nicolargo/p...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "import_error_tag", ":", "return", "self", ".", "stats", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the...
Update RAID stats using the input method.
[ "Update", "RAID", "stats", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L51-L78
train
nicolargo/glances
glances/plugins/glances_raid.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message ret = [] # Only process if stats exist... if not self.stats: return ret # Max size for the interface name name_max_widt...
python
def msg_curse(self, args=None, max_width=None): """Return the dict to display in the curse interface.""" # Init the return message ret = [] # Only process if stats exist... if not self.stats: return ret # Max size for the interface name name_max_widt...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Only process if stats exist...", "if", "not", "self", ".", "stats", ":", "return", "ret", "# Max size for ...
Return the dict to display in the curse interface.
[ "Return", "the", "dict", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L80-L152
train
nicolargo/glances
glances/plugins/glances_raid.py
Plugin.raid_alert
def raid_alert(self, status, used, available, type): """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 type == 'raid0': ...
python
def raid_alert(self, status, used, available, type): """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 type == 'raid0': ...
[ "def", "raid_alert", "(", "self", ",", "status", ",", "used", ",", "available", ",", "type", ")", ":", "if", "type", "==", "'raid0'", ":", "return", "'OK'", "if", "status", "==", "'inactive'", ":", "return", "'CRITICAL'", "if", "used", "is", "None", "o...
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.
[ "RAID", "alert", "messages", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L154-L169
train
nicolargo/glances
glances/plugins/glances_uptime.py
Plugin.update
def update(self): """Update uptime stat using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib self.uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time(...
python
def update(self): """Update uptime stat using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib self.uptime = datetime.now() - datetime.fromtimestamp(psutil.boot_time(...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "self", ".", "uptime", "=", "datetime", "....
Update uptime stat using the input method.
[ "Update", "uptime", "stat", "using", "the", "input", "method", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_uptime.py#L62-L85
train
nicolargo/glances
glances/plugins/glances_cloud.py
Plugin.update
def update(self): """Update the cloud stats. Return the stats (dict) """ # Init new stats stats = self.get_init_value() # Requests lib is needed to get stats from the Cloud API if import_error_tag: return stats # Update the stats if ...
python
def update(self): """Update the cloud stats. Return the stats (dict) """ # Init new stats stats = self.get_init_value() # Requests lib is needed to get stats from the Cloud API if import_error_tag: return stats # Update the stats if ...
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "# Requests lib is needed to get stats from the Cloud API", "if", "import_error_tag", ":", "return", "stats", "# Update the stats", "if", "self", ".", "i...
Update the cloud stats. Return the stats (dict)
[ "Update", "the", "cloud", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L78-L103
train
nicolargo/glances
glances/plugins/glances_cloud.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=None): """Return the string to display in the curse interface.""" # Init the return message ret = [] if not self.stats or self.stats == {} or self.is_disable(): return ret # Generate the output if 'instance-type' in s...
python
def msg_curse(self, args=None, max_width=None): """Return the string to display in the curse interface.""" # Init the return message ret = [] if not self.stats or self.stats == {} or self.is_disable(): return ret # Generate the output if 'instance-type' in s...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "if", "not", "self", ".", "stats", "or", "self", ".", "stats", "==", "{", "}", "or", "self", ".", ...
Return the string to display in the curse interface.
[ "Return", "the", "string", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L105-L126
train
nicolargo/glances
glances/plugins/glances_cloud.py
ThreadOpenStack.run
def run(self): """Grab plugin's stats. Infinite loop, should be stopped by calling the stop() method """ if import_error_tag: self.stop() return False for k, v in iteritems(self.OPENSTACK_API_METADATA): r_url = '{}/{}'.format(self.OPENSTACK_A...
python
def run(self): """Grab plugin's stats. Infinite loop, should be stopped by calling the stop() method """ if import_error_tag: self.stop() return False for k, v in iteritems(self.OPENSTACK_API_METADATA): r_url = '{}/{}'.format(self.OPENSTACK_A...
[ "def", "run", "(", "self", ")", ":", "if", "import_error_tag", ":", "self", ".", "stop", "(", ")", "return", "False", "for", "k", ",", "v", "in", "iteritems", "(", "self", ".", "OPENSTACK_API_METADATA", ")", ":", "r_url", "=", "'{}/{}'", ".", "format",...
Grab plugin's stats. Infinite loop, should be stopped by calling the stop() method
[ "Grab", "plugin", "s", "stats", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L152-L173
train
nicolargo/glances
glances/plugins/glances_help.py
Plugin.generate_view_data
def generate_view_data(self): """Generate the views.""" self.view_data['version'] = '{} {}'.format('Glances', __version__) self.view_data['psutil_version'] = ' with psutil {}'.format(psutil_version) try: self.view_data['configuration_file'] = 'Configuration file: {}'.format(...
python
def generate_view_data(self): """Generate the views.""" self.view_data['version'] = '{} {}'.format('Glances', __version__) self.view_data['psutil_version'] = ' with psutil {}'.format(psutil_version) try: self.view_data['configuration_file'] = 'Configuration file: {}'.format(...
[ "def", "generate_view_data", "(", "self", ")", ":", "self", ".", "view_data", "[", "'version'", "]", "=", "'{} {}'", ".", "format", "(", "'Glances'", ",", "__version__", ")", "self", ".", "view_data", "[", "'psutil_version'", "]", "=", "' with psutil {}'", "...
Generate the views.
[ "Generate", "the", "views", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_help.py#L55-L103
train
nicolargo/glances
glances/plugins/glances_help.py
Plugin.msg_curse
def msg_curse(self, args=None, max_width=None): """Return the list to display in the curse interface.""" # Init the return message ret = [] # Build the string message # Header ret.append(self.curse_add_line(self.view_data['version'], 'TITLE')) ret.append(self.cur...
python
def msg_curse(self, args=None, max_width=None): """Return the list to display in the curse interface.""" # Init the return message ret = [] # Build the string message # Header ret.append(self.curse_add_line(self.view_data['version'], 'TITLE')) ret.append(self.cur...
[ "def", "msg_curse", "(", "self", ",", "args", "=", "None", ",", "max_width", "=", "None", ")", ":", "# Init the return message", "ret", "=", "[", "]", "# Build the string message", "# Header", "ret", ".", "append", "(", "self", ".", "curse_add_line", "(", "s...
Return the list to display in the curse interface.
[ "Return", "the", "list", "to", "display", "in", "the", "curse", "interface", "." ]
5bd4d587a736e0d2b03170b56926841d2a3eb7ee
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_help.py#L109-L189
train