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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.fundm | def fundm(self):
"""以字典形式返回分级母基数据
"""
# 添加当前的ctime
self.__fundm_url = self.__fundm_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__fundm_url)
# 获取返回的json字符串
fundmjson = json.loads(rep.text)
# 格式化返回的json字符串
data = self.fo... | python | def fundm(self):
"""以字典形式返回分级母基数据
"""
# 添加当前的ctime
self.__fundm_url = self.__fundm_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__fundm_url)
# 获取返回的json字符串
fundmjson = json.loads(rep.text)
# 格式化返回的json字符串
data = self.fo... | [
"def",
"fundm",
"(",
"self",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__fundm_url",
"=",
"self",
".",
"__fundm_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=",
"requests",
".",
"get",
... | 以字典形式返回分级母基数据 | [
"以字典形式返回分级母基数据"
] | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L209-L221 | train |
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.fundb | def fundb(self, fields=None, min_volume=0, min_discount=0, forever=False):
"""以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False
"""
if fields is None:
field... | python | def fundb(self, fields=None, min_volume=0, min_discount=0, forever=False):
"""以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False
"""
if fields is None:
field... | [
"def",
"fundb",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"min_volume",
"=",
"0",
",",
"min_discount",
"=",
"0",
",",
"forever",
"=",
"False",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"[",
"]",
"# 添加当前的ctime",
"self",
".",
"_... | 以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False | [
"以字典形式返回分级B数据",
":",
"param",
"fields",
":",
"利率范围,形如",
"[",
"+",
"3",
".",
"0%",
"6",
".",
"0%",
"]",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元",
":",
"param",
"min_discount",
":",
"最小折价率",
"单位%",
":",
"param",
"forever",
":",
"是否选择永续品种",
"默认",
"Fa... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L223-L266 | train |
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.fundarb | def fundarb(
self,
jsl_username,
jsl_password,
avolume=100,
bvolume=100,
ptype="price",
):
"""以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:par... | python | def fundarb(
self,
jsl_username,
jsl_password,
avolume=100,
bvolume=100,
ptype="price",
):
"""以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:par... | [
"def",
"fundarb",
"(",
"self",
",",
"jsl_username",
",",
"jsl_password",
",",
"avolume",
"=",
"100",
",",
"bvolume",
"=",
"100",
",",
"ptype",
"=",
"\"price\"",
",",
")",
":",
"session",
"=",
"requests",
".",
"session",
"(",
")",
"headers",
"=",
"{",
... | 以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:param ptype: 溢价计算方式,price=现价,buy=买一,sell=卖一 | [
"以字典形式返回分级A数据",
":",
"param",
"jsl_username",
":",
"集思录用户名",
":",
"param",
"jsl_password",
":",
"集思路登录密码",
":",
"param",
"avolume",
":",
"A成交额,单位百万",
":",
"param",
"bvolume",
":",
"B成交额,单位百万",
":",
"param",
"ptype",
":",
"溢价计算方式,price",
"=",
"现价,buy",
"=",
"... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L268-L323 | train |
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.etfindex | def etfindex(
self, index_id="", min_volume=0, max_discount=None, min_discount=None
):
"""
以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价... | python | def etfindex(
self, index_id="", min_volume=0, max_discount=None, min_discount=None
):
"""
以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价... | [
"def",
"etfindex",
"(",
"self",
",",
"index_id",
"=",
"\"\"",
",",
"min_volume",
"=",
"0",
",",
"max_discount",
"=",
"None",
",",
"min_discount",
"=",
"None",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__etf_index_url",
"=",
"self",
".",
"__etf_index_url",
".... | 以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:return: {"fund_id":{}} | [
"以字典形式返回",
"指数ETF",
"数据",
":",
"param",
"index_id",
":",
"获取指定的指数",
":",
"param",
"min_volume",
":",
"最小成交量",
":",
"param",
"min_discount",
":",
"最低溢价率",
"适用于溢价套利",
"格式",
"-",
"1",
".",
"2%",
"-",
"1",
".",
"2",
"-",
"0",
".",
"012",
"三种均可",
":",
"... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L325-L391 | train |
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.qdii | def qdii(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__qdii_url = self.__qdii_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__qdii_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | python | def qdii(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__qdii_url = self.__qdii_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__qdii_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | [
"def",
"qdii",
"(",
"self",
",",
"min_volume",
"=",
"0",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__qdii_url",
"=",
"self",
".",
"__qdii_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=... | 以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元 | [
"以字典形式返回QDII数据",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元"
] | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L393-L415 | train |
shidenggui/easyquotation | easyquotation/jsl.py | Jsl.cb | def cb(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__cb_url = self.__cb_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__cb_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | python | def cb(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__cb_url = self.__cb_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__cb_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | [
"def",
"cb",
"(",
"self",
",",
"min_volume",
"=",
"0",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__cb_url",
"=",
"self",
".",
"__cb_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=",
"... | 以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元 | [
"以字典形式返回QDII数据",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元"
] | a75820db4f05f5386e1c1024d05b0bfc1de6cbda | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L418-L439 | train |
nicolargo/glances | glances/plugins/glances_now.py | Plugin.update | def update(self):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# Add the time zone (issue #1249 and issue #1337)
if 'tmzone' in localtime():
self.stats... | python | def update(self):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# Add the time zone (issue #1249 and issue #1337)
if 'tmzone' in localtime():
self.stats... | [
"def",
"update",
"(",
"self",
")",
":",
"# Had to convert it to string because datetime is not JSON serializable",
"self",
".",
"stats",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"# Add the time zone (issue #1249 and issue #133... | Update current date/time. | [
"Update",
"current",
"date",
"/",
"time",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_now.py#L48-L58 | train |
nicolargo/glances | glances/plugins/glances_now.py | Plugin.msg_curse | def msg_curse(self, args=None, max_width=None):
"""Return the string to display in the curse interface."""
# Init the return message
ret = []
# Build the string message
# 23 is the padding for the process list
msg = '{:23}'.format(self.stats)
ret.append(self.curs... | python | def msg_curse(self, args=None, max_width=None):
"""Return the string to display in the curse interface."""
# Init the return message
ret = []
# Build the string message
# 23 is the padding for the process list
msg = '{:23}'.format(self.stats)
ret.append(self.curs... | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Build the string message",
"# 23 is the padding for the process list",
"msg",
"=",
"'{:23}'",
".",
"format",
"... | Return the string to display in the curse interface. | [
"Return",
"the",
"string",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_now.py#L60-L70 | train |
nicolargo/glances | glances/web_list.py | GlancesWebList.load | def load(self, config):
"""Load the web list from the configuration file."""
web_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in the... | python | def load(self, config):
"""Load the web list from the configuration file."""
web_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in the... | [
"def",
"load",
"(",
"self",
",",
"config",
")",
":",
"web_list",
"=",
"[",
"]",
"if",
"config",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"\"No configuration file available. Cannot load ports list.\"",
")",
"elif",
"not",
"config",
".",
"has_section",
"(... | Load the web list from the configuration file. | [
"Load",
"the",
"web",
"list",
"from",
"the",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/web_list.py#L43-L127 | train |
nicolargo/glances | glances/web_list.py | GlancesWebList.set_server | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._web_list[pos][key] = value | python | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._web_list[pos][key] = value | [
"def",
"set_server",
"(",
"self",
",",
"pos",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_web_list",
"[",
"pos",
"]",
"[",
"key",
"]",
"=",
"value"
] | Set the key to the value for the pos (position in the list). | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/web_list.py#L133-L135 | train |
nicolargo/glances | glances/plugins/glances_sensors.py | Plugin.update | def update(self):
"""Update sensors stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the dedicated lib
stats = []
# Get the temperature
try:
... | python | def update(self):
"""Update sensors stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the dedicated lib
stats = []
# Get the temperature
try:
... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the dedicated lib",
"stats",
"=",
"[",
"]",
"# Get the temperature",
... | Update sensors stats using the input method. | [
"Update",
"sensors",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L73-L134 | train |
nicolargo/glances | glances/plugins/glances_sensors.py | Plugin.__set_type | def __set_type(self, stats, sensor_type):
"""Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery'
"""
fo... | python | def __set_type(self, stats, sensor_type):
"""Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery'
"""
fo... | [
"def",
"__set_type",
"(",
"self",
",",
"stats",
",",
"sensor_type",
")",
":",
"for",
"i",
"in",
"stats",
":",
"# Set the sensors type",
"i",
".",
"update",
"(",
"{",
"'type'",
":",
"sensor_type",
"}",
")",
"# also add the key name",
"i",
".",
"update",
"("... | Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery' | [
"Set",
"the",
"plugin",
"type",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L136-L151 | train |
nicolargo/glances | glances/plugins/glances_sensors.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_sensors.py#L168-L217 | train |
nicolargo/glances | glances/plugins/glances_sensors.py | GlancesGrabSensors.build_sensors_list | def build_sensors_list(self, type):
"""Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list
"""
ret = []
if type == SENSOR_TEMP_UNIT and self.init_temp:
input_list = self.stemps
self.stemps = psut... | python | def build_sensors_list(self, type):
"""Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list
"""
ret = []
if type == SENSOR_TEMP_UNIT and self.init_temp:
input_list = self.stemps
self.stemps = psut... | [
"def",
"build_sensors_list",
"(",
"self",
",",
"type",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"type",
"==",
"SENSOR_TEMP_UNIT",
"and",
"self",
".",
"init_temp",
":",
"input_list",
"=",
"self",
".",
"stemps",
"self",
".",
"stemps",
"=",
"psutil",
".",
"s... | Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list | [
"Build",
"the",
"sensors",
"list",
"depending",
"of",
"the",
"type",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L278-L309 | train |
nicolargo/glances | glances/plugins/glances_sensors.py | GlancesGrabSensors.get | def get(self, sensor_type='temperature_core'):
"""Get sensors list."""
self.__update__()
if sensor_type == 'temperature_core':
ret = [s for s in self.sensors_list if s['unit'] == SENSOR_TEMP_UNIT]
elif sensor_type == 'fan_speed':
ret = [s for s in self.sensors_lis... | python | def get(self, sensor_type='temperature_core'):
"""Get sensors list."""
self.__update__()
if sensor_type == 'temperature_core':
ret = [s for s in self.sensors_list if s['unit'] == SENSOR_TEMP_UNIT]
elif sensor_type == 'fan_speed':
ret = [s for s in self.sensors_lis... | [
"def",
"get",
"(",
"self",
",",
"sensor_type",
"=",
"'temperature_core'",
")",
":",
"self",
".",
"__update__",
"(",
")",
"if",
"sensor_type",
"==",
"'temperature_core'",
":",
"ret",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"sensors_list",
"if",
"s",... | Get sensors list. | [
"Get",
"sensors",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L311-L322 | train |
nicolargo/glances | glances/server.py | GlancesServer.add_user | def add_user(self, username, password):
"""Add an user to the dictionary."""
self.server.user_dict[username] = password
self.server.isAuth = True | python | def add_user(self, username, password):
"""Add an user to the dictionary."""
self.server.user_dict[username] = password
self.server.isAuth = True | [
"def",
"add_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"server",
".",
"user_dict",
"[",
"username",
"]",
"=",
"password",
"self",
".",
"server",
".",
"isAuth",
"=",
"True"
] | Add an user to the dictionary. | [
"Add",
"an",
"user",
"to",
"the",
"dictionary",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L233-L236 | train |
nicolargo/glances | glances/server.py | GlancesServer.serve_forever | def serve_forever(self):
"""Call the main loop."""
# Set the server login/password (if -P/--password tag)
if self.args.password != "":
self.add_user(self.args.username, self.args.password)
# Serve forever
self.server.serve_forever() | python | def serve_forever(self):
"""Call the main loop."""
# Set the server login/password (if -P/--password tag)
if self.args.password != "":
self.add_user(self.args.username, self.args.password)
# Serve forever
self.server.serve_forever() | [
"def",
"serve_forever",
"(",
"self",
")",
":",
"# Set the server login/password (if -P/--password tag)",
"if",
"self",
".",
"args",
".",
"password",
"!=",
"\"\"",
":",
"self",
".",
"add_user",
"(",
"self",
".",
"args",
".",
"username",
",",
"self",
".",
"args"... | Call the main loop. | [
"Call",
"the",
"main",
"loop",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L238-L244 | train |
nicolargo/glances | glances/server.py | GlancesServer.end | def end(self):
"""End of the Glances server session."""
if not self.args.disable_autodiscover:
self.autodiscover_client.close()
self.server.end() | python | def end(self):
"""End of the Glances server session."""
if not self.args.disable_autodiscover:
self.autodiscover_client.close()
self.server.end() | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"args",
".",
"disable_autodiscover",
":",
"self",
".",
"autodiscover_client",
".",
"close",
"(",
")",
"self",
".",
"server",
".",
"end",
"(",
")"
] | End of the Glances server session. | [
"End",
"of",
"the",
"Glances",
"server",
"session",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L246-L250 | train |
nicolargo/glances | glances/thresholds.py | GlancesThresholds.get | def get(self, stat_name=None):
"""Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin
"""
if stat_name is None:
return self._thresholds
if stat_nam... | python | def get(self, stat_name=None):
"""Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin
"""
if stat_name is None:
return self._thresholds
if stat_nam... | [
"def",
"get",
"(",
"self",
",",
"stat_name",
"=",
"None",
")",
":",
"if",
"stat_name",
"is",
"None",
":",
"return",
"self",
".",
"_thresholds",
"if",
"stat_name",
"in",
"self",
".",
"_thresholds",
":",
"return",
"self",
".",
"_thresholds",
"[",
"stat_nam... | Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin | [
"Return",
"the",
"threshold",
"dict",
".",
"If",
"stat_name",
"is",
"None",
"return",
"the",
"threshold",
"for",
"all",
"plugins",
"(",
"dict",
"of",
"Threshold",
"*",
")",
"Else",
"return",
"the",
"Threshold",
"*",
"instance",
"for",
"the",
"given",
"plug... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/thresholds.py#L40-L51 | train |
nicolargo/glances | glances/thresholds.py | GlancesThresholds.add | def add(self, stat_name, threshold_description):
"""Add a new threshold to the dict (key = stat_name)"""
if threshold_description not in self.threshold_list:
return False
else:
self._thresholds[stat_name] = getattr(self.current_module,
... | python | def add(self, stat_name, threshold_description):
"""Add a new threshold to the dict (key = stat_name)"""
if threshold_description not in self.threshold_list:
return False
else:
self._thresholds[stat_name] = getattr(self.current_module,
... | [
"def",
"add",
"(",
"self",
",",
"stat_name",
",",
"threshold_description",
")",
":",
"if",
"threshold_description",
"not",
"in",
"self",
".",
"threshold_list",
":",
"return",
"False",
"else",
":",
"self",
".",
"_thresholds",
"[",
"stat_name",
"]",
"=",
"geta... | Add a new threshold to the dict (key = stat_name) | [
"Add",
"a",
"new",
"threshold",
"to",
"the",
"dict",
"(",
"key",
"=",
"stat_name",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/thresholds.py#L53-L60 | train |
nicolargo/glances | glances/exports/glances_rabbitmq.py | Export.init | def init(self):
"""Init the connection to the rabbitmq server."""
if not self.export_enable:
return None
try:
parameters = pika.URLParameters(
'amqp://' + self.user +
':' + self.password +
'@' + self.host +
'... | python | def init(self):
"""Init the connection to the rabbitmq server."""
if not self.export_enable:
return None
try:
parameters = pika.URLParameters(
'amqp://' + self.user +
':' + self.password +
'@' + self.host +
'... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"parameters",
"=",
"pika",
".",
"URLParameters",
"(",
"'amqp://'",
"+",
"self",
".",
"user",
"+",
"':'",
"+",
"self",
".",
"password",
... | Init the connection to the rabbitmq server. | [
"Init",
"the",
"connection",
"to",
"the",
"rabbitmq",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_rabbitmq.py#L66-L81 | train |
nicolargo/glances | glances/exports/glances_rabbitmq.py | Export.export | def export(self, name, columns, points):
"""Write the points in RabbitMQ."""
data = ('hostname=' + self.hostname + ', name=' + name +
', dateinfo=' + datetime.datetime.utcnow().isoformat())
for i in range(len(columns)):
if not isinstance(points[i], Number):
... | python | def export(self, name, columns, points):
"""Write the points in RabbitMQ."""
data = ('hostname=' + self.hostname + ', name=' + name +
', dateinfo=' + datetime.datetime.utcnow().isoformat())
for i in range(len(columns)):
if not isinstance(points[i], Number):
... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"data",
"=",
"(",
"'hostname='",
"+",
"self",
".",
"hostname",
"+",
"', name='",
"+",
"name",
"+",
"', dateinfo='",
"+",
"datetime",
".",
"datetime",
".",
"utcnow",
"("... | Write the points in RabbitMQ. | [
"Write",
"the",
"points",
"in",
"RabbitMQ",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_rabbitmq.py#L83-L96 | train |
nicolargo/glances | glances/exports/glances_statsd.py | normalize | def normalize(name):
"""Normalize name for the Statsd convention"""
# Name should not contain some specials chars (issue #1068)
ret = name.replace(':', '')
ret = ret.replace('%', '')
ret = ret.replace(' ', '_')
return ret | python | def normalize(name):
"""Normalize name for the Statsd convention"""
# Name should not contain some specials chars (issue #1068)
ret = name.replace(':', '')
ret = ret.replace('%', '')
ret = ret.replace(' ', '_')
return ret | [
"def",
"normalize",
"(",
"name",
")",
":",
"# Name should not contain some specials chars (issue #1068)",
"ret",
"=",
"name",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"ret",
"=",
"ret",
".",
"replace",
"(",
"'%'",
",",
"''",
")",
"ret",
"=",
"ret",
".",... | Normalize name for the Statsd convention | [
"Normalize",
"name",
"for",
"the",
"Statsd",
"convention"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_statsd.py#L86-L94 | train |
nicolargo/glances | glances/exports/glances_statsd.py | Export.init | def init(self):
"""Init the connection to the Statsd server."""
if not self.export_enable:
return None
logger.info(
"Stats will be exported to StatsD server: {}:{}".format(self.host,
self.port))
r... | python | def init(self):
"""Init the connection to the Statsd server."""
if not self.export_enable:
return None
logger.info(
"Stats will be exported to StatsD server: {}:{}".format(self.host,
self.port))
r... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"logger",
".",
"info",
"(",
"\"Stats will be exported to StatsD server: {}:{}\"",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
... | Init the connection to the Statsd server. | [
"Init",
"the",
"connection",
"to",
"the",
"Statsd",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_statsd.py#L60-L69 | train |
nicolargo/glances | glances/exports/glances_statsd.py | Export.export | def export(self, name, columns, points):
"""Export the stats to the Statsd server."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
stat_name = '{}.{}'.format(name, columns[i])
stat_value = points[i]
try:
... | python | def export(self, name, columns, points):
"""Export the stats to the Statsd server."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
stat_name = '{}.{}'.format(name, columns[i])
stat_value = points[i]
try:
... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"columns",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"points",
"[",
"i",
"]",
",",
"Number",
")",
":",
"continue"... | Export the stats to the Statsd server. | [
"Export",
"the",
"stats",
"to",
"the",
"Statsd",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_statsd.py#L71-L83 | train |
nicolargo/glances | glances/ports_list.py | GlancesPortsList.load | def load(self, config):
"""Load the ports list from the configuration file."""
ports_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in... | python | def load(self, config):
"""Load the ports list from the configuration file."""
ports_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in... | [
"def",
"load",
"(",
"self",
",",
"config",
")",
":",
"ports_list",
"=",
"[",
"]",
"if",
"config",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"\"No configuration file available. Cannot load ports list.\"",
")",
"elif",
"not",
"config",
".",
"has_section",
... | Load the ports list from the configuration file. | [
"Load",
"the",
"ports",
"list",
"from",
"the",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/ports_list.py#L53-L135 | train |
nicolargo/glances | glances/ports_list.py | GlancesPortsList.set_server | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._ports_list[pos][key] = value | python | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._ports_list[pos][key] = value | [
"def",
"set_server",
"(",
"self",
",",
"pos",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_ports_list",
"[",
"pos",
"]",
"[",
"key",
"]",
"=",
"value"
] | Set the key to the value for the pos (position in the list). | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/ports_list.py#L141-L143 | train |
nicolargo/glances | glances/exports/glances_opentsdb.py | Export.init | def init(self):
"""Init the connection to the OpenTSDB server."""
if not self.export_enable:
return None
try:
db = potsdb.Client(self.host,
port=int(self.port),
check_host=True)
except Exception as e:
... | python | def init(self):
"""Init the connection to the OpenTSDB server."""
if not self.export_enable:
return None
try:
db = potsdb.Client(self.host,
port=int(self.port),
check_host=True)
except Exception as e:
... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"db",
"=",
"potsdb",
".",
"Client",
"(",
"self",
".",
"host",
",",
"port",
"=",
"int",
"(",
"self",
".",
"port",
")",
",",
"check_... | Init the connection to the OpenTSDB server. | [
"Init",
"the",
"connection",
"to",
"the",
"OpenTSDB",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_opentsdb.py#L61-L74 | train |
nicolargo/glances | glances/exports/glances_opentsdb.py | Export.export | def export(self, name, columns, points):
"""Export the stats to the Statsd server."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
stat_name = '{}.{}.{}'.format(self.prefix, name, columns[i])
stat_value = points[i]
... | python | def export(self, name, columns, points):
"""Export the stats to the Statsd server."""
for i in range(len(columns)):
if not isinstance(points[i], Number):
continue
stat_name = '{}.{}.{}'.format(self.prefix, name, columns[i])
stat_value = points[i]
... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"columns",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"points",
"[",
"i",
"]",
",",
"Number",
")",
":",
"continue"... | Export the stats to the Statsd server. | [
"Export",
"the",
"stats",
"to",
"the",
"Statsd",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_opentsdb.py#L76-L88 | train |
nicolargo/glances | glances/logger.py | glances_logger | def glances_logger(env_key='LOG_CFG'):
"""Build and return the logger.
env_key define the env var where a path to a specific JSON logger
could be defined
:return: logger -- Logger instance
"""
_logger = logging.getLogger()
# By default, use the LOGGING_CFG logger configuration
... | python | def glances_logger(env_key='LOG_CFG'):
"""Build and return the logger.
env_key define the env var where a path to a specific JSON logger
could be defined
:return: logger -- Logger instance
"""
_logger = logging.getLogger()
# By default, use the LOGGING_CFG logger configuration
... | [
"def",
"glances_logger",
"(",
"env_key",
"=",
"'LOG_CFG'",
")",
":",
"_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"# By default, use the LOGGING_CFG logger configuration",
"config",
"=",
"LOGGING_CFG",
"# Check if a specific configuration is available",
"user_file",... | Build and return the logger.
env_key define the env var where a path to a specific JSON logger
could be defined
:return: logger -- Logger instance | [
"Build",
"and",
"return",
"the",
"logger",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/logger.py#L97-L120 | train |
nicolargo/glances | glances/plugins/glances_irq.py | Plugin.update | def update(self):
"""Update the IRQ stats."""
# Init new stats
stats = self.get_init_value()
# IRQ plugin only available on GNU/Linux
if not LINUX:
return self.stats
if self.input_method == 'local':
# Grab the stats
stats = self.irq.g... | python | def update(self):
"""Update the IRQ stats."""
# Init new stats
stats = self.get_init_value()
# IRQ plugin only available on GNU/Linux
if not LINUX:
return self.stats
if self.input_method == 'local':
# Grab the stats
stats = self.irq.g... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# IRQ plugin only available on GNU/Linux",
"if",
"not",
"LINUX",
":",
"return",
"self",
".",
"stats",
"if",
"self",
".",
"input_method",
"==",
"... | Update the IRQ stats. | [
"Update",
"the",
"IRQ",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L53-L78 | train |
nicolargo/glances | glances/plugins/glances_irq.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 available on GNU/Linux
# Only process if stats exist and display plugin enable...
if not LINUX or not self.stats or not self... | 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 available on GNU/Linux
# Only process if stats exist and display plugin enable...
if not LINUX or not self.stats or not self... | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only available on GNU/Linux",
"# Only process if stats exist and display plugin enable...",
"if",
"not",
"LINUX",
... | 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_irq.py#L85-L113 | train |
nicolargo/glances | glances/plugins/glances_irq.py | GlancesIRQ.__header | def __header(self, line):
"""Build the header (contain the number of CPU).
CPU0 CPU1 CPU2 CPU3
0: 21 0 0 0 IO-APIC 2-edge timer
"""
self.cpu_number = len(line.split())
return self.cpu_number | python | def __header(self, line):
"""Build the header (contain the number of CPU).
CPU0 CPU1 CPU2 CPU3
0: 21 0 0 0 IO-APIC 2-edge timer
"""
self.cpu_number = len(line.split())
return self.cpu_number | [
"def",
"__header",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"cpu_number",
"=",
"len",
"(",
"line",
".",
"split",
"(",
")",
")",
"return",
"self",
".",
"cpu_number"
] | Build the header (contain the number of CPU).
CPU0 CPU1 CPU2 CPU3
0: 21 0 0 0 IO-APIC 2-edge timer | [
"Build",
"the",
"header",
"(",
"contain",
"the",
"number",
"of",
"CPU",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L142-L149 | train |
nicolargo/glances | glances/plugins/glances_irq.py | GlancesIRQ.__humanname | def __humanname(self, line):
"""Return the IRQ name, alias or number (choose the best for human).
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
"""
... | python | def __humanname(self, line):
"""Return the IRQ name, alias or number (choose the best for human).
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
"""
... | [
"def",
"__humanname",
"(",
"self",
",",
"line",
")",
":",
"splitted_line",
"=",
"line",
".",
"split",
"(",
")",
"irq_line",
"=",
"splitted_line",
"[",
"0",
"]",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"if",
"irq_line",
".",
"isdigit",
"(",
")",
... | Return the IRQ name, alias or number (choose the best for human).
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts | [
"Return",
"the",
"IRQ",
"name",
"alias",
"or",
"number",
"(",
"choose",
"the",
"best",
"for",
"human",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L151-L163 | train |
nicolargo/glances | glances/plugins/glances_irq.py | GlancesIRQ.__sum | def __sum(self, line):
"""Return the IRQ sum number.
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
FIQ: usb_fiq
"""
splitted_line = line.sp... | python | def __sum(self, line):
"""Return the IRQ sum number.
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
FIQ: usb_fiq
"""
splitted_line = line.sp... | [
"def",
"__sum",
"(",
"self",
",",
"line",
")",
":",
"splitted_line",
"=",
"line",
".",
"split",
"(",
")",
"try",
":",
"ret",
"=",
"sum",
"(",
"map",
"(",
"int",
",",
"splitted_line",
"[",
"1",
":",
"(",
"self",
".",
"cpu_number",
"+",
"1",
")",
... | Return the IRQ sum number.
IRQ line samples:
1: 44487 341 44 72 IO-APIC 1-edge i8042
LOC: 33549868 22394684 32474570 21855077 Local timer interrupts
FIQ: usb_fiq | [
"Return",
"the",
"IRQ",
"sum",
"number",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L165-L179 | train |
nicolargo/glances | glances/plugins/glances_irq.py | GlancesIRQ.__update | def __update(self):
"""Load the IRQ file and update the internal dict."""
self.reset()
if not os.path.exists(self.IRQ_FILE):
# Correct issue #947: IRQ file do not exist on OpenVZ container
return self.stats
try:
with open(self.IRQ_FILE) as irq_proc:
... | python | def __update(self):
"""Load the IRQ file and update the internal dict."""
self.reset()
if not os.path.exists(self.IRQ_FILE):
# Correct issue #947: IRQ file do not exist on OpenVZ container
return self.stats
try:
with open(self.IRQ_FILE) as irq_proc:
... | [
"def",
"__update",
"(",
"self",
")",
":",
"self",
".",
"reset",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"IRQ_FILE",
")",
":",
"# Correct issue #947: IRQ file do not exist on OpenVZ container",
"return",
"self",
".",
"stats",
... | Load the IRQ file and update the internal dict. | [
"Load",
"the",
"IRQ",
"file",
"and",
"update",
"the",
"internal",
"dict",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_irq.py#L181-L213 | train |
nicolargo/glances | glances/exports/glances_mqtt.py | Export.init | def init(self):
"""Init the connection to the MQTT server."""
if not self.export_enable:
return None
try:
client = paho.Client(client_id='glances_' + self.hostname,
clean_session=False)
client.username_pw_set(username=self.user... | python | def init(self):
"""Init the connection to the MQTT server."""
if not self.export_enable:
return None
try:
client = paho.Client(client_id='glances_' + self.hostname,
clean_session=False)
client.username_pw_set(username=self.user... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"client",
"=",
"paho",
".",
"Client",
"(",
"client_id",
"=",
"'glances_'",
"+",
"self",
".",
"hostname",
",",
"clean_session",
"=",
"Fal... | Init the connection to the MQTT server. | [
"Init",
"the",
"connection",
"to",
"the",
"MQTT",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_mqtt.py#L65-L82 | train |
nicolargo/glances | glances/exports/glances_mqtt.py | Export.export | def export(self, name, columns, points):
"""Write the points in MQTT."""
WHITELIST = '_-' + string.ascii_letters + string.digits
SUBSTITUTE = '_'
def whitelisted(s,
whitelist=WHITELIST,
substitute=SUBSTITUTE):
return ''.join(c... | python | def export(self, name, columns, points):
"""Write the points in MQTT."""
WHITELIST = '_-' + string.ascii_letters + string.digits
SUBSTITUTE = '_'
def whitelisted(s,
whitelist=WHITELIST,
substitute=SUBSTITUTE):
return ''.join(c... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"WHITELIST",
"=",
"'_-'",
"+",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
"SUBSTITUTE",
"=",
"'_'",
"def",
"whitelisted",
"(",
"s",
",",
"whitelist",
... | Write the points in MQTT. | [
"Write",
"the",
"points",
"in",
"MQTT",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_mqtt.py#L84-L104 | train |
nicolargo/glances | glances/plugins/glances_batpercent.py | Plugin.update | def update(self):
"""Update battery capacity stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats
self.glancesgrabbat.update()
stats = self.glancesgrabbat.get()
elif s... | python | def update(self):
"""Update battery capacity stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats
self.glancesgrabbat.update()
stats = self.glancesgrabbat.get()
elif s... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats",
"self",
".",
"glancesgrabbat",
".",
"update",
"(",
")",
"stats",
"... | Update battery capacity stats using the input method. | [
"Update",
"battery",
"capacity",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_batpercent.py#L66-L84 | train |
nicolargo/glances | glances/plugins/glances_batpercent.py | GlancesGrabBat.update | def update(self):
"""Update the stats."""
if batinfo_tag:
# Use the batinfo lib to grab the stats
# Compatible with multiple batteries
self.bat.update()
self.bat_list = [{
'label': 'Battery',
'value': self.battery_percent,
... | python | def update(self):
"""Update the stats."""
if batinfo_tag:
# Use the batinfo lib to grab the stats
# Compatible with multiple batteries
self.bat.update()
self.bat_list = [{
'label': 'Battery',
'value': self.battery_percent,
... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"batinfo_tag",
":",
"# Use the batinfo lib to grab the stats",
"# Compatible with multiple batteries",
"self",
".",
"bat",
".",
"update",
"(",
")",
"self",
".",
"bat_list",
"=",
"[",
"{",
"'label'",
":",
"'Battery'",
... | Update the stats. | [
"Update",
"the",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_batpercent.py#L101-L120 | train |
nicolargo/glances | glances/plugins/glances_batpercent.py | GlancesGrabBat.battery_percent | def battery_percent(self):
"""Get batteries capacity percent."""
if not batinfo_tag or not self.bat.stat:
return []
# Init the bsum (sum of percent)
# and Loop over batteries (yes a computer could have more than 1 battery)
bsum = 0
for b in self.bat.stat:
... | python | def battery_percent(self):
"""Get batteries capacity percent."""
if not batinfo_tag or not self.bat.stat:
return []
# Init the bsum (sum of percent)
# and Loop over batteries (yes a computer could have more than 1 battery)
bsum = 0
for b in self.bat.stat:
... | [
"def",
"battery_percent",
"(",
"self",
")",
":",
"if",
"not",
"batinfo_tag",
"or",
"not",
"self",
".",
"bat",
".",
"stat",
":",
"return",
"[",
"]",
"# Init the bsum (sum of percent)",
"# and Loop over batteries (yes a computer could have more than 1 battery)",
"bsum",
"... | Get batteries capacity percent. | [
"Get",
"batteries",
"capacity",
"percent",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_batpercent.py#L127-L142 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.load | def load(self):
"""Load server and password list from the confiuration file."""
# Init the static server list (if defined)
self.static_server = GlancesStaticServer(config=self.config)
# Init the password list (if defined)
self.password = GlancesPassword(config=self.config) | python | def load(self):
"""Load server and password list from the confiuration file."""
# Init the static server list (if defined)
self.static_server = GlancesStaticServer(config=self.config)
# Init the password list (if defined)
self.password = GlancesPassword(config=self.config) | [
"def",
"load",
"(",
"self",
")",
":",
"# Init the static server list (if defined)",
"self",
".",
"static_server",
"=",
"GlancesStaticServer",
"(",
"config",
"=",
"self",
".",
"config",
")",
"# Init the password list (if defined)",
"self",
".",
"password",
"=",
"Glance... | Load server and password list from the confiuration file. | [
"Load",
"server",
"and",
"password",
"list",
"from",
"the",
"confiuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L58-L64 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.get_servers_list | def get_servers_list(self):
"""Return the current server list (list of dict).
Merge of static + autodiscover servers list.
"""
ret = []
if self.args.browser:
ret = self.static_server.get_servers_list()
if self.autodiscover_server is not None:
... | python | def get_servers_list(self):
"""Return the current server list (list of dict).
Merge of static + autodiscover servers list.
"""
ret = []
if self.args.browser:
ret = self.static_server.get_servers_list()
if self.autodiscover_server is not None:
... | [
"def",
"get_servers_list",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"self",
".",
"args",
".",
"browser",
":",
"ret",
"=",
"self",
".",
"static_server",
".",
"get_servers_list",
"(",
")",
"if",
"self",
".",
"autodiscover_server",
"is",
"not",
... | Return the current server list (list of dict).
Merge of static + autodiscover servers list. | [
"Return",
"the",
"current",
"server",
"list",
"(",
"list",
"of",
"dict",
")",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L66-L78 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.__get_uri | def __get_uri(self, server):
"""Return the URI for the given server dict."""
# Select the connection mode (with or without password)
if server['password'] != "":
if server['status'] == 'PROTECTED':
# Try with the preconfigure password (only if status is PROTECTED)
... | python | def __get_uri(self, server):
"""Return the URI for the given server dict."""
# Select the connection mode (with or without password)
if server['password'] != "":
if server['status'] == 'PROTECTED':
# Try with the preconfigure password (only if status is PROTECTED)
... | [
"def",
"__get_uri",
"(",
"self",
",",
"server",
")",
":",
"# Select the connection mode (with or without password)",
"if",
"server",
"[",
"'password'",
"]",
"!=",
"\"\"",
":",
"if",
"server",
"[",
"'status'",
"]",
"==",
"'PROTECTED'",
":",
"# Try with the preconfigu... | Return the URI for the given server dict. | [
"Return",
"the",
"URI",
"for",
"the",
"given",
"server",
"dict",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L80-L92 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.__update_stats | def __update_stats(self, server):
"""
Update stats for the given server (picked from the server list)
"""
# Get the server URI
uri = self.__get_uri(server)
# Try to connect to the server
t = GlancesClientTransport()
t.set_timeout(3)
# Get common ... | python | def __update_stats(self, server):
"""
Update stats for the given server (picked from the server list)
"""
# Get the server URI
uri = self.__get_uri(server)
# Try to connect to the server
t = GlancesClientTransport()
t.set_timeout(3)
# Get common ... | [
"def",
"__update_stats",
"(",
"self",
",",
"server",
")",
":",
"# Get the server URI",
"uri",
"=",
"self",
".",
"__get_uri",
"(",
"server",
")",
"# Try to connect to the server",
"t",
"=",
"GlancesClientTransport",
"(",
")",
"t",
".",
"set_timeout",
"(",
"3",
... | Update stats for the given server (picked from the server list) | [
"Update",
"stats",
"for",
"the",
"given",
"server",
"(",
"picked",
"from",
"the",
"server",
"list",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L94-L147 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.__display_server | def __display_server(self, server):
"""
Connect and display the given server
"""
# Display the Glances client for the selected server
logger.debug("Selected server {}".format(server))
# Connection can take time
# Display a popup
self.screen.display_popup(... | python | def __display_server(self, server):
"""
Connect and display the given server
"""
# Display the Glances client for the selected server
logger.debug("Selected server {}".format(server))
# Connection can take time
# Display a popup
self.screen.display_popup(... | [
"def",
"__display_server",
"(",
"self",
",",
"server",
")",
":",
"# Display the Glances client for the selected server",
"logger",
".",
"debug",
"(",
"\"Selected server {}\"",
".",
"format",
"(",
"server",
")",
")",
"# Connection can take time",
"# Display a popup",
"self... | Connect and display the given server | [
"Connect",
"and",
"display",
"the",
"given",
"server"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L149-L214 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.__serve_forever | def __serve_forever(self):
"""Main client loop."""
# No need to update the server list
# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)
# Or define staticaly in the configuration file (module static_list.py)
# For each server in the list, grab elementary sta... | python | def __serve_forever(self):
"""Main client loop."""
# No need to update the server list
# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)
# Or define staticaly in the configuration file (module static_list.py)
# For each server in the list, grab elementary sta... | [
"def",
"__serve_forever",
"(",
"self",
")",
":",
"# No need to update the server list",
"# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)",
"# Or define staticaly in the configuration file (module static_list.py)",
"# For each server in the list, grab elementary stats (CPU, L... | Main client loop. | [
"Main",
"client",
"loop",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L216-L243 | train |
nicolargo/glances | glances/client_browser.py | GlancesClientBrowser.set_in_selected | def set_in_selected(self, key, value):
"""Set the (key, value) for the selected server in the list."""
# Static list then dynamic one
if self.screen.active_server >= len(self.static_server.get_servers_list()):
self.autodiscover_server.set_server(
self.screen.active_se... | python | def set_in_selected(self, key, value):
"""Set the (key, value) for the selected server in the list."""
# Static list then dynamic one
if self.screen.active_server >= len(self.static_server.get_servers_list()):
self.autodiscover_server.set_server(
self.screen.active_se... | [
"def",
"set_in_selected",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Static list then dynamic one",
"if",
"self",
".",
"screen",
".",
"active_server",
">=",
"len",
"(",
"self",
".",
"static_server",
".",
"get_servers_list",
"(",
")",
")",
":",
"self... | Set the (key, value) for the selected server in the list. | [
"Set",
"the",
"(",
"key",
"value",
")",
"for",
"the",
"selected",
"server",
"in",
"the",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/client_browser.py#L256-L264 | train |
nicolargo/glances | glances/exports/glances_graph.py | Export.update | def update(self, stats):
"""Generate Graph file in the output folder."""
if self.generate_every != 0 and self._timer.finished():
self.args.generate_graph = True
self._timer.reset()
if not self.args.generate_graph:
return
plugins = stats.getPluginsLi... | python | def update(self, stats):
"""Generate Graph file in the output folder."""
if self.generate_every != 0 and self._timer.finished():
self.args.generate_graph = True
self._timer.reset()
if not self.args.generate_graph:
return
plugins = stats.getPluginsLi... | [
"def",
"update",
"(",
"self",
",",
"stats",
")",
":",
"if",
"self",
".",
"generate_every",
"!=",
"0",
"and",
"self",
".",
"_timer",
".",
"finished",
"(",
")",
":",
"self",
".",
"args",
".",
"generate_graph",
"=",
"True",
"self",
".",
"_timer",
".",
... | Generate Graph file in the output folder. | [
"Generate",
"Graph",
"file",
"in",
"the",
"output",
"folder",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_graph.py#L88-L105 | train |
nicolargo/glances | glances/exports/glances_graph.py | Export.export | def export(self, title, data):
"""Generate graph from the data.
Example for the mem plugin:
{'percent': [
(datetime.datetime(2018, 3, 24, 16, 27, 47, 282070), 51.8),
(datetime.datetime(2018, 3, 24, 16, 27, 47, 540999), 51.9),
(datetime.datetime(2018, 3, 24, 1... | python | def export(self, title, data):
"""Generate graph from the data.
Example for the mem plugin:
{'percent': [
(datetime.datetime(2018, 3, 24, 16, 27, 47, 282070), 51.8),
(datetime.datetime(2018, 3, 24, 16, 27, 47, 540999), 51.9),
(datetime.datetime(2018, 3, 24, 1... | [
"def",
"export",
"(",
"self",
",",
"title",
",",
"data",
")",
":",
"if",
"data",
"==",
"{",
"}",
":",
"return",
"False",
"chart",
"=",
"DateTimeLine",
"(",
"title",
"=",
"title",
".",
"capitalize",
"(",
")",
",",
"width",
"=",
"self",
".",
"width",... | Generate graph from the data.
Example for the mem plugin:
{'percent': [
(datetime.datetime(2018, 3, 24, 16, 27, 47, 282070), 51.8),
(datetime.datetime(2018, 3, 24, 16, 27, 47, 540999), 51.9),
(datetime.datetime(2018, 3, 24, 16, 27, 50, 653390), 52.0),
(da... | [
"Generate",
"graph",
"from",
"the",
"data",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_graph.py#L107-L140 | train |
nicolargo/glances | glances/main.py | GlancesMain.init_args | def init_args(self):
"""Init all the command line arguments."""
version = "Glances v" + __version__ + " with psutil v" + psutil_version
parser = argparse.ArgumentParser(
prog='glances',
conflict_handler='resolve',
formatter_class=argparse.RawDescriptionHelpFor... | python | def init_args(self):
"""Init all the command line arguments."""
version = "Glances v" + __version__ + " with psutil v" + psutil_version
parser = argparse.ArgumentParser(
prog='glances',
conflict_handler='resolve',
formatter_class=argparse.RawDescriptionHelpFor... | [
"def",
"init_args",
"(",
"self",
")",
":",
"version",
"=",
"\"Glances v\"",
"+",
"__version__",
"+",
"\" with psutil v\"",
"+",
"psutil_version",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"prog",
"=",
"'glances'",
",",
"conflict_handler",
"=",
"'res... | Init all the command line arguments. | [
"Init",
"all",
"the",
"command",
"line",
"arguments",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/main.py#L110-L250 | train |
nicolargo/glances | glances/main.py | GlancesMain.parse_args | def parse_args(self):
"""Parse command line arguments."""
args = self.init_args().parse_args()
# Load the configuration file, if it exists
self.config = Config(args.conf_file)
# Debug mode
if args.debug:
from logging import DEBUG
logger.setLevel(... | python | def parse_args(self):
"""Parse command line arguments."""
args = self.init_args().parse_args()
# Load the configuration file, if it exists
self.config = Config(args.conf_file)
# Debug mode
if args.debug:
from logging import DEBUG
logger.setLevel(... | [
"def",
"parse_args",
"(",
"self",
")",
":",
"args",
"=",
"self",
".",
"init_args",
"(",
")",
".",
"parse_args",
"(",
")",
"# Load the configuration file, if it exists",
"self",
".",
"config",
"=",
"Config",
"(",
"args",
".",
"conf_file",
")",
"# Debug mode",
... | Parse command line arguments. | [
"Parse",
"command",
"line",
"arguments",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/main.py#L252-L417 | train |
nicolargo/glances | glances/main.py | GlancesMain.is_standalone | def is_standalone(self):
"""Return True if Glances is running in standalone mode."""
return (not self.args.client and
not self.args.browser and
not self.args.server and
not self.args.webserver) | python | def is_standalone(self):
"""Return True if Glances is running in standalone mode."""
return (not self.args.client and
not self.args.browser and
not self.args.server and
not self.args.webserver) | [
"def",
"is_standalone",
"(",
"self",
")",
":",
"return",
"(",
"not",
"self",
".",
"args",
".",
"client",
"and",
"not",
"self",
".",
"args",
".",
"browser",
"and",
"not",
"self",
".",
"args",
".",
"server",
"and",
"not",
"self",
".",
"args",
".",
"w... | Return True if Glances is running in standalone mode. | [
"Return",
"True",
"if",
"Glances",
"is",
"running",
"in",
"standalone",
"mode",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/main.py#L419-L424 | train |
nicolargo/glances | glances/main.py | GlancesMain.is_client | def is_client(self):
"""Return True if Glances is running in client mode."""
return (self.args.client or self.args.browser) and not self.args.server | python | def is_client(self):
"""Return True if Glances is running in client mode."""
return (self.args.client or self.args.browser) and not self.args.server | [
"def",
"is_client",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"args",
".",
"client",
"or",
"self",
".",
"args",
".",
"browser",
")",
"and",
"not",
"self",
".",
"args",
".",
"server"
] | Return True if Glances is running in client mode. | [
"Return",
"True",
"if",
"Glances",
"is",
"running",
"in",
"client",
"mode",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/main.py#L426-L428 | train |
nicolargo/glances | glances/main.py | GlancesMain.__get_password | def __get_password(self, description='',
confirm=False, clear=False, username='glances'):
"""Read a password from the command line.
- if confirm = True, with confirmation
- if clear = True, plain (clear password)
"""
from glances.password import GlancesPas... | python | def __get_password(self, description='',
confirm=False, clear=False, username='glances'):
"""Read a password from the command line.
- if confirm = True, with confirmation
- if clear = True, plain (clear password)
"""
from glances.password import GlancesPas... | [
"def",
"__get_password",
"(",
"self",
",",
"description",
"=",
"''",
",",
"confirm",
"=",
"False",
",",
"clear",
"=",
"False",
",",
"username",
"=",
"'glances'",
")",
":",
"from",
"glances",
".",
"password",
"import",
"GlancesPassword",
"password",
"=",
"G... | Read a password from the command line.
- if confirm = True, with confirmation
- if clear = True, plain (clear password) | [
"Read",
"a",
"password",
"from",
"the",
"command",
"line",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/main.py#L458-L467 | train |
nicolargo/glances | glances/outputs/glances_stdout.py | GlancesStdout.build_list | def build_list(self):
"""Return a list of tuples taken from self.args.stdout
[(plugin, attribute), ... ]"""
ret = []
for p in self.args.stdout.split(','):
if '.' in p:
p, a = p.split('.')
else:
a = None
ret.append((p, a)... | python | def build_list(self):
"""Return a list of tuples taken from self.args.stdout
[(plugin, attribute), ... ]"""
ret = []
for p in self.args.stdout.split(','):
if '.' in p:
p, a = p.split('.')
else:
a = None
ret.append((p, a)... | [
"def",
"build_list",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"p",
"in",
"self",
".",
"args",
".",
"stdout",
".",
"split",
"(",
"','",
")",
":",
"if",
"'.'",
"in",
"p",
":",
"p",
",",
"a",
"=",
"p",
".",
"split",
"(",
"'.'",
")",... | Return a list of tuples taken from self.args.stdout
[(plugin, attribute), ... ] | [
"Return",
"a",
"list",
"of",
"tuples",
"taken",
"from",
"self",
".",
"args",
".",
"stdout",
"[",
"(",
"plugin",
"attribute",
")",
"...",
"]"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout.py#L42-L52 | train |
nicolargo/glances | glances/outputs/glances_stdout.py | GlancesStdout.update | def update(self,
stats,
duration=3):
"""Display stats to stdout.
Refresh every duration second.
"""
for plugin, attribute in self.plugins_list:
# Check if the plugin exist and is enable
if plugin in stats.getPluginsList() and \
... | python | def update(self,
stats,
duration=3):
"""Display stats to stdout.
Refresh every duration second.
"""
for plugin, attribute in self.plugins_list:
# Check if the plugin exist and is enable
if plugin in stats.getPluginsList() and \
... | [
"def",
"update",
"(",
"self",
",",
"stats",
",",
"duration",
"=",
"3",
")",
":",
"for",
"plugin",
",",
"attribute",
"in",
"self",
".",
"plugins_list",
":",
"# Check if the plugin exist and is enable",
"if",
"plugin",
"in",
"stats",
".",
"getPluginsList",
"(",
... | Display stats to stdout.
Refresh every duration second. | [
"Display",
"stats",
"to",
"stdout",
".",
"Refresh",
"every",
"duration",
"second",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_stdout.py#L57-L84 | train |
nicolargo/glances | glances/plugins/glances_load.py | Plugin.update | def update(self):
"""Update load stats."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
# Get the load using the os standard lib
load = self._getloadavg()
if ... | python | def update(self):
"""Update load stats."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the standard system lib
# Get the load using the os standard lib
load = self._getloadavg()
if ... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the standard system lib",
"# Get the load using the os standard lib",
"load"... | Update load stats. | [
"Update",
"load",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_load.py#L80-L116 | train |
nicolargo/glances | glances/plugins/glances_load.py | Plugin.update_views | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
try:
# Alert and log
self.views['min15']['decoration'] = self.get_alert_log(self.stats['min15'], maximum=100 * sel... | python | def update_views(self):
"""Update stats views."""
# Call the father's method
super(Plugin, self).update_views()
# Add specifics informations
try:
# Alert and log
self.views['min15']['decoration'] = self.get_alert_log(self.stats['min15'], maximum=100 * sel... | [
"def",
"update_views",
"(",
"self",
")",
":",
"# Call the father's method",
"super",
"(",
"Plugin",
",",
"self",
")",
".",
"update_views",
"(",
")",
"# Add specifics informations",
"try",
":",
"# Alert and log",
"self",
".",
"views",
"[",
"'min15'",
"]",
"[",
... | Update stats views. | [
"Update",
"stats",
"views",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_load.py#L118-L131 | train |
nicolargo/glances | glances/plugins/glances_load.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, not empty (issue #871) and plugin not disabled
if not self.stats or (self.stats == {}) or self.is_disable():... | 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, not empty (issue #871) and plugin not disabled
if not self.stats or (self.stats == {}) or self.is_disable():... | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist, not empty (issue #871) and plugin not disabled",
"if",
"not",
"self",
".",
"stats",
... | 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_load.py#L133-L174 | train |
nicolargo/glances | glances/plugins/glances_psutilversion.py | Plugin.update | def update(self):
"""Update the stats."""
# Reset stats
self.reset()
# Return psutil version as a tuple
if self.input_method == 'local':
# psutil version only available in local
try:
self.stats = psutil_version_info
except Name... | python | def update(self):
"""Update the stats."""
# Reset stats
self.reset()
# Return psutil version as a tuple
if self.input_method == 'local':
# psutil version only available in local
try:
self.stats = psutil_version_info
except Name... | [
"def",
"update",
"(",
"self",
")",
":",
"# Reset stats",
"self",
".",
"reset",
"(",
")",
"# Return psutil version as a tuple",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# psutil version only available in local",
"try",
":",
"self",
".",
"stats",
"=... | Update the stats. | [
"Update",
"the",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_psutilversion.py#L44-L59 | train |
nicolargo/glances | glances/outdated.py | Outdated.load_config | def load_config(self, config):
"""Load outdated parameter in the global section of the configuration file."""
global_section = 'global'
if (hasattr(config, 'has_section') and
config.has_section(global_section)):
self.args.disable_check_update = config.get_value(globa... | python | def load_config(self, config):
"""Load outdated parameter in the global section of the configuration file."""
global_section = 'global'
if (hasattr(config, 'has_section') and
config.has_section(global_section)):
self.args.disable_check_update = config.get_value(globa... | [
"def",
"load_config",
"(",
"self",
",",
"config",
")",
":",
"global_section",
"=",
"'global'",
"if",
"(",
"hasattr",
"(",
"config",
",",
"'has_section'",
")",
"and",
"config",
".",
"has_section",
"(",
"global_section",
")",
")",
":",
"self",
".",
"args",
... | Load outdated parameter in the global section of the configuration file. | [
"Load",
"outdated",
"parameter",
"in",
"the",
"global",
"section",
"of",
"the",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L66-L77 | train |
nicolargo/glances | glances/outdated.py | Outdated.get_pypi_version | def get_pypi_version(self):
"""Wrapper to get the latest PyPI version (async)
The data are stored in a cached file
Only update online once a week
"""
if self.args.disable_check_update:
return
# If the cached file exist, read-it
cached_data = self._loa... | python | def get_pypi_version(self):
"""Wrapper to get the latest PyPI version (async)
The data are stored in a cached file
Only update online once a week
"""
if self.args.disable_check_update:
return
# If the cached file exist, read-it
cached_data = self._loa... | [
"def",
"get_pypi_version",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"disable_check_update",
":",
"return",
"# If the cached file exist, read-it",
"cached_data",
"=",
"self",
".",
"_load_cache",
"(",
")",
"if",
"cached_data",
"==",
"{",
"}",
":",
... | Wrapper to get the latest PyPI version (async)
The data are stored in a cached file
Only update online once a week | [
"Wrapper",
"to",
"get",
"the",
"latest",
"PyPI",
"version",
"(",
"async",
")",
"The",
"data",
"are",
"stored",
"in",
"a",
"cached",
"file",
"Only",
"update",
"online",
"once",
"a",
"week"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L88-L107 | train |
nicolargo/glances | glances/outdated.py | Outdated.is_outdated | def is_outdated(self):
"""Return True if a new version is available"""
if self.args.disable_check_update:
# Check is disabled by configuration
return False
logger.debug("Check Glances version (installed: {} / latest: {})".format(self.installed_version(), self.latest_vers... | python | def is_outdated(self):
"""Return True if a new version is available"""
if self.args.disable_check_update:
# Check is disabled by configuration
return False
logger.debug("Check Glances version (installed: {} / latest: {})".format(self.installed_version(), self.latest_vers... | [
"def",
"is_outdated",
"(",
"self",
")",
":",
"if",
"self",
".",
"args",
".",
"disable_check_update",
":",
"# Check is disabled by configuration",
"return",
"False",
"logger",
".",
"debug",
"(",
"\"Check Glances version (installed: {} / latest: {})\"",
".",
"format",
"("... | Return True if a new version is available | [
"Return",
"True",
"if",
"a",
"new",
"version",
"is",
"available"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L109-L116 | train |
nicolargo/glances | glances/outdated.py | Outdated._load_cache | def _load_cache(self):
"""Load cache file and return cached data"""
# If the cached file exist, read-it
max_refresh_date = timedelta(days=7)
cached_data = {}
try:
with open(self.cache_file, 'rb') as f:
cached_data = pickle.load(f)
except Except... | python | def _load_cache(self):
"""Load cache file and return cached data"""
# If the cached file exist, read-it
max_refresh_date = timedelta(days=7)
cached_data = {}
try:
with open(self.cache_file, 'rb') as f:
cached_data = pickle.load(f)
except Except... | [
"def",
"_load_cache",
"(",
"self",
")",
":",
"# If the cached file exist, read-it",
"max_refresh_date",
"=",
"timedelta",
"(",
"days",
"=",
"7",
")",
"cached_data",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"self",
".",
"cache_file",
",",
"'rb'",
")",
... | Load cache file and return cached data | [
"Load",
"cache",
"file",
"and",
"return",
"cached",
"data"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L118-L136 | train |
nicolargo/glances | glances/outdated.py | Outdated._save_cache | def _save_cache(self):
"""Save data to the cache file."""
# Create the cache directory
safe_makedirs(self.cache_dir)
# Create/overwrite the cache file
try:
with open(self.cache_file, 'wb') as f:
pickle.dump(self.data, f)
except Exception as e:... | python | def _save_cache(self):
"""Save data to the cache file."""
# Create the cache directory
safe_makedirs(self.cache_dir)
# Create/overwrite the cache file
try:
with open(self.cache_file, 'wb') as f:
pickle.dump(self.data, f)
except Exception as e:... | [
"def",
"_save_cache",
"(",
"self",
")",
":",
"# Create the cache directory",
"safe_makedirs",
"(",
"self",
".",
"cache_dir",
")",
"# Create/overwrite the cache file",
"try",
":",
"with",
"open",
"(",
"self",
".",
"cache_file",
",",
"'wb'",
")",
"as",
"f",
":",
... | Save data to the cache file. | [
"Save",
"data",
"to",
"the",
"cache",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L138-L148 | train |
nicolargo/glances | glances/outdated.py | Outdated._update_pypi_version | def _update_pypi_version(self):
"""Get the latest PyPI version (as a string) via the RESTful JSON API"""
logger.debug("Get latest Glances version from the PyPI RESTful API ({})".format(PYPI_API_URL))
# Update the current time
self.data[u'refresh_date'] = datetime.now()
try:
... | python | def _update_pypi_version(self):
"""Get the latest PyPI version (as a string) via the RESTful JSON API"""
logger.debug("Get latest Glances version from the PyPI RESTful API ({})".format(PYPI_API_URL))
# Update the current time
self.data[u'refresh_date'] = datetime.now()
try:
... | [
"def",
"_update_pypi_version",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Get latest Glances version from the PyPI RESTful API ({})\"",
".",
"format",
"(",
"PYPI_API_URL",
")",
")",
"# Update the current time",
"self",
".",
"data",
"[",
"u'refresh_date'",
"]... | Get the latest PyPI version (as a string) via the RESTful JSON API | [
"Get",
"the",
"latest",
"PyPI",
"version",
"(",
"as",
"a",
"string",
")",
"via",
"the",
"RESTful",
"JSON",
"API"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L150-L169 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.cursor_up | def cursor_up(self, stats):
"""Set the cursor to position N-1 in the list."""
if 0 <= self.cursor_position - 1:
self.cursor_position -= 1
else:
if self._current_page - 1 < 0 :
self._current_page = self._page_max - 1
self.cursor_position = (... | python | def cursor_up(self, stats):
"""Set the cursor to position N-1 in the list."""
if 0 <= self.cursor_position - 1:
self.cursor_position -= 1
else:
if self._current_page - 1 < 0 :
self._current_page = self._page_max - 1
self.cursor_position = (... | [
"def",
"cursor_up",
"(",
"self",
",",
"stats",
")",
":",
"if",
"0",
"<=",
"self",
".",
"cursor_position",
"-",
"1",
":",
"self",
".",
"cursor_position",
"-=",
"1",
"else",
":",
"if",
"self",
".",
"_current_page",
"-",
"1",
"<",
"0",
":",
"self",
".... | Set the cursor to position N-1 in the list. | [
"Set",
"the",
"cursor",
"to",
"position",
"N",
"-",
"1",
"in",
"the",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L122-L132 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.cursor_down | def cursor_down(self, stats):
"""Set the cursor to position N-1 in the list."""
if self.cursor_position + 1 < self.get_pagelines(stats):
self.cursor_position += 1
else:
if self._current_page + 1 < self._page_max:
self._current_page += 1
... | python | def cursor_down(self, stats):
"""Set the cursor to position N-1 in the list."""
if self.cursor_position + 1 < self.get_pagelines(stats):
self.cursor_position += 1
else:
if self._current_page + 1 < self._page_max:
self._current_page += 1
... | [
"def",
"cursor_down",
"(",
"self",
",",
"stats",
")",
":",
"if",
"self",
".",
"cursor_position",
"+",
"1",
"<",
"self",
".",
"get_pagelines",
"(",
"stats",
")",
":",
"self",
".",
"cursor_position",
"+=",
"1",
"else",
":",
"if",
"self",
".",
"_current_p... | Set the cursor to position N-1 in the list. | [
"Set",
"the",
"cursor",
"to",
"position",
"N",
"-",
"1",
"in",
"the",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L134-L144 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.cursor_pageup | def cursor_pageup(self, stats):
"""Set prev page."""
if self._current_page - 1 < 0:
self._current_page = self._page_max - 1
else:
self._current_page -= 1
self.cursor_position = 0 | python | def cursor_pageup(self, stats):
"""Set prev page."""
if self._current_page - 1 < 0:
self._current_page = self._page_max - 1
else:
self._current_page -= 1
self.cursor_position = 0 | [
"def",
"cursor_pageup",
"(",
"self",
",",
"stats",
")",
":",
"if",
"self",
".",
"_current_page",
"-",
"1",
"<",
"0",
":",
"self",
".",
"_current_page",
"=",
"self",
".",
"_page_max",
"-",
"1",
"else",
":",
"self",
".",
"_current_page",
"-=",
"1",
"se... | Set prev page. | [
"Set",
"prev",
"page",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L146-L152 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.cursor_pagedown | def cursor_pagedown(self, stats):
"""Set next page."""
if self._current_page + 1 < self._page_max:
self._current_page += 1
else:
self._current_page = 0
self.cursor_position = 0 | python | def cursor_pagedown(self, stats):
"""Set next page."""
if self._current_page + 1 < self._page_max:
self._current_page += 1
else:
self._current_page = 0
self.cursor_position = 0 | [
"def",
"cursor_pagedown",
"(",
"self",
",",
"stats",
")",
":",
"if",
"self",
".",
"_current_page",
"+",
"1",
"<",
"self",
".",
"_page_max",
":",
"self",
".",
"_current_page",
"+=",
"1",
"else",
":",
"self",
".",
"_current_page",
"=",
"0",
"self",
".",
... | Set next page. | [
"Set",
"next",
"page",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L154-L160 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.update | def update(self,
stats,
duration=3,
cs_status=None,
return_to_browser=False):
"""Update the servers' list screen.
Wait for __refresh_time sec / catch key every 100 ms.
stats: Dict of dict with servers stats
"""
# Flush... | python | def update(self,
stats,
duration=3,
cs_status=None,
return_to_browser=False):
"""Update the servers' list screen.
Wait for __refresh_time sec / catch key every 100 ms.
stats: Dict of dict with servers stats
"""
# Flush... | [
"def",
"update",
"(",
"self",
",",
"stats",
",",
"duration",
"=",
"3",
",",
"cs_status",
"=",
"None",
",",
"return_to_browser",
"=",
"False",
")",
":",
"# Flush display",
"logger",
".",
"debug",
"(",
"'Servers list: {}'",
".",
"format",
"(",
"stats",
")",
... | Update the servers' list screen.
Wait for __refresh_time sec / catch key every 100 ms.
stats: Dict of dict with servers stats | [
"Update",
"the",
"servers",
"list",
"screen",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L216-L246 | train |
nicolargo/glances | glances/outputs/glances_curses_browser.py | GlancesCursesBrowser.display | def display(self, stats, cs_status=None):
"""Display the servers list.
Return:
True if the stats have been displayed
False if the stats have not been displayed (no server available)
"""
# Init the internal line/column for Glances Curses
self.init_line_col... | python | def display(self, stats, cs_status=None):
"""Display the servers list.
Return:
True if the stats have been displayed
False if the stats have not been displayed (no server available)
"""
# Init the internal line/column for Glances Curses
self.init_line_col... | [
"def",
"display",
"(",
"self",
",",
"stats",
",",
"cs_status",
"=",
"None",
")",
":",
"# Init the internal line/column for Glances Curses",
"self",
".",
"init_line_column",
"(",
")",
"# Get the current screen size",
"screen_x",
"=",
"self",
".",
"screen",
".",
"getm... | Display the servers list.
Return:
True if the stats have been displayed
False if the stats have not been displayed (no server available) | [
"Display",
"the",
"servers",
"list",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outputs/glances_curses_browser.py#L256-L399 | train |
nicolargo/glances | glances/plugins/glances_smart.py | is_admin | def is_admin():
"""
https://stackoverflow.com/a/19719292
@return: True if the current user is an 'Admin' whatever that
means (root on Unix), otherwise False.
Warning: The inner function fails unless you have Windows XP SP2 or
higher. The failure causes a traceback to be printed and this
func... | python | def is_admin():
"""
https://stackoverflow.com/a/19719292
@return: True if the current user is an 'Admin' whatever that
means (root on Unix), otherwise False.
Warning: The inner function fails unless you have Windows XP SP2 or
higher. The failure causes a traceback to be printed and this
func... | [
"def",
"is_admin",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"import",
"ctypes",
"import",
"traceback",
"# WARNING: requires Windows XP SP2 or higher!",
"try",
":",
"return",
"ctypes",
".",
"windll",
".",
"shell32",
".",
"IsUserAnAdmin",
"(",
... | https://stackoverflow.com/a/19719292
@return: True if the current user is an 'Admin' whatever that
means (root on Unix), otherwise False.
Warning: The inner function fails unless you have Windows XP SP2 or
higher. The failure causes a traceback to be printed and this
function to return False. | [
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"a",
"/",
"19719292"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_smart.py#L64-L85 | train |
nicolargo/glances | glances/plugins/glances_smart.py | get_smart_data | def get_smart_data():
"""
Get SMART attribute data
:return: list of multi leveled dictionaries
each dict has a key "DeviceName" with the identification of the device in smartctl
also has keys of the SMART attribute id, with value of another dict of the attributes
[
... | python | def get_smart_data():
"""
Get SMART attribute data
:return: list of multi leveled dictionaries
each dict has a key "DeviceName" with the identification of the device in smartctl
also has keys of the SMART attribute id, with value of another dict of the attributes
[
... | [
"def",
"get_smart_data",
"(",
")",
":",
"stats",
"=",
"[",
"]",
"# get all devices",
"devlist",
"=",
"DeviceList",
"(",
")",
"for",
"dev",
"in",
"devlist",
".",
"devices",
":",
"stats",
".",
"append",
"(",
"{",
"DEVKEY",
":",
"str",
"(",
"dev",
")",
... | Get SMART attribute data
:return: list of multi leveled dictionaries
each dict has a key "DeviceName" with the identification of the device in smartctl
also has keys of the SMART attribute id, with value of another dict of the attributes
[
{
... | [
"Get",
"SMART",
"attribute",
"data",
":",
"return",
":",
"list",
"of",
"multi",
"leveled",
"dictionaries",
"each",
"dict",
"has",
"a",
"key",
"DeviceName",
"with",
"the",
"identification",
"of",
"the",
"device",
"in",
"smartctl",
"also",
"has",
"keys",
"of",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_smart.py#L102-L143 | train |
nicolargo/glances | glances/plugins/glances_smart.py | Plugin.update | def update(self):
"""Update SMART stats using the input method."""
# Init new stats
stats = self.get_init_value()
if import_error_tag:
return self.stats
if self.input_method == 'local':
stats = get_smart_data()
elif self.input_method == 'snmp':
... | python | def update(self):
"""Update SMART stats using the input method."""
# Init new stats
stats = self.get_init_value()
if import_error_tag:
return self.stats
if self.input_method == 'local':
stats = get_smart_data()
elif self.input_method == 'snmp':
... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"import_error_tag",
":",
"return",
"self",
".",
"stats",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"stats",
"=",
"get_sm... | Update SMART stats using the input method. | [
"Update",
"SMART",
"stats",
"using",
"the",
"input",
"method",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_smart.py#L169-L185 | train |
nicolargo/glances | glances/exports/glances_prometheus.py | Export.init | def init(self):
"""Init the Prometheus Exporter"""
try:
start_http_server(port=int(self.port), addr=self.host)
except Exception as e:
logger.critical("Can not start Prometheus exporter on {}:{} ({})".format(self.host, self.port, e))
sys.exit(2)
else:
... | python | def init(self):
"""Init the Prometheus Exporter"""
try:
start_http_server(port=int(self.port), addr=self.host)
except Exception as e:
logger.critical("Can not start Prometheus exporter on {}:{} ({})".format(self.host, self.port, e))
sys.exit(2)
else:
... | [
"def",
"init",
"(",
"self",
")",
":",
"try",
":",
"start_http_server",
"(",
"port",
"=",
"int",
"(",
"self",
".",
"port",
")",
",",
"addr",
"=",
"self",
".",
"host",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"critical",
"(",
"\"Can... | Init the Prometheus Exporter | [
"Init",
"the",
"Prometheus",
"Exporter"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_prometheus.py#L63-L71 | train |
nicolargo/glances | glances/exports/glances_prometheus.py | Export.export | def export(self, name, columns, points):
"""Write the points to the Prometheus exporter using Gauge."""
logger.debug("Export {} stats to Prometheus exporter".format(name))
# Remove non number stats and convert all to float (for Boolean)
data = {k: float(v) for (k, v) in iteritems(dict(z... | python | def export(self, name, columns, points):
"""Write the points to the Prometheus exporter using Gauge."""
logger.debug("Export {} stats to Prometheus exporter".format(name))
# Remove non number stats and convert all to float (for Boolean)
data = {k: float(v) for (k, v) in iteritems(dict(z... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"logger",
".",
"debug",
"(",
"\"Export {} stats to Prometheus exporter\"",
".",
"format",
"(",
"name",
")",
")",
"# Remove non number stats and convert all to float (for Boolean)",
"da... | Write the points to the Prometheus exporter using Gauge. | [
"Write",
"the",
"points",
"to",
"the",
"Prometheus",
"exporter",
"using",
"Gauge",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_prometheus.py#L73-L99 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport._plugins_to_export | def _plugins_to_export(self):
"""Return the list of plugins to export."""
ret = self.exportable_plugins
for p in ret:
if getattr(self.args, 'disable_' + p):
ret.remove(p)
return ret | python | def _plugins_to_export(self):
"""Return the list of plugins to export."""
ret = self.exportable_plugins
for p in ret:
if getattr(self.args, 'disable_' + p):
ret.remove(p)
return ret | [
"def",
"_plugins_to_export",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"exportable_plugins",
"for",
"p",
"in",
"ret",
":",
"if",
"getattr",
"(",
"self",
".",
"args",
",",
"'disable_'",
"+",
"p",
")",
":",
"ret",
".",
"remove",
"(",
"p",
")",
... | Return the list of plugins to export. | [
"Return",
"the",
"list",
"of",
"plugins",
"to",
"export",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L79-L85 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport.load_conf | def load_conf(self, section, mandatories=['host', 'port'], options=None):
"""Load the export <section> configuration in the Glances configuration file.
:param section: name of the export section to load
:param mandatories: a list of mandatories parameters to load
:param options: a list ... | python | def load_conf(self, section, mandatories=['host', 'port'], options=None):
"""Load the export <section> configuration in the Glances configuration file.
:param section: name of the export section to load
:param mandatories: a list of mandatories parameters to load
:param options: a list ... | [
"def",
"load_conf",
"(",
"self",
",",
"section",
",",
"mandatories",
"=",
"[",
"'host'",
",",
"'port'",
"]",
",",
"options",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"[",
"]",
"if",
"self",
".",
"config",
"is",
"None",
":",
"return",
... | Load the export <section> configuration in the Glances configuration file.
:param section: name of the export section to load
:param mandatories: a list of mandatories parameters to load
:param options: a list of optionnals parameters to load
:returns: Boolean -- True if section is fou... | [
"Load",
"the",
"export",
"<section",
">",
"configuration",
"in",
"the",
"Glances",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L90-L125 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport.get_item_key | def get_item_key(self, item):
"""Return the value of the item 'key'."""
try:
ret = item[item['key']]
except KeyError:
logger.error("No 'key' available in {}".format(item))
if isinstance(ret, list):
return ret[0]
else:
return ret | python | def get_item_key(self, item):
"""Return the value of the item 'key'."""
try:
ret = item[item['key']]
except KeyError:
logger.error("No 'key' available in {}".format(item))
if isinstance(ret, list):
return ret[0]
else:
return ret | [
"def",
"get_item_key",
"(",
"self",
",",
"item",
")",
":",
"try",
":",
"ret",
"=",
"item",
"[",
"item",
"[",
"'key'",
"]",
"]",
"except",
"KeyError",
":",
"logger",
".",
"error",
"(",
"\"No 'key' available in {}\"",
".",
"format",
"(",
"item",
")",
")"... | Return the value of the item 'key'. | [
"Return",
"the",
"value",
"of",
"the",
"item",
"key",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L127-L136 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport.parse_tags | def parse_tags(self, tags):
"""Parse tags into a dict.
input tags: a comma separated list of 'key:value' pairs.
Example: foo:bar,spam:eggs
output dtags: a dict of tags.
Example: {'foo': 'bar', 'spam': 'eggs'}
"""
dtags = {}
if tags:
tr... | python | def parse_tags(self, tags):
"""Parse tags into a dict.
input tags: a comma separated list of 'key:value' pairs.
Example: foo:bar,spam:eggs
output dtags: a dict of tags.
Example: {'foo': 'bar', 'spam': 'eggs'}
"""
dtags = {}
if tags:
tr... | [
"def",
"parse_tags",
"(",
"self",
",",
"tags",
")",
":",
"dtags",
"=",
"{",
"}",
"if",
"tags",
":",
"try",
":",
"dtags",
"=",
"dict",
"(",
"[",
"x",
".",
"split",
"(",
"':'",
")",
"for",
"x",
"in",
"tags",
".",
"split",
"(",
"','",
")",
"]",
... | Parse tags into a dict.
input tags: a comma separated list of 'key:value' pairs.
Example: foo:bar,spam:eggs
output dtags: a dict of tags.
Example: {'foo': 'bar', 'spam': 'eggs'} | [
"Parse",
"tags",
"into",
"a",
"dict",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L138-L155 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport.update | def update(self, stats):
"""Update stats to a server.
The method builds two lists: names and values
and calls the export method to export the stats.
Note: this class can be overwrite (for example in CSV and Graph).
"""
if not self.export_enable:
return False... | python | def update(self, stats):
"""Update stats to a server.
The method builds two lists: names and values
and calls the export method to export the stats.
Note: this class can be overwrite (for example in CSV and Graph).
"""
if not self.export_enable:
return False... | [
"def",
"update",
"(",
"self",
",",
"stats",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"False",
"# Get all the stats & limits",
"all_stats",
"=",
"stats",
".",
"getAllExportsAsDict",
"(",
"plugin_list",
"=",
"self",
".",
"plugins_to_expo... | Update stats to a server.
The method builds two lists: names and values
and calls the export method to export the stats.
Note: this class can be overwrite (for example in CSV and Graph). | [
"Update",
"stats",
"to",
"a",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L157-L185 | train |
nicolargo/glances | glances/exports/glances_export.py | GlancesExport.__build_export | def __build_export(self, stats):
"""Build the export lists."""
export_names = []
export_values = []
if isinstance(stats, dict):
# Stats is a dict
# Is there a key ?
if 'key' in iterkeys(stats) and stats['key'] in iterkeys(stats):
pre_k... | python | def __build_export(self, stats):
"""Build the export lists."""
export_names = []
export_values = []
if isinstance(stats, dict):
# Stats is a dict
# Is there a key ?
if 'key' in iterkeys(stats) and stats['key'] in iterkeys(stats):
pre_k... | [
"def",
"__build_export",
"(",
"self",
",",
"stats",
")",
":",
"export_names",
"=",
"[",
"]",
"export_values",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"stats",
",",
"dict",
")",
":",
"# Stats is a dict",
"# Is there a key ?",
"if",
"'key'",
"in",
"iterkeys",
... | Build the export lists. | [
"Build",
"the",
"export",
"lists",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_export.py#L187-L223 | train |
nicolargo/glances | glances/stats_server.py | GlancesStatsServer.update | def update(self, input_stats=None):
"""Update the stats."""
input_stats = input_stats or {}
# Force update of all the stats
super(GlancesStatsServer, self).update()
# Build all_stats variable (concatenation of all the stats)
self.all_stats = self._set_stats(input_stats) | python | def update(self, input_stats=None):
"""Update the stats."""
input_stats = input_stats or {}
# Force update of all the stats
super(GlancesStatsServer, self).update()
# Build all_stats variable (concatenation of all the stats)
self.all_stats = self._set_stats(input_stats) | [
"def",
"update",
"(",
"self",
",",
"input_stats",
"=",
"None",
")",
":",
"input_stats",
"=",
"input_stats",
"or",
"{",
"}",
"# Force update of all the stats",
"super",
"(",
"GlancesStatsServer",
",",
"self",
")",
".",
"update",
"(",
")",
"# Build all_stats varia... | Update the stats. | [
"Update",
"the",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_server.py#L41-L49 | train |
nicolargo/glances | glances/stats_server.py | GlancesStatsServer._set_stats | def _set_stats(self, input_stats):
"""Set the stats to the input_stats one."""
# Build the all_stats with the get_raw() method of the plugins
return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enable()} | python | def _set_stats(self, input_stats):
"""Set the stats to the input_stats one."""
# Build the all_stats with the get_raw() method of the plugins
return {p: self._plugins[p].get_raw() for p in self._plugins if self._plugins[p].is_enable()} | [
"def",
"_set_stats",
"(",
"self",
",",
"input_stats",
")",
":",
"# Build the all_stats with the get_raw() method of the plugins",
"return",
"{",
"p",
":",
"self",
".",
"_plugins",
"[",
"p",
"]",
".",
"get_raw",
"(",
")",
"for",
"p",
"in",
"self",
".",
"_plugin... | Set the stats to the input_stats one. | [
"Set",
"the",
"stats",
"to",
"the",
"input_stats",
"one",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/stats_server.py#L51-L54 | train |
nicolargo/glances | glances/exports/glances_influxdb.py | Export.init | def init(self):
"""Init the connection to the InfluxDB server."""
if not self.export_enable:
return None
try:
db = InfluxDBClient(host=self.host,
port=self.port,
username=self.user,
... | python | def init(self):
"""Init the connection to the InfluxDB server."""
if not self.export_enable:
return None
try:
db = InfluxDBClient(host=self.host,
port=self.port,
username=self.user,
... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"db",
"=",
"InfluxDBClient",
"(",
"host",
"=",
"self",
".",
"host",
",",
"port",
"=",
"self",
".",
"port",
",",
"username",
"=",
"se... | Init the connection to the InfluxDB server. | [
"Init",
"the",
"connection",
"to",
"the",
"InfluxDB",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_influxdb.py#L59-L82 | train |
nicolargo/glances | glances/exports/glances_influxdb.py | Export._normalize | def _normalize(self, name, columns, points):
"""Normalize data for the InfluxDB's data model."""
for i, _ in enumerate(points):
# Supported type:
# https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/
if points[i] is None:
... | python | def _normalize(self, name, columns, points):
"""Normalize data for the InfluxDB's data model."""
for i, _ in enumerate(points):
# Supported type:
# https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/
if points[i] is None:
... | [
"def",
"_normalize",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"points",
")",
":",
"# Supported type:",
"# https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/",
"if",... | Normalize data for the InfluxDB's data model. | [
"Normalize",
"data",
"for",
"the",
"InfluxDB",
"s",
"data",
"model",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_influxdb.py#L84-L110 | train |
nicolargo/glances | glances/exports/glances_influxdb.py | Export.export | def export(self, name, columns, points):
"""Write the points to the InfluxDB server."""
# Manage prefix
if self.prefix is not None:
name = self.prefix + '.' + name
# Write input to the InfluxDB database
try:
self.client.write_points(self._normalize(name, c... | python | def export(self, name, columns, points):
"""Write the points to the InfluxDB server."""
# Manage prefix
if self.prefix is not None:
name = self.prefix + '.' + name
# Write input to the InfluxDB database
try:
self.client.write_points(self._normalize(name, c... | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"# Manage prefix",
"if",
"self",
".",
"prefix",
"is",
"not",
"None",
":",
"name",
"=",
"self",
".",
"prefix",
"+",
"'.'",
"+",
"name",
"# Write input to the InfluxDB databa... | Write the points to the InfluxDB server. | [
"Write",
"the",
"points",
"to",
"the",
"InfluxDB",
"server",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_influxdb.py#L112-L124 | train |
nicolargo/glances | glances/filter.py | GlancesFilter.filter | def filter(self, value):
"""Set the filter (as a sting) and compute the regular expression
A filter could be one of the following:
- python > Process name of cmd start with python
- .*python.* > Process name of cmd contain python
- username:nicolargo > Process of nicolargo user
... | python | def filter(self, value):
"""Set the filter (as a sting) and compute the regular expression
A filter could be one of the following:
- python > Process name of cmd start with python
- .*python.* > Process name of cmd contain python
- username:nicolargo > Process of nicolargo user
... | [
"def",
"filter",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_filter_input",
"=",
"value",
"if",
"value",
"is",
"None",
":",
"self",
".",
"_filter",
"=",
"None",
"self",
".",
"_filter_key",
"=",
"None",
"else",
":",
"new_filter",
"=",
"value",
... | Set the filter (as a sting) and compute the regular expression
A filter could be one of the following:
- python > Process name of cmd start with python
- .*python.* > Process name of cmd contain python
- username:nicolargo > Process of nicolargo user | [
"Set",
"the",
"filter",
"(",
"as",
"a",
"sting",
")",
"and",
"compute",
"the",
"regular",
"expression",
"A",
"filter",
"could",
"be",
"one",
"of",
"the",
"following",
":",
"-",
"python",
">",
"Process",
"name",
"of",
"cmd",
"start",
"with",
"python",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/filter.py#L69-L100 | train |
nicolargo/glances | glances/filter.py | GlancesFilter.is_filtered | def is_filtered(self, process):
"""Return True if the process item match the current filter
The proces item is a dict.
"""
if self.filter is None:
# No filter => Not filtered
return False
if self.filter_key is None:
# Apply filter on command l... | python | def is_filtered(self, process):
"""Return True if the process item match the current filter
The proces item is a dict.
"""
if self.filter is None:
# No filter => Not filtered
return False
if self.filter_key is None:
# Apply filter on command l... | [
"def",
"is_filtered",
"(",
"self",
",",
"process",
")",
":",
"if",
"self",
".",
"filter",
"is",
"None",
":",
"# No filter => Not filtered",
"return",
"False",
"if",
"self",
".",
"filter_key",
"is",
"None",
":",
"# Apply filter on command line and process name",
"r... | Return True if the process item match the current filter
The proces item is a dict. | [
"Return",
"True",
"if",
"the",
"process",
"item",
"match",
"the",
"current",
"filter",
"The",
"proces",
"item",
"is",
"a",
"dict",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/filter.py#L112-L126 | train |
nicolargo/glances | glances/filter.py | GlancesFilter._is_process_filtered | def _is_process_filtered(self, process, key=None):
"""Return True if the process[key] should be filtered according to the current filter"""
if key is None:
key = self.filter_key
try:
# If the item process[key] is a list, convert it to a string
# in order to ma... | python | def _is_process_filtered(self, process, key=None):
"""Return True if the process[key] should be filtered according to the current filter"""
if key is None:
key = self.filter_key
try:
# If the item process[key] is a list, convert it to a string
# in order to ma... | [
"def",
"_is_process_filtered",
"(",
"self",
",",
"process",
",",
"key",
"=",
"None",
")",
":",
"if",
"key",
"is",
"None",
":",
"key",
"=",
"self",
".",
"filter_key",
"try",
":",
"# If the item process[key] is a list, convert it to a string",
"# in order to match it ... | Return True if the process[key] should be filtered according to the current filter | [
"Return",
"True",
"if",
"the",
"process",
"[",
"key",
"]",
"should",
"be",
"filtered",
"according",
"to",
"the",
"current",
"filter"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/filter.py#L128-L149 | train |
nicolargo/glances | glances/password_list.py | GlancesPasswordList.load | def load(self, config):
"""Load the password from the configuration file."""
password_dict = {}
if config is None:
logger.warning("No configuration file available. Cannot load password list.")
elif not config.has_section(self._section):
logger.warning("No [%s] se... | python | def load(self, config):
"""Load the password from the configuration file."""
password_dict = {}
if config is None:
logger.warning("No configuration file available. Cannot load password list.")
elif not config.has_section(self._section):
logger.warning("No [%s] se... | [
"def",
"load",
"(",
"self",
",",
"config",
")",
":",
"password_dict",
"=",
"{",
"}",
"if",
"config",
"is",
"None",
":",
"logger",
".",
"warning",
"(",
"\"No configuration file available. Cannot load password list.\"",
")",
"elif",
"not",
"config",
".",
"has_sect... | Load the password from the configuration file. | [
"Load",
"the",
"password",
"from",
"the",
"configuration",
"file",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password_list.py#L39-L56 | train |
nicolargo/glances | glances/password_list.py | GlancesPasswordList.get_password | def get_password(self, host=None):
"""
If host=None, return the current server list (dict).
Else, return the host's password (or the default one if defined or None)
"""
if host is None:
return self._password_dict
else:
try:
return s... | python | def get_password(self, host=None):
"""
If host=None, return the current server list (dict).
Else, return the host's password (or the default one if defined or None)
"""
if host is None:
return self._password_dict
else:
try:
return s... | [
"def",
"get_password",
"(",
"self",
",",
"host",
"=",
"None",
")",
":",
"if",
"host",
"is",
"None",
":",
"return",
"self",
".",
"_password_dict",
"else",
":",
"try",
":",
"return",
"self",
".",
"_password_dict",
"[",
"host",
"]",
"except",
"(",
"KeyErr... | If host=None, return the current server list (dict).
Else, return the host's password (or the default one if defined or None) | [
"If",
"host",
"=",
"None",
"return",
"the",
"current",
"server",
"list",
"(",
"dict",
")",
".",
"Else",
"return",
"the",
"host",
"s",
"password",
"(",
"or",
"the",
"default",
"one",
"if",
"defined",
"or",
"None",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password_list.py#L58-L72 | train |
nicolargo/glances | glances/amps/glances_systemd.py | Amp.update | def update(self, process_list):
"""Update the AMP"""
# Get the systemctl status
logger.debug('{}: Update stats using systemctl {}'.format(self.NAME, self.get('systemctl_cmd')))
try:
res = check_output(self.get('systemctl_cmd').split())
except (OSError, CalledProcessEr... | python | def update(self, process_list):
"""Update the AMP"""
# Get the systemctl status
logger.debug('{}: Update stats using systemctl {}'.format(self.NAME, self.get('systemctl_cmd')))
try:
res = check_output(self.get('systemctl_cmd').split())
except (OSError, CalledProcessEr... | [
"def",
"update",
"(",
"self",
",",
"process_list",
")",
":",
"# Get the systemctl status",
"logger",
".",
"debug",
"(",
"'{}: Update stats using systemctl {}'",
".",
"format",
"(",
"self",
".",
"NAME",
",",
"self",
".",
"get",
"(",
"'systemctl_cmd'",
")",
")",
... | Update the AMP | [
"Update",
"the",
"AMP"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_systemd.py#L68-L95 | train |
nicolargo/glances | glances/plugins/glances_gpu.py | get_mem | def get_mem(device_handle):
"""Get GPU device memory consumption in percent."""
try:
memory_info = pynvml.nvmlDeviceGetMemoryInfo(device_handle)
return memory_info.used * 100.0 / memory_info.total
except pynvml.NVMLError:
return None | python | def get_mem(device_handle):
"""Get GPU device memory consumption in percent."""
try:
memory_info = pynvml.nvmlDeviceGetMemoryInfo(device_handle)
return memory_info.used * 100.0 / memory_info.total
except pynvml.NVMLError:
return None | [
"def",
"get_mem",
"(",
"device_handle",
")",
":",
"try",
":",
"memory_info",
"=",
"pynvml",
".",
"nvmlDeviceGetMemoryInfo",
"(",
"device_handle",
")",
"return",
"memory_info",
".",
"used",
"*",
"100.0",
"/",
"memory_info",
".",
"total",
"except",
"pynvml",
"."... | Get GPU device memory consumption in percent. | [
"Get",
"GPU",
"device",
"memory",
"consumption",
"in",
"percent",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_gpu.py#L267-L273 | train |
nicolargo/glances | glances/plugins/glances_gpu.py | Plugin.init_nvidia | def init_nvidia(self):
"""Init the NVIDIA API."""
if import_error_tag:
self.nvml_ready = False
try:
pynvml.nvmlInit()
self.device_handles = get_device_handles()
self.nvml_ready = True
except Exception:
logger.debug("pynvml coul... | python | def init_nvidia(self):
"""Init the NVIDIA API."""
if import_error_tag:
self.nvml_ready = False
try:
pynvml.nvmlInit()
self.device_handles = get_device_handles()
self.nvml_ready = True
except Exception:
logger.debug("pynvml coul... | [
"def",
"init_nvidia",
"(",
"self",
")",
":",
"if",
"import_error_tag",
":",
"self",
".",
"nvml_ready",
"=",
"False",
"try",
":",
"pynvml",
".",
"nvmlInit",
"(",
")",
"self",
".",
"device_handles",
"=",
"get_device_handles",
"(",
")",
"self",
".",
"nvml_rea... | Init the NVIDIA API. | [
"Init",
"the",
"NVIDIA",
"API",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_gpu.py#L62-L75 | train |
nicolargo/glances | glances/plugins/glances_gpu.py | Plugin.update | def update(self):
"""Update the GPU stats."""
# Init new stats
stats = self.get_init_value()
# !!! JUST FOR TEST (because i did not have any NVidia GPU... :()
# self.stats = [{"key": "gpu_id", "mem": None, "proc": 60, "gpu_id": 0, "name": "GeForce GTX 560 Ti"}]
# self.st... | python | def update(self):
"""Update the GPU stats."""
# Init new stats
stats = self.get_init_value()
# !!! JUST FOR TEST (because i did not have any NVidia GPU... :()
# self.stats = [{"key": "gpu_id", "mem": None, "proc": 60, "gpu_id": 0, "name": "GeForce GTX 560 Ti"}]
# self.st... | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"# !!! JUST FOR TEST (because i did not have any NVidia GPU... :()",
"# self.stats = [{\"key\": \"gpu_id\", \"mem\": None, \"proc\": 60, \"gpu_id\": 0, \"name\": \"GeForce... | Update the GPU stats. | [
"Update",
"the",
"GPU",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_gpu.py#L83-L111 | train |
nicolargo/glances | glances/plugins/glances_gpu.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, not empty (issue #871) and plugin not disabled
if not self.stats or (self.stats == []) or self.is_disable():... | 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, not empty (issue #871) and plugin not disabled
if not self.stats or (self.stats == []) or self.is_disable():... | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist, not empty (issue #871) and plugin not disabled",
"if",
"not",
"self",
".",
"stats",
... | 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_gpu.py#L134-L217 | train |
nicolargo/glances | glances/plugins/glances_gpu.py | Plugin.get_device_stats | def get_device_stats(self):
"""Get GPU stats."""
stats = []
for index, device_handle in enumerate(self.device_handles):
device_stats = {}
# Dictionnary key is the GPU_ID
device_stats['key'] = self.get_key()
# GPU id (for multiple GPU, start at 0)
... | python | def get_device_stats(self):
"""Get GPU stats."""
stats = []
for index, device_handle in enumerate(self.device_handles):
device_stats = {}
# Dictionnary key is the GPU_ID
device_stats['key'] = self.get_key()
# GPU id (for multiple GPU, start at 0)
... | [
"def",
"get_device_stats",
"(",
"self",
")",
":",
"stats",
"=",
"[",
"]",
"for",
"index",
",",
"device_handle",
"in",
"enumerate",
"(",
"self",
".",
"device_handles",
")",
":",
"device_stats",
"=",
"{",
"}",
"# Dictionnary key is the GPU_ID",
"device_stats",
"... | Get GPU stats. | [
"Get",
"GPU",
"stats",
"."
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_gpu.py#L219-L237 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.