id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
222,400
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.parse_stats_file
def parse_stats_file(self, file_name): """ Read and parse given file_name, return config as a dictionary """ stats = {} try: with open(file_name, "r") as fhandle: fbuffer = [] save_buffer = False for line in fhandle: ...
python
def parse_stats_file(self, file_name): """ Read and parse given file_name, return config as a dictionary """ stats = {} try: with open(file_name, "r") as fhandle: fbuffer = [] save_buffer = False for line in fhandle: ...
[ "def", "parse_stats_file", "(", "self", ",", "file_name", ")", ":", "stats", "=", "{", "}", "try", ":", "with", "open", "(", "file_name", ",", "\"r\"", ")", "as", "fhandle", ":", "fbuffer", "=", "[", "]", "save_buffer", "=", "False", "for", "line", "...
Read and parse given file_name, return config as a dictionary
[ "Read", "and", "parse", "given", "file_name", "return", "config", "as", "a", "dictionary" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L80-L121
222,401
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.get_host_stats
def get_host_stats(self, hosts): """ Get statistics for Hosts, resp. Host entities """ stats = { "hosts.total": 0, "hosts.ok": 0, "hosts.down": 0, "hosts.unreachable": 0, "hosts.flapping": 0, "hosts.in_downtime": 0, "hos...
python
def get_host_stats(self, hosts): """ Get statistics for Hosts, resp. Host entities """ stats = { "hosts.total": 0, "hosts.ok": 0, "hosts.down": 0, "hosts.unreachable": 0, "hosts.flapping": 0, "hosts.in_downtime": 0, "hos...
[ "def", "get_host_stats", "(", "self", ",", "hosts", ")", ":", "stats", "=", "{", "\"hosts.total\"", ":", "0", ",", "\"hosts.ok\"", ":", "0", ",", "\"hosts.down\"", ":", "0", ",", "\"hosts.unreachable\"", ":", "0", ",", "\"hosts.flapping\"", ":", "0", ",", ...
Get statistics for Hosts, resp. Host entities
[ "Get", "statistics", "for", "Hosts", "resp", ".", "Host", "entities" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L123-L153
222,402
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector.get_svc_stats
def get_svc_stats(self, svcs): """ Get statistics for Services, resp. Service entities """ stats = { "services.total": 0, "services.ok": 0, "services.warning": 0, "services.critical": 0, "services.unknown": 0, "services.flapping": 0...
python
def get_svc_stats(self, svcs): """ Get statistics for Services, resp. Service entities """ stats = { "services.total": 0, "services.ok": 0, "services.warning": 0, "services.critical": 0, "services.unknown": 0, "services.flapping": 0...
[ "def", "get_svc_stats", "(", "self", ",", "svcs", ")", ":", "stats", "=", "{", "\"services.total\"", ":", "0", ",", "\"services.ok\"", ":", "0", ",", "\"services.warning\"", ":", "0", ",", "\"services.critical\"", ":", "0", ",", "\"services.unknown\"", ":", ...
Get statistics for Services, resp. Service entities
[ "Get", "statistics", "for", "Services", "resp", ".", "Service", "entities" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L155-L187
222,403
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector._convert_tripplet
def _convert_tripplet(self, tripplet): """ Turn '10,178,528' into tuple of integers """ splitted = tripplet.split(",") if len(splitted) != 3: self.log.debug("Got %i chunks, expected 3.", len(splitted)) return (0, 0, 0) try: x01 = int(splitted[0]) ...
python
def _convert_tripplet(self, tripplet): """ Turn '10,178,528' into tuple of integers """ splitted = tripplet.split(",") if len(splitted) != 3: self.log.debug("Got %i chunks, expected 3.", len(splitted)) return (0, 0, 0) try: x01 = int(splitted[0]) ...
[ "def", "_convert_tripplet", "(", "self", ",", "tripplet", ")", ":", "splitted", "=", "tripplet", ".", "split", "(", "\",\"", ")", "if", "len", "(", "splitted", ")", "!=", "3", ":", "self", ".", "log", ".", "debug", "(", "\"Got %i chunks, expected 3.\"", ...
Turn '10,178,528' into tuple of integers
[ "Turn", "10", "178", "528", "into", "tuple", "of", "integers" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L189-L206
222,404
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector._get_uptime
def _get_uptime(self, app_stats): """ Return Icinga's uptime """ if "program_start" not in app_stats.keys(): return 0 if not app_stats["program_start"].isdigit(): return 0 uptime = int(time.time()) - int(app_stats["program_start"]) if uptime < 0: ...
python
def _get_uptime(self, app_stats): """ Return Icinga's uptime """ if "program_start" not in app_stats.keys(): return 0 if not app_stats["program_start"].isdigit(): return 0 uptime = int(time.time()) - int(app_stats["program_start"]) if uptime < 0: ...
[ "def", "_get_uptime", "(", "self", ",", "app_stats", ")", ":", "if", "\"program_start\"", "not", "in", "app_stats", ".", "keys", "(", ")", ":", "return", "0", "if", "not", "app_stats", "[", "\"program_start\"", "]", ".", "isdigit", "(", ")", ":", "return...
Return Icinga's uptime
[ "Return", "Icinga", "s", "uptime" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L323-L335
222,405
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector._parse_config_buffer
def _parse_config_buffer(self, fbuffer): """ Parse buffered chunk of config into dict """ if len(fbuffer) < 1 or not fbuffer[0].endswith("{"): # Invalid input return {} entity = {} entity_type = fbuffer.pop(0) entity_type = entity_type.rstrip("{") ...
python
def _parse_config_buffer(self, fbuffer): """ Parse buffered chunk of config into dict """ if len(fbuffer) < 1 or not fbuffer[0].endswith("{"): # Invalid input return {} entity = {} entity_type = fbuffer.pop(0) entity_type = entity_type.rstrip("{") ...
[ "def", "_parse_config_buffer", "(", "self", ",", "fbuffer", ")", ":", "if", "len", "(", "fbuffer", ")", "<", "1", "or", "not", "fbuffer", "[", "0", "]", ".", "endswith", "(", "\"{\"", ")", ":", "# Invalid input", "return", "{", "}", "entity", "=", "{...
Parse buffered chunk of config into dict
[ "Parse", "buffered", "chunk", "of", "config", "into", "dict" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L337-L357
222,406
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector._sanitize_entity
def _sanitize_entity(self, entity): """ Make given entity 'sane' for further use. """ aliases = { "current_state": "state", "is_flapping": "flapping", "scheduled_downtime_depth": "in_downtime", "has_been_checked": "checked", "sh...
python
def _sanitize_entity(self, entity): """ Make given entity 'sane' for further use. """ aliases = { "current_state": "state", "is_flapping": "flapping", "scheduled_downtime_depth": "in_downtime", "has_been_checked": "checked", "sh...
[ "def", "_sanitize_entity", "(", "self", ",", "entity", ")", ":", "aliases", "=", "{", "\"current_state\"", ":", "\"state\"", ",", "\"is_flapping\"", ":", "\"flapping\"", ",", "\"scheduled_downtime_depth\"", ":", "\"in_downtime\"", ",", "\"has_been_checked\"", ":", "...
Make given entity 'sane' for further use.
[ "Make", "given", "entity", "sane", "for", "further", "use", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L359-L395
222,407
python-diamond/Diamond
src/collectors/icinga_stats/icinga_stats.py
IcingaStatsCollector._trim
def _trim(self, somestr): """ Trim left-right given string """ tmp = RE_LSPACES.sub("", somestr) tmp = RE_TSPACES.sub("", tmp) return str(tmp)
python
def _trim(self, somestr): """ Trim left-right given string """ tmp = RE_LSPACES.sub("", somestr) tmp = RE_TSPACES.sub("", tmp) return str(tmp)
[ "def", "_trim", "(", "self", ",", "somestr", ")", ":", "tmp", "=", "RE_LSPACES", ".", "sub", "(", "\"\"", ",", "somestr", ")", "tmp", "=", "RE_TSPACES", ".", "sub", "(", "\"\"", ",", "tmp", ")", "return", "str", "(", "tmp", ")" ]
Trim left-right given string
[ "Trim", "left", "-", "right", "given", "string" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/icinga_stats/icinga_stats.py#L441-L445
222,408
python-diamond/Diamond
src/collectors/jolokia/jolokia.py
JolokiaCollector._list_request
def _list_request(self): """Returns a dictionary with JMX domain names as keys""" try: # https://jolokia.org/reference/html/protocol.html # # A maxDepth of 1 restricts the return value to a map with the JMX # domains as keys. The values of the maps don't h...
python
def _list_request(self): """Returns a dictionary with JMX domain names as keys""" try: # https://jolokia.org/reference/html/protocol.html # # A maxDepth of 1 restricts the return value to a map with the JMX # domains as keys. The values of the maps don't h...
[ "def", "_list_request", "(", "self", ")", ":", "try", ":", "# https://jolokia.org/reference/html/protocol.html", "#", "# A maxDepth of 1 restricts the return value to a map with the JMX", "# domains as keys. The values of the maps don't have any meaning", "# and are dummy values.", "#", ...
Returns a dictionary with JMX domain names as keys
[ "Returns", "a", "dictionary", "with", "JMX", "domain", "names", "as", "keys" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jolokia/jolokia.py#L213-L238
222,409
python-diamond/Diamond
src/collectors/cephstats/cephstats.py
CephStatsCollector._get_stats
def _get_stats(self): """ Get ceph stats """ try: output = subprocess.check_output(['ceph', '-s']) except subprocess.CalledProcessError as err: self.log.info( 'Could not get stats: %s' % err) self.log.exception('Could not get st...
python
def _get_stats(self): """ Get ceph stats """ try: output = subprocess.check_output(['ceph', '-s']) except subprocess.CalledProcessError as err: self.log.info( 'Could not get stats: %s' % err) self.log.exception('Could not get st...
[ "def", "_get_stats", "(", "self", ")", ":", "try", ":", "output", "=", "subprocess", ".", "check_output", "(", "[", "'ceph'", ",", "'-s'", "]", ")", "except", "subprocess", ".", "CalledProcessError", "as", "err", ":", "self", ".", "log", ".", "info", "...
Get ceph stats
[ "Get", "ceph", "stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/cephstats/cephstats.py#L65-L76
222,410
python-diamond/Diamond
src/collectors/filestat/filestat.py
FilestatCollector.process_lsof
def process_lsof(self, users, types): """ Get the list of users and file types to collect for and collect the data from lsof """ d = {} for u in users: d[u] = {} tmp = os.popen("lsof -wbu %s | awk '{ print $5 }'" % ( u)).read().spli...
python
def process_lsof(self, users, types): """ Get the list of users and file types to collect for and collect the data from lsof """ d = {} for u in users: d[u] = {} tmp = os.popen("lsof -wbu %s | awk '{ print $5 }'" % ( u)).read().spli...
[ "def", "process_lsof", "(", "self", ",", "users", ",", "types", ")", ":", "d", "=", "{", "}", "for", "u", "in", "users", ":", "d", "[", "u", "]", "=", "{", "}", "tmp", "=", "os", ".", "popen", "(", "\"lsof -wbu %s | awk '{ print $5 }'\"", "%", "(",...
Get the list of users and file types to collect for and collect the data from lsof
[ "Get", "the", "list", "of", "users", "and", "file", "types", "to", "collect", "for", "and", "collect", "the", "data", "from", "lsof" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/filestat/filestat.py#L231-L243
222,411
python-diamond/Diamond
src/collectors/nfacct/nfacct.py
NetfilterAccountingCollector.collect
def collect(self): """ Collect and publish netfilter counters """ cmd = [self.config['bin'], "list"] if str_to_bool(self.config['reset']): cmd.append("reset") if str_to_bool(self.config['use_sudo']): cmd.insert(0, self.config['sudo_cmd']) ...
python
def collect(self): """ Collect and publish netfilter counters """ cmd = [self.config['bin'], "list"] if str_to_bool(self.config['reset']): cmd.append("reset") if str_to_bool(self.config['use_sudo']): cmd.insert(0, self.config['sudo_cmd']) ...
[ "def", "collect", "(", "self", ")", ":", "cmd", "=", "[", "self", ".", "config", "[", "'bin'", "]", ",", "\"list\"", "]", "if", "str_to_bool", "(", "self", ".", "config", "[", "'reset'", "]", ")", ":", "cmd", ".", "append", "(", "\"reset\"", ")", ...
Collect and publish netfilter counters
[ "Collect", "and", "publish", "netfilter", "counters" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nfacct/nfacct.py#L47-L75
222,412
python-diamond/Diamond
src/collectors/openvpn/openvpn.py
OpenVPNCollector.parse_url
def parse_url(self, uri): """ Convert urlparse from a python 2.4 layout to a python 2.7 layout """ parsed = urlparse.urlparse(uri) if 'scheme' not in parsed: class Object(object): pass newparsed = Object() newparsed.scheme = par...
python
def parse_url(self, uri): """ Convert urlparse from a python 2.4 layout to a python 2.7 layout """ parsed = urlparse.urlparse(uri) if 'scheme' not in parsed: class Object(object): pass newparsed = Object() newparsed.scheme = par...
[ "def", "parse_url", "(", "self", ",", "uri", ")", ":", "parsed", "=", "urlparse", ".", "urlparse", "(", "uri", ")", "if", "'scheme'", "not", "in", "parsed", ":", "class", "Object", "(", "object", ")", ":", "pass", "newparsed", "=", "Object", "(", ")"...
Convert urlparse from a python 2.4 layout to a python 2.7 layout
[ "Convert", "urlparse", "from", "a", "python", "2", ".", "4", "layout", "to", "a", "python", "2", ".", "7", "layout" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/openvpn/openvpn.py#L66-L86
222,413
python-diamond/Diamond
src/collectors/jcollectd/jcollectd.py
sanitize_word
def sanitize_word(s): """Remove non-alphanumerical characters from metric word. And trim excessive underscores. """ s = re.sub('[^\w-]+', '_', s) s = re.sub('__+', '_', s) return s.strip('_')
python
def sanitize_word(s): """Remove non-alphanumerical characters from metric word. And trim excessive underscores. """ s = re.sub('[^\w-]+', '_', s) s = re.sub('__+', '_', s) return s.strip('_')
[ "def", "sanitize_word", "(", "s", ")", ":", "s", "=", "re", ".", "sub", "(", "'[^\\w-]+'", ",", "'_'", ",", "s", ")", "s", "=", "re", ".", "sub", "(", "'__+'", ",", "'_'", ",", "s", ")", "return", "s", ".", "strip", "(", "'_'", ")" ]
Remove non-alphanumerical characters from metric word. And trim excessive underscores.
[ "Remove", "non", "-", "alphanumerical", "characters", "from", "metric", "word", ".", "And", "trim", "excessive", "underscores", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/jcollectd.py#L197-L203
222,414
python-diamond/Diamond
src/collectors/mesos/mesos.py
MesosCollector._add_cpu_usage
def _add_cpu_usage(self, cur_read): """Compute cpu usage based on cpu time spent compared to elapsed time """ for executor_id, cur_data in cur_read.items(): if executor_id in self.executors_prev_read: prev_data = self.executors_prev_read[executor_id] ...
python
def _add_cpu_usage(self, cur_read): """Compute cpu usage based on cpu time spent compared to elapsed time """ for executor_id, cur_data in cur_read.items(): if executor_id in self.executors_prev_read: prev_data = self.executors_prev_read[executor_id] ...
[ "def", "_add_cpu_usage", "(", "self", ",", "cur_read", ")", ":", "for", "executor_id", ",", "cur_data", "in", "cur_read", ".", "items", "(", ")", ":", "if", "executor_id", "in", "self", ".", "executors_prev_read", ":", "prev_data", "=", "self", ".", "execu...
Compute cpu usage based on cpu time spent compared to elapsed time
[ "Compute", "cpu", "usage", "based", "on", "cpu", "time", "spent", "compared", "to", "elapsed", "time" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mesos/mesos.py#L101-L119
222,415
python-diamond/Diamond
src/collectors/mesos/mesos.py
MesosCollector._add_cpu_percent
def _add_cpu_percent(self, cur_read): """Compute cpu percent basing on the provided utilisation """ for executor_id, cur_data in cur_read.items(): stats = cur_data['statistics'] cpus_limit = stats.get('cpus_limit') cpus_utilisation = stats.get('cpus_utilisatio...
python
def _add_cpu_percent(self, cur_read): """Compute cpu percent basing on the provided utilisation """ for executor_id, cur_data in cur_read.items(): stats = cur_data['statistics'] cpus_limit = stats.get('cpus_limit') cpus_utilisation = stats.get('cpus_utilisatio...
[ "def", "_add_cpu_percent", "(", "self", ",", "cur_read", ")", ":", "for", "executor_id", ",", "cur_data", "in", "cur_read", ".", "items", "(", ")", ":", "stats", "=", "cur_data", "[", "'statistics'", "]", "cpus_limit", "=", "stats", ".", "get", "(", "'cp...
Compute cpu percent basing on the provided utilisation
[ "Compute", "cpu", "percent", "basing", "on", "the", "provided", "utilisation" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mesos/mesos.py#L121-L129
222,416
python-diamond/Diamond
src/collectors/mesos/mesos.py
MesosCollector._add_mem_percent
def _add_mem_percent(self, cur_read): """Compute memory percent utilisation based on the mem_rss_bytes and mem_limit_bytes """ for executor_id, cur_data in cur_read.items(): stats = cur_data['statistics'] mem_rss_bytes = stats.get('mem_rss_bytes') mem_...
python
def _add_mem_percent(self, cur_read): """Compute memory percent utilisation based on the mem_rss_bytes and mem_limit_bytes """ for executor_id, cur_data in cur_read.items(): stats = cur_data['statistics'] mem_rss_bytes = stats.get('mem_rss_bytes') mem_...
[ "def", "_add_mem_percent", "(", "self", ",", "cur_read", ")", ":", "for", "executor_id", ",", "cur_data", "in", "cur_read", ".", "items", "(", ")", ":", "stats", "=", "cur_data", "[", "'statistics'", "]", "mem_rss_bytes", "=", "stats", ".", "get", "(", "...
Compute memory percent utilisation based on the mem_rss_bytes and mem_limit_bytes
[ "Compute", "memory", "percent", "utilisation", "based", "on", "the", "mem_rss_bytes", "and", "mem_limit_bytes" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mesos/mesos.py#L131-L140
222,417
python-diamond/Diamond
src/collectors/mesos/mesos.py
MesosCollector._group_and_publish_tasks_statistics
def _group_and_publish_tasks_statistics(self, result): """This function group statistics of same tasks by adding them. It also add 'instances_count' statistic to get information about how many instances is running on the server Args: result: result of mesos query. List of di...
python
def _group_and_publish_tasks_statistics(self, result): """This function group statistics of same tasks by adding them. It also add 'instances_count' statistic to get information about how many instances is running on the server Args: result: result of mesos query. List of di...
[ "def", "_group_and_publish_tasks_statistics", "(", "self", ",", "result", ")", ":", "for", "i", "in", "result", ":", "executor_id", "=", "i", "[", "'executor_id'", "]", "i", "[", "'executor_id'", "]", "=", "executor_id", "[", ":", "executor_id", ".", "rfind"...
This function group statistics of same tasks by adding them. It also add 'instances_count' statistic to get information about how many instances is running on the server Args: result: result of mesos query. List of dictionaries with 'executor_id', 'framework_id' as a str...
[ "This", "function", "group", "statistics", "of", "same", "tasks", "by", "adding", "them", ".", "It", "also", "add", "instances_count", "statistic", "to", "get", "information", "about", "how", "many", "instances", "is", "running", "on", "the", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mesos/mesos.py#L142-L169
222,418
python-diamond/Diamond
src/collectors/mesos/mesos.py
MesosCollector._get
def _get(self, path): """ Execute a Mesos API call. """ url = self._get_url(path) try: response = urllib2.urlopen(url) except Exception as err: self.log.error("%s: %s", url, err) return False try: doc = json.load(re...
python
def _get(self, path): """ Execute a Mesos API call. """ url = self._get_url(path) try: response = urllib2.urlopen(url) except Exception as err: self.log.error("%s: %s", url, err) return False try: doc = json.load(re...
[ "def", "_get", "(", "self", ",", "path", ")", ":", "url", "=", "self", ".", "_get_url", "(", "path", ")", "try", ":", "response", "=", "urllib2", ".", "urlopen", "(", "url", ")", "except", "Exception", "as", "err", ":", "self", ".", "log", ".", "...
Execute a Mesos API call.
[ "Execute", "a", "Mesos", "API", "call", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mesos/mesos.py#L194-L212
222,419
python-diamond/Diamond
src/collectors/postgres/postgres.py
PostgresqlCollector.get_default_config_help
def get_default_config_help(self): """ Return help text for collector """ config_help = super(PostgresqlCollector, self).get_default_config_help() config_help.update({ 'host': 'Hostname', 'dbname': 'DB to connect to in order to ...
python
def get_default_config_help(self): """ Return help text for collector """ config_help = super(PostgresqlCollector, self).get_default_config_help() config_help.update({ 'host': 'Hostname', 'dbname': 'DB to connect to in order to ...
[ "def", "get_default_config_help", "(", "self", ")", ":", "config_help", "=", "super", "(", "PostgresqlCollector", ",", "self", ")", ".", "get_default_config_help", "(", ")", "config_help", ".", "update", "(", "{", "'host'", ":", "'Hostname'", ",", "'dbname'", ...
Return help text for collector
[ "Return", "help", "text", "for", "collector" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/postgres/postgres.py#L27-L50
222,420
python-diamond/Diamond
src/collectors/postgres/postgres.py
PostgresqlCollector.collect
def collect(self): """ Do pre-flight checks, get list of db names, collect metrics, publish """ if psycopg2 is None: self.log.error('Unable to import module psycopg2') return {} # Get list of databases dbs = self._get_db_names() if len(dbs...
python
def collect(self): """ Do pre-flight checks, get list of db names, collect metrics, publish """ if psycopg2 is None: self.log.error('Unable to import module psycopg2') return {} # Get list of databases dbs = self._get_db_names() if len(dbs...
[ "def", "collect", "(", "self", ")", ":", "if", "psycopg2", "is", "None", ":", "self", ".", "log", ".", "error", "(", "'Unable to import module psycopg2'", ")", "return", "{", "}", "# Get list of databases", "dbs", "=", "self", ".", "_get_db_names", "(", ")",...
Do pre-flight checks, get list of db names, collect metrics, publish
[ "Do", "pre", "-", "flight", "checks", "get", "list", "of", "db", "names", "collect", "metrics", "publish" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/postgres/postgres.py#L74-L126
222,421
python-diamond/Diamond
src/collectors/postgres/postgres.py
PostgresqlCollector._get_db_names
def _get_db_names(self): """ Try to get a list of db names """ query = """ SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate AND NOT datname='postgres' AND NOT datname='rdsadmin' ORDER BY 1 """ conn = self._connec...
python
def _get_db_names(self): """ Try to get a list of db names """ query = """ SELECT datname FROM pg_database WHERE datallowconn AND NOT datistemplate AND NOT datname='postgres' AND NOT datname='rdsadmin' ORDER BY 1 """ conn = self._connec...
[ "def", "_get_db_names", "(", "self", ")", ":", "query", "=", "\"\"\"\n SELECT datname FROM pg_database\n WHERE datallowconn AND NOT datistemplate\n AND NOT datname='postgres' AND NOT datname='rdsadmin' ORDER BY 1\n \"\"\"", "conn", "=", "self", ".", ...
Try to get a list of db names
[ "Try", "to", "get", "a", "list", "of", "db", "names" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/postgres/postgres.py#L128-L148
222,422
python-diamond/Diamond
src/collectors/postgres/postgres.py
PostgresqlCollector._connect
def _connect(self, database=None): """ Connect to given database """ conn_args = { 'host': self.config['host'], 'user': self.config['user'], 'password': self.config['password'], 'port': self.config['port'], 'sslmode': self.confi...
python
def _connect(self, database=None): """ Connect to given database """ conn_args = { 'host': self.config['host'], 'user': self.config['user'], 'password': self.config['password'], 'port': self.config['port'], 'sslmode': self.confi...
[ "def", "_connect", "(", "self", ",", "database", "=", "None", ")", ":", "conn_args", "=", "{", "'host'", ":", "self", ".", "config", "[", "'host'", "]", ",", "'user'", ":", "self", ".", "config", "[", "'user'", "]", ",", "'password'", ":", "self", ...
Connect to given database
[ "Connect", "to", "given", "database" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/postgres/postgres.py#L150-L179
222,423
python-diamond/Diamond
src/collectors/iodrivesnmp/iodrivesnmp.py
IODriveSNMPCollector.get_string_index_oid
def get_string_index_oid(self, s): """Turns a string into an oid format is length of name followed by name chars in ascii""" return (len(self.get_bytes(s)), ) + self.get_bytes(s)
python
def get_string_index_oid(self, s): """Turns a string into an oid format is length of name followed by name chars in ascii""" return (len(self.get_bytes(s)), ) + self.get_bytes(s)
[ "def", "get_string_index_oid", "(", "self", ",", "s", ")", ":", "return", "(", "len", "(", "self", ".", "get_bytes", "(", "s", ")", ")", ",", ")", "+", "self", ".", "get_bytes", "(", "s", ")" ]
Turns a string into an oid format is length of name followed by name chars in ascii
[ "Turns", "a", "string", "into", "an", "oid", "format", "is", "length", "of", "name", "followed", "by", "name", "chars", "in", "ascii" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/iodrivesnmp/iodrivesnmp.py#L89-L92
222,424
python-diamond/Diamond
src/collectors/iodrivesnmp/iodrivesnmp.py
IODriveSNMPCollector.collect_snmp
def collect_snmp(self, device, host, port, community): """ Collect Fusion IO Drive SNMP stats from device host and device are from the conf file. In the future device should be changed to be what IODRive device it being checked. i.e. fioa, fiob. """ # Set timesta...
python
def collect_snmp(self, device, host, port, community): """ Collect Fusion IO Drive SNMP stats from device host and device are from the conf file. In the future device should be changed to be what IODRive device it being checked. i.e. fioa, fiob. """ # Set timesta...
[ "def", "collect_snmp", "(", "self", ",", "device", ",", "host", ",", "port", ",", "community", ")", ":", "# Set timestamp", "timestamp", "=", "time", ".", "time", "(", ")", "for", "k", ",", "v", "in", "self", ".", "IODRIVE_STATS", ".", "items", "(", ...
Collect Fusion IO Drive SNMP stats from device host and device are from the conf file. In the future device should be changed to be what IODRive device it being checked. i.e. fioa, fiob.
[ "Collect", "Fusion", "IO", "Drive", "SNMP", "stats", "from", "device", "host", "and", "device", "are", "from", "the", "conf", "file", ".", "In", "the", "future", "device", "should", "be", "changed", "to", "be", "what", "IODRive", "device", "it", "being", ...
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/iodrivesnmp/iodrivesnmp.py#L98-L135
222,425
python-diamond/Diamond
src/diamond/handler/graphite.py
GraphiteHandler._send_data
def _send_data(self, data): """ Try to send all data in buffer. """ try: self.socket.sendall(data) self._reset_errors() except: self._close() self._throttle_error("GraphiteHandler: Socket error, " "t...
python
def _send_data(self, data): """ Try to send all data in buffer. """ try: self.socket.sendall(data) self._reset_errors() except: self._close() self._throttle_error("GraphiteHandler: Socket error, " "t...
[ "def", "_send_data", "(", "self", ",", "data", ")", ":", "try", ":", "self", ".", "socket", ".", "sendall", "(", "data", ")", "self", ".", "_reset_errors", "(", ")", "except", ":", "self", ".", "_close", "(", ")", "self", ".", "_throttle_error", "(",...
Try to send all data in buffer.
[ "Try", "to", "send", "all", "data", "in", "buffer", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphite.py#L126-L142
222,426
python-diamond/Diamond
src/diamond/handler/graphite.py
GraphiteHandler._send
def _send(self): """ Send data to graphite. Data that can not be sent will be queued. """ # Check to see if we have a valid socket. If not, try to connect. try: try: if self.socket is None: self.log.debug("GraphiteHandler: Socket is...
python
def _send(self): """ Send data to graphite. Data that can not be sent will be queued. """ # Check to see if we have a valid socket. If not, try to connect. try: try: if self.socket is None: self.log.debug("GraphiteHandler: Socket is...
[ "def", "_send", "(", "self", ")", ":", "# Check to see if we have a valid socket. If not, try to connect.", "try", ":", "try", ":", "if", "self", ".", "socket", "is", "None", ":", "self", ".", "log", ".", "debug", "(", "\"GraphiteHandler: Socket is not connected. \"",...
Send data to graphite. Data that can not be sent will be queued.
[ "Send", "data", "to", "graphite", ".", "Data", "that", "can", "not", "be", "sent", "will", "be", "queued", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphite.py#L151-L183
222,427
python-diamond/Diamond
src/diamond/handler/graphite.py
GraphiteHandler._connect
def _connect(self): """ Connect to the graphite server """ if (self.proto == 'udp'): stream = socket.SOCK_DGRAM else: stream = socket.SOCK_STREAM if (self.proto[-1] == '4'): family = socket.AF_INET connection_struct = (self...
python
def _connect(self): """ Connect to the graphite server """ if (self.proto == 'udp'): stream = socket.SOCK_DGRAM else: stream = socket.SOCK_STREAM if (self.proto[-1] == '4'): family = socket.AF_INET connection_struct = (self...
[ "def", "_connect", "(", "self", ")", ":", "if", "(", "self", ".", "proto", "==", "'udp'", ")", ":", "stream", "=", "socket", ".", "SOCK_DGRAM", "else", ":", "stream", "=", "socket", ".", "SOCK_STREAM", "if", "(", "self", ".", "proto", "[", "-", "1"...
Connect to the graphite server
[ "Connect", "to", "the", "graphite", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphite.py#L185-L251
222,428
python-diamond/Diamond
src/diamond/handler/null.py
NullHandler.process
def process(self, metric): """ Process a metric by doing nothing """ self.log.debug("Metric: %s", str(metric).rstrip().replace(' ', '\t'))
python
def process(self, metric): """ Process a metric by doing nothing """ self.log.debug("Metric: %s", str(metric).rstrip().replace(' ', '\t'))
[ "def", "process", "(", "self", ",", "metric", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Metric: %s\"", ",", "str", "(", "metric", ")", ".", "rstrip", "(", ")", ".", "replace", "(", "' '", ",", "'\\t'", ")", ")" ]
Process a metric by doing nothing
[ "Process", "a", "metric", "by", "doing", "nothing" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/null.py#L15-L19
222,429
python-diamond/Diamond
src/diamond/collector.py
Collector.load_config
def load_config(self, configfile=None, override_config=None): """ Process a configfile, or reload if previously given one. """ self.config = configobj.ConfigObj() # Load in the collector's defaults if self.get_default_config() is not None: self.config.merge(s...
python
def load_config(self, configfile=None, override_config=None): """ Process a configfile, or reload if previously given one. """ self.config = configobj.ConfigObj() # Load in the collector's defaults if self.get_default_config() is not None: self.config.merge(s...
[ "def", "load_config", "(", "self", ",", "configfile", "=", "None", ",", "override_config", "=", "None", ")", ":", "self", ".", "config", "=", "configobj", ".", "ConfigObj", "(", ")", "# Load in the collector's defaults", "if", "self", ".", "get_default_config", ...
Process a configfile, or reload if previously given one.
[ "Process", "a", "configfile", "or", "reload", "if", "previously", "given", "one", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L181-L212
222,430
python-diamond/Diamond
src/diamond/collector.py
Collector.process_config
def process_config(self): """ Intended to put any code that should be run after any config reload event """ if 'byte_unit' in self.config: if isinstance(self.config['byte_unit'], basestring): self.config['byte_unit'] = self.config['byte_unit'].split() ...
python
def process_config(self): """ Intended to put any code that should be run after any config reload event """ if 'byte_unit' in self.config: if isinstance(self.config['byte_unit'], basestring): self.config['byte_unit'] = self.config['byte_unit'].split() ...
[ "def", "process_config", "(", "self", ")", ":", "if", "'byte_unit'", "in", "self", ".", "config", ":", "if", "isinstance", "(", "self", ".", "config", "[", "'byte_unit'", "]", ",", "basestring", ")", ":", "self", ".", "config", "[", "'byte_unit'", "]", ...
Intended to put any code that should be run after any config reload event
[ "Intended", "to", "put", "any", "code", "that", "should", "be", "run", "after", "any", "config", "reload", "event" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L214-L242
222,431
python-diamond/Diamond
src/diamond/collector.py
Collector.get_metric_path
def get_metric_path(self, name, instance=None): """ Get metric path. Instance indicates that this is a metric for a virtual machine and should have a different root prefix. """ if 'path' in self.config: path = self.config['path'] else: ...
python
def get_metric_path(self, name, instance=None): """ Get metric path. Instance indicates that this is a metric for a virtual machine and should have a different root prefix. """ if 'path' in self.config: path = self.config['path'] else: ...
[ "def", "get_metric_path", "(", "self", ",", "name", ",", "instance", "=", "None", ")", ":", "if", "'path'", "in", "self", ".", "config", ":", "path", "=", "self", ".", "config", "[", "'path'", "]", "else", ":", "path", "=", "self", ".", "__class__", ...
Get metric path. Instance indicates that this is a metric for a virtual machine and should have a different root prefix.
[ "Get", "metric", "path", ".", "Instance", "indicates", "that", "this", "is", "a", "metric", "for", "a", "virtual", "machine", "and", "should", "have", "a", "different", "root", "prefix", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L310-L362
222,432
python-diamond/Diamond
src/diamond/collector.py
Collector.publish
def publish(self, name, value, raw_value=None, precision=0, metric_type='GAUGE', instance=None): """ Publish a metric with the given name """ # Check whitelist/blacklist if self.config['metrics_whitelist']: if not self.config['metrics_whitelist'].match...
python
def publish(self, name, value, raw_value=None, precision=0, metric_type='GAUGE', instance=None): """ Publish a metric with the given name """ # Check whitelist/blacklist if self.config['metrics_whitelist']: if not self.config['metrics_whitelist'].match...
[ "def", "publish", "(", "self", ",", "name", ",", "value", ",", "raw_value", "=", "None", ",", "precision", "=", "0", ",", "metric_type", "=", "'GAUGE'", ",", "instance", "=", "None", ")", ":", "# Check whitelist/blacklist", "if", "self", ".", "config", "...
Publish a metric with the given name
[ "Publish", "a", "metric", "with", "the", "given", "name" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L373-L404
222,433
python-diamond/Diamond
src/diamond/collector.py
Collector.derivative
def derivative(self, name, new, max_value=0, time_delta=True, interval=None, allow_negative=False, instance=None): """ Calculate the derivative of the metric. """ # Format Metric Path path = self.get_metric_path(name, instance=instance) ...
python
def derivative(self, name, new, max_value=0, time_delta=True, interval=None, allow_negative=False, instance=None): """ Calculate the derivative of the metric. """ # Format Metric Path path = self.get_metric_path(name, instance=instance) ...
[ "def", "derivative", "(", "self", ",", "name", ",", "new", ",", "max_value", "=", "0", ",", "time_delta", "=", "True", ",", "interval", "=", "None", ",", "allow_negative", "=", "False", ",", "instance", "=", "None", ")", ":", "# Format Metric Path", "pat...
Calculate the derivative of the metric.
[ "Calculate", "the", "derivative", "of", "the", "metric", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L430-L467
222,434
python-diamond/Diamond
src/diamond/collector.py
Collector._run
def _run(self): """ Run the collector unless it's already running """ try: start_time = time.time() # Collect Data self.collect() end_time = time.time() collector_time = int((end_time - start_time) * 1000) self.lo...
python
def _run(self): """ Run the collector unless it's already running """ try: start_time = time.time() # Collect Data self.collect() end_time = time.time() collector_time = int((end_time - start_time) * 1000) self.lo...
[ "def", "_run", "(", "self", ")", ":", "try", ":", "start_time", "=", "time", ".", "time", "(", ")", "# Collect Data", "self", ".", "collect", "(", ")", "end_time", "=", "time", ".", "time", "(", ")", "collector_time", "=", "int", "(", "(", "end_time"...
Run the collector unless it's already running
[ "Run", "the", "collector", "unless", "it", "s", "already", "running" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L469-L493
222,435
python-diamond/Diamond
src/diamond/collector.py
Collector.find_binary
def find_binary(self, binary): """ Scan and return the first path to a binary that we can find """ if os.path.exists(binary): return binary # Extract out the filename if we were given a full path binary_name = os.path.basename(binary) # Gather $PATH ...
python
def find_binary(self, binary): """ Scan and return the first path to a binary that we can find """ if os.path.exists(binary): return binary # Extract out the filename if we were given a full path binary_name = os.path.basename(binary) # Gather $PATH ...
[ "def", "find_binary", "(", "self", ",", "binary", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "binary", ")", ":", "return", "binary", "# Extract out the filename if we were given a full path", "binary_name", "=", "os", ".", "path", ".", "basename", ...
Scan and return the first path to a binary that we can find
[ "Scan", "and", "return", "the", "first", "path", "to", "a", "binary", "that", "we", "can", "find" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/collector.py#L495-L528
222,436
python-diamond/Diamond
src/collectors/memcached_slab/memcached_slab.py
parse_slab_stats
def parse_slab_stats(slab_stats): """Convert output from memcached's `stats slabs` into a Python dict. Newlines are returned by memcached along with carriage returns (i.e. '\r\n'). >>> parse_slab_stats( "STAT 1:chunk_size 96\r\nSTAT 1:chunks_per_page 10922\r\nSTAT " "active_sla...
python
def parse_slab_stats(slab_stats): """Convert output from memcached's `stats slabs` into a Python dict. Newlines are returned by memcached along with carriage returns (i.e. '\r\n'). >>> parse_slab_stats( "STAT 1:chunk_size 96\r\nSTAT 1:chunks_per_page 10922\r\nSTAT " "active_sla...
[ "def", "parse_slab_stats", "(", "slab_stats", ")", ":", "stats_dict", "=", "{", "'slabs'", ":", "defaultdict", "(", "lambda", ":", "{", "}", ")", "}", "for", "line", "in", "slab_stats", ".", "splitlines", "(", ")", ":", "if", "line", "==", "'END'", ":"...
Convert output from memcached's `stats slabs` into a Python dict. Newlines are returned by memcached along with carriage returns (i.e. '\r\n'). >>> parse_slab_stats( "STAT 1:chunk_size 96\r\nSTAT 1:chunks_per_page 10922\r\nSTAT " "active_slabs 1\r\nSTAT total_malloced 1048512\r\nEN...
[ "Convert", "output", "from", "memcached", "s", "stats", "slabs", "into", "a", "Python", "dict", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memcached_slab/memcached_slab.py#L19-L56
222,437
python-diamond/Diamond
src/collectors/memcached_slab/memcached_slab.py
dict_to_paths
def dict_to_paths(dict_): """Convert a dict to metric paths. >>> dict_to_paths({'foo': {'bar': 1}, 'baz': 2}) { 'foo.bar': 1, 'baz': 2, } """ metrics = {} for k, v in dict_.iteritems(): if isinstance(v, dict): submetrics = dict_to_paths(v) for...
python
def dict_to_paths(dict_): """Convert a dict to metric paths. >>> dict_to_paths({'foo': {'bar': 1}, 'baz': 2}) { 'foo.bar': 1, 'baz': 2, } """ metrics = {} for k, v in dict_.iteritems(): if isinstance(v, dict): submetrics = dict_to_paths(v) for...
[ "def", "dict_to_paths", "(", "dict_", ")", ":", "metrics", "=", "{", "}", "for", "k", ",", "v", "in", "dict_", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "submetrics", "=", "dict_to_paths", "(", "v", ")", ...
Convert a dict to metric paths. >>> dict_to_paths({'foo': {'bar': 1}, 'baz': 2}) { 'foo.bar': 1, 'baz': 2, }
[ "Convert", "a", "dict", "to", "metric", "paths", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memcached_slab/memcached_slab.py#L59-L76
222,438
python-diamond/Diamond
src/collectors/memcached_slab/memcached_slab.py
MemcachedSlabCollector.get_slab_stats
def get_slab_stats(self): """Retrieve slab stats from memcached.""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.host, self.port)) s.send("stats slabs\n") try: data = "" while True: data += s.recv(4096) ...
python
def get_slab_stats(self): """Retrieve slab stats from memcached.""" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((self.host, self.port)) s.send("stats slabs\n") try: data = "" while True: data += s.recv(4096) ...
[ "def", "get_slab_stats", "(", "self", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "s", ".", "connect", "(", "(", "self", ".", "host", ",", "self", ".", "port", ")", ")", "s", ...
Retrieve slab stats from memcached.
[ "Retrieve", "slab", "stats", "from", "memcached", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/memcached_slab/memcached_slab.py#L99-L112
222,439
python-diamond/Diamond
src/collectors/netapp/netapp_inode.py
netapp_inodeCol.push
def push(self, metric_name=None, metric_value=None, volume=None): """ Ship that shit off to graphite broski """ graphite_path = self.path_prefix graphite_path += '.' + self.device + '.' + 'volume' graphite_path += '.' + volume + '.' + metric_name metric = Metric(graphit...
python
def push(self, metric_name=None, metric_value=None, volume=None): """ Ship that shit off to graphite broski """ graphite_path = self.path_prefix graphite_path += '.' + self.device + '.' + 'volume' graphite_path += '.' + volume + '.' + metric_name metric = Metric(graphit...
[ "def", "push", "(", "self", ",", "metric_name", "=", "None", ",", "metric_value", "=", "None", ",", "volume", "=", "None", ")", ":", "graphite_path", "=", "self", ".", "path_prefix", "graphite_path", "+=", "'.'", "+", "self", ".", "device", "+", "'.'", ...
Ship that shit off to graphite broski
[ "Ship", "that", "shit", "off", "to", "graphite", "broski" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp_inode.py#L61-L72
222,440
python-diamond/Diamond
src/collectors/netapp/netapp_inode.py
netapp_inodeCol.get_netapp_data
def get_netapp_data(self): """ Retrieve netapp volume information returns ElementTree of netapp volume information """ netapp_data = self.server.invoke('volume-list-info') if netapp_data.results_status() == 'failed': self.log.error( 'While usin...
python
def get_netapp_data(self): """ Retrieve netapp volume information returns ElementTree of netapp volume information """ netapp_data = self.server.invoke('volume-list-info') if netapp_data.results_status() == 'failed': self.log.error( 'While usin...
[ "def", "get_netapp_data", "(", "self", ")", ":", "netapp_data", "=", "self", ".", "server", ".", "invoke", "(", "'volume-list-info'", ")", "if", "netapp_data", ".", "results_status", "(", ")", "==", "'failed'", ":", "self", ".", "log", ".", "error", "(", ...
Retrieve netapp volume information returns ElementTree of netapp volume information
[ "Retrieve", "netapp", "volume", "information" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp_inode.py#L74-L91
222,441
python-diamond/Diamond
src/diamond/handler/sentry.py
BaseResult.verbose_message
def verbose_message(self): """return more complete message""" if self.threshold is None: return 'No threshold' return '%.1f is %s than %.1f' % (self.value, self.adjective, self.threshold)
python
def verbose_message(self): """return more complete message""" if self.threshold is None: return 'No threshold' return '%.1f is %s than %.1f' % (self.value, self.adjective, self.threshold)
[ "def", "verbose_message", "(", "self", ")", ":", "if", "self", ".", "threshold", "is", "None", ":", "return", "'No threshold'", "return", "'%.1f is %s than %.1f'", "%", "(", "self", ".", "value", ",", "self", ".", "adjective", ",", "self", ".", "threshold", ...
return more complete message
[ "return", "more", "complete", "message" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L77-L83
222,442
python-diamond/Diamond
src/diamond/handler/sentry.py
Rule.process
def process(self, metric, handler): """ process a single diamond metric @type metric: diamond.metric.Metric @param metric: metric to process @type handler: diamond.handler.sentry.SentryHandler @param handler: configured Sentry graphite handler @rtype None ...
python
def process(self, metric, handler): """ process a single diamond metric @type metric: diamond.metric.Metric @param metric: metric to process @type handler: diamond.handler.sentry.SentryHandler @param handler: configured Sentry graphite handler @rtype None ...
[ "def", "process", "(", "self", ",", "metric", ",", "handler", ")", ":", "match", "=", "self", ".", "regexp", ".", "match", "(", "metric", ".", "path", ")", "if", "match", ":", "minimum", "=", "Minimum", "(", "metric", ".", "value", ",", "self", "."...
process a single diamond metric @type metric: diamond.metric.Metric @param metric: metric to process @type handler: diamond.handler.sentry.SentryHandler @param handler: configured Sentry graphite handler @rtype None
[ "process", "a", "single", "diamond", "metric" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L179-L220
222,443
python-diamond/Diamond
src/diamond/handler/sentry.py
SentryHandler.compile_rules
def compile_rules(self): """ Compile alert rules @rtype list of Rules """ output = [] # validate configuration, skip invalid section for key_name, section in self.config.items(): rule = self.compile_section(section) if rule is not None: ...
python
def compile_rules(self): """ Compile alert rules @rtype list of Rules """ output = [] # validate configuration, skip invalid section for key_name, section in self.config.items(): rule = self.compile_section(section) if rule is not None: ...
[ "def", "compile_rules", "(", "self", ")", ":", "output", "=", "[", "]", "# validate configuration, skip invalid section", "for", "key_name", ",", "section", "in", "self", ".", "config", ".", "items", "(", ")", ":", "rule", "=", "self", ".", "compile_section", ...
Compile alert rules @rtype list of Rules
[ "Compile", "alert", "rules" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L277-L288
222,444
python-diamond/Diamond
src/diamond/handler/sentry.py
SentryHandler.compile_section
def compile_section(self, section): """ Validate if a section is a valid rule @type section: configobj.Section @param section: section to validate @rtype Rule or None @return None if invalid """ if section.__class__ != Section: # not a section,...
python
def compile_section(self, section): """ Validate if a section is a valid rule @type section: configobj.Section @param section: section to validate @rtype Rule or None @return None if invalid """ if section.__class__ != Section: # not a section,...
[ "def", "compile_section", "(", "self", ",", "section", ")", ":", "if", "section", ".", "__class__", "!=", "Section", ":", "# not a section, just skip", "return", "# name and path are mandatory", "keys", "=", "section", ".", "keys", "(", ")", "for", "key", "in", ...
Validate if a section is a valid rule @type section: configobj.Section @param section: section to validate @rtype Rule or None @return None if invalid
[ "Validate", "if", "a", "section", "is", "a", "valid", "rule" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L290-L337
222,445
python-diamond/Diamond
src/diamond/handler/sentry.py
SentryHandler.configure_sentry_errors
def configure_sentry_errors(self): """ Configure sentry.errors to use the same loggers as the root handler @rtype: None """ sentry_errors_logger = logging.getLogger('sentry.errors') root_logger = logging.getLogger() for handler in root_logger.handlers: ...
python
def configure_sentry_errors(self): """ Configure sentry.errors to use the same loggers as the root handler @rtype: None """ sentry_errors_logger = logging.getLogger('sentry.errors') root_logger = logging.getLogger() for handler in root_logger.handlers: ...
[ "def", "configure_sentry_errors", "(", "self", ")", ":", "sentry_errors_logger", "=", "logging", ".", "getLogger", "(", "'sentry.errors'", ")", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "for", "handler", "in", "root_logger", ".", "handlers", ":"...
Configure sentry.errors to use the same loggers as the root handler @rtype: None
[ "Configure", "sentry", ".", "errors", "to", "use", "the", "same", "loggers", "as", "the", "root", "handler" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L339-L347
222,446
python-diamond/Diamond
src/diamond/handler/sentry.py
SentryHandler.process
def process(self, metric): """ process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None """ for rule in self.rules: rule.process(metric, self)
python
def process(self, metric): """ process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None """ for rule in self.rules: rule.process(metric, self)
[ "def", "process", "(", "self", ",", "metric", ")", ":", "for", "rule", "in", "self", ".", "rules", ":", "rule", ".", "process", "(", "metric", ",", "self", ")" ]
process a single metric @type metric: diamond.metric.Metric @param metric: metric to process @rtype None
[ "process", "a", "single", "metric" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/sentry.py#L349-L357
222,447
python-diamond/Diamond
src/collectors/network/network.py
NetworkCollector.collect
def collect(self): """ Collect network interface stats. """ # Initialize results results = {} if os.access(self.PROC, os.R_OK): # Open File file = open(self.PROC) # Build Regular Expression greed = '' if str_t...
python
def collect(self): """ Collect network interface stats. """ # Initialize results results = {} if os.access(self.PROC, os.R_OK): # Open File file = open(self.PROC) # Build Regular Expression greed = '' if str_t...
[ "def", "collect", "(", "self", ")", ":", "# Initialize results", "results", "=", "{", "}", "if", "os", ".", "access", "(", "self", ".", "PROC", ",", "os", ".", "R_OK", ")", ":", "# Open File", "file", "=", "open", "(", "self", ".", "PROC", ")", "# ...
Collect network interface stats.
[ "Collect", "network", "interface", "stats", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/network/network.py#L51-L133
222,448
python-diamond/Diamond
src/collectors/conntrack/conntrack.py
ConnTrackCollector.get_default_config_help
def get_default_config_help(self): """ Return help text for collector configuration """ config_help = super(ConnTrackCollector, self).get_default_config_help() config_help.update({ "dir": "Directories with files of interest, comma seperated", "files":...
python
def get_default_config_help(self): """ Return help text for collector configuration """ config_help = super(ConnTrackCollector, self).get_default_config_help() config_help.update({ "dir": "Directories with files of interest, comma seperated", "files":...
[ "def", "get_default_config_help", "(", "self", ")", ":", "config_help", "=", "super", "(", "ConnTrackCollector", ",", "self", ")", ".", "get_default_config_help", "(", ")", "config_help", ".", "update", "(", "{", "\"dir\"", ":", "\"Directories with files of interest...
Return help text for collector configuration
[ "Return", "help", "text", "for", "collector", "configuration" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/conntrack/conntrack.py#L22-L31
222,449
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._replace_and_publish
def _replace_and_publish(self, path, prettyname, value, device): """ Inputs a complete path for a metric and a value. Replace the metric name and publish. """ if value is None: return newpath = path # Change metric name before publish if needed. ...
python
def _replace_and_publish(self, path, prettyname, value, device): """ Inputs a complete path for a metric and a value. Replace the metric name and publish. """ if value is None: return newpath = path # Change metric name before publish if needed. ...
[ "def", "_replace_and_publish", "(", "self", ",", "path", ",", "prettyname", ",", "value", ",", "device", ")", ":", "if", "value", "is", "None", ":", "return", "newpath", "=", "path", "# Change metric name before publish if needed.", "newpath", "=", "\".\"", ".",...
Inputs a complete path for a metric and a value. Replace the metric name and publish.
[ "Inputs", "a", "complete", "path", "for", "a", "metric", "and", "a", "value", ".", "Replace", "the", "metric", "name", "and", "publish", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L204-L215
222,450
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._gen_delta_depend
def _gen_delta_depend(self, path, derivative, multiplier, prettyname, device): """ For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well. """ primary_delta = derivati...
python
def _gen_delta_depend(self, path, derivative, multiplier, prettyname, device): """ For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well. """ primary_delta = derivati...
[ "def", "_gen_delta_depend", "(", "self", ",", "path", ",", "derivative", ",", "multiplier", ",", "prettyname", ",", "device", ")", ":", "primary_delta", "=", "derivative", "[", "path", "]", "shortpath", "=", "\".\"", ".", "join", "(", "path", ".", "split",...
For some metrics we need to divide the delta for one metric with the delta of another. Publishes a metric if the convertion goes well.
[ "For", "some", "metrics", "we", "need", "to", "divide", "the", "delta", "for", "one", "metric", "with", "the", "delta", "of", "another", ".", "Publishes", "a", "metric", "if", "the", "convertion", "goes", "well", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L217-L240
222,451
python-diamond/Diamond
src/collectors/netapp/netapp.py
NetAppCollector._gen_delta_per_sec
def _gen_delta_per_sec(self, path, value_delta, time_delta, multiplier, prettyname, device): """ Calulates the difference between to point, and scales is to per second. """ if time_delta < 0: return value = (value_delta / time_delta) * multi...
python
def _gen_delta_per_sec(self, path, value_delta, time_delta, multiplier, prettyname, device): """ Calulates the difference between to point, and scales is to per second. """ if time_delta < 0: return value = (value_delta / time_delta) * multi...
[ "def", "_gen_delta_per_sec", "(", "self", ",", "path", ",", "value_delta", ",", "time_delta", ",", "multiplier", ",", "prettyname", ",", "device", ")", ":", "if", "time_delta", "<", "0", ":", "return", "value", "=", "(", "value_delta", "/", "time_delta", "...
Calulates the difference between to point, and scales is to per second.
[ "Calulates", "the", "difference", "between", "to", "point", "and", "scales", "is", "to", "per", "second", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netapp.py#L242-L253
222,452
python-diamond/Diamond
src/diamond/handler/datadog.py
DatadogHandler._send
def _send(self): """ Take metrics from queue and send it to Datadog API """ while len(self.queue) > 0: metric = self.queue.popleft() path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), metric.g...
python
def _send(self): """ Take metrics from queue and send it to Datadog API """ while len(self.queue) > 0: metric = self.queue.popleft() path = '%s.%s.%s' % ( metric.getPathPrefix(), metric.getCollectorPath(), metric.g...
[ "def", "_send", "(", "self", ")", ":", "while", "len", "(", "self", ".", "queue", ")", ">", "0", ":", "metric", "=", "self", ".", "queue", ".", "popleft", "(", ")", "path", "=", "'%s.%s.%s'", "%", "(", "metric", ".", "getPathPrefix", "(", ")", ",...
Take metrics from queue and send it to Datadog API
[ "Take", "metrics", "from", "queue", "and", "send", "it", "to", "Datadog", "API" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/datadog.py#L84-L106
222,453
python-diamond/Diamond
setup.py
get_version
def get_version(): """ Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs """ try: f = open('version.txt') except IOError: os.system("./version.sh > version.txt") f =...
python
def get_version(): """ Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs """ try: f = open('version.txt') except IOError: os.system("./version.sh > version.txt") f =...
[ "def", "get_version", "(", ")", ":", "try", ":", "f", "=", "open", "(", "'version.txt'", ")", "except", "IOError", ":", "os", ".", "system", "(", "\"./version.sh > version.txt\"", ")", "f", "=", "open", "(", "'version.txt'", ")", "version", "=", "''", "....
Read the version.txt file to get the new version string Generate it if version.txt is not available. Generation is required for pip installs
[ "Read", "the", "version", ".", "txt", "file", "to", "get", "the", "new", "version", "string", "Generate", "it", "if", "version", ".", "txt", "is", "not", "available", ".", "Generation", "is", "required", "for", "pip", "installs" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/setup.py#L98-L111
222,454
python-diamond/Diamond
setup.py
pkgPath
def pkgPath(root, path, rpath="/"): """ Package up a path recursively """ global data_files if not os.path.exists(path): return files = [] for spath in os.listdir(path): # Ignore test directories if spath == 'test': continue subpath = os.path.j...
python
def pkgPath(root, path, rpath="/"): """ Package up a path recursively """ global data_files if not os.path.exists(path): return files = [] for spath in os.listdir(path): # Ignore test directories if spath == 'test': continue subpath = os.path.j...
[ "def", "pkgPath", "(", "root", ",", "path", ",", "rpath", "=", "\"/\"", ")", ":", "global", "data_files", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "return", "files", "=", "[", "]", "for", "spath", "in", "os", ".", "li...
Package up a path recursively
[ "Package", "up", "a", "path", "recursively" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/setup.py#L114-L132
222,455
python-diamond/Diamond
src/diamond/handler/statsite.py
StatsiteHandler._send
def _send(self, data): """ Send data to statsite. Data that can not be sent will be queued. """ retry = self.RETRY # Attempt to send any data in the queue while retry > 0: # Check socket if not self.socket: # Log Error ...
python
def _send(self, data): """ Send data to statsite. Data that can not be sent will be queued. """ retry = self.RETRY # Attempt to send any data in the queue while retry > 0: # Check socket if not self.socket: # Log Error ...
[ "def", "_send", "(", "self", ",", "data", ")", ":", "retry", "=", "self", ".", "RETRY", "# Attempt to send any data in the queue", "while", "retry", ">", "0", ":", "# Check socket", "if", "not", "self", ".", "socket", ":", "# Log Error", "self", ".", "log", ...
Send data to statsite. Data that can not be sent will be queued.
[ "Send", "data", "to", "statsite", ".", "Data", "that", "can", "not", "be", "sent", "will", "be", "queued", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/statsite.py#L127-L159
222,456
python-diamond/Diamond
src/diamond/handler/statsite.py
StatsiteHandler._connect
def _connect(self): """ Connect to the statsite server """ # Create socket if self.udpport > 0: self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = self.udpport elif self.tcpport > 0: self.socket = socket.socket(s...
python
def _connect(self): """ Connect to the statsite server """ # Create socket if self.udpport > 0: self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.port = self.udpport elif self.tcpport > 0: self.socket = socket.socket(s...
[ "def", "_connect", "(", "self", ")", ":", "# Create socket", "if", "self", ".", "udpport", ">", "0", ":", "self", ".", "socket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_DGRAM", ")", "self", ".", "port", ...
Connect to the statsite server
[ "Connect", "to", "the", "statsite", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/statsite.py#L161-L192
222,457
python-diamond/Diamond
src/diamond/utils/classes.py
load_include_path
def load_include_path(paths): """ Scan for and add paths to the include path """ for path in paths: # Verify the path is valid if not os.path.isdir(path): continue # Add path to the system path, to avoid name clashes # with mysql-connector for example ... ...
python
def load_include_path(paths): """ Scan for and add paths to the include path """ for path in paths: # Verify the path is valid if not os.path.isdir(path): continue # Add path to the system path, to avoid name clashes # with mysql-connector for example ... ...
[ "def", "load_include_path", "(", "paths", ")", ":", "for", "path", "in", "paths", ":", "# Verify the path is valid", "if", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "continue", "# Add path to the system path, to avoid name clashes", "# with mysq...
Scan for and add paths to the include path
[ "Scan", "for", "and", "add", "paths", "to", "the", "include", "path" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L19-L36
222,458
python-diamond/Diamond
src/diamond/utils/classes.py
load_dynamic_class
def load_dynamic_class(fqn, subclass): """ Dynamically load fqn class and verify it's a subclass of subclass """ if not isinstance(fqn, basestring): return fqn cls = load_class_from_name(fqn) if cls == subclass or not issubclass(cls, subclass): raise TypeError("%s is not a vali...
python
def load_dynamic_class(fqn, subclass): """ Dynamically load fqn class and verify it's a subclass of subclass """ if not isinstance(fqn, basestring): return fqn cls = load_class_from_name(fqn) if cls == subclass or not issubclass(cls, subclass): raise TypeError("%s is not a vali...
[ "def", "load_dynamic_class", "(", "fqn", ",", "subclass", ")", ":", "if", "not", "isinstance", "(", "fqn", ",", "basestring", ")", ":", "return", "fqn", "cls", "=", "load_class_from_name", "(", "fqn", ")", "if", "cls", "==", "subclass", "or", "not", "iss...
Dynamically load fqn class and verify it's a subclass of subclass
[ "Dynamically", "load", "fqn", "class", "and", "verify", "it", "s", "a", "subclass", "of", "subclass" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L39-L51
222,459
python-diamond/Diamond
src/diamond/utils/classes.py
load_collectors_from_paths
def load_collectors_from_paths(paths): """ Scan for collectors to load from path """ # Initialize return value collectors = {} if paths is None: return if isinstance(paths, basestring): paths = paths.split(',') paths = map(str.strip, paths) load_include_path(pa...
python
def load_collectors_from_paths(paths): """ Scan for collectors to load from path """ # Initialize return value collectors = {} if paths is None: return if isinstance(paths, basestring): paths = paths.split(',') paths = map(str.strip, paths) load_include_path(pa...
[ "def", "load_collectors_from_paths", "(", "paths", ")", ":", "# Initialize return value", "collectors", "=", "{", "}", "if", "paths", "is", "None", ":", "return", "if", "isinstance", "(", "paths", ",", "basestring", ")", ":", "paths", "=", "paths", ".", "spl...
Scan for collectors to load from path
[ "Scan", "for", "collectors", "to", "load", "from", "path" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L112-L181
222,460
python-diamond/Diamond
src/diamond/utils/classes.py
load_collectors_from_entry_point
def load_collectors_from_entry_point(path): """ Load collectors that were installed into an entry_point. """ collectors = {} for ep in pkg_resources.iter_entry_points(path): try: mod = ep.load() except Exception: logger.error('Failed to import entry_point: %s....
python
def load_collectors_from_entry_point(path): """ Load collectors that were installed into an entry_point. """ collectors = {} for ep in pkg_resources.iter_entry_points(path): try: mod = ep.load() except Exception: logger.error('Failed to import entry_point: %s....
[ "def", "load_collectors_from_entry_point", "(", "path", ")", ":", "collectors", "=", "{", "}", "for", "ep", "in", "pkg_resources", ".", "iter_entry_points", "(", "path", ")", ":", "try", ":", "mod", "=", "ep", ".", "load", "(", ")", "except", "Exception", ...
Load collectors that were installed into an entry_point.
[ "Load", "collectors", "that", "were", "installed", "into", "an", "entry_point", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L184-L198
222,461
python-diamond/Diamond
src/diamond/utils/classes.py
get_collectors_from_module
def get_collectors_from_module(mod): """ Locate all of the collector classes within a given module """ for attrname in dir(mod): attr = getattr(mod, attrname) # Only attempt to load classes that are infact classes # are Collectors but are not the base Collector class if (...
python
def get_collectors_from_module(mod): """ Locate all of the collector classes within a given module """ for attrname in dir(mod): attr = getattr(mod, attrname) # Only attempt to load classes that are infact classes # are Collectors but are not the base Collector class if (...
[ "def", "get_collectors_from_module", "(", "mod", ")", ":", "for", "attrname", "in", "dir", "(", "mod", ")", ":", "attr", "=", "getattr", "(", "mod", ",", "attrname", ")", "# Only attempt to load classes that are infact classes", "# are Collectors but are not the base Co...
Locate all of the collector classes within a given module
[ "Locate", "all", "of", "the", "collector", "classes", "within", "a", "given", "module" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/utils/classes.py#L201-L226
222,462
python-diamond/Diamond
src/diamond/handler/mysql.py
MySQLHandler._send
def _send(self, data): """ Insert the data """ data = data.strip().split(' ') try: cursor = self.conn.cursor() cursor.execute("INSERT INTO %s (%s, %s, %s) VALUES(%%s, %%s, %%s)" % (self.table, self.col_metric, ...
python
def _send(self, data): """ Insert the data """ data = data.strip().split(' ') try: cursor = self.conn.cursor() cursor.execute("INSERT INTO %s (%s, %s, %s) VALUES(%%s, %%s, %%s)" % (self.table, self.col_metric, ...
[ "def", "_send", "(", "self", ",", "data", ")", ":", "data", "=", "data", ".", "strip", "(", ")", ".", "split", "(", "' '", ")", "try", ":", "cursor", "=", "self", ".", "conn", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "\"INSERT INTO...
Insert the data
[ "Insert", "the", "data" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mysql.py#L73-L90
222,463
python-diamond/Diamond
src/diamond/handler/mysql.py
MySQLHandler._connect
def _connect(self): """ Connect to the MySQL server """ self._close() self.conn = MySQLdb.Connect(host=self.hostname, port=self.port, user=self.username, passwd=self.passwo...
python
def _connect(self): """ Connect to the MySQL server """ self._close() self.conn = MySQLdb.Connect(host=self.hostname, port=self.port, user=self.username, passwd=self.passwo...
[ "def", "_connect", "(", "self", ")", ":", "self", ".", "_close", "(", ")", "self", ".", "conn", "=", "MySQLdb", ".", "Connect", "(", "host", "=", "self", ".", "hostname", ",", "port", "=", "self", ".", "port", ",", "user", "=", "self", ".", "user...
Connect to the MySQL server
[ "Connect", "to", "the", "MySQL", "server" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mysql.py#L92-L101
222,464
python-diamond/Diamond
src/collectors/nvidia_gpu/nvidia_gpu.py
NvidiaGPUCollector.collect
def collect(self): """ Collector GPU stats """ stats_config = self.config['stats'] if USE_PYTHON_BINDING: collect_metrics = self.collect_via_pynvml else: collect_metrics = self.collect_via_nvidia_smi collect_metrics(stats_config)
python
def collect(self): """ Collector GPU stats """ stats_config = self.config['stats'] if USE_PYTHON_BINDING: collect_metrics = self.collect_via_pynvml else: collect_metrics = self.collect_via_nvidia_smi collect_metrics(stats_config)
[ "def", "collect", "(", "self", ")", ":", "stats_config", "=", "self", ".", "config", "[", "'stats'", "]", "if", "USE_PYTHON_BINDING", ":", "collect_metrics", "=", "self", ".", "collect_via_pynvml", "else", ":", "collect_metrics", "=", "self", ".", "collect_via...
Collector GPU stats
[ "Collector", "GPU", "stats" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nvidia_gpu/nvidia_gpu.py#L119-L129
222,465
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
decode_network_values
def decode_network_values(ptype, plen, buf): """Decodes a list of DS values in collectd network format """ nvalues = short.unpack_from(buf, header.size)[0] off = header.size + short.size + nvalues valskip = double.size # Check whether our expected packet size is the reported one assert ((va...
python
def decode_network_values(ptype, plen, buf): """Decodes a list of DS values in collectd network format """ nvalues = short.unpack_from(buf, header.size)[0] off = header.size + short.size + nvalues valskip = double.size # Check whether our expected packet size is the reported one assert ((va...
[ "def", "decode_network_values", "(", "ptype", ",", "plen", ",", "buf", ")", ":", "nvalues", "=", "short", ".", "unpack_from", "(", "buf", ",", "header", ".", "size", ")", "[", "0", "]", "off", "=", "header", ".", "size", "+", "short", ".", "size", ...
Decodes a list of DS values in collectd network format
[ "Decodes", "a", "list", "of", "DS", "values", "in", "collectd", "network", "format" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L83-L111
222,466
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
decode_network_packet
def decode_network_packet(buf): """Decodes a network packet in collectd format. """ off = 0 blen = len(buf) while off < blen: ptype, plen = header.unpack_from(buf, off) if plen > blen - off: raise ValueError("Packet longer than amount of data in buffer") if pty...
python
def decode_network_packet(buf): """Decodes a network packet in collectd format. """ off = 0 blen = len(buf) while off < blen: ptype, plen = header.unpack_from(buf, off) if plen > blen - off: raise ValueError("Packet longer than amount of data in buffer") if pty...
[ "def", "decode_network_packet", "(", "buf", ")", ":", "off", "=", "0", "blen", "=", "len", "(", "buf", ")", "while", "off", "<", "blen", ":", "ptype", ",", "plen", "=", "header", ".", "unpack_from", "(", "buf", ",", "off", ")", "if", "plen", ">", ...
Decodes a network packet in collectd format.
[ "Decodes", "a", "network", "packet", "in", "collectd", "format", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L143-L159
222,467
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.receive
def receive(self, poll_interval): """Receives a single raw collect network packet. """ readable, writeable, errored = select.select(self._readlist, [], [], poll_interval) for s in readable: data, addr = s.recvfrom(self.BUFF...
python
def receive(self, poll_interval): """Receives a single raw collect network packet. """ readable, writeable, errored = select.select(self._readlist, [], [], poll_interval) for s in readable: data, addr = s.recvfrom(self.BUFF...
[ "def", "receive", "(", "self", ",", "poll_interval", ")", ":", "readable", ",", "writeable", ",", "errored", "=", "select", ".", "select", "(", "self", ".", "_readlist", ",", "[", "]", ",", "[", "]", ",", "poll_interval", ")", "for", "s", "in", "read...
Receives a single raw collect network packet.
[ "Receives", "a", "single", "raw", "collect", "network", "packet", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L341-L351
222,468
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.decode
def decode(self, poll_interval, buf=None): """Decodes a given buffer or the next received packet. """ if buf is None: buf = self.receive(poll_interval) if buf is None: return None return decode_network_packet(buf)
python
def decode(self, poll_interval, buf=None): """Decodes a given buffer or the next received packet. """ if buf is None: buf = self.receive(poll_interval) if buf is None: return None return decode_network_packet(buf)
[ "def", "decode", "(", "self", ",", "poll_interval", ",", "buf", "=", "None", ")", ":", "if", "buf", "is", "None", ":", "buf", "=", "self", ".", "receive", "(", "poll_interval", ")", "if", "buf", "is", "None", ":", "return", "None", "return", "decode_...
Decodes a given buffer or the next received packet.
[ "Decodes", "a", "given", "buffer", "or", "the", "next", "received", "packet", "." ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L353-L360
222,469
python-diamond/Diamond
src/collectors/jcollectd/collectd_network.py
Reader.interpret
def interpret(self, iterable=None, poll_interval=0.2): """Interprets a sequence """ if iterable is None: iterable = self.decode(poll_interval) if iterable is None: return None if isinstance(iterable, basestring): iterable = self.decode...
python
def interpret(self, iterable=None, poll_interval=0.2): """Interprets a sequence """ if iterable is None: iterable = self.decode(poll_interval) if iterable is None: return None if isinstance(iterable, basestring): iterable = self.decode...
[ "def", "interpret", "(", "self", ",", "iterable", "=", "None", ",", "poll_interval", "=", "0.2", ")", ":", "if", "iterable", "is", "None", ":", "iterable", "=", "self", ".", "decode", "(", "poll_interval", ")", "if", "iterable", "is", "None", ":", "ret...
Interprets a sequence
[ "Interprets", "a", "sequence" ]
0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47
https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/jcollectd/collectd_network.py#L362-L373
222,470
ncclient/ncclient
ncclient/manager.py
make_device_handler
def make_device_handler(device_params): """ Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be ...
python
def make_device_handler(device_params): """ Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be ...
[ "def", "make_device_handler", "(", "device_params", ")", ":", "if", "device_params", "is", "None", ":", "device_params", "=", "{", "}", "handler", "=", "device_params", ".", "get", "(", "'handler'", ",", "None", ")", "if", "handler", ":", "return", "handler"...
Create a device handler object that provides device specific parameters and functions, which are called in various places throughout our code. If no device_params are defined or the "name" in the parameter dict is not known then a default handler will be returned.
[ "Create", "a", "device", "handler", "object", "that", "provides", "device", "specific", "parameters", "and", "functions", "which", "are", "called", "in", "various", "places", "throughout", "our", "code", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/manager.py#L63-L89
222,471
ncclient/ncclient
ncclient/manager.py
Manager.take_notification
def take_notification(self, block=True, timeout=None): """Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that ...
python
def take_notification(self, block=True, timeout=None): """Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that ...
[ "def", "take_notification", "(", "self", ",", "block", "=", "True", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "_session", ".", "take_notification", "(", "block", ",", "timeout", ")" ]
Attempt to retrieve one notification from the queue of received notifications. If block is True, the call will wait until a notification is received. If timeout is a number greater than 0, the call will wait that many seconds to receive a notification before timing out. ...
[ "Attempt", "to", "retrieve", "one", "notification", "from", "the", "queue", "of", "received", "notifications", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/manager.py#L258-L274
222,472
ncclient/ncclient
ncclient/operations/third_party/hpcomware/rpc.py
DisplayCommand.request
def request(self, cmds): """ Single Execution element is permitted. cmds can be a list or single command """ if isinstance(cmds, list): cmd = '\n'.join(cmds) elif isinstance(cmds, str) or isinstance(cmds, unicode): cmd = cmds node = etree....
python
def request(self, cmds): """ Single Execution element is permitted. cmds can be a list or single command """ if isinstance(cmds, list): cmd = '\n'.join(cmds) elif isinstance(cmds, str) or isinstance(cmds, unicode): cmd = cmds node = etree....
[ "def", "request", "(", "self", ",", "cmds", ")", ":", "if", "isinstance", "(", "cmds", ",", "list", ")", ":", "cmd", "=", "'\\n'", ".", "join", "(", "cmds", ")", "elif", "isinstance", "(", "cmds", ",", "str", ")", "or", "isinstance", "(", "cmds", ...
Single Execution element is permitted. cmds can be a list or single command
[ "Single", "Execution", "element", "is", "permitted", ".", "cmds", "can", "be", "a", "list", "or", "single", "command" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/third_party/hpcomware/rpc.py#L7-L22
222,473
ncclient/ncclient
ncclient/xml_.py
validated_element
def validated_element(x, tags=None, attrs=None): """Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which...
python
def validated_element(x, tags=None, attrs=None): """Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which...
[ "def", "validated_element", "(", "x", ",", "tags", "=", "None", ",", "attrs", "=", "None", ")", ":", "ele", "=", "to_ele", "(", "x", ")", "if", "tags", ":", "if", "isinstance", "(", "tags", ",", "(", "str", ",", "bytes", ")", ")", ":", "tags", ...
Checks if the root element of an XML document or Element meets the supplied criteria. *tags* if specified is either a single allowable tag name or sequence of allowable alternatives *attrs* if specified is a sequence of required attributes, each of which may be a sequence of several allowable alternatives ...
[ "Checks", "if", "the", "root", "element", "of", "an", "XML", "document", "or", "Element", "meets", "the", "supplied", "criteria", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L125-L148
222,474
ncclient/ncclient
ncclient/xml_.py
NCElement.tostring
def tostring(self): """return a pretty-printed string output for rpc reply""" parser = etree.XMLParser(remove_blank_text=True) outputtree = etree.XML(etree.tostring(self.__doc), parser) return etree.tostring(outputtree, pretty_print=True)
python
def tostring(self): """return a pretty-printed string output for rpc reply""" parser = etree.XMLParser(remove_blank_text=True) outputtree = etree.XML(etree.tostring(self.__doc), parser) return etree.tostring(outputtree, pretty_print=True)
[ "def", "tostring", "(", "self", ")", ":", "parser", "=", "etree", ".", "XMLParser", "(", "remove_blank_text", "=", "True", ")", "outputtree", "=", "etree", ".", "XML", "(", "etree", ".", "tostring", "(", "self", ".", "__doc", ")", ",", "parser", ")", ...
return a pretty-printed string output for rpc reply
[ "return", "a", "pretty", "-", "printed", "string", "output", "for", "rpc", "reply" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L192-L196
222,475
ncclient/ncclient
ncclient/xml_.py
NCElement.remove_namespaces
def remove_namespaces(self, rpc_reply): """remove xmlns attributes from rpc reply""" self.__xslt=self.__transform_reply self.__parser = etree.XMLParser(remove_blank_text=True) self.__xslt_doc = etree.parse(io.BytesIO(self.__xslt), self.__parser) self.__transform = etree.XSLT(self...
python
def remove_namespaces(self, rpc_reply): """remove xmlns attributes from rpc reply""" self.__xslt=self.__transform_reply self.__parser = etree.XMLParser(remove_blank_text=True) self.__xslt_doc = etree.parse(io.BytesIO(self.__xslt), self.__parser) self.__transform = etree.XSLT(self...
[ "def", "remove_namespaces", "(", "self", ",", "rpc_reply", ")", ":", "self", ".", "__xslt", "=", "self", ".", "__transform_reply", "self", ".", "__parser", "=", "etree", ".", "XMLParser", "(", "remove_blank_text", "=", "True", ")", "self", ".", "__xslt_doc",...
remove xmlns attributes from rpc reply
[ "remove", "xmlns", "attributes", "from", "rpc", "reply" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/xml_.py#L203-L210
222,476
ncclient/ncclient
ncclient/operations/retrieve.py
GetSchema.request
def request(self, identifier, version=None, format=None): """Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seeals...
python
def request(self, identifier, version=None, format=None): """Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seeals...
[ "def", "request", "(", "self", ",", "identifier", ",", "version", "=", "None", ",", "format", "=", "None", ")", ":", "node", "=", "etree", ".", "Element", "(", "qualify", "(", "\"get-schema\"", ",", "NETCONF_MONITORING_NS", ")", ")", "if", "identifier", ...
Retrieve a named schema, with optional revision and type. *identifier* name of the schema to be retrieved *version* version of schema to get *format* format of the schema to be retrieved, yang is the default :seealso: :ref:`filter_params`
[ "Retrieve", "a", "named", "schema", "with", "optional", "revision", "and", "type", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/retrieve.py#L175-L198
222,477
ncclient/ncclient
ncclient/devices/default.py
DefaultDeviceHandler.is_rpc_error_exempt
def is_rpc_error_exempt(self, error_text): """ Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be ...
python
def is_rpc_error_exempt(self, error_text): """ Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be ...
[ "def", "is_rpc_error_exempt", "(", "self", ",", "error_text", ")", ":", "if", "error_text", "is", "not", "None", ":", "error_text", "=", "error_text", ".", "lower", "(", ")", ".", "strip", "(", ")", "else", ":", "error_text", "=", "'no error given'", "# Co...
Check whether an RPC error message is excempt, thus NOT causing an exception. On some devices the RPC operations may indicate an error response, even though the operation actually succeeded. This may be in cases where a warning would be more appropriate. In that case, the client may be better a...
[ "Check", "whether", "an", "RPC", "error", "message", "is", "excempt", "thus", "NOT", "causing", "an", "exception", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/devices/default.py#L146-L192
222,478
ncclient/ncclient
ncclient/devices/nexus.py
NexusDeviceHandler.get_ssh_subsystem_names
def get_ssh_subsystem_names(self): """ Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts ""...
python
def get_ssh_subsystem_names(self): """ Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts ""...
[ "def", "get_ssh_subsystem_names", "(", "self", ")", ":", "preferred_ssh_subsystem", "=", "self", ".", "device_params", ".", "get", "(", "\"ssh_subsystem_name\"", ")", "name_list", "=", "[", "\"netconf\"", ",", "\"xmlagent\"", "]", "if", "preferred_ssh_subsystem", ":...
Return a list of possible SSH subsystem names. Different NXOS versions use different SSH subsystem names for netconf. Therefore, we return a list so that several can be tried, if necessary. The Nexus device handler also accepts
[ "Return", "a", "list", "of", "possible", "SSH", "subsystem", "names", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/devices/nexus.py#L79-L95
222,479
ncclient/ncclient
ncclient/transport/session.py
Session.add_listener
def add_listener(self, listener): """Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener` """ self.logger.debug('installing listener %r', listener) if not isinstance(listener, SessionListener): ra...
python
def add_listener(self, listener): """Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener` """ self.logger.debug('installing listener %r', listener) if not isinstance(listener, SessionListener): ra...
[ "def", "add_listener", "(", "self", ",", "listener", ")", ":", "self", ".", "logger", ".", "debug", "(", "'installing listener %r'", ",", "listener", ")", "if", "not", "isinstance", "(", "listener", ",", "SessionListener", ")", ":", "raise", "SessionError", ...
Register a listener that will be notified of incoming messages and errors. :type listener: :class:`SessionListener`
[ "Register", "a", "listener", "that", "will", "be", "notified", "of", "incoming", "messages", "and", "errors", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L125-L135
222,480
ncclient/ncclient
ncclient/transport/session.py
Session.remove_listener
def remove_listener(self, listener): """Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener` """ self.logger.debug('discarding listener %r', listener) with self._lock: self._listeners.discard(listener...
python
def remove_listener(self, listener): """Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener` """ self.logger.debug('discarding listener %r', listener) with self._lock: self._listeners.discard(listener...
[ "def", "remove_listener", "(", "self", ",", "listener", ")", ":", "self", ".", "logger", ".", "debug", "(", "'discarding listener %r'", ",", "listener", ")", "with", "self", ".", "_lock", ":", "self", ".", "_listeners", ".", "discard", "(", "listener", ")"...
Unregister some listener; ignore if the listener was never registered. :type listener: :class:`SessionListener`
[ "Unregister", "some", "listener", ";", "ignore", "if", "the", "listener", "was", "never", "registered", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L137-L145
222,481
ncclient/ncclient
ncclient/transport/session.py
Session.get_listener_instance
def get_listener_instance(self, cls): """If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener` """ with self._lock: for listener in self._listeners: if isinstance(listener, cls): ...
python
def get_listener_instance(self, cls): """If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener` """ with self._lock: for listener in self._listeners: if isinstance(listener, cls): ...
[ "def", "get_listener_instance", "(", "self", ",", "cls", ")", ":", "with", "self", ".", "_lock", ":", "for", "listener", "in", "self", ".", "_listeners", ":", "if", "isinstance", "(", "listener", ",", "cls", ")", ":", "return", "listener" ]
If a listener of the specified type is registered, returns the instance. :type cls: :class:`SessionListener`
[ "If", "a", "listener", "of", "the", "specified", "type", "is", "registered", "returns", "the", "instance", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/session.py#L147-L156
222,482
ncclient/ncclient
ncclient/operations/subscribe.py
CreateSubscription.request
def request(self, filter=None, stream_name=None, start_time=None, stop_time=None): """Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` ...
python
def request(self, filter=None, stream_name=None, start_time=None, stop_time=None): """Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` ...
[ "def", "request", "(", "self", ",", "filter", "=", "None", ",", "stream_name", "=", "None", ",", "start_time", "=", "None", ",", "stop_time", "=", "None", ")", ":", "node", "=", "new_ele_ns", "(", "\"create-subscription\"", ",", "NETCONF_NOTIFICATION_NS", ")...
Creates a subscription for notifications from the server. *filter* specifies the subset of notifications to receive (by default all notificaitons are received) :seealso: :ref:`filter_params` *stream_name* specifies the notification stream name. The default is None meaning all ...
[ "Creates", "a", "subscription", "for", "notifications", "from", "the", "server", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/subscribe.py#L27-L64
222,483
ncclient/ncclient
ncclient/operations/edit.py
DeleteConfig.request
def request(self, target): """Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`""" node = new_ele("delete-config") node.append(util.datastore_or_url("target", target, self._assert)) ...
python
def request(self, target): """Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`""" node = new_ele("delete-config") node.append(util.datastore_or_url("target", target, self._assert)) ...
[ "def", "request", "(", "self", ",", "target", ")", ":", "node", "=", "new_ele", "(", "\"delete-config\"", ")", "node", ".", "append", "(", "util", ".", "datastore_or_url", "(", "\"target\"", ",", "target", ",", "self", ".", "_assert", ")", ")", "return",...
Delete a configuration datastore. *target* specifies the name or URL of configuration datastore to delete :seealso: :ref:`srctarget_params`
[ "Delete", "a", "configuration", "datastore", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L73-L81
222,484
ncclient/ncclient
ncclient/operations/edit.py
CopyConfig.request
def request(self, source, target): """Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuratio...
python
def request(self, source, target): """Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuratio...
[ "def", "request", "(", "self", ",", "source", ",", "target", ")", ":", "node", "=", "new_ele", "(", "\"copy-config\"", ")", "node", ".", "append", "(", "util", ".", "datastore_or_url", "(", "\"target\"", ",", "target", ",", "self", ".", "_assert", ")", ...
Create or replace an entire configuration datastore with the contents of another complete configuration datastore. *source* is the name of the configuration datastore to use as the source of the copy operation or `config` element containing the configuration subtree to copy *target* is the nam...
[ "Create", "or", "replace", "an", "entire", "configuration", "datastore", "with", "the", "contents", "of", "another", "complete", "configuration", "datastore", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L87-L106
222,485
ncclient/ncclient
ncclient/operations/edit.py
Validate.request
def request(self, source="candidate"): """Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`""" node = new_e...
python
def request(self, source="candidate"): """Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`""" node = new_e...
[ "def", "request", "(", "self", ",", "source", "=", "\"candidate\"", ")", ":", "node", "=", "new_ele", "(", "\"validate\"", ")", "if", "type", "(", "source", ")", "is", "str", ":", "src", "=", "util", ".", "datastore_or_url", "(", "\"source\"", ",", "so...
Validate the contents of the specified configuration. *source* is the name of the configuration datastore being validated or `config` element containing the configuration subtree to be validated :seealso: :ref:`srctarget_params`
[ "Validate", "the", "contents", "of", "the", "specified", "configuration", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/edit.py#L114-L128
222,486
ncclient/ncclient
ncclient/operations/lock.py
Lock.request
def request(self, target="candidate"): """Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock """ node = new_ele("lock") sub_ele(sub_ele(node, "target"), target) return self._request(node)
python
def request(self, target="candidate"): """Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock """ node = new_ele("lock") sub_ele(sub_ele(node, "target"), target) return self._request(node)
[ "def", "request", "(", "self", ",", "target", "=", "\"candidate\"", ")", ":", "node", "=", "new_ele", "(", "\"lock\"", ")", "sub_ele", "(", "sub_ele", "(", "node", ",", "\"target\"", ")", ",", "target", ")", "return", "self", ".", "_request", "(", "nod...
Allows the client to lock the configuration system of a device. *target* is the name of the configuration datastore to lock
[ "Allows", "the", "client", "to", "lock", "the", "configuration", "system", "of", "a", "device", "." ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/lock.py#L28-L35
222,487
ncclient/ncclient
ncclient/transport/ssh.py
SSHSession._parse10
def _parse10(self): """Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.""" self.logger.debug("parsing ...
python
def _parse10(self): """Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.""" self.logger.debug("parsing ...
[ "def", "_parse10", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"parsing netconf v1.0\"", ")", "buf", "=", "self", ".", "_buffer", "buf", ".", "seek", "(", "self", ".", "_parsing_pos10", ")", "if", "MSG_DELIM", "in", "buf", ".", "...
Messages are delimited by MSG_DELIM. The buffer could have grown by a maximum of BUF_SIZE bytes everytime this method is called. Retains state across method calls and if a chunk has been read it will not be considered again.
[ "Messages", "are", "delimited", "by", "MSG_DELIM", ".", "The", "buffer", "could", "have", "grown", "by", "a", "maximum", "of", "BUF_SIZE", "bytes", "everytime", "this", "method", "is", "called", ".", "Retains", "state", "across", "method", "calls", "and", "i...
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/transport/ssh.py#L139-L170
222,488
ncclient/ncclient
ncclient/operations/util.py
one_of
def one_of(*args): "Verifies that only one of the arguments is not None" for i, arg in enumerate(args): if arg is not None: for argh in args[i+1:]: if argh is not None: raise OperationError("Too many parameters") else: return ...
python
def one_of(*args): "Verifies that only one of the arguments is not None" for i, arg in enumerate(args): if arg is not None: for argh in args[i+1:]: if argh is not None: raise OperationError("Too many parameters") else: return ...
[ "def", "one_of", "(", "*", "args", ")", ":", "for", "i", ",", "arg", "in", "enumerate", "(", "args", ")", ":", "if", "arg", "is", "not", "None", ":", "for", "argh", "in", "args", "[", "i", "+", "1", ":", "]", ":", "if", "argh", "is", "not", ...
Verifies that only one of the arguments is not None
[ "Verifies", "that", "only", "one", "of", "the", "arguments", "is", "not", "None" ]
2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a
https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/operations/util.py#L21-L30
222,489
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._get_scale_and_shape
def _get_scale_and_shape(self, transformed_lvs): """ Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, ...
python
def _get_scale_and_shape(self, transformed_lvs): """ Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, ...
[ "def", "_get_scale_and_shape", "(", "self", ",", "transformed_lvs", ")", ":", "if", "self", ".", "scale", "is", "True", ":", "if", "self", ".", "shape", "is", "True", ":", "model_shape", "=", "transformed_lvs", "[", "-", "1", "]", "model_scale", "=", "tr...
Obtains model scale, shape and skewness latent variables Parameters ---------- transformed_lvs : np.array Transformed latent variable vector Returns ---------- - Tuple of model scale, model shape, model skewness
[ "Obtains", "model", "scale", "shape", "and", "skewness", "latent", "variables" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L152-L181
222,490
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._get_scale_and_shape_sim
def _get_scale_and_shape_sim(self, transformed_lvs): """ Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) ...
python
def _get_scale_and_shape_sim(self, transformed_lvs): """ Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) ...
[ "def", "_get_scale_and_shape_sim", "(", "self", ",", "transformed_lvs", ")", ":", "if", "self", ".", "scale", "is", "True", ":", "if", "self", ".", "shape", "is", "True", ":", "model_shape", "=", "self", ".", "latent_variables", ".", "z_list", "[", "-", ...
Obtains model scale, shape, skewness latent variables for a 2d array of simulations. Parameters ---------- transformed_lvs : np.array Transformed latent variable vector (2d - with draws of each variable) Returns ---------- - Tuple of np.arrays (each ...
[ "Obtains", "model", "scale", "shape", "skewness", "latent", "variables", "for", "a", "2d", "array", "of", "simulations", "." ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L183-L213
222,491
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX._summarize_simulations
def _summarize_simulations(self, mean_values, sim_vector, date_index, h, past_values): """ Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. ...
python
def _summarize_simulations(self, mean_values, sim_vector, date_index, h, past_values): """ Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. ...
[ "def", "_summarize_simulations", "(", "self", ",", "mean_values", ",", "sim_vector", ",", "date_index", ",", "h", ",", "past_values", ")", ":", "error_bars", "=", "[", "]", "for", "pre", "in", "range", "(", "5", ",", "100", ",", "5", ")", ":", "error_b...
Produces forecasted values to plot, along with prediction intervals This is a utility function that constructs the prediction intervals and other quantities used for plot_predict() in particular. Parameters ---------- mean_values : np.ndarray Mean predictions for h...
[ "Produces", "forecasted", "values", "to", "plot", "along", "with", "prediction", "intervals" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L606-L639
222,492
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX.normal_neg_loglik
def normal_neg_loglik(self, beta): """ Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklih...
python
def normal_neg_loglik(self, beta): """ Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklih...
[ "def", "normal_neg_loglik", "(", "self", ",", "beta", ")", ":", "mu", ",", "Y", "=", "self", ".", "_model", "(", "beta", ")", "return", "-", "np", ".", "sum", "(", "ss", ".", "norm", ".", "logpdf", "(", "Y", ",", "loc", "=", "mu", ",", "scale",...
Calculates the negative log-likelihood of the model for Normal family Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables Returns ---------- The negative logliklihood of the model
[ "Calculates", "the", "negative", "log", "-", "likelihood", "of", "the", "model", "for", "Normal", "family" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L641-L654
222,493
RJT1990/pyflux
pyflux/arma/arimax.py
ARIMAX.normal_mb_neg_loglik
def normal_mb_neg_loglik(self, beta, mini_batch): """ Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of ...
python
def normal_mb_neg_loglik(self, beta, mini_batch): """ Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of ...
[ "def", "normal_mb_neg_loglik", "(", "self", ",", "beta", ",", "mini_batch", ")", ":", "mu", ",", "Y", "=", "self", ".", "_mb_model", "(", "beta", ",", "mini_batch", ")", "return", "-", "np", ".", "sum", "(", "ss", ".", "norm", ".", "logpdf", "(", "...
Calculates the negative log-likelihood of the Normal model for a minibatch Parameters ---------- beta : np.ndarray Contains untransformed starting values for latent variables mini_batch : int Size of each mini batch of data Returns ---------- ...
[ "Calculates", "the", "negative", "log", "-", "likelihood", "of", "the", "Normal", "model", "for", "a", "minibatch" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/arma/arimax.py#L656-L673
222,494
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.draw_variable
def draw_variable(loc, scale, shape, skewness, nsims): """ Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float...
python
def draw_variable(loc, scale, shape, skewness, nsims): """ Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float...
[ "def", "draw_variable", "(", "loc", ",", "scale", ",", "shape", ",", "skewness", ",", "nsims", ")", ":", "return", "loc", "+", "scale", "*", "Skewt", ".", "rvs", "(", "shape", ",", "skewness", ",", "nsims", ")" ]
Draws random variables from Skew t distribution Parameters ---------- loc : float location parameter for the distribution scale : float scale parameter for the distribution shape : float tail thickness parameter for the distribution ...
[ "Draws", "random", "variables", "from", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L138-L162
222,495
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.first_order_score
def first_order_score(y, mean, scale, shape, skewness): """ GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution ...
python
def first_order_score(y, mean, scale, shape, skewness): """ GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution ...
[ "def", "first_order_score", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "m1", "=", "(", "np", ".", "sqrt", "(", "shape", ")", "*", "sp", ".", "gamma", "(", "(", "shape", "-", "1.0", ")", "/", "2.0", ")", ")", ...
GAS Skew t Update term using gradient only - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the Skew t distribution scale : float scale parameter for the Skew t distri...
[ "GAS", "Skew", "t", "Update", "term", "using", "gradient", "only", "-", "native", "Python", "function" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L165-L194
222,496
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.rvs
def rvs(df, gamma, n): """ Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if li...
python
def rvs(df, gamma, n): """ Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if li...
[ "def", "rvs", "(", "df", ",", "gamma", ",", "n", ")", ":", "if", "type", "(", "n", ")", "==", "list", ":", "u", "=", "np", ".", "random", ".", "uniform", "(", "size", "=", "n", "[", "0", "]", "*", "n", "[", "1", "]", ")", "result", "=", ...
Generates random variables from a Skew t distribution Parameters ---------- df : float degrees of freedom parameter gamma : float skewness parameter n : int or list Number of simulations to perform; if list input, produces array
[ "Generates", "random", "variables", "from", "a", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L197-L223
222,497
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.logpdf
def logpdf(self, mu): """ Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: mu = s...
python
def logpdf(self, mu): """ Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu)) """ if self.transform is not None: mu = s...
[ "def", "logpdf", "(", "self", ",", "mu", ")", ":", "if", "self", ".", "transform", "is", "not", "None", ":", "mu", "=", "self", ".", "transform", "(", "mu", ")", "return", "self", ".", "logpdf_internal_prior", "(", "mu", ",", "df", "=", "self", "."...
Log PDF for Skew t prior Parameters ---------- mu : float Latent variable for which the prior is being formed over Returns ---------- - log(p(mu))
[ "Log", "PDF", "for", "Skew", "t", "prior" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L239-L254
222,498
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.markov_blanket
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float...
python
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float...
[ "def", "markov_blanket", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "m1", "=", "(", "np", ".", "sqrt", "(", "shape", ")", "*", "sp", ".", "gamma", "(", "(", "shape", "-", "1.0", ")", "/", "2.0", ")", ")", "/...
Markov blanket for each likelihood term Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Skew t distribution scale : float scale parameter for the Skew t distribution ...
[ "Markov", "blanket", "for", "each", "likelihood", "term" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L257-L283
222,499
RJT1990/pyflux
pyflux/families/skewt.py
Skewt.pdf_internal
def pdf_internal(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ Raw PDF function for the Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(gamma + 1.0/gamma)*stats.t.pdf(x=gamma*x[(x-loc) < 0], loc=loc[(x-loc) < 0]*gamma,df=df, scale=scale) result[x>=...
python
def pdf_internal(x, df, loc=0.0, scale=1.0, gamma = 1.0): """ Raw PDF function for the Skew t distribution """ result = np.zeros(x.shape[0]) result[x<0] = 2.0/(gamma + 1.0/gamma)*stats.t.pdf(x=gamma*x[(x-loc) < 0], loc=loc[(x-loc) < 0]*gamma,df=df, scale=scale) result[x>=...
[ "def", "pdf_internal", "(", "x", ",", "df", ",", "loc", "=", "0.0", ",", "scale", "=", "1.0", ",", "gamma", "=", "1.0", ")", ":", "result", "=", "np", ".", "zeros", "(", "x", ".", "shape", "[", "0", "]", ")", "result", "[", "x", "<", "0", "...
Raw PDF function for the Skew t distribution
[ "Raw", "PDF", "function", "for", "the", "Skew", "t", "distribution" ]
297f2afc2095acd97c12e827dd500e8ea5da0c0f
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/skewt.py#L340-L347