partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | _GlancesCurses.__display_right | Display the right sidebar in the Curses interface.
docker + processcount + amps + processlist + alert | glances/outputs/glances_curses.py | 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):
"""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... | [
"Display",
"the",
"right",
"sidebar",
"in",
"the",
"Curses",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L742-L767 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.display_popup | 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... | glances/outputs/glances_curses.py | 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):
"""
Display a centered popup.
If is_input is False:
Dis... | [
"Display",
"a",
"centered",
"popup",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L769-L845 | [
"def",
"display_popup",
"(",
"self",
",",
"message",
",",
"size_x",
"=",
"None",
",",
"size_y",
"=",
"None",
",",
"duration",
"=",
"3",
",",
"is_input",
"=",
"False",
",",
"input_size",
"=",
"30",
",",
"input_value",
"=",
"None",
")",
":",
"# Center th... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.display_plugin | 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 | glances/outputs/glances_curses.py | 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):
"""Display the plugin_stats on the screen.
If display_optional=True display the optional stats
... | [
"Display",
"the",
"plugin_stats",
"on",
"the",
"screen",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L847-L937 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.flush | 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 | glances/outputs/glances_curses.py | 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):
"""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",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L943-L953 | [
"def",
"flush",
"(",
"self",
",",
"stats",
",",
"cs_status",
"=",
"None",
")",
":",
"self",
".",
"erase",
"(",
")",
"self",
".",
"display",
"(",
"stats",
",",
"cs_status",
"=",
"cs_status",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.update | 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_... | glances/outputs/glances_curses.py | 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):
"""Update the screen.
INPUT
stats: Stats database to display
duration: duration of the loop
cs_status:
"None": standalone or serv... | [
"Update",
"the",
"screen",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L955-L1002 | [
"def",
"update",
"(",
"self",
",",
"stats",
",",
"duration",
"=",
"3",
",",
"cs_status",
"=",
"None",
",",
"return_to_browser",
"=",
"False",
")",
":",
"# Flush display",
"self",
".",
"flush",
"(",
"stats",
",",
"cs_status",
"=",
"cs_status",
")",
"# If ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.get_stats_display_width | Return the width of the formatted curses message. | glances/outputs/glances_curses.py | 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):
"""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... | [
"Return",
"the",
"width",
"of",
"the",
"formatted",
"curses",
"message",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L1008-L1023 | [
"def",
"get_stats_display_width",
"(",
"self",
",",
"curse_msg",
",",
"without_option",
"=",
"False",
")",
":",
"try",
":",
"if",
"without_option",
":",
"# Size without options",
"c",
"=",
"len",
"(",
"max",
"(",
"''",
".",
"join",
"(",
"[",
"(",
"u",
"(... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | _GlancesCurses.get_stats_display_height | r"""Return the height of the formatted curses message.
The height is defined by the number of '\n' (new line). | glances/outputs/glances_curses.py | 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):
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... | [
"r",
"Return",
"the",
"height",
"of",
"the",
"formatted",
"curses",
"message",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses.py#L1025-L1036 | [
"def",
"get_stats_display_height",
"(",
"self",
",",
"curse_msg",
")",
":",
"try",
":",
"c",
"=",
"[",
"i",
"[",
"'msg'",
"]",
"for",
"i",
"in",
"curse_msg",
"[",
"'msgdict'",
"]",
"]",
".",
"count",
"(",
"'\\n'",
")",
"except",
"Exception",
"as",
"e... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesSNMPClient.__buid_result | Build the results. | glances/snmp.py | 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):
"""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... | [
"Build",
"the",
"results",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L51-L62 | [
"def",
"__buid_result",
"(",
"self",
",",
"varBinds",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"name",
",",
"val",
"in",
"varBinds",
":",
"if",
"str",
"(",
"val",
")",
"==",
"''",
":",
"ret",
"[",
"name",
".",
"prettyPrint",
"(",
")",
"]",
"=",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesSNMPClient.get_by_oid | SNMP simple request (list of OID).
One request per OID list.
* oid: oid list
> Return a dict | glances/snmp.py | 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):
"""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... | [
"SNMP",
"simple",
"request",
"(",
"list",
"of",
"OID",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L71-L91 | [
"def",
"get_by_oid",
"(",
"self",
",",
"*",
"oid",
")",
":",
"if",
"self",
".",
"version",
"==",
"'3'",
":",
"errorIndication",
",",
"errorStatus",
",",
"errorIndex",
",",
"varBinds",
"=",
"self",
".",
"cmdGen",
".",
"getCmd",
"(",
"cmdgen",
".",
"UsmU... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesSNMPClient.getbulk_by_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 the number of supplied variables that
should not be iterated over... | glances/snmp.py | 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):
"""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 ... | [
"SNMP",
"getbulk",
"request",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/snmp.py#L100-L133 | [
"def",
"getbulk_by_oid",
"(",
"self",
",",
"non_repeaters",
",",
"max_repetitions",
",",
"*",
"oid",
")",
":",
"if",
"self",
".",
"version",
".",
"startswith",
"(",
"'3'",
")",
":",
"errorIndication",
",",
"errorStatus",
",",
"errorIndex",
",",
"varBinds",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStaticServer.load | Load the server list from the configuration file. | glances/static_list.py | 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):
"""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... | [
"Load",
"the",
"server",
"list",
"from",
"the",
"configuration",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/static_list.py#L40-L84 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStaticServer.set_server | Set the key to the value for the server_pos (position in the list). | glances/static_list.py | 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):
"""Set the key to the value for the server_pos (position in the list)."""
self._server_list[server_pos][key] = value | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"server_pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/static_list.py#L90-L92 | [
"def",
"set_server",
"(",
"self",
",",
"server_pos",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_server_list",
"[",
"server_pos",
"]",
"[",
"key",
"]",
"=",
"value"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AutoDiscovered.add_server | Add a new server to the list. | glances/autodiscover.py | 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):
"""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... | [
"Add",
"a",
"new",
"server",
"to",
"the",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L71-L84 | [
"def",
"add_server",
"(",
"self",
",",
"name",
",",
"ip",
",",
"port",
")",
":",
"new_server",
"=",
"{",
"'key'",
":",
"name",
",",
"# Zeroconf name with both hostname and port",
"'name'",
":",
"name",
".",
"split",
"(",
"':'",
")",
"[",
"0",
"]",
",",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AutoDiscovered.remove_server | Remove a server from the dict. | glances/autodiscover.py | 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):
"""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... | [
"Remove",
"a",
"server",
"from",
"the",
"dict",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L86-L97 | [
"def",
"remove_server",
"(",
"self",
",",
"name",
")",
":",
"for",
"i",
"in",
"self",
".",
"_server_list",
":",
"if",
"i",
"[",
"'key'",
"]",
"==",
"name",
":",
"try",
":",
"self",
".",
"_server_list",
".",
"remove",
"(",
"i",
")",
"logger",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAutoDiscoverListener.set_server | Set the key to the value for the server_pos (position in the list). | glances/autodiscover.py | 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):
"""Set the key to the value for the server_pos (position in the list)."""
self.servers.set_server(server_pos, key, value) | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"server_pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L112-L114 | [
"def",
"set_server",
"(",
"self",
",",
"server_pos",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"servers",
".",
"set_server",
"(",
"server_pos",
",",
"key",
",",
"value",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAutoDiscoverListener.add_service | 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 | glances/autodiscover.py | 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):
"""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... | [
"Method",
"called",
"when",
"a",
"new",
"Zeroconf",
"client",
"is",
"detected",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L116-L138 | [
"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",
",",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAutoDiscoverListener.remove_service | Remove the server from the list. | glances/autodiscover.py | 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):
"""Remove the server from the list."""
self.servers.remove_server(srv_name)
logger.info(
"Glances server %s removed from the autodetect list" % srv_name) | [
"Remove",
"the",
"server",
"from",
"the",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L140-L144 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAutoDiscoverServer.set_server | Set the key to the value for the server_pos (position in the list). | glances/autodiscover.py | 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):
"""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) | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"server_pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L175-L178 | [
"def",
"set_server",
"(",
"self",
",",
"server_pos",
",",
"key",
",",
"value",
")",
":",
"if",
"zeroconf_tag",
"and",
"self",
".",
"zeroconf_enable_tag",
":",
"self",
".",
"listener",
".",
"set_server",
"(",
"server_pos",
",",
"key",
",",
"value",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAutoDiscoverClient.find_active_ip_address | Try to find the active IP addresses. | glances/autodiscover.py | 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():
"""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... | [
"Try",
"to",
"find",
"the",
"active",
"IP",
"addresses",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/autodiscover.py#L226-L232 | [
"def",
"find_active_ip_address",
"(",
")",
":",
"import",
"netifaces",
"# Interface of the default gateway",
"gateway_itf",
"=",
"netifaces",
".",
"gateways",
"(",
")",
"[",
"'default'",
"]",
"[",
"netifaces",
".",
"AF_INET",
"]",
"[",
"1",
"]",
"# IP address for ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | compress | Compress result with deflate algorithm if the client ask for it. | glances/outputs/glances_bottle.py | 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):
"""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(
... | [
"Compress",
"result",
"with",
"deflate",
"algorithm",
"if",
"the",
"client",
"ask",
"for",
"it",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L41-L70 | [
"def",
"compress",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wrapper that take one function and return the compressed result.\"\"\"",
"ret",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle.load_config | Load the outputs section of the configuration file. | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Load",
"the",
"outputs",
"section",
"of",
"the",
"configuration",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L117-L123 | [
"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 ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle.check_auth | Check if a username/password combination is valid. | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Check",
"if",
"a",
"username",
"/",
"password",
"combination",
"is",
"valid",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L134-L141 | [
"def",
"check_auth",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"username",
"==",
"self",
".",
"args",
".",
"username",
":",
"from",
"glances",
".",
"password",
"import",
"GlancesPassword",
"pwd",
"=",
"GlancesPassword",
"(",
")",
"retu... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._route | Define route. | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Define",
"route",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L143-L196 | [
"def",
"_route",
"(",
"self",
")",
":",
"# REST API",
"self",
".",
"_app",
".",
"route",
"(",
"'/api/%s/config'",
"%",
"self",
".",
"API_VERSION",
",",
"method",
"=",
"\"GET\"",
",",
"callback",
"=",
"self",
".",
"_api_config",
")",
"self",
".",
"_app",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle.start | Start the bottle. | glances/outputs/glances_bottle.py | 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):
"""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
... | [
"Start",
"the",
"bottle",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L198-L218 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._index | Bottle callback for index.html (/) file. | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Bottle",
"callback",
"for",
"index",
".",
"html",
"(",
"/",
")",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L224-L234 | [
"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__",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_help | Glances API RESTful implementation.
Return the help data or 404 error. | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L242-L255 | [
"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",
":"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_plugins | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTFul",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L258-L293 | [
"def",
"_api_plugins",
"(",
"self",
")",
":",
"response",
".",
"content_type",
"=",
"'application/json; charset=utf-8'",
"# Update the stat",
"self",
".",
"__update__",
"(",
")",
"try",
":",
"plist",
"=",
"json",
".",
"dumps",
"(",
"self",
".",
"plugins_list",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_all | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L296-L323 | [
"def",
"_api_all",
"(",
"self",
")",
":",
"response",
".",
"content_type",
"=",
"'application/json; charset=utf-8'",
"if",
"self",
".",
"args",
".",
"debug",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempfile",
".",
"gettempdir",
"(",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_all_limits | 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/outputs/glances_bottle.py | 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):
"""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'
... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L326-L341 | [
"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"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_all_views | 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/outputs/glances_bottle.py | 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):
"""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'
... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L344-L359 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L362-L383 | [
"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)\"",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_history | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L386-L408 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_limits | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L411-L432 | [
"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: %... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_views | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L435-L456 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_itemvalue | Father method for _api_item and _api_value. | glances/outputs/glances_bottle.py | 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):
"""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, ... | [
"Father",
"method",
"for",
"_api_item",
"and",
"_api_value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L459-L487 | [
"def",
"_api_itemvalue",
"(",
"self",
",",
"plugin",
",",
"item",
",",
"value",
"=",
"None",
",",
"history",
"=",
"False",
",",
"nb",
"=",
"0",
")",
":",
"response",
".",
"content_type",
"=",
"'application/json; charset=utf-8'",
"if",
"plugin",
"not",
"in"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_item_history | 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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L502-L511 | [
"def",
"_api_item_history",
"(",
"self",
",",
"plugin",
",",
"item",
",",
"nb",
"=",
"0",
")",
":",
"return",
"self",
".",
"_api_itemvalue",
"(",
"plugin",
",",
"item",
",",
"history",
"=",
"True",
",",
"nb",
"=",
"int",
"(",
"nb",
")",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_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/outputs/glances_bottle.py | 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):
"""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) | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L514-L522 | [
"def",
"_api_value",
"(",
"self",
",",
"plugin",
",",
"item",
",",
"value",
")",
":",
"return",
"self",
".",
"_api_itemvalue",
"(",
"plugin",
",",
"item",
",",
"value",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_config | Glances API RESTful implementation.
Return the JSON representation of the Glances configuration file
HTTP/200 if OK
HTTP/404 if others error | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L525-L539 | [
"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",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_config_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 | glances/outputs/glances_bottle.py | 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):
"""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=... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L542-L561 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_args | Glances API RESTful implementation.
Return the JSON representation of the Glances command line arguments
HTTP/200 if OK
HTTP/404 if others error | glances/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L564-L580 | [
"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",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesBottle._api_args_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/outputs/glances_bottle.py | 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):
"""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... | [
"Glances",
"API",
"RESTful",
"implementation",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_bottle.py#L583-L603 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update disk I/O stats using the input method. | glances/plugins/glances_diskio.py | 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):
"""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
... | [
"Update",
"disk",
"I",
"/",
"O",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_diskio.py#L60-L138 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_diskio.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_diskio.py#L154-L227 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | start | Start Glances. | glances/__init__.py | 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):
"""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 ... | [
"Start",
"Glances",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/__init__.py#L86-L112 | [
"def",
"start",
"(",
"config",
",",
"args",
")",
":",
"# Load mode",
"global",
"mode",
"if",
"core",
".",
"is_standalone",
"(",
")",
":",
"from",
"glances",
".",
"standalone",
"import",
"GlancesStandalone",
"as",
"GlancesMode",
"elif",
"core",
".",
"is_clien... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | main | Main entry point for Glances.
Select the mode (standalone, client or server)
Run it... | glances/__init__.py | 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():
"""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('{} {}... | [
"Main",
"entry",
"point",
"for",
"Glances",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/__init__.py#L115-L140 | [
"def",
"main",
"(",
")",
":",
"# Catch the CTRL-C signal",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"__signal_handler",
")",
"# Log Glances and psutil version",
"logger",
".",
"info",
"(",
"'Start Glances {}'",
".",
"format",
"(",
"__version__",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | 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 | glances/config.py | 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():
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('... | [
"r",
"Return",
"the",
"per",
"-",
"user",
"config",
"dir",
"(",
"full",
"path",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L33-L51 | [
"def",
"user_config_dir",
"(",
")",
":",
"if",
"WINDOWS",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'APPDATA'",
")",
"elif",
"MACOS",
":",
"path",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/Library/Application Support'",
")",
"el... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | 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 | glances/config.py | 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():
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... | [
"r",
"Return",
"the",
"per",
"-",
"user",
"cache",
"dir",
"(",
"full",
"path",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L54-L70 | [
"def",
"user_cache_dir",
"(",
")",
":",
"if",
"WINDOWS",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'LOCALAPPDATA'",
")",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"'APPDATA'",
")",
",",
"'glan... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | 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 | glances/config.py | 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():
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 ... | [
"r",
"Return",
"the",
"system",
"-",
"wide",
"config",
"dir",
"(",
"full",
"path",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L73-L91 | [
"def",
"system_config_dir",
"(",
")",
":",
"if",
"LINUX",
"or",
"SUNOS",
":",
"path",
"=",
"'/etc'",
"elif",
"BSD",
"or",
"MACOS",
":",
"path",
"=",
"'/usr/local/etc'",
"else",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'APPDATA'",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.config_file_paths | 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/... | glances/config.py | 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):
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
* ... | [
"r",
"Get",
"a",
"list",
"of",
"config",
"file",
"paths",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L113-L137 | [
"def",
"config_file_paths",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"]",
"if",
"self",
".",
"config_dir",
":",
"paths",
".",
"append",
"(",
"self",
".",
"config_dir",
")",
"paths",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"user_conf... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.read | Read the config file, if it exists. Using defaults otherwise. | glances/config.py | 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):
"""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... | [
"Read",
"the",
"config",
"file",
"if",
"it",
"exists",
".",
"Using",
"defaults",
"otherwise",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L139-L225 | [
"def",
"read",
"(",
"self",
")",
":",
"for",
"config_file",
"in",
"self",
".",
"config_file_paths",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'Search glances.conf file in {}'",
".",
"format",
"(",
"config_file",
")",
")",
"if",
"os",
".",
"path",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.as_dict | Return the configuration as a dict | glances/config.py | 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):
"""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... | [
"Return",
"the",
"configuration",
"as",
"a",
"dict"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L232-L239 | [
"def",
"as_dict",
"(",
"self",
")",
":",
"dictionary",
"=",
"{",
"}",
"for",
"section",
"in",
"self",
".",
"parser",
".",
"sections",
"(",
")",
":",
"dictionary",
"[",
"section",
"]",
"=",
"{",
"}",
"for",
"option",
"in",
"self",
".",
"parser",
"."... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.set_default_cwc | Set default values for careful, warning and critical. | glances/config.py | 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']):
"""Set default values for careful, warning and critical."""
if option_header is None:
header = ''
else:
header = option_header + '_'
sel... | [
"Set",
"default",
"values",
"for",
"careful",
"warning",
"and",
"critical",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L253-L263 | [
"def",
"set_default_cwc",
"(",
"self",
",",
"section",
",",
"option_header",
"=",
"None",
",",
"cwc",
"=",
"[",
"'50'",
",",
"'70'",
",",
"'90'",
"]",
")",
":",
"if",
"option_header",
"is",
"None",
":",
"header",
"=",
"''",
"else",
":",
"header",
"="... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.set_default | If the option did not exist, create a default value. | glances/config.py | 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 the option did not exist, create a default value."""
if not self.parser.has_option(section, option):
self.parser.set(section, option, default) | [
"If",
"the",
"option",
"did",
"not",
"exist",
"create",
"a",
"default",
"value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L265-L269 | [
"def",
"set_default",
"(",
"self",
",",
"section",
",",
"option",
",",
"default",
")",
":",
"if",
"not",
"self",
".",
"parser",
".",
"has_option",
"(",
"section",
",",
"option",
")",
":",
"self",
".",
"parser",
".",
"set",
"(",
"section",
",",
"optio... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.get_value | 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` | glances/config.py | 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):
"""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... | [
"Get",
"the",
"value",
"of",
"an",
"option",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L271-L295 | [
"def",
"get_value",
"(",
"self",
",",
"section",
",",
"option",
",",
"default",
"=",
"None",
")",
":",
"ret",
"=",
"default",
"try",
":",
"ret",
"=",
"self",
".",
"parser",
".",
"get",
"(",
"section",
",",
"option",
")",
"except",
"NoOptionError",
":... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.get_int_value | Get the int value of an option, if it exists. | glances/config.py | 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):
"""Get the int value of an option, if it exists."""
try:
return self.parser.getint(section, option)
except NoOptionError:
return int(default) | [
"Get",
"the",
"int",
"value",
"of",
"an",
"option",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L297-L302 | [
"def",
"get_int_value",
"(",
"self",
",",
"section",
",",
"option",
",",
"default",
"=",
"0",
")",
":",
"try",
":",
"return",
"self",
".",
"parser",
".",
"getint",
"(",
"section",
",",
"option",
")",
"except",
"NoOptionError",
":",
"return",
"int",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.get_float_value | Get the float value of an option, if it exists. | glances/config.py | 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):
"""Get the float value of an option, if it exists."""
try:
return self.parser.getfloat(section, option)
except NoOptionError:
return float(default) | [
"Get",
"the",
"float",
"value",
"of",
"an",
"option",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L304-L309 | [
"def",
"get_float_value",
"(",
"self",
",",
"section",
",",
"option",
",",
"default",
"=",
"0.0",
")",
":",
"try",
":",
"return",
"self",
".",
"parser",
".",
"getfloat",
"(",
"section",
",",
"option",
")",
"except",
"NoOptionError",
":",
"return",
"float... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Config.get_bool_value | Get the bool value of an option, if it exists. | glances/config.py | 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):
"""Get the bool value of an option, if it exists."""
try:
return self.parser.getboolean(section, option)
except NoOptionError:
return bool(default) | [
"Get",
"the",
"bool",
"value",
"of",
"an",
"option",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/config.py#L311-L316 | [
"def",
"get_bool_value",
"(",
"self",
",",
"section",
",",
"option",
",",
"default",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"parser",
".",
"getboolean",
"(",
"section",
",",
"option",
")",
"except",
"NoOptionError",
":",
"return",
"boo... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents.__event_exist | 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. | glances/events.py | 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):
"""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... | [
"Return",
"the",
"event",
"position",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L65-L76 | [
"def",
"__event_exist",
"(",
"self",
",",
"event_type",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"len",
"(",
")",
")",
":",
"if",
"self",
".",
"events_list",
"[",
"i",
"]",
"[",
"1",
"]",
"<",
"0",
"and",
"self",
".",
"events_list",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents.get_event_sort_key | Return the process sort key | glances/events.py | 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):
"""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"):
# ... | [
"Return",
"the",
"process",
"sort",
"key"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L78-L90 | [
"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",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents.set_process_sort | Define the process auto sort key from the alert type. | glances/events.py | 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):
"""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) | [
"Define",
"the",
"process",
"auto",
"sort",
"key",
"from",
"the",
"alert",
"type",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L92-L95 | [
"def",
"set_process_sort",
"(",
"self",
",",
"event_type",
")",
":",
"if",
"glances_processes",
".",
"auto_sort",
":",
"glances_processes",
".",
"sort_key",
"=",
"self",
".",
"get_event_sort_key",
"(",
"event_type",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents.add | 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. | glances/events.py | 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):
"""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 ... | [
"Add",
"a",
"new",
"item",
"to",
"the",
"logs",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L102-L123 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents._create_event | Add a new item in the log list.
Item is added only if the criticity (event_state) is WARNING or CRITICAL. | glances/events.py | 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):
"""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"... | [
"Add",
"a",
"new",
"item",
"in",
"the",
"log",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L125-L161 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents._update_event | Update an event in the list | glances/events.py | 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):
"""Update an event in the list"""
if event_state == "OK" or event_state == "CAREFUL":
# Reset the automatic process sort key
self.reset_process_sort(... | [
"Update",
"an",
"event",
"in",
"the",
"list"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L163-L208 | [
"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\"",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesEvents.clean | Clean the logs list by deleting finished items.
By default, only delete WARNING message.
If critical = True, also delete CRITICAL message. | glances/events.py | 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):
"""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... | [
"Clean",
"the",
"logs",
"list",
"by",
"deleting",
"finished",
"items",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/events.py#L210-L224 | [
"def",
"clean",
"(",
"self",
",",
"critical",
"=",
"False",
")",
":",
"# Create a new clean list",
"clean_events_list",
"=",
"[",
"]",
"while",
"self",
".",
"len",
"(",
")",
">",
"0",
":",
"item",
"=",
"self",
".",
"events_list",
".",
"pop",
"(",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStatsClientSNMP.check_snmp | Chek if SNMP is available on the server. | glances/stats_client_snmp.py | 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):
"""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... | [
"Chek",
"if",
"SNMP",
"is",
"available",
"on",
"the",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L57-L82 | [
"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",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStatsClientSNMP.get_system_name | Get the short os name from the OS name OID string. | glances/stats_client_snmp.py | 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):
"""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... | [
"Get",
"the",
"short",
"os",
"name",
"from",
"the",
"OS",
"name",
"OID",
"string",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L84-L97 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStatsClientSNMP.update | Update the stats using SNMP. | glances/stats_client_snmp.py | 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):
"""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
... | [
"Update",
"the",
"stats",
"using",
"SNMP",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_client_snmp.py#L99-L121 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update RAID stats using the input method. | glances/plugins/glances_raid.py | 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):
"""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... | [
"Update",
"RAID",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L51-L78 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_raid.py | 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):
"""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... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L80-L152 | [
"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 ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.raid_alert | 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. | glances/plugins/glances_raid.py | 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):
"""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':
... | [
"RAID",
"alert",
"messages",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_raid.py#L154-L169 | [
"def",
"raid_alert",
"(",
"self",
",",
"status",
",",
"used",
",",
"available",
",",
"type",
")",
":",
"if",
"type",
"==",
"'raid0'",
":",
"return",
"'OK'",
"if",
"status",
"==",
"'inactive'",
":",
"return",
"'CRITICAL'",
"if",
"used",
"is",
"None",
"o... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update uptime stat using the input method. | glances/plugins/glances_uptime.py | 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):
"""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(... | [
"Update",
"uptime",
"stat",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_uptime.py#L62-L85 | [
"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",
".... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update the cloud stats.
Return the stats (dict) | glances/plugins/glances_cloud.py | 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):
"""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 ... | [
"Update",
"the",
"cloud",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L78-L103 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the string to display in the curse interface. | glances/plugins/glances_cloud.py | 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):
"""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... | [
"Return",
"the",
"string",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L105-L126 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
"stats",
"==",
"{",
"}",
"or",
"self",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadOpenStack.run | Grab plugin's stats.
Infinite loop, should be stopped by calling the stop() method | glances/plugins/glances_cloud.py | 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):
"""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... | [
"Grab",
"plugin",
"s",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cloud.py#L152-L173 | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"import_error_tag",
":",
"self",
".",
"stop",
"(",
")",
"return",
"False",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"OPENSTACK_API_METADATA",
")",
":",
"r_url",
"=",
"'{}/{}'",
".",
"format",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.generate_view_data | Generate the views. | glances/plugins/glances_help.py | 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):
"""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(... | [
"Generate",
"the",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_help.py#L55-L103 | [
"def",
"generate_view_data",
"(",
"self",
")",
":",
"self",
".",
"view_data",
"[",
"'version'",
"]",
"=",
"'{} {}'",
".",
"format",
"(",
"'Glances'",
",",
"__version__",
")",
"self",
".",
"view_data",
"[",
"'psutil_version'",
"]",
"=",
"' with psutil {}'",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the list to display in the curse interface. | glances/plugins/glances_help.py | 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):
"""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... | [
"Return",
"the",
"list",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_help.py#L109-L189 | [
"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... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAttribute.value | Set a value.
Value is a tuple: (<timestamp>, <new_value>) | glances/attribute.py | def value(self, new_value):
"""Set a value.
Value is a tuple: (<timestamp>, <new_value>)
"""
self._value = (datetime.now(), new_value)
self.history_add(self._value) | def value(self, new_value):
"""Set a value.
Value is a tuple: (<timestamp>, <new_value>)
"""
self._value = (datetime.now(), new_value)
self.history_add(self._value) | [
"Set",
"a",
"value",
".",
"Value",
"is",
"a",
"tuple",
":",
"(",
"<timestamp",
">",
"<new_value",
">",
")"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L80-L85 | [
"def",
"value",
"(",
"self",
",",
"new_value",
")",
":",
"self",
".",
"_value",
"=",
"(",
"datetime",
".",
"now",
"(",
")",
",",
"new_value",
")",
"self",
".",
"history_add",
"(",
"self",
".",
"_value",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAttribute.history_add | Add a value in the history | glances/attribute.py | def history_add(self, value):
"""Add a value in the history
"""
if self._history_max_size is None or self.history_len() < self._history_max_size:
self._history.append(value)
else:
self._history = self._history[1:] + [value] | def history_add(self, value):
"""Add a value in the history
"""
if self._history_max_size is None or self.history_len() < self._history_max_size:
self._history.append(value)
else:
self._history = self._history[1:] + [value] | [
"Add",
"a",
"value",
"in",
"the",
"history"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L105-L111 | [
"def",
"history_add",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_history_max_size",
"is",
"None",
"or",
"self",
".",
"history_len",
"(",
")",
"<",
"self",
".",
"_history_max_size",
":",
"self",
".",
"_history",
".",
"append",
"(",
"value",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAttribute.history_json | Return the history in ISO JSON format | glances/attribute.py | def history_json(self, nb=0):
"""Return the history in ISO JSON format"""
return [(i[0].isoformat(), i[1]) for i in self._history[-nb:]] | def history_json(self, nb=0):
"""Return the history in ISO JSON format"""
return [(i[0].isoformat(), i[1]) for i in self._history[-nb:]] | [
"Return",
"the",
"history",
"in",
"ISO",
"JSON",
"format"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L133-L135 | [
"def",
"history_json",
"(",
"self",
",",
"nb",
"=",
"0",
")",
":",
"return",
"[",
"(",
"i",
"[",
"0",
"]",
".",
"isoformat",
"(",
")",
",",
"i",
"[",
"1",
"]",
")",
"for",
"i",
"in",
"self",
".",
"_history",
"[",
"-",
"nb",
":",
"]",
"]"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAttribute.history_mean | Return the mean on the <nb> values in the history. | glances/attribute.py | def history_mean(self, nb=5):
"""Return the mean on the <nb> values in the history.
"""
_, v = zip(*self._history)
return sum(v[-nb:]) / float(v[-1] - v[-nb]) | def history_mean(self, nb=5):
"""Return the mean on the <nb> values in the history.
"""
_, v = zip(*self._history)
return sum(v[-nb:]) / float(v[-1] - v[-nb]) | [
"Return",
"the",
"mean",
"on",
"the",
"<nb",
">",
"values",
"in",
"the",
"history",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L137-L141 | [
"def",
"history_mean",
"(",
"self",
",",
"nb",
"=",
"5",
")",
":",
"_",
",",
"v",
"=",
"zip",
"(",
"*",
"self",
".",
"_history",
")",
"return",
"sum",
"(",
"v",
"[",
"-",
"nb",
":",
"]",
")",
"/",
"float",
"(",
"v",
"[",
"-",
"1",
"]",
"-... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AmpsList.load_configs | Load the AMP configuration files. | glances/amps_list.py | def load_configs(self):
"""Load the AMP configuration files."""
if self.config is None:
return False
# Display a warning (deprecated) message if the monitor section exist
if "monitor" in self.config.sections():
logger.warning("A deprecated [monitor] section exist... | def load_configs(self):
"""Load the AMP configuration files."""
if self.config is None:
return False
# Display a warning (deprecated) message if the monitor section exist
if "monitor" in self.config.sections():
logger.warning("A deprecated [monitor] section exist... | [
"Load",
"the",
"AMP",
"configuration",
"files",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L54-L91 | [
"def",
"load_configs",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
"is",
"None",
":",
"return",
"False",
"# Display a warning (deprecated) message if the monitor section exist",
"if",
"\"monitor\"",
"in",
"self",
".",
"config",
".",
"sections",
"(",
")",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AmpsList.update | Update the command result attributed. | glances/amps_list.py | def update(self):
"""Update the command result attributed."""
# Get the current processes list (once)
processlist = glances_processes.getlist()
# Iter upon the AMPs dict
for k, v in iteritems(self.get()):
if not v.enable():
# Do not update if the enab... | def update(self):
"""Update the command result attributed."""
# Get the current processes list (once)
processlist = glances_processes.getlist()
# Iter upon the AMPs dict
for k, v in iteritems(self.get()):
if not v.enable():
# Do not update if the enab... | [
"Update",
"the",
"command",
"result",
"attributed",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L105-L133 | [
"def",
"update",
"(",
"self",
")",
":",
"# Get the current processes list (once)",
"processlist",
"=",
"glances_processes",
".",
"getlist",
"(",
")",
"# Iter upon the AMPs dict",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"get",
"(",
")",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AmpsList._build_amps_list | Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression | glances/amps_list.py | def _build_amps_list(self, amp_value, processlist):
"""Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression
"""
ret = []
try:
# Search in both cmdline and name (for kernel thread, see #1261)
... | def _build_amps_list(self, amp_value, processlist):
"""Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression
"""
ret = []
try:
# Search in both cmdline and name (for kernel thread, see #1261)
... | [
"Return",
"the",
"AMPS",
"process",
"list",
"according",
"to",
"the",
"amp_value"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L135-L160 | [
"def",
"_build_amps_list",
"(",
"self",
",",
"amp_value",
",",
"processlist",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"# Search in both cmdline and name (for kernel thread, see #1261)",
"for",
"p",
"in",
"processlist",
":",
"add_it",
"=",
"False",
"if",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.update | Update stats in the CSV output file. | glances/exports/glances_csv.py | def update(self, stats):
"""Update stats in the CSV output file."""
# Get the stats
all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
# Init data with timestamp (issue#708)
if self.first_line:
csv_header = ['timestamp']
csv_data = [t... | def update(self, stats):
"""Update stats in the CSV output file."""
# Get the stats
all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
# Init data with timestamp (issue#708)
if self.first_line:
csv_header = ['timestamp']
csv_data = [t... | [
"Update",
"stats",
"in",
"the",
"CSV",
"output",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_csv.py#L64-L98 | [
"def",
"update",
"(",
"self",
",",
"stats",
")",
":",
"# Get the stats",
"all_stats",
"=",
"stats",
".",
"getAllExportsAsDict",
"(",
"plugin_list",
"=",
"self",
".",
"plugins_to_export",
"(",
")",
")",
"# Init data with timestamp (issue#708)",
"if",
"self",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | CpuPercent.__get_cpu | Update and/or return the CPU using the psutil library. | glances/cpu_percent.py | def __get_cpu(self):
"""Update and/or return the CPU using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_cpu.finished():
self.cpu_percent = psutil.cpu_percent(interval=0.0)
# Reset timer for cache
self.timer_cpu = Timer(s... | def __get_cpu(self):
"""Update and/or return the CPU using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_cpu.finished():
self.cpu_percent = psutil.cpu_percent(interval=0.0)
# Reset timer for cache
self.timer_cpu = Timer(s... | [
"Update",
"and",
"/",
"or",
"return",
"the",
"CPU",
"using",
"the",
"psutil",
"library",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/cpu_percent.py#L53-L60 | [
"def",
"__get_cpu",
"(",
"self",
")",
":",
"# Never update more than 1 time per cached_time",
"if",
"self",
".",
"timer_cpu",
".",
"finished",
"(",
")",
":",
"self",
".",
"cpu_percent",
"=",
"psutil",
".",
"cpu_percent",
"(",
"interval",
"=",
"0.0",
")",
"# Re... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | CpuPercent.__get_percpu | Update and/or return the per CPU list using the psutil library. | glances/cpu_percent.py | def __get_percpu(self):
"""Update and/or return the per CPU list using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_percpu.finished():
self.percpu_percent = []
for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=... | def __get_percpu(self):
"""Update and/or return the per CPU list using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_percpu.finished():
self.percpu_percent = []
for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=... | [
"Update",
"and",
"/",
"or",
"return",
"the",
"per",
"CPU",
"list",
"using",
"the",
"psutil",
"library",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/cpu_percent.py#L62-L93 | [
"def",
"__get_percpu",
"(",
"self",
")",
":",
"# Never update more than 1 time per cached_time",
"if",
"self",
".",
"timer_percpu",
".",
"finished",
"(",
")",
":",
"self",
".",
"percpu_percent",
"=",
"[",
"]",
"for",
"cpu_number",
",",
"cputimes",
"in",
"enumera... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStandalone.display_modules_list | Display modules list | glances/standalone.py | def display_modules_list(self):
"""Display modules list"""
print("Plugins list: {}".format(
', '.join(sorted(self.stats.getPluginsList(enable=False)))))
print("Exporters list: {}".format(
', '.join(sorted(self.stats.getExportsList(enable=False))))) | def display_modules_list(self):
"""Display modules list"""
print("Plugins list: {}".format(
', '.join(sorted(self.stats.getPluginsList(enable=False)))))
print("Exporters list: {}".format(
', '.join(sorted(self.stats.getExportsList(enable=False))))) | [
"Display",
"modules",
"list"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L102-L107 | [
"def",
"display_modules_list",
"(",
"self",
")",
":",
"print",
"(",
"\"Plugins list: {}\"",
".",
"format",
"(",
"', '",
".",
"join",
"(",
"sorted",
"(",
"self",
".",
"stats",
".",
"getPluginsList",
"(",
"enable",
"=",
"False",
")",
")",
")",
")",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStandalone.__serve_forever | Main loop for the CLI.
return True if we should continue (no exit key has been pressed) | glances/standalone.py | def __serve_forever(self):
"""Main loop for the CLI.
return True if we should continue (no exit key has been pressed)
"""
# Start a counter used to compute the time needed for
# update and export the stats
counter = Counter()
# Update stats
self.stats.up... | def __serve_forever(self):
"""Main loop for the CLI.
return True if we should continue (no exit key has been pressed)
"""
# Start a counter used to compute the time needed for
# update and export the stats
counter = Counter()
# Update stats
self.stats.up... | [
"Main",
"loop",
"for",
"the",
"CLI",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L109-L143 | [
"def",
"__serve_forever",
"(",
"self",
")",
":",
"# Start a counter used to compute the time needed for",
"# update and export the stats",
"counter",
"=",
"Counter",
"(",
")",
"# Update stats",
"self",
".",
"stats",
".",
"update",
"(",
")",
"logger",
".",
"debug",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStandalone.serve_forever | Wrapper to the serve_forever function. | glances/standalone.py | def serve_forever(self):
"""Wrapper to the serve_forever function."""
loop = True
while loop:
loop = self.__serve_forever()
self.end() | def serve_forever(self):
"""Wrapper to the serve_forever function."""
loop = True
while loop:
loop = self.__serve_forever()
self.end() | [
"Wrapper",
"to",
"the",
"serve_forever",
"function",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L145-L150 | [
"def",
"serve_forever",
"(",
"self",
")",
":",
"loop",
"=",
"True",
"while",
"loop",
":",
"loop",
"=",
"self",
".",
"__serve_forever",
"(",
")",
"self",
".",
"end",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesStandalone.end | End of the standalone CLI. | glances/standalone.py | def end(self):
"""End of the standalone CLI."""
if not self.quiet:
self.screen.end()
# Exit from export modules
self.stats.end()
# Check Glances version versus PyPI one
if self.outdated.is_outdated():
print("You are using Glances version {}, howe... | def end(self):
"""End of the standalone CLI."""
if not self.quiet:
self.screen.end()
# Exit from export modules
self.stats.end()
# Check Glances version versus PyPI one
if self.outdated.is_outdated():
print("You are using Glances version {}, howe... | [
"End",
"of",
"the",
"standalone",
"CLI",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L152-L164 | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"self",
".",
"screen",
".",
"end",
"(",
")",
"# Exit from export modules",
"self",
".",
"stats",
".",
"end",
"(",
")",
"# Check Glances version versus PyPI one",
"if",
"self",
"."... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.get_hash | Return the hashed password, salt + SHA-256. | glances/password.py | def get_hash(self, salt, plain_password):
"""Return the hashed password, salt + SHA-256."""
return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest() | def get_hash(self, salt, plain_password):
"""Return the hashed password, salt + SHA-256."""
return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest() | [
"Return",
"the",
"hashed",
"password",
"salt",
"+",
"SHA",
"-",
"256",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L49-L51 | [
"def",
"get_hash",
"(",
"self",
",",
"salt",
",",
"plain_password",
")",
":",
"return",
"hashlib",
".",
"sha256",
"(",
"salt",
".",
"encode",
"(",
")",
"+",
"plain_password",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.hash_password | Hash password with a salt based on UUID (universally unique identifier). | glances/password.py | def hash_password(self, plain_password):
"""Hash password with a salt based on UUID (universally unique identifier)."""
salt = uuid.uuid4().hex
encrypted_password = self.get_hash(salt, plain_password)
return salt + '$' + encrypted_password | def hash_password(self, plain_password):
"""Hash password with a salt based on UUID (universally unique identifier)."""
salt = uuid.uuid4().hex
encrypted_password = self.get_hash(salt, plain_password)
return salt + '$' + encrypted_password | [
"Hash",
"password",
"with",
"a",
"salt",
"based",
"on",
"UUID",
"(",
"universally",
"unique",
"identifier",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L53-L57 | [
"def",
"hash_password",
"(",
"self",
",",
"plain_password",
")",
":",
"salt",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
"encrypted_password",
"=",
"self",
".",
"get_hash",
"(",
"salt",
",",
"plain_password",
")",
"return",
"salt",
"+",
"'$'",
"+",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.check_password | Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password. | glances/password.py | def check_password(self, hashed_password, plain_password):
"""Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password.
"""
salt, encrypted_password = hashed_password.split('$')
re_encrypted_password = self.get_hash(salt, ... | def check_password(self, hashed_password, plain_password):
"""Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password.
"""
salt, encrypted_password = hashed_password.split('$')
re_encrypted_password = self.get_hash(salt, ... | [
"Encode",
"the",
"plain_password",
"with",
"the",
"salt",
"of",
"the",
"hashed_password",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L59-L66 | [
"def",
"check_password",
"(",
"self",
",",
"hashed_password",
",",
"plain_password",
")",
":",
"salt",
",",
"encrypted_password",
"=",
"hashed_password",
".",
"split",
"(",
"'$'",
")",
"re_encrypted_password",
"=",
"self",
".",
"get_hash",
"(",
"salt",
",",
"p... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.get_password | Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the password to a file (hashed with salt + SHA-256)
For Glances client, get the ... | glances/password.py | def get_password(self, description='', confirm=False, clear=False):
"""Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the passwo... | def get_password(self, description='', confirm=False, clear=False):
"""Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the passwo... | [
"Get",
"the",
"password",
"from",
"a",
"Glances",
"client",
"or",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L68-L110 | [
"def",
"get_password",
"(",
"self",
",",
"description",
"=",
"''",
",",
"confirm",
"=",
"False",
",",
"clear",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"password_file",
")",
"and",
"not",
"clear",
":",
"# If t... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.save_password | Save the hashed password to the Glances folder. | glances/password.py | def save_password(self, hashed_password):
"""Save the hashed password to the Glances folder."""
# Create the glances directory
safe_makedirs(self.password_dir)
# Create/overwrite the password file
with open(self.password_file, 'wb') as file_pwd:
file_pwd.write(b(hash... | def save_password(self, hashed_password):
"""Save the hashed password to the Glances folder."""
# Create the glances directory
safe_makedirs(self.password_dir)
# Create/overwrite the password file
with open(self.password_file, 'wb') as file_pwd:
file_pwd.write(b(hash... | [
"Save",
"the",
"hashed",
"password",
"to",
"the",
"Glances",
"folder",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L112-L119 | [
"def",
"save_password",
"(",
"self",
",",
"hashed_password",
")",
":",
"# Create the glances directory",
"safe_makedirs",
"(",
"self",
".",
"password_dir",
")",
"# Create/overwrite the password file",
"with",
"open",
"(",
"self",
".",
"password_file",
",",
"'wb'",
")"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPassword.load_password | Load the hashed password from the Glances folder. | glances/password.py | def load_password(self):
"""Load the hashed password from the Glances folder."""
# Read the password file, if it exists
with open(self.password_file, 'r') as file_pwd:
hashed_password = file_pwd.read()
return hashed_password | def load_password(self):
"""Load the hashed password from the Glances folder."""
# Read the password file, if it exists
with open(self.password_file, 'r') as file_pwd:
hashed_password = file_pwd.read()
return hashed_password | [
"Load",
"the",
"hashed",
"password",
"from",
"the",
"Glances",
"folder",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L121-L127 | [
"def",
"load_password",
"(",
"self",
")",
":",
"# Read the password file, if it exists",
"with",
"open",
"(",
"self",
".",
"password_file",
",",
"'r'",
")",
"as",
"file_pwd",
":",
"hashed_password",
"=",
"file_pwd",
".",
"read",
"(",
")",
"return",
"hashed_passw... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Sparkline.get | Return the sparkline. | glances/outputs/glances_sparklines.py | def get(self):
"""Return the sparkline."""
ret = sparklines(self.percents)[0]
if self.__with_text:
percents_without_none = [x for x in self.percents if x is not None]
if len(percents_without_none) > 0:
ret = '{}{:5.1f}%'.format(ret, percents_without_none[-... | def get(self):
"""Return the sparkline."""
ret = sparklines(self.percents)[0]
if self.__with_text:
percents_without_none = [x for x in self.percents if x is not None]
if len(percents_without_none) > 0:
ret = '{}{:5.1f}%'.format(ret, percents_without_none[-... | [
"Return",
"the",
"sparkline",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_sparklines.py#L89-L96 | [
"def",
"get",
"(",
"self",
")",
":",
"ret",
"=",
"sparklines",
"(",
"self",
".",
"percents",
")",
"[",
"0",
"]",
"if",
"self",
".",
"__with_text",
":",
"percents_without_none",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"percents",
"if",
"x",
"i... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update CPU stats using the input method. | glances/plugins/glances_cpu.py | def update(self):
"""Update CPU stats using the input method."""
# Grab stats into self.stats
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init... | def update(self):
"""Update CPU stats using the input method."""
# Grab stats into self.stats
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init... | [
"Update",
"CPU",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L77-L91 | [
"def",
"update",
"(",
"self",
")",
":",
"# Grab stats into self.stats",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"stats",
"=",
"self",
".",
"update_local",
"(",
")",
"elif",
"self",
".",
"input_method",
"==",
"'snmp'",
":",
"stats",
"=",
"s... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_local | Update CPU stats using psutil. | glances/plugins/glances_cpu.py | def update_local(self):
"""Update CPU stats using psutil."""
# Grab CPU stats using psutil's cpu_percent and cpu_times_percent
# Get all possible values for CPU stats: user, system, idle,
# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)
# The following s... | def update_local(self):
"""Update CPU stats using psutil."""
# Grab CPU stats using psutil's cpu_percent and cpu_times_percent
# Get all possible values for CPU stats: user, system, idle,
# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)
# The following s... | [
"Update",
"CPU",
"stats",
"using",
"psutil",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L93-L139 | [
"def",
"update_local",
"(",
"self",
")",
":",
"# Grab CPU stats using psutil's cpu_percent and cpu_times_percent",
"# Get all possible values for CPU stats: user, system, idle,",
"# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)",
"# The following stats are returned by th... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_snmp | Update CPU stats using SNMP. | glances/plugins/glances_cpu.py | def update_snmp(self):
"""Update CPU stats using SNMP."""
# Init new stats
stats = self.get_init_value()
# Update stats using SNMP
if self.short_system_name in ('windows', 'esxi'):
# Windows or VMWare ESXi
# You can find the CPU utilization of windows sy... | def update_snmp(self):
"""Update CPU stats using SNMP."""
# Init new stats
stats = self.get_init_value()
# Update stats using SNMP
if self.short_system_name in ('windows', 'esxi'):
# Windows or VMWare ESXi
# You can find the CPU utilization of windows sy... | [
"Update",
"CPU",
"stats",
"using",
"SNMP",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L141-L188 | [
"def",
"update_snmp",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# Update stats using SNMP",
"if",
"self",
".",
"short_system_name",
"in",
"(",
"'windows'",
",",
"'esxi'",
")",
":",
"# Windows or VMWare ESXi"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.