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 | Plugin.update_views | Update stats views. | glances/plugins/glances_cpu.py | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
for key in ['user', 'system', 'iowait']:
if key in self.stats:
self.views[key]['decora... | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
for key in ['user', 'system', 'iowait']:
if key in self.stats:
self.views[key]['decora... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L190-L211 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert and log",
"for",
"key",
"in",
"[",
"'user'",
",",
"'system'",
",",
"'iow... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the list to display in the UI. | glances/plugins/glances_cpu.py | def msg_curse(self, args=None, max_width=None):
"""Return the list to display in the UI."""
# Init the return message
ret = []
# Only process if stats exist and plugin not disable
if not self.stats or self.args.percpu or self.is_disable():
return ret
# Build... | def msg_curse(self, args=None, max_width=None):
"""Return the list to display in the UI."""
# Init the return message
ret = []
# Only process if stats exist and plugin not disable
if not self.stats or self.args.percpu or self.is_disable():
return ret
# Build... | [
"Return",
"the",
"list",
"to",
"display",
"in",
"the",
"UI",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L213-L342 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and plugin not disable",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update Wifi stats using the input method.
Stats is a list of dict (one dict per hotspot)
:returns: list -- Stats is a list of dict (hotspot) | glances/plugins/glances_wifi.py | def update(self):
"""Update Wifi stats using the input method.
Stats is a list of dict (one dict per hotspot)
:returns: list -- Stats is a list of dict (hotspot)
"""
# Init new stats
stats = self.get_init_value()
# Exist if we can not grab the stats
if ... | def update(self):
"""Update Wifi stats using the input method.
Stats is a list of dict (one dict per hotspot)
:returns: list -- Stats is a list of dict (hotspot)
"""
# Init new stats
stats = self.get_init_value()
# Exist if we can not grab the stats
if ... | [
"Update",
"Wifi",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L69-L130 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# Exist if we can not grab the stats",
"if",
"import_error_tag",
":",
"return",
"stats",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_alert | Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert | glances/plugins/glances_wifi.py | def get_alert(self, value):
"""Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert
"""
ret = 'OK'
try:
if value <= self.get_limit('critical', stat_name=self.plugin_name):
... | def get_alert(self, value):
"""Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert
"""
ret = 'OK'
try:
if value <= self.get_limit('critical', stat_name=self.plugin_name):
... | [
"Overwrite",
"the",
"default",
"get_alert",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L132-L151 | [
"def",
"get_alert",
"(",
"self",
",",
"value",
")",
":",
"ret",
"=",
"'OK'",
"try",
":",
"if",
"value",
"<=",
"self",
".",
"get_limit",
"(",
"'critical'",
",",
"stat_name",
"=",
"self",
".",
"plugin_name",
")",
":",
"ret",
"=",
"'CRITICAL'",
"elif",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_wifi.py | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert on signal thresholds
for i in self.stats:
self.views[i[self.get_key()]]['signal']['decoration'] = self.get_ale... | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert on signal thresholds
for i in self.stats:
self.views[i[self.get_key()]]['signal']['decoration'] = self.get_ale... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L153-L162 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert on signal thresholds",
"for",
"i",
"in",
"self",
".",
"stats",
":",
"self"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_wifi.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 import_error_tag or self.is_disable():
return r... | 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 import_error_tag or self.is_disable():
return r... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L164-L208 | [
"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",
"import_er... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update the FS stats using the input method. | glances/plugins/glances_fs.py | def update(self):
"""Update the FS 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 stats using the psutil disk_partitions
# If 'a... | def update(self):
"""Update the FS 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 stats using the psutil disk_partitions
# If 'a... | [
"Update",
"the",
"FS",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L88-L181 | [
"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 stats using the psutil disk_partitions",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_fs.py | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert
for i in self.stats:
self.views[i[self.get_key()]]['used']['decoration'] = self.get_alert(
i['... | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert
for i in self.stats:
self.views[i[self.get_key()]]['used']['decoration'] = self.get_alert(
i['... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L183-L192 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert",
"for",
"i",
"in",
"self",
".",
"stats",
":",
"self",
".",
"views",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_fs.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_fs.py#L194-L245 | [
"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 | Plugin.update | Update RAM memory stats using the input method. | glances/plugins/glances_mem.py | def update(self):
"""Update RAM memory 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 MEM using the psutil virtual_memory method
vm_s... | def update(self):
"""Update RAM memory 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 MEM using the psutil virtual_memory method
vm_s... | [
"Update",
"RAM",
"memory",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L72-L154 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"# Grab MEM using the psutil virtual_memory method",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_mem.py | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
# O... | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
# Alert and log
self.views['used']['decoration'] = self.get_alert_log(self.stats['used'], maximum=self.stats['total'])
# O... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L156-L167 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert and log",
"self",
".",
"views",
"[",
"'used'",
"]",
"[",
"'decoration'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_mem.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 plugin not disabled
if not self.stats or self.is_disable():
return ret
# Build the s... | 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 plugin not disabled
if not self.stats or self.is_disable():
return ret
# Build the s... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L169-L234 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and plugin not disabled",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesHistory.add | Add an new item (key, value) to the current history. | glances/history.py | def add(self, key, value,
description='',
history_max_size=None):
"""Add an new item (key, value) to the current history."""
if key not in self.stats_history:
self.stats_history[key] = GlancesAttribute(key,
descri... | def add(self, key, value,
description='',
history_max_size=None):
"""Add an new item (key, value) to the current history."""
if key not in self.stats_history:
self.stats_history[key] = GlancesAttribute(key,
descri... | [
"Add",
"an",
"new",
"item",
"(",
"key",
"value",
")",
"to",
"the",
"current",
"history",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L37-L45 | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
",",
"description",
"=",
"''",
",",
"history_max_size",
"=",
"None",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"stats_history",
":",
"self",
".",
"stats_history",
"[",
"key",
"]",
"=",
"Glan... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesHistory.get | Get the history as a dict of list | glances/history.py | def get(self, nb=0):
"""Get the history as a dict of list"""
return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history} | def get(self, nb=0):
"""Get the history as a dict of list"""
return {i: self.stats_history[i].history_raw(nb=nb) for i in self.stats_history} | [
"Get",
"the",
"history",
"as",
"a",
"dict",
"of",
"list"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L52-L54 | [
"def",
"get",
"(",
"self",
",",
"nb",
"=",
"0",
")",
":",
"return",
"{",
"i",
":",
"self",
".",
"stats_history",
"[",
"i",
"]",
".",
"history_raw",
"(",
"nb",
"=",
"nb",
")",
"for",
"i",
"in",
"self",
".",
"stats_history",
"}"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesHistory.get_json | Get the history as a dict of list (with list JSON compliant) | glances/history.py | def get_json(self, nb=0):
"""Get the history as a dict of list (with list JSON compliant)"""
return {i: self.stats_history[i].history_json(nb=nb) for i in self.stats_history} | def get_json(self, nb=0):
"""Get the history as a dict of list (with list JSON compliant)"""
return {i: self.stats_history[i].history_json(nb=nb) for i in self.stats_history} | [
"Get",
"the",
"history",
"as",
"a",
"dict",
"of",
"list",
"(",
"with",
"list",
"JSON",
"compliant",
")"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L56-L58 | [
"def",
"get_json",
"(",
"self",
",",
"nb",
"=",
"0",
")",
":",
"return",
"{",
"i",
":",
"self",
".",
"stats_history",
"[",
"i",
"]",
".",
"history_json",
"(",
"nb",
"=",
"nb",
")",
"for",
"i",
"in",
"self",
".",
"stats_history",
"}"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.load_config | Load AMP parameters from the configuration file. | glances/amps/glances_amp.py | def load_config(self, config):
"""Load AMP parameters from the configuration file."""
# Read AMP confifuration.
# For ex, the AMP foo should have the following section:
#
# [foo]
# enable=true
# regex=\/usr\/bin\/nginx
# refresh=60
#
# and... | def load_config(self, config):
"""Load AMP parameters from the configuration file."""
# Read AMP confifuration.
# For ex, the AMP foo should have the following section:
#
# [foo]
# enable=true
# regex=\/usr\/bin\/nginx
# refresh=60
#
# and... | [
"Load",
"AMP",
"parameters",
"from",
"the",
"configuration",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L69-L115 | [
"def",
"load_config",
"(",
"self",
",",
"config",
")",
":",
"# Read AMP confifuration.",
"# For ex, the AMP foo should have the following section:",
"#",
"# [foo]",
"# enable=true",
"# regex=\\/usr\\/bin\\/nginx",
"# refresh=60",
"#",
"# and optionnaly:",
"#",
"# one_line=false",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.enable | Return True|False if the AMP is enabled in the configuration file (enable=true|false). | glances/amps/glances_amp.py | def enable(self):
"""Return True|False if the AMP is enabled in the configuration file (enable=true|false)."""
ret = self.get('enable')
if ret is None:
return False
else:
return ret.lower().startswith('true') | def enable(self):
"""Return True|False if the AMP is enabled in the configuration file (enable=true|false)."""
ret = self.get('enable')
if ret is None:
return False
else:
return ret.lower().startswith('true') | [
"Return",
"True|False",
"if",
"the",
"AMP",
"is",
"enabled",
"in",
"the",
"configuration",
"file",
"(",
"enable",
"=",
"true|false",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L124-L130 | [
"def",
"enable",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"get",
"(",
"'enable'",
")",
"if",
"ret",
"is",
"None",
":",
"return",
"False",
"else",
":",
"return",
"ret",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'true'",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.one_line | Return True|False if the AMP shoukd be displayed in oneline (one_lineline=true|false). | glances/amps/glances_amp.py | def one_line(self):
"""Return True|False if the AMP shoukd be displayed in oneline (one_lineline=true|false)."""
ret = self.get('one_line')
if ret is None:
return False
else:
return ret.lower().startswith('true') | def one_line(self):
"""Return True|False if the AMP shoukd be displayed in oneline (one_lineline=true|false)."""
ret = self.get('one_line')
if ret is None:
return False
else:
return ret.lower().startswith('true') | [
"Return",
"True|False",
"if",
"the",
"AMP",
"shoukd",
"be",
"displayed",
"in",
"oneline",
"(",
"one_lineline",
"=",
"true|false",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L140-L146 | [
"def",
"one_line",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"get",
"(",
"'one_line'",
")",
"if",
"ret",
"is",
"None",
":",
"return",
"False",
"else",
":",
"return",
"ret",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'true'",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.should_update | Return True is the AMP should be updated:
- AMP is enable
- only update every 'refresh' seconds | glances/amps/glances_amp.py | def should_update(self):
"""Return True is the AMP should be updated:
- AMP is enable
- only update every 'refresh' seconds
"""
if self.timer.finished():
self.timer.set(self.refresh())
self.timer.reset()
return self.enable()
return Fals... | def should_update(self):
"""Return True is the AMP should be updated:
- AMP is enable
- only update every 'refresh' seconds
"""
if self.timer.finished():
self.timer.set(self.refresh())
self.timer.reset()
return self.enable()
return Fals... | [
"Return",
"True",
"is",
"the",
"AMP",
"should",
"be",
"updated",
":",
"-",
"AMP",
"is",
"enable",
"-",
"only",
"update",
"every",
"refresh",
"seconds"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L152-L161 | [
"def",
"should_update",
"(",
"self",
")",
":",
"if",
"self",
".",
"timer",
".",
"finished",
"(",
")",
":",
"self",
".",
"timer",
".",
"set",
"(",
"self",
".",
"refresh",
"(",
")",
")",
"self",
".",
"timer",
".",
"reset",
"(",
")",
"return",
"self... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.set_result | Store the result (string) into the result key of the AMP
if one_line is true then replace \n by separator | glances/amps/glances_amp.py | def set_result(self, result, separator=''):
"""Store the result (string) into the result key of the AMP
if one_line is true then replace \n by separator
"""
if self.one_line():
self.configs['result'] = str(result).replace('\n', separator)
else:
self.config... | def set_result(self, result, separator=''):
"""Store the result (string) into the result key of the AMP
if one_line is true then replace \n by separator
"""
if self.one_line():
self.configs['result'] = str(result).replace('\n', separator)
else:
self.config... | [
"Store",
"the",
"result",
"(",
"string",
")",
"into",
"the",
"result",
"key",
"of",
"the",
"AMP",
"if",
"one_line",
"is",
"true",
"then",
"replace",
"\\",
"n",
"by",
"separator"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L179-L186 | [
"def",
"set_result",
"(",
"self",
",",
"result",
",",
"separator",
"=",
"''",
")",
":",
"if",
"self",
".",
"one_line",
"(",
")",
":",
"self",
".",
"configs",
"[",
"'result'",
"]",
"=",
"str",
"(",
"result",
")",
".",
"replace",
"(",
"'\\n'",
",",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.result | Return the result of the AMP (as a string) | glances/amps/glances_amp.py | def result(self):
""" Return the result of the AMP (as a string)"""
ret = self.get('result')
if ret is not None:
ret = u(ret)
return ret | def result(self):
""" Return the result of the AMP (as a string)"""
ret = self.get('result')
if ret is not None:
ret = u(ret)
return ret | [
"Return",
"the",
"result",
"of",
"the",
"AMP",
"(",
"as",
"a",
"string",
")"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L188-L193 | [
"def",
"result",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"get",
"(",
"'result'",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"ret",
"=",
"u",
"(",
"ret",
")",
"return",
"ret"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesAmp.update_wrapper | Wrapper for the children update | glances/amps/glances_amp.py | def update_wrapper(self, process_list):
"""Wrapper for the children update"""
# Set the number of running process
self.set_count(len(process_list))
# Call the children update method
if self.should_update():
return self.update(process_list)
else:
re... | def update_wrapper(self, process_list):
"""Wrapper for the children update"""
# Set the number of running process
self.set_count(len(process_list))
# Call the children update method
if self.should_update():
return self.update(process_list)
else:
re... | [
"Wrapper",
"for",
"the",
"children",
"update"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L195-L203 | [
"def",
"update_wrapper",
"(",
"self",
",",
"process_list",
")",
":",
"# Set the number of running process",
"self",
".",
"set_count",
"(",
"len",
"(",
"process_list",
")",
")",
"# Call the children update method",
"if",
"self",
".",
"should_update",
"(",
")",
":",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update processes stats using the input method. | glances/plugins/glances_processcount.py | def update(self):
"""Update processes 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
# Here, update is call for processcount AND processlist
... | def update(self):
"""Update processes 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
# Here, update is call for processcount AND processlist
... | [
"Update",
"processes",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processcount.py#L63-L83 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"# Here, update is call for processcount AND process... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_processcount.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 args.disable_process:
msg = "PROCESSES DISABLED (press 'z' to dis... | 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 args.disable_process:
msg = "PROCESSES DISABLED (press 'z' to dis... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processcount.py#L85-L151 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and display plugin enable...",
"if",
"args",
".",
"disable_process",
":",
"msg",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | global_message | Parse the decision tree and return the message.
Note: message corresponding to the current threasholds values | glances/plugins/glances_alert.py | def global_message():
"""Parse the decision tree and return the message.
Note: message corresponding to the current threasholds values
"""
# Compute the weight for each item in the tree
current_thresholds = glances_thresholds.get()
for i in tree:
i['weight'] = sum([current_thresholds[t]... | def global_message():
"""Parse the decision tree and return the message.
Note: message corresponding to the current threasholds values
"""
# Compute the weight for each item in the tree
current_thresholds = glances_thresholds.get()
for i in tree:
i['weight'] = sum([current_thresholds[t]... | [
"Parse",
"the",
"decision",
"tree",
"and",
"return",
"the",
"message",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L68-L82 | [
"def",
"global_message",
"(",
")",
":",
"# Compute the weight for each item in the tree",
"current_thresholds",
"=",
"glances_thresholds",
".",
"get",
"(",
")",
"for",
"i",
"in",
"tree",
":",
"i",
"[",
"'weight'",
"]",
"=",
"sum",
"(",
"[",
"current_thresholds",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_alert.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 display plugin enable...
if not self.stats or self.is_disable():
return ret
# Build the string messa... | 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 display plugin enable...
if not self.stats or self.is_disable():
return ret
# Build the string messa... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L111-L160 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
"is_disab... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.approx_equal | Compare a with b using the tolerance (if numerical). | glances/plugins/glances_alert.py | def approx_equal(self, a, b, tolerance=0.0):
"""Compare a with b using the tolerance (if numerical)."""
if str(int(a)).isdigit() and str(int(b)).isdigit():
return abs(a - b) <= max(abs(a), abs(b)) * tolerance
else:
return a == b | def approx_equal(self, a, b, tolerance=0.0):
"""Compare a with b using the tolerance (if numerical)."""
if str(int(a)).isdigit() and str(int(b)).isdigit():
return abs(a - b) <= max(abs(a), abs(b)) * tolerance
else:
return a == b | [
"Compare",
"a",
"with",
"b",
"using",
"the",
"tolerance",
"(",
"if",
"numerical",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L162-L167 | [
"def",
"approx_equal",
"(",
"self",
",",
"a",
",",
"b",
",",
"tolerance",
"=",
"0.0",
")",
":",
"if",
"str",
"(",
"int",
"(",
"a",
")",
")",
".",
"isdigit",
"(",
")",
"and",
"str",
"(",
"int",
"(",
"b",
")",
")",
".",
"isdigit",
"(",
")",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Export the stats to the JSON file. | glances/exports/glances_json.py | def export(self, name, columns, points):
"""Export the stats to the JSON file."""
# Check for completion of loop for all exports
if name == self.plugins_to_export()[0] and self.buffer != {}:
# One whole loop has been completed
# Flush stats to file
logger.deb... | def export(self, name, columns, points):
"""Export the stats to the JSON file."""
# Check for completion of loop for all exports
if name == self.plugins_to_export()[0] and self.buffer != {}:
# One whole loop has been completed
# Flush stats to file
logger.deb... | [
"Export",
"the",
"stats",
"to",
"the",
"JSON",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_json.py#L44-L64 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"# Check for completion of loop for all exports",
"if",
"name",
"==",
"self",
".",
"plugins_to_export",
"(",
")",
"[",
"0",
"]",
"and",
"self",
".",
"buffer",
"!=",
"{",
"}... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.exit | Overwrite the exit method to close threads. | glances/plugins/glances_docker.py | def exit(self):
"""Overwrite the exit method to close threads."""
for t in itervalues(self.thread_list):
t.stop()
# Call the father class
super(Plugin, self).exit() | def exit(self):
"""Overwrite the exit method to close threads."""
for t in itervalues(self.thread_list):
t.stop()
# Call the father class
super(Plugin, self).exit() | [
"Overwrite",
"the",
"exit",
"method",
"to",
"close",
"threads",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L94-L99 | [
"def",
"exit",
"(",
"self",
")",
":",
"for",
"t",
"in",
"itervalues",
"(",
"self",
".",
"thread_list",
")",
":",
"t",
".",
"stop",
"(",
")",
"# Call the father class",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"exit",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_export | Overwrite the default export method.
- Only exports containers
- The key is the first container name | glances/plugins/glances_docker.py | def get_export(self):
"""Overwrite the default export method.
- Only exports containers
- The key is the first container name
"""
ret = []
try:
ret = self.stats['containers']
except KeyError as e:
logger.debug("docker plugin - Docker expor... | def get_export(self):
"""Overwrite the default export method.
- Only exports containers
- The key is the first container name
"""
ret = []
try:
ret = self.stats['containers']
except KeyError as e:
logger.debug("docker plugin - Docker expor... | [
"Overwrite",
"the",
"default",
"export",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L105-L116 | [
"def",
"get_export",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"ret",
"=",
"self",
".",
"stats",
"[",
"'containers'",
"]",
"except",
"KeyError",
"as",
"e",
":",
"logger",
".",
"debug",
"(",
"\"docker plugin - Docker export error {}\"",
".",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.connect | Connect to the Docker server. | glances/plugins/glances_docker.py | def connect(self):
"""Connect to the Docker server."""
try:
ret = docker.from_env()
except Exception as e:
logger.error("docker plugin - Can not connect to Docker ({})".format(e))
ret = None
return ret | def connect(self):
"""Connect to the Docker server."""
try:
ret = docker.from_env()
except Exception as e:
logger.error("docker plugin - Can not connect to Docker ({})".format(e))
ret = None
return ret | [
"Connect",
"to",
"the",
"Docker",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L118-L126 | [
"def",
"connect",
"(",
"self",
")",
":",
"try",
":",
"ret",
"=",
"docker",
".",
"from_env",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"\"docker plugin - Can not connect to Docker ({})\"",
".",
"format",
"(",
"e",
")",
")... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin._all_tag | Return the all tag of the Glances/Docker configuration file.
# By default, Glances only display running containers
# Set the following key to True to display all containers
all=True | glances/plugins/glances_docker.py | def _all_tag(self):
"""Return the all tag of the Glances/Docker configuration file.
# By default, Glances only display running containers
# Set the following key to True to display all containers
all=True
"""
all_tag = self.get_conf_value('all')
if len(all_tag) =... | def _all_tag(self):
"""Return the all tag of the Glances/Docker configuration file.
# By default, Glances only display running containers
# Set the following key to True to display all containers
all=True
"""
all_tag = self.get_conf_value('all')
if len(all_tag) =... | [
"Return",
"the",
"all",
"tag",
"of",
"the",
"Glances",
"/",
"Docker",
"configuration",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L128-L139 | [
"def",
"_all_tag",
"(",
"self",
")",
":",
"all_tag",
"=",
"self",
".",
"get_conf_value",
"(",
"'all'",
")",
"if",
"len",
"(",
"all_tag",
")",
"==",
"0",
":",
"return",
"False",
"else",
":",
"return",
"all_tag",
"[",
"0",
"]",
".",
"lower",
"(",
")"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update Docker stats using the input method. | glances/plugins/glances_docker.py | def update(self):
"""Update Docker stats using the input method."""
# Init new stats
stats = self.get_init_value()
# The Docker-py lib is mandatory
if import_error_tag:
return self.stats
if self.input_method == 'local':
# Update stats
... | def update(self):
"""Update Docker stats using the input method."""
# Init new stats
stats = self.get_init_value()
# The Docker-py lib is mandatory
if import_error_tag:
return self.stats
if self.input_method == 'local':
# Update stats
... | [
"Update",
"Docker",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L143-L252 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# The Docker-py lib is mandatory",
"if",
"import_error_tag",
":",
"return",
"self",
".",
"stats",
"if",
"self",
".",
"input_method",
"==",
"'local... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_docker_cpu | Return the container CPU usage.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'total': 1.49} | glances/plugins/glances_docker.py | def get_docker_cpu(self, container_id, all_stats):
"""Return the container CPU usage.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'total': 1.49}
"""
cpu_new = {}
ret = {'total': 0.0}
... | def get_docker_cpu(self, container_id, all_stats):
"""Return the container CPU usage.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'total': 1.49}
"""
cpu_new = {}
ret = {'total': 0.0}
... | [
"Return",
"the",
"container",
"CPU",
"usage",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L254-L303 | [
"def",
"get_docker_cpu",
"(",
"self",
",",
"container_id",
",",
"all_stats",
")",
":",
"cpu_new",
"=",
"{",
"}",
"ret",
"=",
"{",
"'total'",
":",
"0.0",
"}",
"# Read the stats",
"# For each container, you will find a pseudo-file cpuacct.stat,",
"# containing the CPU usa... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_docker_memory | Return the container MEMORY.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'rss': 1015808, 'cache': 356352, 'usage': ..., 'max_usage': ...} | glances/plugins/glances_docker.py | def get_docker_memory(self, container_id, all_stats):
"""Return the container MEMORY.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'rss': 1015808, 'cache': 356352, 'usage': ..., 'max_usage': ...}
"""
... | def get_docker_memory(self, container_id, all_stats):
"""Return the container MEMORY.
Input: id is the full container id
all_stats is the output of the stats method of the Docker API
Output: a dict {'rss': 1015808, 'cache': 356352, 'usage': ..., 'max_usage': ...}
"""
... | [
"Return",
"the",
"container",
"MEMORY",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L305-L326 | [
"def",
"get_docker_memory",
"(",
"self",
",",
"container_id",
",",
"all_stats",
")",
":",
"ret",
"=",
"{",
"}",
"# Read the stats",
"try",
":",
"# Do not exist anymore with Docker 1.11 (issue #848)",
"# ret['rss'] = all_stats['memory_stats']['stats']['rss']",
"# ret['cache'] = ... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_docker_network | Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'rx': 10, 'tx': 65}.
with:
time_since_update: number of seconds elapsed between the latest grab
rx: Number of byte rece... | glances/plugins/glances_docker.py | def get_docker_network(self, container_id, all_stats):
"""Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'rx': 10, 'tx': 65}.
with:
time_since_update: number of seconds e... | def get_docker_network(self, container_id, all_stats):
"""Return the container network usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'rx': 10, 'tx': 65}.
with:
time_since_update: number of seconds e... | [
"Return",
"the",
"container",
"network",
"usage",
"using",
"the",
"Docker",
"API",
"(",
"v1",
".",
"0",
"or",
"higher",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L328-L384 | [
"def",
"get_docker_network",
"(",
"self",
",",
"container_id",
",",
"all_stats",
")",
":",
"# Init the returned dict",
"network_new",
"=",
"{",
"}",
"# Read the rx/tx stats (in bytes)",
"try",
":",
"netcounters",
"=",
"all_stats",
"[",
"\"networks\"",
"]",
"except",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.get_docker_io | Return the container IO usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'ior': 10, 'iow': 65}.
with:
time_since_update: number of seconds elapsed between the latest grab
ior: Number of byte readed... | glances/plugins/glances_docker.py | def get_docker_io(self, container_id, all_stats):
"""Return the container IO usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'ior': 10, 'iow': 65}.
with:
time_since_update: number of seconds elapsed b... | def get_docker_io(self, container_id, all_stats):
"""Return the container IO usage using the Docker API (v1.0 or higher).
Input: id is the full container id
Output: a dict {'time_since_update': 3000, 'ior': 10, 'iow': 65}.
with:
time_since_update: number of seconds elapsed b... | [
"Return",
"the",
"container",
"IO",
"usage",
"using",
"the",
"Docker",
"API",
"(",
"v1",
".",
"0",
"or",
"higher",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L386-L447 | [
"def",
"get_docker_io",
"(",
"self",
",",
"container_id",
",",
"all_stats",
")",
":",
"# Init the returned dict",
"io_new",
"=",
"{",
"}",
"# Read the ior/iow stats (in bytes)",
"try",
":",
"iocounters",
"=",
"all_stats",
"[",
"\"blkio_stats\"",
"]",
"except",
"KeyE... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update_views | Update stats views. | glances/plugins/glances_docker.py | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
if 'containers' not in self.stats:
return False
# Add specifics informations
# Alert
for i in self.stats['containers']:
# Init... | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
if 'containers' not in self.stats:
return False
# Add specifics informations
# Alert
for i in self.stats['containers']:
# Init... | [
"Update",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L460-L497 | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"if",
"'containers'",
"not",
"in",
"self",
".",
"stats",
":",
"return",
"False",
"# Add specifics informations",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_docker.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 non null) and display plugin enable...
if not self.stats \
or 'containers' not in self.stats ... | 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 non null) and display plugin enable...
if not self.stats \
or 'containers' not in self.stats ... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L499-L606 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist (and non null) and display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin._msg_name | Build the container name. | glances/plugins/glances_docker.py | def _msg_name(self, container, max_width):
"""Build the container name."""
name = container['name']
if len(name) > max_width:
name = '_' + name[-max_width + 1:]
else:
name = name[:max_width]
return ' {:{width}}'.format(name, width=max_width) | def _msg_name(self, container, max_width):
"""Build the container name."""
name = container['name']
if len(name) > max_width:
name = '_' + name[-max_width + 1:]
else:
name = name[:max_width]
return ' {:{width}}'.format(name, width=max_width) | [
"Build",
"the",
"container",
"name",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L608-L615 | [
"def",
"_msg_name",
"(",
"self",
",",
"container",
",",
"max_width",
")",
":",
"name",
"=",
"container",
"[",
"'name'",
"]",
"if",
"len",
"(",
"name",
")",
">",
"max_width",
":",
"name",
"=",
"'_'",
"+",
"name",
"[",
"-",
"max_width",
"+",
"1",
":"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadDockerGrabber.run | Grab the stats.
Infinite loop, should be stopped by calling the stop() method | glances/plugins/glances_docker.py | def run(self):
"""Grab the stats.
Infinite loop, should be stopped by calling the stop() method
"""
for i in self._stats_stream:
self._stats = i
time.sleep(0.1)
if self.stopped():
break | def run(self):
"""Grab the stats.
Infinite loop, should be stopped by calling the stop() method
"""
for i in self._stats_stream:
self._stats = i
time.sleep(0.1)
if self.stopped():
break | [
"Grab",
"the",
"stats",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L651-L660 | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"i",
"in",
"self",
".",
"_stats_stream",
":",
"self",
".",
"_stats",
"=",
"i",
"time",
".",
"sleep",
"(",
"0.1",
")",
"if",
"self",
".",
"stopped",
"(",
")",
":",
"break"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | ThreadDockerGrabber.stop | Stop the thread. | glances/plugins/glances_docker.py | def stop(self, timeout=None):
"""Stop the thread."""
logger.debug("docker plugin - Close thread for container {}".format(self._container.name))
self._stopper.set() | def stop(self, timeout=None):
"""Stop the thread."""
logger.debug("docker plugin - Close thread for container {}".format(self._container.name))
self._stopper.set() | [
"Stop",
"the",
"thread",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L672-L675 | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"docker plugin - Close thread for container {}\"",
".",
"format",
"(",
"self",
".",
"_container",
".",
"name",
")",
")",
"self",
".",
"_stopper",
".",
"set",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.is_enable | Return true if plugin is enabled. | glances/plugins/glances_plugin.py | def is_enable(self, plugin_name=None):
"""Return true if plugin is enabled."""
if not plugin_name:
plugin_name = self.plugin_name
try:
d = getattr(self.args, 'disable_' + plugin_name)
except AttributeError:
return True
else:
return ... | def is_enable(self, plugin_name=None):
"""Return true if plugin is enabled."""
if not plugin_name:
plugin_name = self.plugin_name
try:
d = getattr(self.args, 'disable_' + plugin_name)
except AttributeError:
return True
else:
return ... | [
"Return",
"true",
"if",
"plugin",
"is",
"enabled",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L127-L136 | [
"def",
"is_enable",
"(",
"self",
",",
"plugin_name",
"=",
"None",
")",
":",
"if",
"not",
"plugin_name",
":",
"plugin_name",
"=",
"self",
".",
"plugin_name",
"try",
":",
"d",
"=",
"getattr",
"(",
"self",
".",
"args",
",",
"'disable_'",
"+",
"plugin_name",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin._json_dumps | Return the object 'd' in a JSON format.
Manage the issue #815 for Windows OS | glances/plugins/glances_plugin.py | def _json_dumps(self, d):
"""Return the object 'd' in a JSON format.
Manage the issue #815 for Windows OS
"""
try:
return json.dumps(d)
except UnicodeDecodeError:
return json.dumps(d, ensure_ascii=False) | def _json_dumps(self, d):
"""Return the object 'd' in a JSON format.
Manage the issue #815 for Windows OS
"""
try:
return json.dumps(d)
except UnicodeDecodeError:
return json.dumps(d, ensure_ascii=False) | [
"Return",
"the",
"object",
"d",
"in",
"a",
"JSON",
"format",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L142-L150 | [
"def",
"_json_dumps",
"(",
"self",
",",
"d",
")",
":",
"try",
":",
"return",
"json",
".",
"dumps",
"(",
"d",
")",
"except",
"UnicodeDecodeError",
":",
"return",
"json",
".",
"dumps",
"(",
"d",
",",
"ensure_ascii",
"=",
"False",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.init_stats_history | Init the stats history (dict of GlancesAttribute). | glances/plugins/glances_plugin.py | def init_stats_history(self):
"""Init the stats history (dict of GlancesAttribute)."""
if self.history_enable():
init_list = [a['name'] for a in self.get_items_history_list()]
logger.debug("Stats history activated for plugin {} (items: {})".format(self.plugin_name, init_list))
... | def init_stats_history(self):
"""Init the stats history (dict of GlancesAttribute)."""
if self.history_enable():
init_list = [a['name'] for a in self.get_items_history_list()]
logger.debug("Stats history activated for plugin {} (items: {})".format(self.plugin_name, init_list))
... | [
"Init",
"the",
"stats",
"history",
"(",
"dict",
"of",
"GlancesAttribute",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L155-L160 | [
"def",
"init_stats_history",
"(",
"self",
")",
":",
"if",
"self",
".",
"history_enable",
"(",
")",
":",
"init_list",
"=",
"[",
"a",
"[",
"'name'",
"]",
"for",
"a",
"in",
"self",
".",
"get_items_history_list",
"(",
")",
"]",
"logger",
".",
"debug",
"(",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.reset_stats_history | Reset the stats history (dict of GlancesAttribute). | glances/plugins/glances_plugin.py | def reset_stats_history(self):
"""Reset the stats history (dict of GlancesAttribute)."""
if self.history_enable():
reset_list = [a['name'] for a in self.get_items_history_list()]
logger.debug("Reset history for plugin {} (items: {})".format(self.plugin_name, reset_list))
... | def reset_stats_history(self):
"""Reset the stats history (dict of GlancesAttribute)."""
if self.history_enable():
reset_list = [a['name'] for a in self.get_items_history_list()]
logger.debug("Reset history for plugin {} (items: {})".format(self.plugin_name, reset_list))
... | [
"Reset",
"the",
"stats",
"history",
"(",
"dict",
"of",
"GlancesAttribute",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L162-L167 | [
"def",
"reset_stats_history",
"(",
"self",
")",
":",
"if",
"self",
".",
"history_enable",
"(",
")",
":",
"reset_list",
"=",
"[",
"a",
"[",
"'name'",
"]",
"for",
"a",
"in",
"self",
".",
"get_items_history_list",
"(",
")",
"]",
"logger",
".",
"debug",
"(... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.update_stats_history | Update stats history. | glances/plugins/glances_plugin.py | def update_stats_history(self):
"""Update stats history."""
# If the plugin data is a dict, the dict's key should be used
if self.get_key() is None:
item_name = ''
else:
item_name = self.get_key()
# Build the history
if self.get_export() and self.h... | def update_stats_history(self):
"""Update stats history."""
# If the plugin data is a dict, the dict's key should be used
if self.get_key() is None:
item_name = ''
else:
item_name = self.get_key()
# Build the history
if self.get_export() and self.h... | [
"Update",
"stats",
"history",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L169-L195 | [
"def",
"update_stats_history",
"(",
"self",
")",
":",
"# If the plugin data is a dict, the dict's key should be used",
"if",
"self",
".",
"get_key",
"(",
")",
"is",
"None",
":",
"item_name",
"=",
"''",
"else",
":",
"item_name",
"=",
"self",
".",
"get_key",
"(",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_raw_history | Return the history (RAW format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history | glances/plugins/glances_plugin.py | def get_raw_history(self, item=None, nb=0):
"""Return the history (RAW format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history
"""
s = self.stats_history.get(nb=nb)
... | def get_raw_history(self, item=None, nb=0):
"""Return the history (RAW format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history
"""
s = self.stats_history.get(nb=nb)
... | [
"Return",
"the",
"history",
"(",
"RAW",
"format",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L201-L215 | [
"def",
"get_raw_history",
"(",
"self",
",",
"item",
"=",
"None",
",",
"nb",
"=",
"0",
")",
":",
"s",
"=",
"self",
".",
"stats_history",
".",
"get",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"s",
"else",
":",
"if",
"i... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_json_history | Return the history (JSON format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history
Limit to lasts nb items (all if nb=0) | glances/plugins/glances_plugin.py | def get_json_history(self, item=None, nb=0):
"""Return the history (JSON format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history
Limit to lasts nb items (all if nb=0)
""... | def get_json_history(self, item=None, nb=0):
"""Return the history (JSON format).
- the stats history (dict of list) if item is None
- the stats history for the given item (list) instead
- None if item did not exist in the history
Limit to lasts nb items (all if nb=0)
""... | [
"Return",
"the",
"history",
"(",
"JSON",
"format",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L217-L232 | [
"def",
"get_json_history",
"(",
"self",
",",
"item",
"=",
"None",
",",
"nb",
"=",
"0",
")",
":",
"s",
"=",
"self",
".",
"stats_history",
".",
"get_json",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"s",
"else",
":",
"if"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stats_history | Return the stats history (JSON format). | glances/plugins/glances_plugin.py | def get_stats_history(self, item=None, nb=0):
"""Return the stats history (JSON format)."""
s = self.get_json_history(nb=nb)
if item is None:
return self._json_dumps(s)
if isinstance(s, dict):
try:
return self._json_dumps({item: s[item]})
... | def get_stats_history(self, item=None, nb=0):
"""Return the stats history (JSON format)."""
s = self.get_json_history(nb=nb)
if item is None:
return self._json_dumps(s)
if isinstance(s, dict):
try:
return self._json_dumps({item: s[item]})
... | [
"Return",
"the",
"stats",
"history",
"(",
"JSON",
"format",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L238-L260 | [
"def",
"get_stats_history",
"(",
"self",
",",
"item",
"=",
"None",
",",
"nb",
"=",
"0",
")",
":",
"s",
"=",
"self",
".",
"get_json_history",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"self",
".",
"_json_dumps",
"(",
"s",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_trend | Get the trend regarding to the last nb values.
The trend is the diff between the mean of the last nb values
and the current one. | glances/plugins/glances_plugin.py | def get_trend(self, item, nb=6):
"""Get the trend regarding to the last nb values.
The trend is the diff between the mean of the last nb values
and the current one.
"""
raw_history = self.get_raw_history(item=item, nb=nb)
if raw_history is None or len(raw_history) < nb:
... | def get_trend(self, item, nb=6):
"""Get the trend regarding to the last nb values.
The trend is the diff between the mean of the last nb values
and the current one.
"""
raw_history = self.get_raw_history(item=item, nb=nb)
if raw_history is None or len(raw_history) < nb:
... | [
"Get",
"the",
"trend",
"regarding",
"to",
"the",
"last",
"nb",
"values",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L262-L272 | [
"def",
"get_trend",
"(",
"self",
",",
"item",
",",
"nb",
"=",
"6",
")",
":",
"raw_history",
"=",
"self",
".",
"get_raw_history",
"(",
"item",
"=",
"item",
",",
"nb",
"=",
"nb",
")",
"if",
"raw_history",
"is",
"None",
"or",
"len",
"(",
"raw_history",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.sorted_stats | Get the stats sorted by an alias (if present) or key. | glances/plugins/glances_plugin.py | def sorted_stats(self):
"""Get the stats sorted by an alias (if present) or key."""
key = self.get_key()
return sorted(self.stats, key=lambda stat: tuple(map(
lambda part: int(part) if part.isdigit() else part.lower(),
re.split(r"(\d+|\D+)", self.has_alias(stat[key]) or s... | def sorted_stats(self):
"""Get the stats sorted by an alias (if present) or key."""
key = self.get_key()
return sorted(self.stats, key=lambda stat: tuple(map(
lambda part: int(part) if part.isdigit() else part.lower(),
re.split(r"(\d+|\D+)", self.has_alias(stat[key]) or s... | [
"Get",
"the",
"stats",
"sorted",
"by",
"an",
"alias",
"(",
"if",
"present",
")",
"or",
"key",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L294-L300 | [
"def",
"sorted_stats",
"(",
"self",
")",
":",
"key",
"=",
"self",
".",
"get_key",
"(",
")",
"return",
"sorted",
"(",
"self",
".",
"stats",
",",
"key",
"=",
"lambda",
"stat",
":",
"tuple",
"(",
"map",
"(",
"lambda",
"part",
":",
"int",
"(",
"part",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stats_snmp | Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request. | glances/plugins/glances_plugin.py | def get_stats_snmp(self, bulk=False, snmp_oid=None):
"""Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request.
"""
snmp_oid = snmp_oid or {}
from glances.snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMP... | def get_stats_snmp(self, bulk=False, snmp_oid=None):
"""Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request.
"""
snmp_oid = snmp_oid or {}
from glances.snmp import GlancesSNMPClient
# Init the SNMP request
clientsnmp = GlancesSNMP... | [
"Update",
"stats",
"using",
"SNMP",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L311-L364 | [
"def",
"get_stats_snmp",
"(",
"self",
",",
"bulk",
"=",
"False",
",",
"snmp_oid",
"=",
"None",
")",
":",
"snmp_oid",
"=",
"snmp_oid",
"or",
"{",
"}",
"from",
"glances",
".",
"snmp",
"import",
"GlancesSNMPClient",
"# Init the SNMP request",
"clientsnmp",
"=",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stats_item | Return the stats object for a specific item in JSON format.
Stats should be a list of dict (processlist, network...) | glances/plugins/glances_plugin.py | def get_stats_item(self, item):
"""Return the stats object for a specific item in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if isinstance(self.stats, dict):
try:
return self._json_dumps({item: self.stats[item]})
exc... | def get_stats_item(self, item):
"""Return the stats object for a specific item in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if isinstance(self.stats, dict):
try:
return self._json_dumps({item: self.stats[item]})
exc... | [
"Return",
"the",
"stats",
"object",
"for",
"a",
"specific",
"item",
"in",
"JSON",
"format",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L378-L399 | [
"def",
"get_stats_item",
"(",
"self",
",",
"item",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"stats",
",",
"dict",
")",
":",
"try",
":",
"return",
"self",
".",
"_json_dumps",
"(",
"{",
"item",
":",
"self",
".",
"stats",
"[",
"item",
"]",
"}",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stats_value | Return the stats object for a specific item=value in JSON format.
Stats should be a list of dict (processlist, network...) | glances/plugins/glances_plugin.py | def get_stats_value(self, item, value):
"""Return the stats object for a specific item=value in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if not isinstance(self.stats, list):
return None
else:
if value.isdigit():
... | def get_stats_value(self, item, value):
"""Return the stats object for a specific item=value in JSON format.
Stats should be a list of dict (processlist, network...)
"""
if not isinstance(self.stats, list):
return None
else:
if value.isdigit():
... | [
"Return",
"the",
"stats",
"object",
"for",
"a",
"specific",
"item",
"=",
"value",
"in",
"JSON",
"format",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L401-L416 | [
"def",
"get_stats_value",
"(",
"self",
",",
"item",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"stats",
",",
"list",
")",
":",
"return",
"None",
"else",
":",
"if",
"value",
".",
"isdigit",
"(",
")",
":",
"value",
"=",
"int... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.update_views | Update the stats views.
The V of MVC
A dict of dict with the needed information to display the stats.
Example for the stat xxx:
'xxx': {'decoration': 'DEFAULT',
'optional': False,
'additional': False,
'splittable': False} | glances/plugins/glances_plugin.py | def update_views(self):
"""Update the stats views.
The V of MVC
A dict of dict with the needed information to display the stats.
Example for the stat xxx:
'xxx': {'decoration': 'DEFAULT',
'optional': False,
'additional': False,
'sp... | def update_views(self):
"""Update the stats views.
The V of MVC
A dict of dict with the needed information to display the stats.
Example for the stat xxx:
'xxx': {'decoration': 'DEFAULT',
'optional': False,
'additional': False,
'sp... | [
"Update",
"the",
"stats",
"views",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L418-L454 | [
"def",
"update_views",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"(",
"isinstance",
"(",
"self",
".",
"get_raw",
"(",
")",
",",
"list",
")",
"and",
"self",
".",
"get_raw",
"(",
")",
"is",
"not",
"None",
"and",
"self",
".",
"get_key",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_views | Return the views object.
If key is None, return all the view for the current plugin
else if option is None return the view for the specific key (all option)
else return the view fo the specific key/option
Specify item if the stats are stored in a dict of dict (ex: NETWORK, FS...) | glances/plugins/glances_plugin.py | def get_views(self, item=None, key=None, option=None):
"""Return the views object.
If key is None, return all the view for the current plugin
else if option is None return the view for the specific key (all option)
else return the view fo the specific key/option
Specify item if... | def get_views(self, item=None, key=None, option=None):
"""Return the views object.
If key is None, return all the view for the current plugin
else if option is None return the view for the specific key (all option)
else return the view fo the specific key/option
Specify item if... | [
"Return",
"the",
"views",
"object",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L460-L483 | [
"def",
"get_views",
"(",
"self",
",",
"item",
"=",
"None",
",",
"key",
"=",
"None",
",",
"option",
"=",
"None",
")",
":",
"if",
"item",
"is",
"None",
":",
"item_views",
"=",
"self",
".",
"views",
"else",
":",
"item_views",
"=",
"self",
".",
"views"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_json_views | Return the views (in JSON). | glances/plugins/glances_plugin.py | def get_json_views(self, item=None, key=None, option=None):
"""Return the views (in JSON)."""
return self._json_dumps(self.get_views(item, key, option)) | def get_json_views(self, item=None, key=None, option=None):
"""Return the views (in JSON)."""
return self._json_dumps(self.get_views(item, key, option)) | [
"Return",
"the",
"views",
"(",
"in",
"JSON",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L485-L487 | [
"def",
"get_json_views",
"(",
"self",
",",
"item",
"=",
"None",
",",
"key",
"=",
"None",
",",
"option",
"=",
"None",
")",
":",
"return",
"self",
".",
"_json_dumps",
"(",
"self",
".",
"get_views",
"(",
"item",
",",
"key",
",",
"option",
")",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.load_limits | Load limits from the configuration file, if it exists. | glances/plugins/glances_plugin.py | def load_limits(self, config):
"""Load limits from the configuration file, if it exists."""
# By default set the history length to 3 points per second during one day
self._limits['history_size'] = 28800
if not hasattr(config, 'has_section'):
return False
# Read the ... | def load_limits(self, config):
"""Load limits from the configuration file, if it exists."""
# By default set the history length to 3 points per second during one day
self._limits['history_size'] = 28800
if not hasattr(config, 'has_section'):
return False
# Read the ... | [
"Load",
"limits",
"from",
"the",
"configuration",
"file",
"if",
"it",
"exists",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L489-L513 | [
"def",
"load_limits",
"(",
"self",
",",
"config",
")",
":",
"# By default set the history length to 3 points per second during one day",
"self",
".",
"_limits",
"[",
"'history_size'",
"]",
"=",
"28800",
"if",
"not",
"hasattr",
"(",
"config",
",",
"'has_section'",
")",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stat_name | Return the stat name with an optional header | glances/plugins/glances_plugin.py | def get_stat_name(self, header=""):
""""Return the stat name with an optional header"""
ret = self.plugin_name
if header != "":
ret += '_' + header
return ret | def get_stat_name(self, header=""):
""""Return the stat name with an optional header"""
ret = self.plugin_name
if header != "":
ret += '_' + header
return ret | [
"Return",
"the",
"stat",
"name",
"with",
"an",
"optional",
"header"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L534-L539 | [
"def",
"get_stat_name",
"(",
"self",
",",
"header",
"=",
"\"\"",
")",
":",
"ret",
"=",
"self",
".",
"plugin_name",
"if",
"header",
"!=",
"\"\"",
":",
"ret",
"+=",
"'_'",
"+",
"header",
"return",
"ret"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_alert | Return the alert status relative to a current value.
Use this function for minor stats.
If current < CAREFUL of max then alert = OK
If current > CAREFUL of max then alert = CAREFUL
If current > WARNING of max then alert = WARNING
If current > CRITICAL of max then alert = CRITIC... | glances/plugins/glances_plugin.py | def get_alert(self,
current=0,
minimum=0,
maximum=100,
highlight_zero=True,
is_max=False,
header="",
action_key=None,
log=False):
"""Return the alert status relative to... | def get_alert(self,
current=0,
minimum=0,
maximum=100,
highlight_zero=True,
is_max=False,
header="",
action_key=None,
log=False):
"""Return the alert status relative to... | [
"Return",
"the",
"alert",
"status",
"relative",
"to",
"a",
"current",
"value",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L541-L617 | [
"def",
"get_alert",
"(",
"self",
",",
"current",
"=",
"0",
",",
"minimum",
"=",
"0",
",",
"maximum",
"=",
"100",
",",
"highlight_zero",
"=",
"True",
",",
"is_max",
"=",
"False",
",",
"header",
"=",
"\"\"",
",",
"action_key",
"=",
"None",
",",
"log",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.manage_action | Manage the action for the current stat. | glances/plugins/glances_plugin.py | def manage_action(self,
stat_name,
trigger,
header,
action_key):
"""Manage the action for the current stat."""
# Here is a command line for the current trigger ?
try:
command, repeat = self.get_li... | def manage_action(self,
stat_name,
trigger,
header,
action_key):
"""Manage the action for the current stat."""
# Here is a command line for the current trigger ?
try:
command, repeat = self.get_li... | [
"Manage",
"the",
"action",
"for",
"the",
"current",
"stat",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L625-L659 | [
"def",
"manage_action",
"(",
"self",
",",
"stat_name",
",",
"trigger",
",",
"header",
",",
"action_key",
")",
":",
"# Here is a command line for the current trigger ?",
"try",
":",
"command",
",",
"repeat",
"=",
"self",
".",
"get_limit_action",
"(",
"trigger",
","... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_alert_log | Get the alert log. | glances/plugins/glances_plugin.py | def get_alert_log(self,
current=0,
minimum=0,
maximum=100,
header="",
action_key=None):
"""Get the alert log."""
return self.get_alert(current=current,
minimum=mini... | def get_alert_log(self,
current=0,
minimum=0,
maximum=100,
header="",
action_key=None):
"""Get the alert log."""
return self.get_alert(current=current,
minimum=mini... | [
"Get",
"the",
"alert",
"log",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L661-L673 | [
"def",
"get_alert_log",
"(",
"self",
",",
"current",
"=",
"0",
",",
"minimum",
"=",
"0",
",",
"maximum",
"=",
"100",
",",
"header",
"=",
"\"\"",
",",
"action_key",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_alert",
"(",
"current",
"=",
"curre... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_limit | Return the limit value for the alert. | glances/plugins/glances_plugin.py | def get_limit(self, criticity, stat_name=""):
"""Return the limit value for the alert."""
# Get the limit for stat + header
# Exemple: network_wlan0_rx_careful
try:
limit = self._limits[stat_name + '_' + criticity]
except KeyError:
# Try fallback to plugin... | def get_limit(self, criticity, stat_name=""):
"""Return the limit value for the alert."""
# Get the limit for stat + header
# Exemple: network_wlan0_rx_careful
try:
limit = self._limits[stat_name + '_' + criticity]
except KeyError:
# Try fallback to plugin... | [
"Return",
"the",
"limit",
"value",
"for",
"the",
"alert",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L675-L689 | [
"def",
"get_limit",
"(",
"self",
",",
"criticity",
",",
"stat_name",
"=",
"\"\"",
")",
":",
"# Get the limit for stat + header",
"# Exemple: network_wlan0_rx_careful",
"try",
":",
"limit",
"=",
"self",
".",
"_limits",
"[",
"stat_name",
"+",
"'_'",
"+",
"criticity"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_limit_action | Return the tuple (action, repeat) for the alert.
- action is a command line
- repeat is a bool | glances/plugins/glances_plugin.py | def get_limit_action(self, criticity, stat_name=""):
"""Return the tuple (action, repeat) for the alert.
- action is a command line
- repeat is a bool
"""
# Get the action for stat + header
# Exemple: network_wlan0_rx_careful_action
# Action key available ?
... | def get_limit_action(self, criticity, stat_name=""):
"""Return the tuple (action, repeat) for the alert.
- action is a command line
- repeat is a bool
"""
# Get the action for stat + header
# Exemple: network_wlan0_rx_careful_action
# Action key available ?
... | [
"Return",
"the",
"tuple",
"(",
"action",
"repeat",
")",
"for",
"the",
"alert",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L691-L709 | [
"def",
"get_limit_action",
"(",
"self",
",",
"criticity",
",",
"stat_name",
"=",
"\"\"",
")",
":",
"# Get the action for stat + header",
"# Exemple: network_wlan0_rx_careful_action",
"# Action key available ?",
"ret",
"=",
"[",
"(",
"stat_name",
"+",
"'_'",
"+",
"critic... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_limit_log | Return the log tag for the alert. | glances/plugins/glances_plugin.py | def get_limit_log(self, stat_name, default_action=False):
"""Return the log tag for the alert."""
# Get the log tag for stat + header
# Exemple: network_wlan0_rx_log
try:
log_tag = self._limits[stat_name + '_log']
except KeyError:
# Try fallback to plugin ... | def get_limit_log(self, stat_name, default_action=False):
"""Return the log tag for the alert."""
# Get the log tag for stat + header
# Exemple: network_wlan0_rx_log
try:
log_tag = self._limits[stat_name + '_log']
except KeyError:
# Try fallback to plugin ... | [
"Return",
"the",
"log",
"tag",
"for",
"the",
"alert",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L711-L727 | [
"def",
"get_limit_log",
"(",
"self",
",",
"stat_name",
",",
"default_action",
"=",
"False",
")",
":",
"# Get the log tag for stat + header",
"# Exemple: network_wlan0_rx_log",
"try",
":",
"log_tag",
"=",
"self",
".",
"_limits",
"[",
"stat_name",
"+",
"'_log'",
"]",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_conf_value | Return the configuration (header_) value for the current plugin.
...or the one given by the plugin_name var. | glances/plugins/glances_plugin.py | def get_conf_value(self, value, header="", plugin_name=None):
"""Return the configuration (header_) value for the current plugin.
...or the one given by the plugin_name var.
"""
if plugin_name is None:
# If not default use the current plugin name
plugin_name = se... | def get_conf_value(self, value, header="", plugin_name=None):
"""Return the configuration (header_) value for the current plugin.
...or the one given by the plugin_name var.
"""
if plugin_name is None:
# If not default use the current plugin name
plugin_name = se... | [
"Return",
"the",
"configuration",
"(",
"header_",
")",
"value",
"for",
"the",
"current",
"plugin",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L729-L745 | [
"def",
"get_conf_value",
"(",
"self",
",",
"value",
",",
"header",
"=",
"\"\"",
",",
"plugin_name",
"=",
"None",
")",
":",
"if",
"plugin_name",
"is",
"None",
":",
"# If not default use the current plugin name",
"plugin_name",
"=",
"self",
".",
"plugin_name",
"if... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.is_hide | Return True if the value is in the hide configuration list.
The hide configuration list is defined in the glances.conf file.
It is a comma separed list of regexp.
Example for diskio:
hide=sda2,sda5,loop.* | glances/plugins/glances_plugin.py | def is_hide(self, value, header=""):
"""Return True if the value is in the hide configuration list.
The hide configuration list is defined in the glances.conf file.
It is a comma separed list of regexp.
Example for diskio:
hide=sda2,sda5,loop.*
"""
# TODO: possib... | def is_hide(self, value, header=""):
"""Return True if the value is in the hide configuration list.
The hide configuration list is defined in the glances.conf file.
It is a comma separed list of regexp.
Example for diskio:
hide=sda2,sda5,loop.*
"""
# TODO: possib... | [
"Return",
"True",
"if",
"the",
"value",
"is",
"in",
"the",
"hide",
"configuration",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L747-L756 | [
"def",
"is_hide",
"(",
"self",
",",
"value",
",",
"header",
"=",
"\"\"",
")",
":",
"# TODO: possible optimisation: create a re.compile list",
"return",
"not",
"all",
"(",
"j",
"is",
"None",
"for",
"j",
"in",
"[",
"re",
".",
"match",
"(",
"i",
",",
"value",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.has_alias | Return the alias name for the relative header or None if nonexist. | glances/plugins/glances_plugin.py | def has_alias(self, header):
"""Return the alias name for the relative header or None if nonexist."""
try:
# Force to lower case (issue #1126)
return self._limits[self.plugin_name + '_' + header.lower() + '_' + 'alias'][0]
except (KeyError, IndexError):
# logg... | def has_alias(self, header):
"""Return the alias name for the relative header or None if nonexist."""
try:
# Force to lower case (issue #1126)
return self._limits[self.plugin_name + '_' + header.lower() + '_' + 'alias'][0]
except (KeyError, IndexError):
# logg... | [
"Return",
"the",
"alias",
"name",
"for",
"the",
"relative",
"header",
"or",
"None",
"if",
"nonexist",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L758-L765 | [
"def",
"has_alias",
"(",
"self",
",",
"header",
")",
":",
"try",
":",
"# Force to lower case (issue #1126)",
"return",
"self",
".",
"_limits",
"[",
"self",
".",
"plugin_name",
"+",
"'_'",
"+",
"header",
".",
"lower",
"(",
")",
"+",
"'_'",
"+",
"'alias'",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.get_stats_display | Return a dict with all the information needed to display the stat.
key | description
----------------------------
display | Display the stat (True or False)
msgdict | Message to display (list of dict [{ 'msg': msg, 'decoration': decoration } ... ])
align | Message position | glances/plugins/glances_plugin.py | def get_stats_display(self, args=None, max_width=None):
"""Return a dict with all the information needed to display the stat.
key | description
----------------------------
display | Display the stat (True or False)
msgdict | Message to display (list of dict [{ 'msg': msg, '... | def get_stats_display(self, args=None, max_width=None):
"""Return a dict with all the information needed to display the stat.
key | description
----------------------------
display | Display the stat (True or False)
msgdict | Message to display (list of dict [{ 'msg': msg, '... | [
"Return",
"a",
"dict",
"with",
"all",
"the",
"information",
"needed",
"to",
"display",
"the",
"stat",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L771-L796 | [
"def",
"get_stats_display",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"display_curse",
"=",
"False",
"if",
"hasattr",
"(",
"self",
",",
"'display_curse'",
")",
":",
"display_curse",
"=",
"self",
".",
"display_curse",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.curse_add_line | Return a dict with.
Where:
msg: string
decoration:
DEFAULT: no decoration
UNDERLINE: underline
BOLD: bold
TITLE: for stat title
PROCESS: for process name
STATUS: for process status
... | glances/plugins/glances_plugin.py | def curse_add_line(self, msg, decoration="DEFAULT",
optional=False, additional=False,
splittable=False):
"""Return a dict with.
Where:
msg: string
decoration:
DEFAULT: no decoration
UNDERLINE: underlin... | def curse_add_line(self, msg, decoration="DEFAULT",
optional=False, additional=False,
splittable=False):
"""Return a dict with.
Where:
msg: string
decoration:
DEFAULT: no decoration
UNDERLINE: underlin... | [
"Return",
"a",
"dict",
"with",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L798-L826 | [
"def",
"curse_add_line",
"(",
"self",
",",
"msg",
",",
"decoration",
"=",
"\"DEFAULT\"",
",",
"optional",
"=",
"False",
",",
"additional",
"=",
"False",
",",
"splittable",
"=",
"False",
")",
":",
"return",
"{",
"'msg'",
":",
"msg",
",",
"'decoration'",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.auto_unit | Make a nice human-readable string out of number.
Number of decimal places increases as quantity approaches 1.
CASE: 613421788 RESULT: 585M low_precision: 585M
CASE: 5307033647 RESULT: 4.94G low_precision: 4.9G
CASE: 44968414685 RESULT: 41.9G... | glances/plugins/glances_plugin.py | def auto_unit(self, number,
low_precision=False,
min_symbol='K'
):
"""Make a nice human-readable string out of number.
Number of decimal places increases as quantity approaches 1.
CASE: 613421788 RESULT: 585M low_precision: ... | def auto_unit(self, number,
low_precision=False,
min_symbol='K'
):
"""Make a nice human-readable string out of number.
Number of decimal places increases as quantity approaches 1.
CASE: 613421788 RESULT: 585M low_precision: ... | [
"Make",
"a",
"nice",
"human",
"-",
"readable",
"string",
"out",
"of",
"number",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L845-L895 | [
"def",
"auto_unit",
"(",
"self",
",",
"number",
",",
"low_precision",
"=",
"False",
",",
"min_symbol",
"=",
"'K'",
")",
":",
"symbols",
"=",
"(",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'T'",
",",
"'P'",
",",
"'E'",
",",
"'Z'",
",",
"'Y'",
")",
"if"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin.trend_msg | Return the trend message.
Do not take into account if trend < significant | glances/plugins/glances_plugin.py | def trend_msg(self, trend, significant=1):
"""Return the trend message.
Do not take into account if trend < significant
"""
ret = '-'
if trend is None:
ret = ' '
elif trend > significant:
ret = '/'
elif trend < -significant:
re... | def trend_msg(self, trend, significant=1):
"""Return the trend message.
Do not take into account if trend < significant
"""
ret = '-'
if trend is None:
ret = ' '
elif trend > significant:
ret = '/'
elif trend < -significant:
re... | [
"Return",
"the",
"trend",
"message",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L897-L909 | [
"def",
"trend_msg",
"(",
"self",
",",
"trend",
",",
"significant",
"=",
"1",
")",
":",
"ret",
"=",
"'-'",
"if",
"trend",
"is",
"None",
":",
"ret",
"=",
"' '",
"elif",
"trend",
">",
"significant",
":",
"ret",
"=",
"'/'",
"elif",
"trend",
"<",
"-",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin._check_decorator | Check if the plugin is enabled. | glances/plugins/glances_plugin.py | def _check_decorator(fct):
"""Check if the plugin is enabled."""
def wrapper(self, *args, **kw):
if self.is_enable():
ret = fct(self, *args, **kw)
else:
ret = self.stats
return ret
return wrapper | def _check_decorator(fct):
"""Check if the plugin is enabled."""
def wrapper(self, *args, **kw):
if self.is_enable():
ret = fct(self, *args, **kw)
else:
ret = self.stats
return ret
return wrapper | [
"Check",
"if",
"the",
"plugin",
"is",
"enabled",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L911-L919 | [
"def",
"_check_decorator",
"(",
"fct",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"is_enable",
"(",
")",
":",
"ret",
"=",
"fct",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesPlugin._log_result_decorator | Log (DEBUG) the result of the function fct. | glances/plugins/glances_plugin.py | def _log_result_decorator(fct):
"""Log (DEBUG) the result of the function fct."""
def wrapper(*args, **kw):
ret = fct(*args, **kw)
logger.debug("%s %s %s return %s" % (
args[0].__class__.__name__,
args[0].__class__.__module__[len('glances_'):],
... | def _log_result_decorator(fct):
"""Log (DEBUG) the result of the function fct."""
def wrapper(*args, **kw):
ret = fct(*args, **kw)
logger.debug("%s %s %s return %s" % (
args[0].__class__.__name__,
args[0].__class__.__module__[len('glances_'):],
... | [
"Log",
"(",
"DEBUG",
")",
"the",
"result",
"of",
"the",
"function",
"fct",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L921-L930 | [
"def",
"_log_result_decorator",
"(",
"fct",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"ret",
"=",
"fct",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"logger",
".",
"debug",
"(",
"\"%s %s %s return %s\"",
"%",
"(",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update HDD stats using the input method. | glances/plugins/glances_hddtemp.py | def update(self):
"""Update HDD 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
stats = self.glancesgrabhddtemp.get()
else:
# Update... | def update(self):
"""Update HDD 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
stats = self.glancesgrabhddtemp.get()
else:
# Update... | [
"Update",
"HDD",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_hddtemp.py#L50-L67 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"stats",
"=",
"self",
".",
"glancesgrabhddte... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesGrabHDDTemp.fetch | Fetch the data from hddtemp daemon. | glances/plugins/glances_hddtemp.py | def fetch(self):
"""Fetch the data from hddtemp daemon."""
# Taking care of sudden deaths/stops of hddtemp daemon
try:
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((self.host, self.port))
data = b''
while True:
... | def fetch(self):
"""Fetch the data from hddtemp daemon."""
# Taking care of sudden deaths/stops of hddtemp daemon
try:
sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sck.connect((self.host, self.port))
data = b''
while True:
... | [
"Fetch",
"the",
"data",
"from",
"hddtemp",
"daemon",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_hddtemp.py#L132-L155 | [
"def",
"fetch",
"(",
"self",
")",
":",
"# Taking care of sudden deaths/stops of hddtemp daemon",
"try",
":",
"sck",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"sck",
".",
"connect",
"(",
"(",
"self",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | AxolotlManager.set_prekeys_as_sent | :param prekeyIds:
:type prekeyIds: list
:return:
:rtype: | yowsup/axolotl/manager.py | def set_prekeys_as_sent(self, prekeyIds):
"""
:param prekeyIds:
:type prekeyIds: list
:return:
:rtype:
"""
logger.debug("set_prekeys_as_sent(prekeyIds=[%d prekeyIds])" % len(prekeyIds))
self._store.preKeyStore.setAsSent([prekey.getId() for prekey in prekey... | def set_prekeys_as_sent(self, prekeyIds):
"""
:param prekeyIds:
:type prekeyIds: list
:return:
:rtype:
"""
logger.debug("set_prekeys_as_sent(prekeyIds=[%d prekeyIds])" % len(prekeyIds))
self._store.preKeyStore.setAsSent([prekey.getId() for prekey in prekey... | [
":",
"param",
"prekeyIds",
":",
":",
"type",
"prekeyIds",
":",
"list",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L86-L94 | [
"def",
"set_prekeys_as_sent",
"(",
"self",
",",
"prekeyIds",
")",
":",
"logger",
".",
"debug",
"(",
"\"set_prekeys_as_sent(prekeyIds=[%d prekeyIds])\"",
"%",
"len",
"(",
"prekeyIds",
")",
")",
"self",
".",
"_store",
".",
"preKeyStore",
".",
"setAsSent",
"(",
"["... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlManager.encrypt | :param recipient_id:
:type recipient_id: str
:param data:
:type data: bytes
:return:
:rtype: | yowsup/axolotl/manager.py | def encrypt(self, recipient_id, message):
logger.debug("encrypt(recipientid=%s, message=%s)" % (recipient_id, message))
"""
:param recipient_id:
:type recipient_id: str
:param data:
:type data: bytes
:return:
:rtype:
"""
cipher = self._get_... | def encrypt(self, recipient_id, message):
logger.debug("encrypt(recipientid=%s, message=%s)" % (recipient_id, message))
"""
:param recipient_id:
:type recipient_id: str
:param data:
:type data: bytes
:return:
:rtype:
"""
cipher = self._get_... | [
":",
"param",
"recipient_id",
":",
":",
"type",
"recipient_id",
":",
"str",
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"bytes",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L147-L158 | [
"def",
"encrypt",
"(",
"self",
",",
"recipient_id",
",",
"message",
")",
":",
"logger",
".",
"debug",
"(",
"\"encrypt(recipientid=%s, message=%s)\"",
"%",
"(",
"recipient_id",
",",
"message",
")",
")",
"cipher",
"=",
"self",
".",
"_get_session_cipher",
"(",
"r... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlManager.group_encrypt | :param groupid:
:type groupid: str
:param message:
:type message: bytes
:return:
:rtype: | yowsup/axolotl/manager.py | def group_encrypt(self, groupid, message):
"""
:param groupid:
:type groupid: str
:param message:
:type message: bytes
:return:
:rtype:
"""
logger.debug("group_encrypt(groupid=%s, message=%s)" % (groupid, message))
group_cipher = self._get_... | def group_encrypt(self, groupid, message):
"""
:param groupid:
:type groupid: str
:param message:
:type message: bytes
:return:
:rtype:
"""
logger.debug("group_encrypt(groupid=%s, message=%s)" % (groupid, message))
group_cipher = self._get_... | [
":",
"param",
"groupid",
":",
":",
"type",
"groupid",
":",
"str",
":",
"param",
"message",
":",
":",
"type",
"message",
":",
"bytes",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L192-L203 | [
"def",
"group_encrypt",
"(",
"self",
",",
"groupid",
",",
"message",
")",
":",
"logger",
".",
"debug",
"(",
"\"group_encrypt(groupid=%s, message=%s)\"",
"%",
"(",
"groupid",
",",
"message",
")",
")",
"group_cipher",
"=",
"self",
".",
"_get_group_cipher",
"(",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlManager.group_create_session | :param groupid:
:type groupid: str
:param participantid:
:type participantid: str
:param skmsgdata:
:type skmsgdata: bytearray
:return:
:rtype: | yowsup/axolotl/manager.py | def group_create_session(self, groupid, participantid, skmsgdata):
"""
:param groupid:
:type groupid: str
:param participantid:
:type participantid: str
:param skmsgdata:
:type skmsgdata: bytearray
:return:
:rtype:
"""
logger.debug(... | def group_create_session(self, groupid, participantid, skmsgdata):
"""
:param groupid:
:type groupid: str
:param participantid:
:type participantid: str
:param skmsgdata:
:type skmsgdata: bytearray
:return:
:rtype:
"""
logger.debug(... | [
":",
"param",
"groupid",
":",
":",
"type",
"groupid",
":",
"str",
":",
"param",
"participantid",
":",
":",
"type",
"participantid",
":",
"str",
":",
"param",
"skmsgdata",
":",
":",
"type",
"skmsgdata",
":",
"bytearray",
":",
"return",
":",
":",
"rtype",
... | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L220-L235 | [
"def",
"group_create_session",
"(",
"self",
",",
"groupid",
",",
"participantid",
",",
"skmsgdata",
")",
":",
"logger",
".",
"debug",
"(",
"\"group_create_session(groupid=%s, participantid=%s, skmsgdata=[omitted])\"",
"%",
"(",
"groupid",
",",
"participantid",
")",
")",... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlManager.create_session | :param username:
:type username: str
:param prekeybundle:
:type prekeybundle: PreKeyBundle
:return:
:rtype: | yowsup/axolotl/manager.py | def create_session(self, username, prekeybundle, autotrust=False):
"""
:param username:
:type username: str
:param prekeybundle:
:type prekeybundle: PreKeyBundle
:return:
:rtype:
"""
logger.debug("create_session(username=%s, prekeybunder=[omitted],... | def create_session(self, username, prekeybundle, autotrust=False):
"""
:param username:
:type username: str
:param prekeybundle:
:type prekeybundle: PreKeyBundle
:return:
:rtype:
"""
logger.debug("create_session(username=%s, prekeybunder=[omitted],... | [
":",
"param",
"username",
":",
":",
"type",
"username",
":",
"str",
":",
"param",
"prekeybundle",
":",
":",
"type",
"prekeybundle",
":",
"PreKeyBundle",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L237-L254 | [
"def",
"create_session",
"(",
"self",
",",
"username",
",",
"prekeybundle",
",",
"autotrust",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"create_session(username=%s, prekeybunder=[omitted], autotrust=%s)\"",
"%",
"(",
"username",
",",
"autotrust",
")",
"... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlManager.session_exists | :param username:
:type username: str
:return:
:rtype: | yowsup/axolotl/manager.py | def session_exists(self, username):
"""
:param username:
:type username: str
:return:
:rtype:
"""
logger.debug("session_exists(%s)?" % username)
return self._store.containsSession(username, 1) | def session_exists(self, username):
"""
:param username:
:type username: str
:return:
:rtype:
"""
logger.debug("session_exists(%s)?" % username)
return self._store.containsSession(username, 1) | [
":",
"param",
"username",
":",
":",
"type",
"username",
":",
"str",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/manager.py#L256-L264 | [
"def",
"session_exists",
"(",
"self",
",",
"username",
")",
":",
"logger",
".",
"debug",
"(",
"\"session_exists(%s)?\"",
"%",
"username",
")",
"return",
"self",
".",
"_store",
".",
"containsSession",
"(",
"username",
",",
"1",
")"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | PropsTransform.transform | :param data:
:type data: dict
:return:
:rtype: dict | yowsup/config/transforms/props.py | def transform(self, data):
"""
:param data:
:type data: dict
:return:
:rtype: dict
"""
out = {}
for key, val in data.items():
if key in self._transform_map:
target = self._transform_map[key]
key, val = target(key... | def transform(self, data):
"""
:param data:
:type data: dict
:return:
:rtype: dict
"""
out = {}
for key, val in data.items():
if key in self._transform_map:
target = self._transform_map[key]
key, val = target(key... | [
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"dict",
":",
"return",
":",
":",
"rtype",
":",
"dict"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/transforms/props.py#L10-L26 | [
"def",
"transform",
"(",
"self",
",",
"data",
")",
":",
"out",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"_transform_map",
":",
"target",
"=",
"self",
".",
"_transform_map",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | ConfigManager.load | :param username:
:type username:
:return:
:rtype: | yowsup/config/manager.py | def load(self, username):
"""
:param username:
:type username:
:return:
:rtype:
"""
config_dir = StorageTools.getStorageForPhone(username)
logger.debug("Detecting config for username=%s, dir=%s" % (username, config_dir))
exhausted = []
for ... | def load(self, username):
"""
:param username:
:type username:
:return:
:rtype:
"""
config_dir = StorageTools.getStorageForPhone(username)
logger.debug("Detecting config for username=%s, dir=%s" % (username, config_dir))
exhausted = []
for ... | [
":",
"param",
"username",
":",
":",
"type",
"username",
":",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/manager.py#L33-L56 | [
"def",
"load",
"(",
"self",
",",
"username",
")",
":",
"config_dir",
"=",
"StorageTools",
".",
"getStorageForPhone",
"(",
"username",
")",
"logger",
".",
"debug",
"(",
"\"Detecting config for username=%s, dir=%s\"",
"%",
"(",
"username",
",",
"config_dir",
")",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | ConfigManager._type_to_str | :param type:
:type type: int
:return:
:rtype: | yowsup/config/manager.py | def _type_to_str(self, type):
"""
:param type:
:type type: int
:return:
:rtype:
"""
for key, val in self.TYPE_NAMES.items():
if key == type:
return val | def _type_to_str(self, type):
"""
:param type:
:type type: int
:return:
:rtype:
"""
for key, val in self.TYPE_NAMES.items():
if key == type:
return val | [
":",
"param",
"type",
":",
":",
"type",
"type",
":",
"int",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/manager.py#L58-L67 | [
"def",
"_type_to_str",
"(",
"self",
",",
"type",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"TYPE_NAMES",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"type",
":",
"return",
"val"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | ConfigManager.load_path | :param path:
:type path:
:return:
:rtype: | yowsup/config/manager.py | def load_path(self, path):
"""
:param path:
:type path:
:return:
:rtype:
"""
logger.debug("load_path(path=%s)" % path)
if os.path.isfile(path):
configtype = self.guess_type(path)
logger.debug("Detected config type: %s" % self._type_... | def load_path(self, path):
"""
:param path:
:type path:
:return:
:rtype:
"""
logger.debug("load_path(path=%s)" % path)
if os.path.isfile(path):
configtype = self.guess_type(path)
logger.debug("Detected config type: %s" % self._type_... | [
":",
"param",
"path",
":",
":",
"type",
"path",
":",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/manager.py#L69-L89 | [
"def",
"load_path",
"(",
"self",
",",
"path",
")",
":",
"logger",
".",
"debug",
"(",
"\"load_path(path=%s)\"",
"%",
"path",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"configtype",
"=",
"self",
".",
"guess_type",
"(",
"path",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlControlLayer.receive | :type protocolTreeNode: ProtocolTreeNode | yowsup/layers/axolotl/layer_control.py | def receive(self, protocolTreeNode):
"""
:type protocolTreeNode: ProtocolTreeNode
"""
if not self.processIqRegistry(protocolTreeNode):
if protocolTreeNode.tag == "notification" and protocolTreeNode["type"] == "encrypt":
self.onEncryptNotification(protocolTreeN... | def receive(self, protocolTreeNode):
"""
:type protocolTreeNode: ProtocolTreeNode
"""
if not self.processIqRegistry(protocolTreeNode):
if protocolTreeNode.tag == "notification" and protocolTreeNode["type"] == "encrypt":
self.onEncryptNotification(protocolTreeN... | [
":",
"type",
"protocolTreeNode",
":",
"ProtocolTreeNode"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/axolotl/layer_control.py#L24-L32 | [
"def",
"receive",
"(",
"self",
",",
"protocolTreeNode",
")",
":",
"if",
"not",
"self",
".",
"processIqRegistry",
"(",
"protocolTreeNode",
")",
":",
"if",
"protocolTreeNode",
".",
"tag",
"==",
"\"notification\"",
"and",
"protocolTreeNode",
"[",
"\"type\"",
"]",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlControlLayer.flush_keys | sends prekeys
:return:
:rtype: | yowsup/layers/axolotl/layer_control.py | def flush_keys(self, signed_prekey, prekeys, reboot_connection=False):
"""
sends prekeys
:return:
:rtype:
"""
preKeysDict = {}
for prekey in prekeys:
keyPair = prekey.getKeyPair()
preKeysDict[self.adjustId(prekey.getId())] = self.adjustArra... | def flush_keys(self, signed_prekey, prekeys, reboot_connection=False):
"""
sends prekeys
:return:
:rtype:
"""
preKeysDict = {}
for prekey in prekeys:
keyPair = prekey.getKeyPair()
preKeysDict[self.adjustId(prekey.getId())] = self.adjustArra... | [
"sends",
"prekeys",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/axolotl/layer_control.py#L72-L98 | [
"def",
"flush_keys",
"(",
"self",
",",
"signed_prekey",
",",
"prekeys",
",",
"reboot_connection",
"=",
"False",
")",
":",
"preKeysDict",
"=",
"{",
"}",
"for",
"prekey",
"in",
"prekeys",
":",
"keyPair",
"=",
"prekey",
".",
"getKeyPair",
"(",
")",
"preKeysDi... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | YowStackBuilder.getDefaultStack | :param layer: An optional layer to put on top of default stack
:param axolotl: E2E encryption enabled/ disabled
:return: YowStack | yowsup/stacks/yowstack.py | def getDefaultStack(layer = None, axolotl = False, groups = True, media = True, privacy = True, profiles = True):
"""
:param layer: An optional layer to put on top of default stack
:param axolotl: E2E encryption enabled/ disabled
:return: YowStack
"""
allLayers = YowStac... | def getDefaultStack(layer = None, axolotl = False, groups = True, media = True, privacy = True, profiles = True):
"""
:param layer: An optional layer to put on top of default stack
:param axolotl: E2E encryption enabled/ disabled
:return: YowStack
"""
allLayers = YowStac... | [
":",
"param",
"layer",
":",
"An",
"optional",
"layer",
"to",
"put",
"on",
"top",
"of",
"default",
"stack",
":",
"param",
"axolotl",
":",
"E2E",
"encryption",
"enabled",
"/",
"disabled",
":",
"return",
":",
"YowStack"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/stacks/yowstack.py#L82-L94 | [
"def",
"getDefaultStack",
"(",
"layer",
"=",
"None",
",",
"axolotl",
"=",
"False",
",",
"groups",
"=",
"True",
",",
"media",
"=",
"True",
",",
"privacy",
"=",
"True",
",",
"profiles",
"=",
"True",
")",
":",
"allLayers",
"=",
"YowStackBuilder",
".",
"ge... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | YowInterfaceLayer.processIqRegistry | :type entity: IqProtocolEntity | yowsup/layers/interface/interface.py | def processIqRegistry(self, entity):
"""
:type entity: IqProtocolEntity
"""
if entity.getTag() == "iq":
iq_id = entity.getId()
if iq_id in self.iqRegistry:
originalIq, successClbk, errorClbk = self.iqRegistry[iq_id]
del self.iqRegis... | def processIqRegistry(self, entity):
"""
:type entity: IqProtocolEntity
"""
if entity.getTag() == "iq":
iq_id = entity.getId()
if iq_id in self.iqRegistry:
originalIq, successClbk, errorClbk = self.iqRegistry[iq_id]
del self.iqRegis... | [
":",
"type",
"entity",
":",
"IqProtocolEntity"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/interface/interface.py#L45-L61 | [
"def",
"processIqRegistry",
"(",
"self",
",",
"entity",
")",
":",
"if",
"entity",
".",
"getTag",
"(",
")",
"==",
"\"iq\"",
":",
"iq_id",
"=",
"entity",
".",
"getId",
"(",
")",
"if",
"iq_id",
"in",
"self",
".",
"iqRegistry",
":",
"originalIq",
",",
"s... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | DictKeyValTransform.transform | :param data:
:type data: dict
:return:
:rtype: | yowsup/config/transforms/dict_keyval.py | def transform(self, data):
"""
:param data:
:type data: dict
:return:
:rtype:
"""
out=[]
keys = sorted(data.keys())
for k in keys:
out.append("%s=%s" % (k, data[k]))
return "\n".join(out) | def transform(self, data):
"""
:param data:
:type data: dict
:return:
:rtype:
"""
out=[]
keys = sorted(data.keys())
for k in keys:
out.append("%s=%s" % (k, data[k]))
return "\n".join(out) | [
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"dict",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/transforms/dict_keyval.py#L5-L16 | [
"def",
"transform",
"(",
"self",
",",
"data",
")",
":",
"out",
"=",
"[",
"]",
"keys",
"=",
"sorted",
"(",
"data",
".",
"keys",
"(",
")",
")",
"for",
"k",
"in",
"keys",
":",
"out",
".",
"append",
"(",
"\"%s=%s\"",
"%",
"(",
"k",
",",
"data",
"... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | ConfigSerialize.serialize | :param config:
:type config: yowsup.config.base.config.Config
:return:
:rtype: bytes | yowsup/config/base/serialize.py | def serialize(self, config):
"""
:param config:
:type config: yowsup.config.base.config.Config
:return:
:rtype: bytes
"""
for transform in self._transforms:
config = transform.transform(config)
return config | def serialize(self, config):
"""
:param config:
:type config: yowsup.config.base.config.Config
:return:
:rtype: bytes
"""
for transform in self._transforms:
config = transform.transform(config)
return config | [
":",
"param",
"config",
":",
":",
"type",
"config",
":",
"yowsup",
".",
"config",
".",
"base",
".",
"config",
".",
"Config",
":",
"return",
":",
":",
"rtype",
":",
"bytes"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/base/serialize.py#L6-L15 | [
"def",
"serialize",
"(",
"self",
",",
"config",
")",
":",
"for",
"transform",
"in",
"self",
".",
"_transforms",
":",
"config",
"=",
"transform",
".",
"transform",
"(",
"config",
")",
"return",
"config"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | ConfigSerialize.deserialize | :type cls: type
:param data:
:type data: bytes
:return:
:rtype: yowsup.config.base.config.Config | yowsup/config/base/serialize.py | def deserialize(self, data):
"""
:type cls: type
:param data:
:type data: bytes
:return:
:rtype: yowsup.config.base.config.Config
"""
for transform in self._transforms[::-1]:
data = transform.reverse(data)
return data | def deserialize(self, data):
"""
:type cls: type
:param data:
:type data: bytes
:return:
:rtype: yowsup.config.base.config.Config
"""
for transform in self._transforms[::-1]:
data = transform.reverse(data)
return data | [
":",
"type",
"cls",
":",
"type",
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"bytes",
":",
"return",
":",
":",
"rtype",
":",
"yowsup",
".",
"config",
".",
"base",
".",
"config",
".",
"Config"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/config/base/serialize.py#L17-L27 | [
"def",
"deserialize",
"(",
"self",
",",
"data",
")",
":",
"for",
"transform",
"in",
"self",
".",
"_transforms",
"[",
":",
":",
"-",
"1",
"]",
":",
"data",
"=",
"transform",
".",
"reverse",
"(",
"data",
")",
"return",
"data"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | LiteSenderKeyStore.storeSenderKey | :type senderKeyName: SenderKeName
:type senderKeyRecord: SenderKeyRecord | yowsup/axolotl/store/sqlite/litesenderkeystore.py | def storeSenderKey(self, senderKeyName, senderKeyRecord):
"""
:type senderKeyName: SenderKeName
:type senderKeyRecord: SenderKeyRecord
"""
q = "INSERT INTO sender_keys (group_id, sender_id, record) VALUES(?,?, ?)"
cursor = self.dbConn.cursor()
serialized = senderK... | def storeSenderKey(self, senderKeyName, senderKeyRecord):
"""
:type senderKeyName: SenderKeName
:type senderKeyRecord: SenderKeyRecord
"""
q = "INSERT INTO sender_keys (group_id, sender_id, record) VALUES(?,?, ?)"
cursor = self.dbConn.cursor()
serialized = senderK... | [
":",
"type",
"senderKeyName",
":",
"SenderKeName",
":",
"type",
"senderKeyRecord",
":",
"SenderKeyRecord"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/store/sqlite/litesenderkeystore.py#L17-L34 | [
"def",
"storeSenderKey",
"(",
"self",
",",
"senderKeyName",
",",
"senderKeyRecord",
")",
":",
"q",
"=",
"\"INSERT INTO sender_keys (group_id, sender_id, record) VALUES(?,?, ?)\"",
"cursor",
"=",
"self",
".",
"dbConn",
".",
"cursor",
"(",
")",
"serialized",
"=",
"sende... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | LiteSenderKeyStore.loadSenderKey | :type senderKeyName: SenderKeyName | yowsup/axolotl/store/sqlite/litesenderkeystore.py | def loadSenderKey(self, senderKeyName):
"""
:type senderKeyName: SenderKeyName
"""
q = "SELECT record FROM sender_keys WHERE group_id = ? and sender_id = ?"
cursor = self.dbConn.cursor()
cursor.execute(q, (senderKeyName.getGroupId(), senderKeyName.getSender().getName()))
... | def loadSenderKey(self, senderKeyName):
"""
:type senderKeyName: SenderKeyName
"""
q = "SELECT record FROM sender_keys WHERE group_id = ? and sender_id = ?"
cursor = self.dbConn.cursor()
cursor.execute(q, (senderKeyName.getGroupId(), senderKeyName.getSender().getName()))
... | [
":",
"type",
"senderKeyName",
":",
"SenderKeyName"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/axolotl/store/sqlite/litesenderkeystore.py#L36-L47 | [
"def",
"loadSenderKey",
"(",
"self",
",",
"senderKeyName",
")",
":",
"q",
"=",
"\"SELECT record FROM sender_keys WHERE group_id = ? and sender_id = ?\"",
"cursor",
"=",
"self",
".",
"dbConn",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"q",
",",
"(",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | YowMediaProtocolLayer.sendIq | :type entity: IqProtocolEntity | yowsup/layers/protocol_media/layer.py | def sendIq(self, entity):
"""
:type entity: IqProtocolEntity
"""
if entity.getType() == IqProtocolEntity.TYPE_SET and entity.getXmlns() == "w:m":
#media upload!
self._sendIq(entity, self.onRequestUploadSuccess, self.onRequestUploadError) | def sendIq(self, entity):
"""
:type entity: IqProtocolEntity
"""
if entity.getType() == IqProtocolEntity.TYPE_SET and entity.getXmlns() == "w:m":
#media upload!
self._sendIq(entity, self.onRequestUploadSuccess, self.onRequestUploadError) | [
":",
"type",
"entity",
":",
"IqProtocolEntity"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/protocol_media/layer.py#L56-L62 | [
"def",
"sendIq",
"(",
"self",
",",
"entity",
")",
":",
"if",
"entity",
".",
"getType",
"(",
")",
"==",
"IqProtocolEntity",
".",
"TYPE_SET",
"and",
"entity",
".",
"getXmlns",
"(",
")",
"==",
"\"w:m\"",
":",
"#media upload!",
"self",
".",
"_sendIq",
"(",
... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | AxolotlReceivelayer.receive | :type protocolTreeNode: ProtocolTreeNode | yowsup/layers/axolotl/layer_receive.py | def receive(self, protocolTreeNode):
"""
:type protocolTreeNode: ProtocolTreeNode
"""
if not self.processIqRegistry(protocolTreeNode):
if protocolTreeNode.tag == "message":
self.onMessage(protocolTreeNode)
elif not protocolTreeNode.tag == "receipt"... | def receive(self, protocolTreeNode):
"""
:type protocolTreeNode: ProtocolTreeNode
"""
if not self.processIqRegistry(protocolTreeNode):
if protocolTreeNode.tag == "message":
self.onMessage(protocolTreeNode)
elif not protocolTreeNode.tag == "receipt"... | [
":",
"type",
"protocolTreeNode",
":",
"ProtocolTreeNode"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/axolotl/layer_receive.py#L25-L34 | [
"def",
"receive",
"(",
"self",
",",
"protocolTreeNode",
")",
":",
"if",
"not",
"self",
".",
"processIqRegistry",
"(",
"protocolTreeNode",
")",
":",
"if",
"protocolTreeNode",
".",
"tag",
"==",
"\"message\"",
":",
"self",
".",
"onMessage",
"(",
"protocolTreeNode... | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | YowNoiseLayer.send | :param data:
:type data: bytearray | bytes
:return:
:rtype: | yowsup/layers/noise/layer.py | def send(self, data):
"""
:param data:
:type data: bytearray | bytes
:return:
:rtype:
"""
data = bytes(data) if type(data) is not bytes else data
self._wa_noiseprotocol.send(data) | def send(self, data):
"""
:param data:
:type data: bytearray | bytes
:return:
:rtype:
"""
data = bytes(data) if type(data) is not bytes else data
self._wa_noiseprotocol.send(data) | [
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"bytearray",
"|",
"bytes",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/noise/layer.py#L131-L139 | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"bytes",
"(",
"data",
")",
"if",
"type",
"(",
"data",
")",
"is",
"not",
"bytes",
"else",
"data",
"self",
".",
"_wa_noiseprotocol",
".",
"send",
"(",
"data",
")"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
train | YowNoiseLayer.receive | :param data:
:type data: bytes
:return:
:rtype: | yowsup/layers/noise/layer.py | def receive(self, data):
"""
:param data:
:type data: bytes
:return:
:rtype:
"""
self._incoming_segments_queue.put(data)
if not self._in_handshake():
self._flush_incoming_buffer() | def receive(self, data):
"""
:param data:
:type data: bytes
:return:
:rtype:
"""
self._incoming_segments_queue.put(data)
if not self._in_handshake():
self._flush_incoming_buffer() | [
":",
"param",
"data",
":",
":",
"type",
"data",
":",
"bytes",
":",
"return",
":",
":",
"rtype",
":"
] | tgalal/yowsup | python | https://github.com/tgalal/yowsup/blob/b0739461ba962bf221fc76047d9d60d8ce61bc3e/yowsup/layers/noise/layer.py#L147-L156 | [
"def",
"receive",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_incoming_segments_queue",
".",
"put",
"(",
"data",
")",
"if",
"not",
"self",
".",
"_in_handshake",
"(",
")",
":",
"self",
".",
"_flush_incoming_buffer",
"(",
")"
] | b0739461ba962bf221fc76047d9d60d8ce61bc3e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.