repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nicolargo/glances | glances/attribute.py | GlancesAttribute.value | def value(self, new_value):
"""Set a value.
Value is a tuple: (<timestamp>, <new_value>)
"""
self._value = (datetime.now(), new_value)
self.history_add(self._value) | python | def value(self, new_value):
"""Set a value.
Value is a tuple: (<timestamp>, <new_value>)
"""
self._value = (datetime.now(), new_value)
self.history_add(self._value) | [
"def",
"value",
"(",
"self",
",",
"new_value",
")",
":",
"self",
".",
"_value",
"=",
"(",
"datetime",
".",
"now",
"(",
")",
",",
"new_value",
")",
"self",
".",
"history_add",
"(",
"self",
".",
"_value",
")"
] | Set a value.
Value is a tuple: (<timestamp>, <new_value>) | [
"Set",
"a",
"value",
".",
"Value",
"is",
"a",
"tuple",
":",
"(",
"<timestamp",
">",
"<new_value",
">",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L80-L85 | train |
nicolargo/glances | glances/attribute.py | GlancesAttribute.history_add | def history_add(self, value):
"""Add a value in the history
"""
if self._history_max_size is None or self.history_len() < self._history_max_size:
self._history.append(value)
else:
self._history = self._history[1:] + [value] | python | def history_add(self, value):
"""Add a value in the history
"""
if self._history_max_size is None or self.history_len() < self._history_max_size:
self._history.append(value)
else:
self._history = self._history[1:] + [value] | [
"def",
"history_add",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_history_max_size",
"is",
"None",
"or",
"self",
".",
"history_len",
"(",
")",
"<",
"self",
".",
"_history_max_size",
":",
"self",
".",
"_history",
".",
"append",
"(",
"value",... | Add a value in the history | [
"Add",
"a",
"value",
"in",
"the",
"history"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L105-L111 | train |
nicolargo/glances | glances/attribute.py | GlancesAttribute.history_json | def history_json(self, nb=0):
"""Return the history in ISO JSON format"""
return [(i[0].isoformat(), i[1]) for i in self._history[-nb:]] | python | def history_json(self, nb=0):
"""Return the history in ISO JSON format"""
return [(i[0].isoformat(), i[1]) for i in self._history[-nb:]] | [
"def",
"history_json",
"(",
"self",
",",
"nb",
"=",
"0",
")",
":",
"return",
"[",
"(",
"i",
"[",
"0",
"]",
".",
"isoformat",
"(",
")",
",",
"i",
"[",
"1",
"]",
")",
"for",
"i",
"in",
"self",
".",
"_history",
"[",
"-",
"nb",
":",
"]",
"]"
] | Return the history in ISO JSON format | [
"Return",
"the",
"history",
"in",
"ISO",
"JSON",
"format"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L133-L135 | train |
nicolargo/glances | glances/attribute.py | GlancesAttribute.history_mean | def history_mean(self, nb=5):
"""Return the mean on the <nb> values in the history.
"""
_, v = zip(*self._history)
return sum(v[-nb:]) / float(v[-1] - v[-nb]) | python | def history_mean(self, nb=5):
"""Return the mean on the <nb> values in the history.
"""
_, v = zip(*self._history)
return sum(v[-nb:]) / float(v[-1] - v[-nb]) | [
"def",
"history_mean",
"(",
"self",
",",
"nb",
"=",
"5",
")",
":",
"_",
",",
"v",
"=",
"zip",
"(",
"*",
"self",
".",
"_history",
")",
"return",
"sum",
"(",
"v",
"[",
"-",
"nb",
":",
"]",
")",
"/",
"float",
"(",
"v",
"[",
"-",
"1",
"]",
"-... | Return the mean on the <nb> values in the history. | [
"Return",
"the",
"mean",
"on",
"the",
"<nb",
">",
"values",
"in",
"the",
"history",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/attribute.py#L137-L141 | train |
nicolargo/glances | glances/amps_list.py | AmpsList.load_configs | def load_configs(self):
"""Load the AMP configuration files."""
if self.config is None:
return False
# Display a warning (deprecated) message if the monitor section exist
if "monitor" in self.config.sections():
logger.warning("A deprecated [monitor] section exist... | python | def load_configs(self):
"""Load the AMP configuration files."""
if self.config is None:
return False
# Display a warning (deprecated) message if the monitor section exist
if "monitor" in self.config.sections():
logger.warning("A deprecated [monitor] section exist... | [
"def",
"load_configs",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
"is",
"None",
":",
"return",
"False",
"# Display a warning (deprecated) message if the monitor section exist",
"if",
"\"monitor\"",
"in",
"self",
".",
"config",
".",
"sections",
"(",
")",
"... | Load the AMP configuration files. | [
"Load",
"the",
"AMP",
"configuration",
"files",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L54-L91 | train |
nicolargo/glances | glances/amps_list.py | AmpsList.update | def update(self):
"""Update the command result attributed."""
# Get the current processes list (once)
processlist = glances_processes.getlist()
# Iter upon the AMPs dict
for k, v in iteritems(self.get()):
if not v.enable():
# Do not update if the enab... | python | def update(self):
"""Update the command result attributed."""
# Get the current processes list (once)
processlist = glances_processes.getlist()
# Iter upon the AMPs dict
for k, v in iteritems(self.get()):
if not v.enable():
# Do not update if the enab... | [
"def",
"update",
"(",
"self",
")",
":",
"# Get the current processes list (once)",
"processlist",
"=",
"glances_processes",
".",
"getlist",
"(",
")",
"# Iter upon the AMPs dict",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"get",
"(",
")",
")",
... | Update the command result attributed. | [
"Update",
"the",
"command",
"result",
"attributed",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L105-L133 | train |
nicolargo/glances | glances/amps_list.py | AmpsList._build_amps_list | def _build_amps_list(self, amp_value, processlist):
"""Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression
"""
ret = []
try:
# Search in both cmdline and name (for kernel thread, see #1261)
... | python | def _build_amps_list(self, amp_value, processlist):
"""Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression
"""
ret = []
try:
# Search in both cmdline and name (for kernel thread, see #1261)
... | [
"def",
"_build_amps_list",
"(",
"self",
",",
"amp_value",
",",
"processlist",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"# Search in both cmdline and name (for kernel thread, see #1261)",
"for",
"p",
"in",
"processlist",
":",
"add_it",
"=",
"False",
"if",
"(",
... | Return the AMPS process list according to the amp_value
Search application monitored processes by a regular expression | [
"Return",
"the",
"AMPS",
"process",
"list",
"according",
"to",
"the",
"amp_value"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps_list.py#L135-L160 | train |
nicolargo/glances | glances/exports/glances_csv.py | Export.update | def update(self, stats):
"""Update stats in the CSV output file."""
# Get the stats
all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
# Init data with timestamp (issue#708)
if self.first_line:
csv_header = ['timestamp']
csv_data = [t... | python | def update(self, stats):
"""Update stats in the CSV output file."""
# Get the stats
all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())
# Init data with timestamp (issue#708)
if self.first_line:
csv_header = ['timestamp']
csv_data = [t... | [
"def",
"update",
"(",
"self",
",",
"stats",
")",
":",
"# Get the stats",
"all_stats",
"=",
"stats",
".",
"getAllExportsAsDict",
"(",
"plugin_list",
"=",
"self",
".",
"plugins_to_export",
"(",
")",
")",
"# Init data with timestamp (issue#708)",
"if",
"self",
".",
... | Update stats in the CSV output file. | [
"Update",
"stats",
"in",
"the",
"CSV",
"output",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_csv.py#L64-L98 | train |
nicolargo/glances | glances/cpu_percent.py | CpuPercent.__get_cpu | def __get_cpu(self):
"""Update and/or return the CPU using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_cpu.finished():
self.cpu_percent = psutil.cpu_percent(interval=0.0)
# Reset timer for cache
self.timer_cpu = Timer(s... | python | def __get_cpu(self):
"""Update and/or return the CPU using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_cpu.finished():
self.cpu_percent = psutil.cpu_percent(interval=0.0)
# Reset timer for cache
self.timer_cpu = Timer(s... | [
"def",
"__get_cpu",
"(",
"self",
")",
":",
"# Never update more than 1 time per cached_time",
"if",
"self",
".",
"timer_cpu",
".",
"finished",
"(",
")",
":",
"self",
".",
"cpu_percent",
"=",
"psutil",
".",
"cpu_percent",
"(",
"interval",
"=",
"0.0",
")",
"# Re... | Update and/or return the CPU using the psutil library. | [
"Update",
"and",
"/",
"or",
"return",
"the",
"CPU",
"using",
"the",
"psutil",
"library",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/cpu_percent.py#L53-L60 | train |
nicolargo/glances | glances/cpu_percent.py | CpuPercent.__get_percpu | def __get_percpu(self):
"""Update and/or return the per CPU list using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_percpu.finished():
self.percpu_percent = []
for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=... | python | def __get_percpu(self):
"""Update and/or return the per CPU list using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_percpu.finished():
self.percpu_percent = []
for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=... | [
"def",
"__get_percpu",
"(",
"self",
")",
":",
"# Never update more than 1 time per cached_time",
"if",
"self",
".",
"timer_percpu",
".",
"finished",
"(",
")",
":",
"self",
".",
"percpu_percent",
"=",
"[",
"]",
"for",
"cpu_number",
",",
"cputimes",
"in",
"enumera... | Update and/or return the per CPU list using the psutil library. | [
"Update",
"and",
"/",
"or",
"return",
"the",
"per",
"CPU",
"list",
"using",
"the",
"psutil",
"library",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/cpu_percent.py#L62-L93 | train |
nicolargo/glances | glances/standalone.py | GlancesStandalone.display_modules_list | def display_modules_list(self):
"""Display modules list"""
print("Plugins list: {}".format(
', '.join(sorted(self.stats.getPluginsList(enable=False)))))
print("Exporters list: {}".format(
', '.join(sorted(self.stats.getExportsList(enable=False))))) | python | def display_modules_list(self):
"""Display modules list"""
print("Plugins list: {}".format(
', '.join(sorted(self.stats.getPluginsList(enable=False)))))
print("Exporters list: {}".format(
', '.join(sorted(self.stats.getExportsList(enable=False))))) | [
"def",
"display_modules_list",
"(",
"self",
")",
":",
"print",
"(",
"\"Plugins list: {}\"",
".",
"format",
"(",
"', '",
".",
"join",
"(",
"sorted",
"(",
"self",
".",
"stats",
".",
"getPluginsList",
"(",
"enable",
"=",
"False",
")",
")",
")",
")",
")",
... | Display modules list | [
"Display",
"modules",
"list"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L102-L107 | train |
nicolargo/glances | glances/standalone.py | GlancesStandalone.__serve_forever | def __serve_forever(self):
"""Main loop for the CLI.
return True if we should continue (no exit key has been pressed)
"""
# Start a counter used to compute the time needed for
# update and export the stats
counter = Counter()
# Update stats
self.stats.up... | python | def __serve_forever(self):
"""Main loop for the CLI.
return True if we should continue (no exit key has been pressed)
"""
# Start a counter used to compute the time needed for
# update and export the stats
counter = Counter()
# Update stats
self.stats.up... | [
"def",
"__serve_forever",
"(",
"self",
")",
":",
"# Start a counter used to compute the time needed for",
"# update and export the stats",
"counter",
"=",
"Counter",
"(",
")",
"# Update stats",
"self",
".",
"stats",
".",
"update",
"(",
")",
"logger",
".",
"debug",
"("... | Main loop for the CLI.
return True if we should continue (no exit key has been pressed) | [
"Main",
"loop",
"for",
"the",
"CLI",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L109-L143 | train |
nicolargo/glances | glances/standalone.py | GlancesStandalone.serve_forever | def serve_forever(self):
"""Wrapper to the serve_forever function."""
loop = True
while loop:
loop = self.__serve_forever()
self.end() | python | def serve_forever(self):
"""Wrapper to the serve_forever function."""
loop = True
while loop:
loop = self.__serve_forever()
self.end() | [
"def",
"serve_forever",
"(",
"self",
")",
":",
"loop",
"=",
"True",
"while",
"loop",
":",
"loop",
"=",
"self",
".",
"__serve_forever",
"(",
")",
"self",
".",
"end",
"(",
")"
] | Wrapper to the serve_forever function. | [
"Wrapper",
"to",
"the",
"serve_forever",
"function",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L145-L150 | train |
nicolargo/glances | glances/standalone.py | GlancesStandalone.end | def end(self):
"""End of the standalone CLI."""
if not self.quiet:
self.screen.end()
# Exit from export modules
self.stats.end()
# Check Glances version versus PyPI one
if self.outdated.is_outdated():
print("You are using Glances version {}, howe... | python | def end(self):
"""End of the standalone CLI."""
if not self.quiet:
self.screen.end()
# Exit from export modules
self.stats.end()
# Check Glances version versus PyPI one
if self.outdated.is_outdated():
print("You are using Glances version {}, howe... | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"self",
".",
"screen",
".",
"end",
"(",
")",
"# Exit from export modules",
"self",
".",
"stats",
".",
"end",
"(",
")",
"# Check Glances version versus PyPI one",
"if",
"self",
"."... | End of the standalone CLI. | [
"End",
"of",
"the",
"standalone",
"CLI",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/standalone.py#L152-L164 | train |
nicolargo/glances | glances/password.py | GlancesPassword.get_hash | def get_hash(self, salt, plain_password):
"""Return the hashed password, salt + SHA-256."""
return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest() | python | def get_hash(self, salt, plain_password):
"""Return the hashed password, salt + SHA-256."""
return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest() | [
"def",
"get_hash",
"(",
"self",
",",
"salt",
",",
"plain_password",
")",
":",
"return",
"hashlib",
".",
"sha256",
"(",
"salt",
".",
"encode",
"(",
")",
"+",
"plain_password",
".",
"encode",
"(",
")",
")",
".",
"hexdigest",
"(",
")"
] | Return the hashed password, salt + SHA-256. | [
"Return",
"the",
"hashed",
"password",
"salt",
"+",
"SHA",
"-",
"256",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L49-L51 | train |
nicolargo/glances | glances/password.py | GlancesPassword.hash_password | def hash_password(self, plain_password):
"""Hash password with a salt based on UUID (universally unique identifier)."""
salt = uuid.uuid4().hex
encrypted_password = self.get_hash(salt, plain_password)
return salt + '$' + encrypted_password | python | def hash_password(self, plain_password):
"""Hash password with a salt based on UUID (universally unique identifier)."""
salt = uuid.uuid4().hex
encrypted_password = self.get_hash(salt, plain_password)
return salt + '$' + encrypted_password | [
"def",
"hash_password",
"(",
"self",
",",
"plain_password",
")",
":",
"salt",
"=",
"uuid",
".",
"uuid4",
"(",
")",
".",
"hex",
"encrypted_password",
"=",
"self",
".",
"get_hash",
"(",
"salt",
",",
"plain_password",
")",
"return",
"salt",
"+",
"'$'",
"+",... | Hash password with a salt based on UUID (universally unique identifier). | [
"Hash",
"password",
"with",
"a",
"salt",
"based",
"on",
"UUID",
"(",
"universally",
"unique",
"identifier",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L53-L57 | train |
nicolargo/glances | glances/password.py | GlancesPassword.check_password | def check_password(self, hashed_password, plain_password):
"""Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password.
"""
salt, encrypted_password = hashed_password.split('$')
re_encrypted_password = self.get_hash(salt, ... | python | def check_password(self, hashed_password, plain_password):
"""Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password.
"""
salt, encrypted_password = hashed_password.split('$')
re_encrypted_password = self.get_hash(salt, ... | [
"def",
"check_password",
"(",
"self",
",",
"hashed_password",
",",
"plain_password",
")",
":",
"salt",
",",
"encrypted_password",
"=",
"hashed_password",
".",
"split",
"(",
"'$'",
")",
"re_encrypted_password",
"=",
"self",
".",
"get_hash",
"(",
"salt",
",",
"p... | Encode the plain_password with the salt of the hashed_password.
Return the comparison with the encrypted_password. | [
"Encode",
"the",
"plain_password",
"with",
"the",
"salt",
"of",
"the",
"hashed_password",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L59-L66 | train |
nicolargo/glances | glances/password.py | GlancesPassword.get_password | def get_password(self, description='', confirm=False, clear=False):
"""Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the passwo... | python | def get_password(self, description='', confirm=False, clear=False):
"""Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the passwo... | [
"def",
"get_password",
"(",
"self",
",",
"description",
"=",
"''",
",",
"confirm",
"=",
"False",
",",
"clear",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"password_file",
")",
"and",
"not",
"clear",
":",
"# If t... | Get the password from a Glances client or server.
For Glances server, get the password (confirm=True, clear=False):
1) from the password file (if it exists)
2) from the CLI
Optionally: save the password to a file (hashed with salt + SHA-256)
For Glances client, get the ... | [
"Get",
"the",
"password",
"from",
"a",
"Glances",
"client",
"or",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L68-L110 | train |
nicolargo/glances | glances/password.py | GlancesPassword.save_password | def save_password(self, hashed_password):
"""Save the hashed password to the Glances folder."""
# Create the glances directory
safe_makedirs(self.password_dir)
# Create/overwrite the password file
with open(self.password_file, 'wb') as file_pwd:
file_pwd.write(b(hash... | python | def save_password(self, hashed_password):
"""Save the hashed password to the Glances folder."""
# Create the glances directory
safe_makedirs(self.password_dir)
# Create/overwrite the password file
with open(self.password_file, 'wb') as file_pwd:
file_pwd.write(b(hash... | [
"def",
"save_password",
"(",
"self",
",",
"hashed_password",
")",
":",
"# Create the glances directory",
"safe_makedirs",
"(",
"self",
".",
"password_dir",
")",
"# Create/overwrite the password file",
"with",
"open",
"(",
"self",
".",
"password_file",
",",
"'wb'",
")"... | Save the hashed password to the Glances folder. | [
"Save",
"the",
"hashed",
"password",
"to",
"the",
"Glances",
"folder",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L112-L119 | train |
nicolargo/glances | glances/password.py | GlancesPassword.load_password | def load_password(self):
"""Load the hashed password from the Glances folder."""
# Read the password file, if it exists
with open(self.password_file, 'r') as file_pwd:
hashed_password = file_pwd.read()
return hashed_password | python | def load_password(self):
"""Load the hashed password from the Glances folder."""
# Read the password file, if it exists
with open(self.password_file, 'r') as file_pwd:
hashed_password = file_pwd.read()
return hashed_password | [
"def",
"load_password",
"(",
"self",
")",
":",
"# Read the password file, if it exists",
"with",
"open",
"(",
"self",
".",
"password_file",
",",
"'r'",
")",
"as",
"file_pwd",
":",
"hashed_password",
"=",
"file_pwd",
".",
"read",
"(",
")",
"return",
"hashed_passw... | Load the hashed password from the Glances folder. | [
"Load",
"the",
"hashed",
"password",
"from",
"the",
"Glances",
"folder",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L121-L127 | train |
nicolargo/glances | glances/outputs/glances_sparklines.py | Sparkline.get | def get(self):
"""Return the sparkline."""
ret = sparklines(self.percents)[0]
if self.__with_text:
percents_without_none = [x for x in self.percents if x is not None]
if len(percents_without_none) > 0:
ret = '{}{:5.1f}%'.format(ret, percents_without_none[-... | python | def get(self):
"""Return the sparkline."""
ret = sparklines(self.percents)[0]
if self.__with_text:
percents_without_none = [x for x in self.percents if x is not None]
if len(percents_without_none) > 0:
ret = '{}{:5.1f}%'.format(ret, percents_without_none[-... | [
"def",
"get",
"(",
"self",
")",
":",
"ret",
"=",
"sparklines",
"(",
"self",
".",
"percents",
")",
"[",
"0",
"]",
"if",
"self",
".",
"__with_text",
":",
"percents_without_none",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"percents",
"if",
"x",
"i... | Return the sparkline. | [
"Return",
"the",
"sparkline",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_sparklines.py#L89-L96 | train |
nicolargo/glances | glances/plugins/glances_cpu.py | Plugin.update | def update(self):
"""Update CPU stats using the input method."""
# Grab stats into self.stats
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init... | python | def update(self):
"""Update CPU stats using the input method."""
# Grab stats into self.stats
if self.input_method == 'local':
stats = self.update_local()
elif self.input_method == 'snmp':
stats = self.update_snmp()
else:
stats = self.get_init... | [
"def",
"update",
"(",
"self",
")",
":",
"# Grab stats into self.stats",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"stats",
"=",
"self",
".",
"update_local",
"(",
")",
"elif",
"self",
".",
"input_method",
"==",
"'snmp'",
":",
"stats",
"=",
"s... | Update CPU stats using the input method. | [
"Update",
"CPU",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L77-L91 | train |
nicolargo/glances | glances/plugins/glances_cpu.py | Plugin.update_local | def update_local(self):
"""Update CPU stats using psutil."""
# Grab CPU stats using psutil's cpu_percent and cpu_times_percent
# Get all possible values for CPU stats: user, system, idle,
# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)
# The following s... | python | def update_local(self):
"""Update CPU stats using psutil."""
# Grab CPU stats using psutil's cpu_percent and cpu_times_percent
# Get all possible values for CPU stats: user, system, idle,
# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)
# The following s... | [
"def",
"update_local",
"(",
"self",
")",
":",
"# Grab CPU stats using psutil's cpu_percent and cpu_times_percent",
"# Get all possible values for CPU stats: user, system, idle,",
"# nice (UNIX), iowait (Linux), irq (Linux, FreeBSD), steal (Linux 2.6.11+)",
"# The following stats are returned by th... | Update CPU stats using psutil. | [
"Update",
"CPU",
"stats",
"using",
"psutil",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L93-L139 | train |
nicolargo/glances | glances/plugins/glances_cpu.py | Plugin.update_snmp | def update_snmp(self):
"""Update CPU stats using SNMP."""
# Init new stats
stats = self.get_init_value()
# Update stats using SNMP
if self.short_system_name in ('windows', 'esxi'):
# Windows or VMWare ESXi
# You can find the CPU utilization of windows sy... | python | def update_snmp(self):
"""Update CPU stats using SNMP."""
# Init new stats
stats = self.get_init_value()
# Update stats using SNMP
if self.short_system_name in ('windows', 'esxi'):
# Windows or VMWare ESXi
# You can find the CPU utilization of windows sy... | [
"def",
"update_snmp",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# Update stats using SNMP",
"if",
"self",
".",
"short_system_name",
"in",
"(",
"'windows'",
",",
"'esxi'",
")",
":",
"# Windows or VMWare ESXi"... | Update CPU stats using SNMP. | [
"Update",
"CPU",
"stats",
"using",
"SNMP",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L141-L188 | train |
nicolargo/glances | glances/plugins/glances_cpu.py | Plugin.update_views | 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... | python | 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",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert and log",
"for",
"key",
"in",
"[",
"'user'",
",",
"'system'",
",",
"'iow... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L190-L211 | train |
nicolargo/glances | glances/plugins/glances_cpu.py | Plugin.msg_curse | 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... | python | 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",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and plugin not disable",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
... | Return the list to display in the UI. | [
"Return",
"the",
"list",
"to",
"display",
"in",
"the",
"UI",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_cpu.py#L213-L342 | train |
nicolargo/glances | glances/plugins/glances_wifi.py | Plugin.update | 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 ... | python | 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",
")",
":",
"# 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'",
":",
... | 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) | [
"Update",
"Wifi",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L69-L130 | train |
nicolargo/glances | glances/plugins/glances_wifi.py | Plugin.get_alert | 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):
... | python | 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",
")",
":",
"ret",
"=",
"'OK'",
"try",
":",
"if",
"value",
"<=",
"self",
".",
"get_limit",
"(",
"'critical'",
",",
"stat_name",
"=",
"self",
".",
"plugin_name",
")",
":",
"ret",
"=",
"'CRITICAL'",
"elif",
... | Overwrite the default get_alert method.
Alert is on signal quality where lower is better...
:returns: string -- Signal alert | [
"Overwrite",
"the",
"default",
"get_alert",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L132-L151 | train |
nicolargo/glances | glances/plugins/glances_wifi.py | Plugin.update_views | 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... | python | 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",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert on signal thresholds",
"for",
"i",
"in",
"self",
".",
"stats",
":",
"self"... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L153-L162 | train |
nicolargo/glances | glances/plugins/glances_wifi.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or import_error_tag or self.is_disable():
return r... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or import_error_tag or self.is_disable():
return r... | [
"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... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_wifi.py#L164-L208 | train |
nicolargo/glances | glances/plugins/glances_fs.py | Plugin.update | 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... | python | 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",
")",
":",
"# 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",... | Update the FS stats using the input method. | [
"Update",
"the",
"FS",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L88-L181 | train |
nicolargo/glances | glances/plugins/glances_fs.py | Plugin.update_views | 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['... | python | 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",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert",
"for",
"i",
"in",
"self",
".",
"stats",
":",
"self",
".",
"views",
... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L183-L192 | train |
nicolargo/glances | glances/plugins/glances_fs.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Max si... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Max si... | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L194-L245 | train |
nicolargo/glances | glances/plugins/glances_mem.py | Plugin.update | 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... | python | 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",
")",
":",
"# 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",... | Update RAM memory stats using the input method. | [
"Update",
"RAM",
"memory",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L72-L154 | train |
nicolargo/glances | glances/plugins/glances_mem.py | Plugin.update_views | 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... | python | 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",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"# Alert and log",
"self",
".",
"views",
"[",
"'used'",
"]",
"[",
"'decoration'",
... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L156-L167 | train |
nicolargo/glances | glances/plugins/glances_mem.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and plugin not disabled
if not self.stats or self.is_disable():
return ret
# Build the s... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and 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",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and plugin not disabled",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_mem.py#L169-L234 | train |
nicolargo/glances | glances/history.py | GlancesHistory.add | 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... | python | 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",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"stats_history",
":",
"self",
".",
"stats_history",
"[",
"key",
"]",
"=",
"Glan... | Add an new item (key, value) to the current history. | [
"Add",
"an",
"new",
"item",
"(",
"key",
"value",
")",
"to",
"the",
"current",
"history",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L37-L45 | train |
nicolargo/glances | glances/history.py | GlancesHistory.get | 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} | python | 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",
")",
":",
"return",
"{",
"i",
":",
"self",
".",
"stats_history",
"[",
"i",
"]",
".",
"history_raw",
"(",
"nb",
"=",
"nb",
")",
"for",
"i",
"in",
"self",
".",
"stats_history",
"}"
] | Get the history as a dict of list | [
"Get",
"the",
"history",
"as",
"a",
"dict",
"of",
"list"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L52-L54 | train |
nicolargo/glances | glances/history.py | GlancesHistory.get_json | 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} | python | 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",
")",
":",
"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) | [
"Get",
"the",
"history",
"as",
"a",
"dict",
"of",
"list",
"(",
"with",
"list",
"JSON",
"compliant",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/history.py#L56-L58 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.load_config | 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... | python | 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",
")",
":",
"# 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",... | Load AMP parameters from the configuration file. | [
"Load",
"AMP",
"parameters",
"from",
"the",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L69-L115 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.enable | 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') | python | 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",
")",
":",
"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). | [
"Return",
"True|False",
"if",
"the",
"AMP",
"is",
"enabled",
"in",
"the",
"configuration",
"file",
"(",
"enable",
"=",
"true|false",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L124-L130 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.one_line | 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') | python | 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",
")",
":",
"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). | [
"Return",
"True|False",
"if",
"the",
"AMP",
"shoukd",
"be",
"displayed",
"in",
"oneline",
"(",
"one_lineline",
"=",
"true|false",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L140-L146 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.should_update | 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... | python | 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",
")",
":",
"if",
"self",
".",
"timer",
".",
"finished",
"(",
")",
":",
"self",
".",
"timer",
".",
"set",
"(",
"self",
".",
"refresh",
"(",
")",
")",
"self",
".",
"timer",
".",
"reset",
"(",
")",
"return",
"self... | Return True is the AMP should be updated:
- AMP is enable
- only update every 'refresh' seconds | [
"Return",
"True",
"is",
"the",
"AMP",
"should",
"be",
"updated",
":",
"-",
"AMP",
"is",
"enable",
"-",
"only",
"update",
"every",
"refresh",
"seconds"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L152-L161 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.set_result | 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... | python | 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",
"=",
"''",
")",
":",
"if",
"self",
".",
"one_line",
"(",
")",
":",
"self",
".",
"configs",
"[",
"'result'",
"]",
"=",
"str",
"(",
"result",
")",
".",
"replace",
"(",
"'\\n'",
",",
... | Store the result (string) into the result key of the AMP
if one_line is true then replace \n by separator | [
"Store",
"the",
"result",
"(",
"string",
")",
"into",
"the",
"result",
"key",
"of",
"the",
"AMP",
"if",
"one_line",
"is",
"true",
"then",
"replace",
"\\",
"n",
"by",
"separator"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L179-L186 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.result | 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 | python | 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",
")",
":",
"ret",
"=",
"self",
".",
"get",
"(",
"'result'",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"ret",
"=",
"u",
"(",
"ret",
")",
"return",
"ret"
] | Return the result of the AMP (as a string) | [
"Return",
"the",
"result",
"of",
"the",
"AMP",
"(",
"as",
"a",
"string",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L188-L193 | train |
nicolargo/glances | glances/amps/glances_amp.py | GlancesAmp.update_wrapper | 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... | python | 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",
")",
":",
"# Set the number of running process",
"self",
".",
"set_count",
"(",
"len",
"(",
"process_list",
")",
")",
"# Call the children update method",
"if",
"self",
".",
"should_update",
"(",
")",
":",
... | Wrapper for the children update | [
"Wrapper",
"for",
"the",
"children",
"update"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L195-L203 | train |
nicolargo/glances | glances/plugins/glances_processcount.py | Plugin.update | 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
... | python | 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",
")",
":",
"# 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... | Update processes stats using the input method. | [
"Update",
"processes",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processcount.py#L63-L83 | train |
nicolargo/glances | glances/plugins/glances_processcount.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if args.disable_process:
msg = "PROCESSES DISABLED (press 'z' to dis... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if args.disable_process:
msg = "PROCESSES DISABLED (press 'z' to dis... | [
"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",
"... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_processcount.py#L85-L151 | train |
nicolargo/glances | glances/plugins/glances_alert.py | global_message | 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]... | python | 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",
"(",
")",
":",
"# Compute the weight for each item in the tree",
"current_thresholds",
"=",
"glances_thresholds",
".",
"get",
"(",
")",
"for",
"i",
"in",
"tree",
":",
"i",
"[",
"'weight'",
"]",
"=",
"sum",
"(",
"[",
"current_thresholds",
... | Parse the decision tree and return the message.
Note: message corresponding to the current threasholds values | [
"Parse",
"the",
"decision",
"tree",
"and",
"return",
"the",
"message",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L68-L82 | train |
nicolargo/glances | glances/plugins/glances_alert.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if display plugin enable...
if not self.stats or self.is_disable():
return ret
# Build the string messa... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if 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",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
".",
"is_disab... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L111-L160 | train |
nicolargo/glances | glances/plugins/glances_alert.py | Plugin.approx_equal | 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 | python | 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",
")",
":",
"if",
"str",
"(",
"int",
"(",
"a",
")",
")",
".",
"isdigit",
"(",
")",
"and",
"str",
"(",
"int",
"(",
"b",
")",
")",
".",
"isdigit",
"(",
")",
"... | Compare a with b using the tolerance (if numerical). | [
"Compare",
"a",
"with",
"b",
"using",
"the",
"tolerance",
"(",
"if",
"numerical",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_alert.py#L162-L167 | train |
nicolargo/glances | glances/exports/glances_json.py | Export.export | 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... | python | 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",
")",
":",
"# Check for completion of loop for all exports",
"if",
"name",
"==",
"self",
".",
"plugins_to_export",
"(",
")",
"[",
"0",
"]",
"and",
"self",
".",
"buffer",
"!=",
"{",
"}... | Export the stats to the JSON file. | [
"Export",
"the",
"stats",
"to",
"the",
"JSON",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_json.py#L44-L64 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.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() | python | 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",
")",
":",
"for",
"t",
"in",
"itervalues",
"(",
"self",
".",
"thread_list",
")",
":",
"t",
".",
"stop",
"(",
")",
"# Call the father class",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"exit",
"(",
")"
] | Overwrite the exit method to close threads. | [
"Overwrite",
"the",
"exit",
"method",
"to",
"close",
"threads",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L94-L99 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.get_export | 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... | python | 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",
")",
":",
"ret",
"=",
"[",
"]",
"try",
":",
"ret",
"=",
"self",
".",
"stats",
"[",
"'containers'",
"]",
"except",
"KeyError",
"as",
"e",
":",
"logger",
".",
"debug",
"(",
"\"docker plugin - Docker export error {}\"",
".",
... | Overwrite the default export method.
- Only exports containers
- The key is the first container name | [
"Overwrite",
"the",
"default",
"export",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L105-L116 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.connect | 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 | python | 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",
")",
":",
"try",
":",
"ret",
"=",
"docker",
".",
"from_env",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"\"docker plugin - Can not connect to Docker ({})\"",
".",
"format",
"(",
"e",
")",
")... | Connect to the Docker server. | [
"Connect",
"to",
"the",
"Docker",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L118-L126 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin._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) =... | python | 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",
")",
":",
"all_tag",
"=",
"self",
".",
"get_conf_value",
"(",
"'all'",
")",
"if",
"len",
"(",
"all_tag",
")",
"==",
"0",
":",
"return",
"False",
"else",
":",
"return",
"all_tag",
"[",
"0",
"]",
".",
"lower",
"(",
")"... | 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 | [
"Return",
"the",
"all",
"tag",
"of",
"the",
"Glances",
"/",
"Docker",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L128-L139 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.update | 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
... | python | 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",
")",
":",
"# 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 Docker stats using the input method. | [
"Update",
"Docker",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L143-L252 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.get_docker_cpu | 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}
... | python | 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",
")",
":",
"cpu_new",
"=",
"{",
"}",
"ret",
"=",
"{",
"'total'",
":",
"0.0",
"}",
"# Read the stats",
"# For each container, you will find a pseudo-file cpuacct.stat,",
"# containing the CPU usa... | 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} | [
"Return",
"the",
"container",
"CPU",
"usage",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L254-L303 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.get_docker_memory | 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': ...}
"""
... | python | 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",
")",
":",
"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'] = ... | 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",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L305-L326 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.get_docker_network | 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... | python | 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",
")",
":",
"# Init the returned dict",
"network_new",
"=",
"{",
"}",
"# Read the rx/tx stats (in bytes)",
"try",
":",
"netcounters",
"=",
"all_stats",
"[",
"\"networks\"",
"]",
"except",
... | 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... | [
"Return",
"the",
"container",
"network",
"usage",
"using",
"the",
"Docker",
"API",
"(",
"v1",
".",
"0",
"or",
"higher",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L328-L384 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.get_docker_io | 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... | python | 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",
")",
":",
"# Init the returned dict",
"io_new",
"=",
"{",
"}",
"# Read the ior/iow stats (in bytes)",
"try",
":",
"iocounters",
"=",
"all_stats",
"[",
"\"blkio_stats\"",
"]",
"except",
"KeyE... | 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... | [
"Return",
"the",
"container",
"IO",
"usage",
"using",
"the",
"Docker",
"API",
"(",
"v1",
".",
"0",
"or",
"higher",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L386-L447 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.update_views | 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... | python | 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",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"if",
"'containers'",
"not",
"in",
"self",
".",
"stats",
":",
"return",
"False",
"# Add specifics informations",
... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L460-L497 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist (and non null) and display plugin enable...
if not self.stats \
or 'containers' not in self.stats ... | python | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist (and 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",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist (and non null) and display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or... | Return the dict to display in the curse interface. | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L499-L606 | train |
nicolargo/glances | glances/plugins/glances_docker.py | Plugin._msg_name | 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) | python | 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",
")",
":",
"name",
"=",
"container",
"[",
"'name'",
"]",
"if",
"len",
"(",
"name",
")",
">",
"max_width",
":",
"name",
"=",
"'_'",
"+",
"name",
"[",
"-",
"max_width",
"+",
"1",
":"... | Build the container name. | [
"Build",
"the",
"container",
"name",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L608-L615 | train |
nicolargo/glances | glances/plugins/glances_docker.py | ThreadDockerGrabber.run | 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 | python | 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",
")",
":",
"for",
"i",
"in",
"self",
".",
"_stats_stream",
":",
"self",
".",
"_stats",
"=",
"i",
"time",
".",
"sleep",
"(",
"0.1",
")",
"if",
"self",
".",
"stopped",
"(",
")",
":",
"break"
] | Grab the stats.
Infinite loop, should be stopped by calling the stop() method | [
"Grab",
"the",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L651-L660 | train |
nicolargo/glances | glances/plugins/glances_docker.py | ThreadDockerGrabber.stop | def stop(self, timeout=None):
"""Stop the thread."""
logger.debug("docker plugin - Close thread for container {}".format(self._container.name))
self._stopper.set() | python | 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",
")",
":",
"logger",
".",
"debug",
"(",
"\"docker plugin - Close thread for container {}\"",
".",
"format",
"(",
"self",
".",
"_container",
".",
"name",
")",
")",
"self",
".",
"_stopper",
".",
"set",
... | Stop the thread. | [
"Stop",
"the",
"thread",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_docker.py#L672-L675 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.is_enable | 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 ... | python | 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",
")",
":",
"if",
"not",
"plugin_name",
":",
"plugin_name",
"=",
"self",
".",
"plugin_name",
"try",
":",
"d",
"=",
"getattr",
"(",
"self",
".",
"args",
",",
"'disable_'",
"+",
"plugin_name",... | Return true if plugin is enabled. | [
"Return",
"true",
"if",
"plugin",
"is",
"enabled",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L127-L136 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin._json_dumps | 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) | python | 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",
")",
":",
"try",
":",
"return",
"json",
".",
"dumps",
"(",
"d",
")",
"except",
"UnicodeDecodeError",
":",
"return",
"json",
".",
"dumps",
"(",
"d",
",",
"ensure_ascii",
"=",
"False",
")"
] | Return the object 'd' in a JSON format.
Manage the issue #815 for Windows OS | [
"Return",
"the",
"object",
"d",
"in",
"a",
"JSON",
"format",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L142-L150 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.init_stats_history | 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))
... | python | 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",
")",
":",
"if",
"self",
".",
"history_enable",
"(",
")",
":",
"init_list",
"=",
"[",
"a",
"[",
"'name'",
"]",
"for",
"a",
"in",
"self",
".",
"get_items_history_list",
"(",
")",
"]",
"logger",
".",
"debug",
"(",... | Init the stats history (dict of GlancesAttribute). | [
"Init",
"the",
"stats",
"history",
"(",
"dict",
"of",
"GlancesAttribute",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L155-L160 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.reset_stats_history | 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))
... | python | 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",
")",
":",
"if",
"self",
".",
"history_enable",
"(",
")",
":",
"reset_list",
"=",
"[",
"a",
"[",
"'name'",
"]",
"for",
"a",
"in",
"self",
".",
"get_items_history_list",
"(",
")",
"]",
"logger",
".",
"debug",
"(... | Reset the stats history (dict of GlancesAttribute). | [
"Reset",
"the",
"stats",
"history",
"(",
"dict",
"of",
"GlancesAttribute",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L162-L167 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.update_stats_history | 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... | python | 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",
")",
":",
"# 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",
"(",
... | Update stats history. | [
"Update",
"stats",
"history",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L169-L195 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_raw_history | 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)
... | python | 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",
")",
":",
"s",
"=",
"self",
".",
"stats_history",
".",
"get",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"s",
"else",
":",
"if",
"i... | 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 | [
"Return",
"the",
"history",
"(",
"RAW",
"format",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L201-L215 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_json_history | 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)
""... | python | 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",
")",
":",
"s",
"=",
"self",
".",
"stats_history",
".",
"get_json",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"s",
"else",
":",
"if"... | 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",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L217-L232 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stats_history | 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]})
... | python | 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",
")",
":",
"s",
"=",
"self",
".",
"get_json_history",
"(",
"nb",
"=",
"nb",
")",
"if",
"item",
"is",
"None",
":",
"return",
"self",
".",
"_json_dumps",
"(",
"s",... | Return the stats history (JSON format). | [
"Return",
"the",
"stats",
"history",
"(",
"JSON",
"format",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L238-L260 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_trend | 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:
... | python | 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",
")",
":",
"raw_history",
"=",
"self",
".",
"get_raw_history",
"(",
"item",
"=",
"item",
",",
"nb",
"=",
"nb",
")",
"if",
"raw_history",
"is",
"None",
"or",
"len",
"(",
"raw_history",
... | 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. | [
"Get",
"the",
"trend",
"regarding",
"to",
"the",
"last",
"nb",
"values",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L262-L272 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.sorted_stats | 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... | python | 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",
")",
":",
"key",
"=",
"self",
".",
"get_key",
"(",
")",
"return",
"sorted",
"(",
"self",
".",
"stats",
",",
"key",
"=",
"lambda",
"stat",
":",
"tuple",
"(",
"map",
"(",
"lambda",
"part",
":",
"int",
"(",
"part",
... | Get the stats sorted by an alias (if present) or key. | [
"Get",
"the",
"stats",
"sorted",
"by",
"an",
"alias",
"(",
"if",
"present",
")",
"or",
"key",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L294-L300 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stats_snmp | 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... | python | 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",
")",
":",
"snmp_oid",
"=",
"snmp_oid",
"or",
"{",
"}",
"from",
"glances",
".",
"snmp",
"import",
"GlancesSNMPClient",
"# Init the SNMP request",
"clientsnmp",
"=",
... | Update stats using SNMP.
If bulk=True, use a bulk request instead of a get request. | [
"Update",
"stats",
"using",
"SNMP",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L311-L364 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stats_item | 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... | python | 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",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"stats",
",",
"dict",
")",
":",
"try",
":",
"return",
"self",
".",
"_json_dumps",
"(",
"{",
"item",
":",
"self",
".",
"stats",
"[",
"item",
"]",
"}",... | Return the stats object for a specific item in JSON format.
Stats should be a list of dict (processlist, network...) | [
"Return",
"the",
"stats",
"object",
"for",
"a",
"specific",
"item",
"in",
"JSON",
"format",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L378-L399 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stats_value | 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():
... | python | 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",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"stats",
",",
"list",
")",
":",
"return",
"None",
"else",
":",
"if",
"value",
".",
"isdigit",
"(",
")",
":",
"value",
"=",
"int... | Return the stats object for a specific item=value in JSON format.
Stats should be a list of dict (processlist, network...) | [
"Return",
"the",
"stats",
"object",
"for",
"a",
"specific",
"item",
"=",
"value",
"in",
"JSON",
"format",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L401-L416 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.update_views | 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... | python | 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",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"(",
"isinstance",
"(",
"self",
".",
"get_raw",
"(",
")",
",",
"list",
")",
"and",
"self",
".",
"get_raw",
"(",
")",
"is",
"not",
"None",
"and",
"self",
".",
"get_key",
"("... | 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} | [
"Update",
"the",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L418-L454 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_views | 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... | python | 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",
")",
":",
"if",
"item",
"is",
"None",
":",
"item_views",
"=",
"self",
".",
"views",
"else",
":",
"item_views",
"=",
"self",
".",
"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...) | [
"Return",
"the",
"views",
"object",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L460-L483 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_json_views | 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)) | python | 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",
"self",
".",
"_json_dumps",
"(",
"self",
".",
"get_views",
"(",
"item",
",",
"key",
",",
"option",
")",
")"
] | Return the views (in JSON). | [
"Return",
"the",
"views",
"(",
"in",
"JSON",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L485-L487 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.load_limits | 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 ... | python | 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",
")",
":",
"# 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'",
")",... | Load limits from the configuration file, if it exists. | [
"Load",
"limits",
"from",
"the",
"configuration",
"file",
"if",
"it",
"exists",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L489-L513 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stat_name | def get_stat_name(self, header=""):
""""Return the stat name with an optional header"""
ret = self.plugin_name
if header != "":
ret += '_' + header
return ret | python | 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",
"=",
"\"\"",
")",
":",
"ret",
"=",
"self",
".",
"plugin_name",
"if",
"header",
"!=",
"\"\"",
":",
"ret",
"+=",
"'_'",
"+",
"header",
"return",
"ret"
] | Return the stat name with an optional header | [
"Return",
"the",
"stat",
"name",
"with",
"an",
"optional",
"header"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L534-L539 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_alert | 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... | python | 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",
... | 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... | [
"Return",
"the",
"alert",
"status",
"relative",
"to",
"a",
"current",
"value",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L541-L617 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.manage_action | 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... | python | 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",
")",
":",
"# Here is a command line for the current trigger ?",
"try",
":",
"command",
",",
"repeat",
"=",
"self",
".",
"get_limit_action",
"(",
"trigger",
","... | Manage the action for the current stat. | [
"Manage",
"the",
"action",
"for",
"the",
"current",
"stat",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L625-L659 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_alert_log | 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... | python | 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",
")",
":",
"return",
"self",
".",
"get_alert",
"(",
"current",
"=",
"curre... | Get the alert log. | [
"Get",
"the",
"alert",
"log",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L661-L673 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_limit | 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... | python | 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",
"=",
"\"\"",
")",
":",
"# Get the limit for stat + header",
"# Exemple: network_wlan0_rx_careful",
"try",
":",
"limit",
"=",
"self",
".",
"_limits",
"[",
"stat_name",
"+",
"'_'",
"+",
"criticity"... | Return the limit value for the alert. | [
"Return",
"the",
"limit",
"value",
"for",
"the",
"alert",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L675-L689 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_limit_action | 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 ?
... | python | 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",
"=",
"\"\"",
")",
":",
"# Get the action for stat + header",
"# Exemple: network_wlan0_rx_careful_action",
"# Action key available ?",
"ret",
"=",
"[",
"(",
"stat_name",
"+",
"'_'",
"+",
"critic... | Return the tuple (action, repeat) for the alert.
- action is a command line
- repeat is a bool | [
"Return",
"the",
"tuple",
"(",
"action",
"repeat",
")",
"for",
"the",
"alert",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L691-L709 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_limit_log | 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 ... | python | 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",
")",
":",
"# Get the log tag for stat + header",
"# Exemple: network_wlan0_rx_log",
"try",
":",
"log_tag",
"=",
"self",
".",
"_limits",
"[",
"stat_name",
"+",
"'_log'",
"]",
... | Return the log tag for the alert. | [
"Return",
"the",
"log",
"tag",
"for",
"the",
"alert",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L711-L727 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_conf_value | 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... | python | 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",
")",
":",
"if",
"plugin_name",
"is",
"None",
":",
"# If not default use the current plugin name",
"plugin_name",
"=",
"self",
".",
"plugin_name",
"if... | Return the configuration (header_) value for the current plugin.
...or the one given by the plugin_name var. | [
"Return",
"the",
"configuration",
"(",
"header_",
")",
"value",
"for",
"the",
"current",
"plugin",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L729-L745 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.is_hide | 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... | python | 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",
"=",
"\"\"",
")",
":",
"# TODO: possible optimisation: create a re.compile list",
"return",
"not",
"all",
"(",
"j",
"is",
"None",
"for",
"j",
"in",
"[",
"re",
".",
"match",
"(",
"i",
",",
"value",... | 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.* | [
"Return",
"True",
"if",
"the",
"value",
"is",
"in",
"the",
"hide",
"configuration",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L747-L756 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.has_alias | 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... | python | 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",
")",
":",
"try",
":",
"# Force to lower case (issue #1126)",
"return",
"self",
".",
"_limits",
"[",
"self",
".",
"plugin_name",
"+",
"'_'",
"+",
"header",
".",
"lower",
"(",
")",
"+",
"'_'",
"+",
"'alias'",
... | Return the alias name for the relative header or None if nonexist. | [
"Return",
"the",
"alias",
"name",
"for",
"the",
"relative",
"header",
"or",
"None",
"if",
"nonexist",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L758-L765 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.get_stats_display | 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, '... | python | 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",
")",
":",
"display_curse",
"=",
"False",
"if",
"hasattr",
"(",
"self",
",",
"'display_curse'",
")",
":",
"display_curse",
"=",
"self",
".",
"display_curse",
"... | 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 | [
"Return",
"a",
"dict",
"with",
"all",
"the",
"information",
"needed",
"to",
"display",
"the",
"stat",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L771-L796 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.curse_add_line | 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... | python | 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",
"{",
"'msg'",
":",
"msg",
",",
"'decoration'",
"... | 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
... | [
"Return",
"a",
"dict",
"with",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L798-L826 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.auto_unit | 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: ... | python | 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'",
")",
":",
"symbols",
"=",
"(",
"'K'",
",",
"'M'",
",",
"'G'",
",",
"'T'",
",",
"'P'",
",",
"'E'",
",",
"'Z'",
",",
"'Y'",
")",
"if"... | 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... | [
"Make",
"a",
"nice",
"human",
"-",
"readable",
"string",
"out",
"of",
"number",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L845-L895 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin.trend_msg | 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... | python | 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",
")",
":",
"ret",
"=",
"'-'",
"if",
"trend",
"is",
"None",
":",
"ret",
"=",
"' '",
"elif",
"trend",
">",
"significant",
":",
"ret",
"=",
"'/'",
"elif",
"trend",
"<",
"-",
... | Return the trend message.
Do not take into account if trend < significant | [
"Return",
"the",
"trend",
"message",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L897-L909 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin._check_decorator | 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 | python | 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",
")",
":",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"is_enable",
"(",
")",
":",
"ret",
"=",
"fct",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"... | Check if the plugin is enabled. | [
"Check",
"if",
"the",
"plugin",
"is",
"enabled",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L911-L919 | train |
nicolargo/glances | glances/plugins/glances_plugin.py | GlancesPlugin._log_result_decorator | 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_'):],
... | python | 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",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"ret",
"=",
"fct",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
"logger",
".",
"debug",
"(",
"\"%s %s %s return %s\"",
"%",
"(",... | Log (DEBUG) the result of the function fct. | [
"Log",
"(",
"DEBUG",
")",
"the",
"result",
"of",
"the",
"function",
"fct",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_plugin.py#L921-L930 | train |
nicolargo/glances | glances/plugins/glances_hddtemp.py | Plugin.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... | python | 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",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"stats",
"=",
"self",
".",
"glancesgrabhddte... | Update HDD stats using the input method. | [
"Update",
"HDD",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_hddtemp.py#L50-L67 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.