sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def saveState(self, stateObj):
"""Utility methos to save plugin state stored in stateObj to persistent
storage to permit access to previous state in subsequent plugin runs.
Any object that can be pickled and unpickled can be used to store the
plugin state.
@p... | Utility methos to save plugin state stored in stateObj to persistent
storage to permit access to previous state in subsequent plugin runs.
Any object that can be pickled and unpickled can be used to store the
plugin state.
@param stateObj: Object that stores plugin st... | entailment |
def restoreState(self):
"""Utility method to restore plugin state from persistent storage to
permit access to previous plugin state.
@return: Object that stores plugin state.
"""
if os.path.exists(self._stateFile):
try:
fp = open(sel... | Utility method to restore plugin state from persistent storage to
permit access to previous plugin state.
@return: Object that stores plugin state. | entailment |
def appendGraph(self, graph_name, graph):
"""Utility method to associate Graph Object to Plugin.
This utility method is for use in constructor of child classes for
associating a MuninGraph instances to the plugin.
@param graph_name: Graph Name
@param graph: ... | Utility method to associate Graph Object to Plugin.
This utility method is for use in constructor of child classes for
associating a MuninGraph instances to the plugin.
@param graph_name: Graph Name
@param graph: MuninGraph Instance | entailment |
def appendSubgraph(self, parent_name, graph_name, graph):
"""Utility method to associate Subgraph Instance to Root Graph Instance.
This utility method is for use in constructor of child classes for
associating a MuninGraph Subgraph instance with a Root Graph instance.
@param ... | Utility method to associate Subgraph Instance to Root Graph Instance.
This utility method is for use in constructor of child classes for
associating a MuninGraph Subgraph instance with a Root Graph instance.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name... | entailment |
def setGraphVal(self, graph_name, field_name, val):
"""Utility method to set Value for Field in Graph.
The private method is for use in retrieveVals() method of child classes.
@param graph_name: Graph Name
@param field_name: Field Name.
@param val: Value ... | Utility method to set Value for Field in Graph.
The private method is for use in retrieveVals() method of child classes.
@param graph_name: Graph Name
@param field_name: Field Name.
@param val: Value for field. | entailment |
def setSubgraphVal(self, parent_name, graph_name, field_name, val):
"""Set Value for Field in Subgraph.
The private method is for use in retrieveVals() method of child
classes.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@param field_... | Set Value for Field in Subgraph.
The private method is for use in retrieveVals() method of child
classes.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@param field_name: Field Name.
@param val: Value for field. | entailment |
def getSubgraphList(self, parent_name):
"""Returns list of names of subgraphs for Root Graph with name parent_name.
@param parent_name: Name of Root Graph.
@return: List of subgraph names.
"""
if not self.isMultigraph:
raise AttributeError... | Returns list of names of subgraphs for Root Graph with name parent_name.
@param parent_name: Name of Root Graph.
@return: List of subgraph names. | entailment |
def graphHasField(self, graph_name, field_name):
"""Return true if graph with name graph_name has field with
name field_name.
@param graph_name: Graph Name
@param field_name: Field Name.
@return: Boolean
"""
graph = self._graphDict.get(graph_nam... | Return true if graph with name graph_name has field with
name field_name.
@param graph_name: Graph Name
@param field_name: Field Name.
@return: Boolean | entailment |
def subGraphHasField(self, parent_name, graph_name, field_name):
"""Return true if subgraph with name graph_name with parent graph with
name parent_name has field with name field_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@param field_nam... | Return true if subgraph with name graph_name with parent graph with
name parent_name has field with name field_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@param field_name: Field Name.
@return: Boolean | entailment |
def getGraphFieldList(self, graph_name):
"""Returns list of names of fields for graph with name graph_name.
@param graph_name: Graph Name
@return: List of field names for graph.
"""
graph = self._getGraph(graph_name, True)
return graph.getField... | Returns list of names of fields for graph with name graph_name.
@param graph_name: Graph Name
@return: List of field names for graph. | entailment |
def getGraphFieldCount(self, graph_name):
"""Returns number of fields for graph with name graph_name.
@param graph_name: Graph Name
@return: Number of fields for graph.
"""
graph = self._getGraph(graph_name, True)
return graph.getFieldCount() | Returns number of fields for graph with name graph_name.
@param graph_name: Graph Name
@return: Number of fields for graph. | entailment |
def getSubgraphFieldList(self, parent_name, graph_name):
"""Returns list of names of fields for subgraph with name graph_name
and parent graph with name parent_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@return: List of field n... | Returns list of names of fields for subgraph with name graph_name
and parent graph with name parent_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@return: List of field names for subgraph. | entailment |
def getSubgraphFieldCount(self, parent_name, graph_name):
"""Returns number of fields for subgraph with name graph_name and parent
graph with name parent_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@return: Number of fields for... | Returns number of fields for subgraph with name graph_name and parent
graph with name parent_name.
@param parent_name: Root Graph Name
@param graph_name: Subgraph Name
@return: Number of fields for subgraph. | entailment |
def config(self):
"""Implements Munin Plugin Graph Configuration.
Prints out configuration for graphs.
Use as is. Not required to be overwritten in child classes. The plugin
will work correctly as long as the Munin Graph objects have been
populated.
"""
... | Implements Munin Plugin Graph Configuration.
Prints out configuration for graphs.
Use as is. Not required to be overwritten in child classes. The plugin
will work correctly as long as the Munin Graph objects have been
populated. | entailment |
def fetch(self):
"""Implements Munin Plugin Fetch Option.
Prints out measured values.
"""
self.retrieveVals()
for parent_name in self._graphNames:
graph = self._graphDict[parent_name]
if self.isMultigraph:
print "multigraph %s" % self._ge... | Implements Munin Plugin Fetch Option.
Prints out measured values. | entailment |
def run(self):
"""Implements main entry point for plugin execution."""
if len(self._argv) > 1 and len(self._argv[1]) > 0:
oper = self._argv[1]
else:
oper = 'fetch'
if oper == 'fetch':
ret = self.fetch()
elif oper == 'config':
ret = ... | Implements main entry point for plugin execution. | entailment |
def addField(self, name, label, type=None, draw=None, info=None, #@ReservedAssignment
extinfo=None, colour=None, negative=None, graph=None,
min=None, max=None, cdef=None, line=None, #@ReservedAssignment
warning=None, critical=None):
"""Add field to Munin Grap... | Add field to Munin Graph
@param name: Field Name
@param label: Field Label
@param type: Stat Type:
'COUNTER' / 'ABSOLUTE' / 'DERIVE' / 'GAUGE'
@param draw: Graph Type:
'AREA' / 'LINE{1,2,3}'... | entailment |
def hasField(self, name):
"""Returns true if field with field_name exists.
@param name: Field Name
@return: Boolean
"""
if self._autoFixNames:
name = self._fixName(name)
return self._fieldAttrDict.has_key(name) | Returns true if field with field_name exists.
@param name: Field Name
@return: Boolean | entailment |
def getConfig(self):
"""Returns dictionary of config entries for Munin Graph.
@return: Dictionary of config entries.
"""
return {'graph': self._graphAttrDict,
'fields': [(field_name, self._fieldAttrDict.get(field_name))
for fi... | Returns dictionary of config entries for Munin Graph.
@return: Dictionary of config entries. | entailment |
def setVal(self, name, val):
"""Set value for field in graph.
@param name : Graph Name
@param value : Value for field.
"""
if self._autoFixNames:
name = self._fixName(name)
self._fieldValDict[name] = val | Set value for field in graph.
@param name : Graph Name
@param value : Value for field. | entailment |
def getVals(self):
"""Returns value list for Munin Graph
@return: List of name-value pairs.
"""
return [(name, self._fieldValDict.get(name))
for name in self._fieldNameList] | Returns value list for Munin Graph
@return: List of name-value pairs. | entailment |
def initStats(self, extras=None):
"""Query and parse Web Server Status Page.
@param extras: Include extra metrics, which can be computationally more
expensive.
"""
if extras is not None:
self._extras = extras
if self._extras:
... | Query and parse Web Server Status Page.
@param extras: Include extra metrics, which can be computationally more
expensive. | entailment |
def initStats(self):
"""Query and parse Nginx Web Server Status Page."""
url = "%s://%s:%d/%s" % (self._proto, self._host, self._port,
self._statuspath)
response = util.get_url(url, self._user, self._password)
self._statusDict = {}
for line in re... | Query and parse Nginx Web Server Status Page. | entailment |
def read_file(filename):
"""Read a file into a string"""
path = os.path.abspath(os.path.dirname(__file__))
filepath = os.path.join(path, filename)
try:
return open(filepath).read()
except IOError:
return '' | Read a file into a string | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
proc_info = ProcessInfo()
stats = {}
for (prefix, is_thread) in (('proc', False),
('thread', True)):
graph_name = '%s_status' % prefix
if self.hasGraph(graph_name):
... | Retrieve values for graphs. | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
file_stats = self._fileInfo.getContainerStats()
for contname in self._fileContList:
stats = file_stats.get(contname)
if stats is not None:
if self.hasGraph('rackspace_cloudfiles_container_size'):
... | Retrieve values for graphs. | entailment |
def plot(results, subjgroup=None, subjname='Subject Group', listgroup=None,
listname='List', subjconds=None, listconds=None, plot_type=None,
plot_style=None, title=None, legend=True, xlim=None, ylim=None,
save_path=None, show=True, ax=None, **kwargs):
"""
General plot function that gr... | General plot function that groups data by subject/list number and performs analysis.
Parameters
----------
results : quail.FriedEgg
Object containing results
subjgroup : list of strings or ints
String/int variables indicating how to group over subjects. Must be
the length of t... | entailment |
def getIfStats(self):
"""Return dictionary of Traffic Stats for Network Interfaces.
@return: Nested dictionary of statistics for each interface.
"""
info_dict = {}
try:
fp = open(ifaceStatsFile, 'r')
data = fp.read()
fp.close(... | Return dictionary of Traffic Stats for Network Interfaces.
@return: Nested dictionary of statistics for each interface. | entailment |
def getIfConfig(self):
"""Return dictionary of Interface Configuration (ifconfig).
@return: Dictionary of if configurations keyed by if name.
"""
conf = {}
try:
out = subprocess.Popen([ipCmd, "addr", "show"],
stdou... | Return dictionary of Interface Configuration (ifconfig).
@return: Dictionary of if configurations keyed by if name. | entailment |
def getRoutes(self):
"""Get routing table.
@return: List of routes.
"""
routes = []
try:
out = subprocess.Popen([routeCmd, "-n"],
stdout=subprocess.PIPE).communicate()[0]
except:
raise Exception... | Get routing table.
@return: List of routes. | entailment |
def execNetstatCmd(self, *args):
"""Execute ps command with positional params args and return result as
list of lines.
@param *args: Positional params for netstat command.
@return: List of output lines
"""
out = util.exec_command([netstatCmd,] + li... | Execute ps command with positional params args and return result as
list of lines.
@param *args: Positional params for netstat command.
@return: List of output lines | entailment |
def parseNetstatCmd(self, tcp=True, udp=True, ipv4=True, ipv6=True,
include_listen=True, only_listen=False,
show_users=False, show_procs=False,
resolve_hosts=False, resolve_ports=False,
resolve_users=True):
"""Exec... | Execute netstat command and return result as a nested dictionary.
@param tcp: Include TCP ports in ouput if True.
@param udp: Include UDP ports in ouput if True.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv... | entailment |
def getStats(self, tcp=True, udp=True, ipv4=True, ipv6=True,
include_listen=True, only_listen=False,
show_users=False, show_procs=False,
resolve_hosts=False, resolve_ports=False, resolve_users=True,
**kwargs):
"""Execute netstat command and ... | Execute netstat command and return result as a nested dictionary.
@param tcp: Include TCP ports in ouput if True.
@param udp: Include UDP ports in ouput if True.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv... | entailment |
def getTCPportConnStatus(self, ipv4=True, ipv6=True, include_listen=False,
**kwargs):
"""Returns the number of TCP endpoints discriminated by status.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv6 ports in ou... | Returns the number of TCP endpoints discriminated by status.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv6 ports in output if True.
@param include_listen: Include listening ports in output if True.
@param **kwargs: Keyword... | entailment |
def getTCPportConnCount(self, ipv4=True, ipv6=True, resolve_ports=False,
**kwargs):
"""Returns TCP connection counts for each local port.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv6 ports in output if True.
... | Returns TCP connection counts for each local port.
@param ipv4: Include IPv4 ports in output if True.
@param ipv6: Include IPv6 ports in output if True.
@param resolve_ports: Resolve numeric ports to names if True.
@param **kwargs: Keyword variables are us... | entailment |
def accuracy_helper(egg, match='exact', distance='euclidean',
features=None):
"""
Computes proportion of words recalled
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or smooth)
Matching approach to compute recall matrix. If ... | Computes proportion of words recalled
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or smooth)
Matching approach to compute recall matrix. If exact, the presented and
recalled items must be identical (default). If best, the recalled item
... | entailment |
def _connect(self):
"""Establish connection to PostgreSQL Database."""
if self._connParams:
self._conn = psycopg2.connect(**self._connParams)
else:
self._conn = psycopg2.connect('')
try:
ver_str = self._conn.get_parameter_status('server_version')
... | Establish connection to PostgreSQL Database. | entailment |
def _createStatsDict(self, headers, rows):
"""Utility method that returns database stats as a nested dictionary.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Nested dictionary of values.
Fi... | Utility method that returns database stats as a nested dictionary.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Nested dictionary of values.
First key is the database name and the second key is the... | entailment |
def _createTotalsDict(self, headers, rows):
"""Utility method that returns totals for database statistics.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Dictionary of totals for each statistics column.
... | Utility method that returns totals for database statistics.
@param headers: List of columns in query result.
@param rows: List of rows in query result.
@return: Dictionary of totals for each statistics column. | entailment |
def _simpleQuery(self, query):
"""Executes simple query which returns a single column.
@param query: Query string.
@return: Query result string.
"""
cur = self._conn.cursor()
cur.execute(query)
row = cur.fetchone()
return util.parse_... | Executes simple query which returns a single column.
@param query: Query string.
@return: Query result string. | entailment |
def getParam(self, key):
"""Returns value of Run-time Database Parameter 'key'.
@param key: Run-time parameter name.
@return: Run-time parameter value.
"""
cur = self._conn.cursor()
cur.execute("SHOW %s" % key)
row = cur.fetchone()
ret... | Returns value of Run-time Database Parameter 'key'.
@param key: Run-time parameter name.
@return: Run-time parameter value. | entailment |
def getConnectionStats(self):
"""Returns dictionary with number of connections for each database.
@return: Dictionary of database connection statistics.
"""
cur = self._conn.cursor()
cur.execute("""SELECT datname,numbackends FROM pg_stat_database;""")
ro... | Returns dictionary with number of connections for each database.
@return: Dictionary of database connection statistics. | entailment |
def getDatabaseStats(self):
"""Returns database block read, transaction and tuple stats for each
database.
@return: Nested dictionary of stats.
"""
headers = ('datname', 'numbackends', 'xact_commit', 'xact_rollback',
'blks_read', 'blks_hit',... | Returns database block read, transaction and tuple stats for each
database.
@return: Nested dictionary of stats. | entailment |
def getLockStatsMode(self):
"""Returns the number of active lock discriminated by lock mode.
@return: : Dictionary of stats.
"""
info_dict = {'all': dict(zip(self.lockModes, (0,) * len(self.lockModes))),
'wait': dict(zip(self.lockModes, (0,) * len(s... | Returns the number of active lock discriminated by lock mode.
@return: : Dictionary of stats. | entailment |
def getLockStatsDB(self):
"""Returns the number of active lock discriminated by database.
@return: : Dictionary of stats.
"""
info_dict = {'all': {},
'wait': {}}
cur = self._conn.cursor()
cur.execute("SELECT d.datname, l.granted, COU... | Returns the number of active lock discriminated by database.
@return: : Dictionary of stats. | entailment |
def getBgWriterStats(self):
"""Returns Global Background Writer and Checkpoint Activity stats.
@return: Nested dictionary of stats.
"""
info_dict = {}
if self.checkVersion('8.3'):
cur = self._conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)... | Returns Global Background Writer and Checkpoint Activity stats.
@return: Nested dictionary of stats. | entailment |
def getXlogStatus(self):
"""Returns Transaction Logging or Recovery Status.
@return: Dictionary of status items.
"""
inRecovery = None
if self.checkVersion('9.0'):
inRecovery = self._simpleQuery("SELECT pg_is_in_recovery();")
cur = self._conn... | Returns Transaction Logging or Recovery Status.
@return: Dictionary of status items. | entailment |
def getSlaveStatus(self):
"""Returns status of replication slaves.
@return: Dictionary of status items.
"""
info_dict = {}
if self.checkVersion('9.1'):
cols = ['procpid', 'usename', 'application_name',
'client_addr', 'client_port... | Returns status of replication slaves.
@return: Dictionary of status items. | entailment |
def _connect(self):
"""Establish connection to MySQL Database."""
if self._connParams:
self._conn = MySQLdb.connect(**self._connParams)
else:
self._conn = MySQLdb.connect('') | Establish connection to MySQL Database. | entailment |
def getStorageEngines(self):
"""Returns list of supported storage engines.
@return: List of storage engine names.
"""
cur = self._conn.cursor()
cur.execute("""SHOW STORAGE ENGINES;""")
rows = cur.fetchall()
if rows:
return [row[0].low... | Returns list of supported storage engines.
@return: List of storage engine names. | entailment |
def getParam(self, key):
"""Returns value of Run-time Database Parameter 'key'.
@param key: Run-time parameter name.
@return: Run-time parameter value.
"""
cur = self._conn.cursor()
cur.execute("SHOW GLOBAL VARIABLES LIKE %s", key)
row = cur.f... | Returns value of Run-time Database Parameter 'key'.
@param key: Run-time parameter name.
@return: Run-time parameter value. | entailment |
def getParams(self):
"""Returns dictionary of all run-time parameters.
@return: Dictionary of all Run-time parameters.
"""
cur = self._conn.cursor()
cur.execute("SHOW GLOBAL VARIABLES")
rows = cur.fetchall()
info_dict = {}
for row in rows... | Returns dictionary of all run-time parameters.
@return: Dictionary of all Run-time parameters. | entailment |
def getProcessStatus(self):
"""Returns number of processes discriminated by state.
@return: Dictionary mapping process state to number of processes.
"""
info_dict = {}
cur = self._conn.cursor()
cur.execute("""SHOW FULL PROCESSLIST;""")
rows = cur... | Returns number of processes discriminated by state.
@return: Dictionary mapping process state to number of processes. | entailment |
def getProcessDatabase(self):
"""Returns number of processes discriminated by database name.
@return: Dictionary mapping database name to number of processes.
"""
info_dict = {}
cur = self._conn.cursor()
cur.execute("""SHOW FULL PROCESSLIST;""")
... | Returns number of processes discriminated by database name.
@return: Dictionary mapping database name to number of processes. | entailment |
def getDatabases(self):
"""Returns list of databases.
@return: List of databases.
"""
cur = self._conn.cursor()
cur.execute("""SHOW DATABASES;""")
rows = cur.fetchall()
if rows:
return [row[0] for row in rows]
else:
... | Returns list of databases.
@return: List of databases. | entailment |
def spc_helper(egg, match='exact', distance='euclidean',
features=None):
"""
Computes probability of a word being recalled (in the appropriate recall list), given its presentation position
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or ... | Computes probability of a word being recalled (in the appropriate recall list), given its presentation position
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or smooth)
Matching approach to compute recall matrix. If exact, the presented and
rec... | entailment |
def _retrieve(self):
"""Query Apache Tomcat Server Status Page in XML format and return
the result as an ElementTree object.
@return: ElementTree object of Status Page XML.
"""
url = "%s://%s:%d/manager/status" % (self._proto, self._host, self._port)
pa... | Query Apache Tomcat Server Status Page in XML format and return
the result as an ElementTree object.
@return: ElementTree object of Status Page XML. | entailment |
def getMemoryStats(self):
"""Return JVM Memory Stats for Apache Tomcat Server.
@return: Dictionary of memory utilization stats.
"""
if self._statusxml is None:
self.initStats()
node = self._statusxml.find('jvm/memory')
memstats = {}
i... | Return JVM Memory Stats for Apache Tomcat Server.
@return: Dictionary of memory utilization stats. | entailment |
def getConnectorStats(self):
"""Return dictionary of Connector Stats for Apache Tomcat Server.
@return: Nested dictionary of Connector Stats.
"""
if self._statusxml is None:
self.initStats()
connnodes = self._statusxml.findall('connector')
co... | Return dictionary of Connector Stats for Apache Tomcat Server.
@return: Nested dictionary of Connector Stats. | entailment |
def load(filepath, update=True):
"""
Loads eggs, fried eggs ands example data
Parameters
----------
filepath : str
Location of file
update : bool
If true, updates egg to latest format
Returns
----------
data : quail.Egg or quail.FriedEgg
Data loaded from di... | Loads eggs, fried eggs ands example data
Parameters
----------
filepath : str
Location of file
update : bool
If true, updates egg to latest format
Returns
----------
data : quail.Egg or quail.FriedEgg
Data loaded from disk | entailment |
def load_fegg(filepath, update=True):
"""
Loads pickled egg
Parameters
----------
filepath : str
Location of pickled egg
update : bool
If true, updates egg to latest format
Returns
----------
egg : Egg data object
A loaded unpickled egg
"""
try:
... | Loads pickled egg
Parameters
----------
filepath : str
Location of pickled egg
update : bool
If true, updates egg to latest format
Returns
----------
egg : Egg data object
A loaded unpickled egg | entailment |
def load_egg(filepath, update=True):
"""
Loads pickled egg
Parameters
----------
filepath : str
Location of pickled egg
update : bool
If true, updates egg to latest format
Returns
----------
egg : Egg data object
A loaded unpickled egg
"""
try:
... | Loads pickled egg
Parameters
----------
filepath : str
Location of pickled egg
update : bool
If true, updates egg to latest format
Returns
----------
egg : Egg data object
A loaded unpickled egg | entailment |
def loadEL(dbpath=None, recpath=None, remove_subs=None, wordpool=None, groupby=None, experiments=None,
filters=None):
'''
Function that loads sql files generated by autoFR Experiment
'''
assert (dbpath is not None), "You must specify a db file or files."
assert (recpath is not None), "You must ... | Function that loads sql files generated by autoFR Experiment | entailment |
def load_example_data(dataset='automatic'):
"""
Loads example data
The automatic and manual example data are eggs containing 30 subjects who completed a free
recall experiment as described here: https://psyarxiv.com/psh48/. The subjects
studied 8 lists of 16 words each and then performed a free rec... | Loads example data
The automatic and manual example data are eggs containing 30 subjects who completed a free
recall experiment as described here: https://psyarxiv.com/psh48/. The subjects
studied 8 lists of 16 words each and then performed a free recall test.
The naturalistic example data is is an eg... | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
fs = FSinfo(self._fshost, self._fsport, self._fspass)
if self.hasGraph('fs_calls'):
count = fs.getCallCount()
self.setGraphVal('fs_calls', 'calls', count)
if self.hasGraph('fs_channels'):
count ... | Retrieve values for graphs. | entailment |
def autoconf(self):
"""Implements Munin Plugin Auto-Configuration Option.
@return: True if plugin can be auto-configured, False otherwise.
"""
fs = FSinfo(self._fshost, self._fsport, self._fspass)
return fs is not None | Implements Munin Plugin Auto-Configuration Option.
@return: True if plugin can be auto-configured, False otherwise. | entailment |
def spsolve(A, b):
"""Solve the sparse linear system Ax=b, where b may be a vector or a matrix.
Parameters
----------
A : ndarray or sparse matrix
The square matrix A will be converted into CSC or CSR form
b : ndarray or sparse matrix
The matrix or vector representing the right hand... | Solve the sparse linear system Ax=b, where b may be a vector or a matrix.
Parameters
----------
A : ndarray or sparse matrix
The square matrix A will be converted into CSC or CSR form
b : ndarray or sparse matrix
The matrix or vector representing the right hand side of the equation.
... | entailment |
def solve(self, b):
"""
Solve linear equation A x = b for x
Parameters
----------
b : ndarray
Right-hand side of the matrix equation. Can be vector or a matrix.
Returns
-------
x : ndarray
Solution to the matrix equation
... | Solve linear equation A x = b for x
Parameters
----------
b : ndarray
Right-hand side of the matrix equation. Can be vector or a matrix.
Returns
-------
x : ndarray
Solution to the matrix equation | entailment |
def solve_sparse(self, B):
"""
Solve linear equation of the form A X = B. Where B and X are sparse matrices.
Parameters
----------
B : any scipy.sparse matrix
Right-hand side of the matrix equation.
Note: it will be converted to csc_matrix via `.tocsc()`.... | Solve linear equation of the form A X = B. Where B and X are sparse matrices.
Parameters
----------
B : any scipy.sparse matrix
Right-hand side of the matrix equation.
Note: it will be converted to csc_matrix via `.tocsc()`.
Returns
-------
X : c... | entailment |
def recall_matrix(egg, match='exact', distance='euclidean', features=None):
"""
Computes recall matrix given list of presented and list of recalled words
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or smooth)
Matching approach to compute recal... | Computes recall matrix given list of presented and list of recalled words
Parameters
----------
egg : quail.Egg
Data to analyze
match : str (exact, best or smooth)
Matching approach to compute recall matrix. If exact, the presented and
recalled items must be identical (default... | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
net_info = NetstatInfo()
if self.hasGraph('netstat_conn_status'):
stats = net_info.getTCPportConnStatus(include_listen=True)
for fname in ('listen', 'established', 'syn_sent', 'syn_recv',
... | Retrieve values for graphs. | entailment |
def _parseFreePBXconf(self):
"""Parses FreePBX configuration file /etc/amportal for user and password
for Asterisk Manager Interface.
@return: True if configuration file is found and parsed successfully.
"""
amiuser = None
amipass = None
if os.pa... | Parses FreePBX configuration file /etc/amportal for user and password
for Asterisk Manager Interface.
@return: True if configuration file is found and parsed successfully. | entailment |
def _parseAsteriskConf(self):
"""Parses Asterisk configuration file /etc/asterisk/manager.conf for
user and password for Manager Interface. Returns True on success.
@return: True if configuration file is found and parsed successfully.
"""
if os.path.isfile(confF... | Parses Asterisk configuration file /etc/asterisk/manager.conf for
user and password for Manager Interface. Returns True on success.
@return: True if configuration file is found and parsed successfully. | entailment |
def _connect(self):
"""Connect to Asterisk Manager Interface."""
try:
if sys.version_info[:2] >= (2,6):
self._conn = telnetlib.Telnet(self._amihost, self._amiport,
connTimeout)
else:
self._conn = telne... | Connect to Asterisk Manager Interface. | entailment |
def _sendAction(self, action, attrs=None, chan_vars=None):
"""Send action to Asterisk Manager Interface.
@param action: Action name
@param attrs: Tuple of key-value pairs for action attributes.
@param chan_vars: Tuple of key-value pairs for channel variables.
"""... | Send action to Asterisk Manager Interface.
@param action: Action name
@param attrs: Tuple of key-value pairs for action attributes.
@param chan_vars: Tuple of key-value pairs for channel variables. | entailment |
def _getResponse(self):
"""Read and parse response from Asterisk Manager Interface.
@return: Dictionary with response key-value pairs.
"""
resp_dict= dict()
resp_str = self._conn.read_until("\r\n\r\n", connTimeout)
for line in resp_str.split("\r\n"):
... | Read and parse response from Asterisk Manager Interface.
@return: Dictionary with response key-value pairs. | entailment |
def _getGreeting(self):
"""Read and parse Asterisk Manager Interface Greeting to determine and
set Manager Interface version.
"""
greeting = self._conn.read_until("\r\n", connTimeout)
mobj = re.match('Asterisk Call Manager\/([\d\.]+)\s*$', greeting)
if mobj:
... | Read and parse Asterisk Manager Interface Greeting to determine and
set Manager Interface version. | entailment |
def _initAsteriskVersion(self):
"""Query Asterisk Manager Interface for Asterisk Version to configure
system for compatibility with multiple versions
.
CLI Command - core show version
"""
if self._ami_version > util.SoftwareVersion('1.0'):
cmd = "core show ve... | Query Asterisk Manager Interface for Asterisk Version to configure
system for compatibility with multiple versions
.
CLI Command - core show version | entailment |
def _login(self):
"""Login to Asterisk Manager Interface."""
self._sendAction("login", (
("Username", self._amiuser),
("Secret", self._amipass),
("Events", "off"),
))
resp = self._getResponse()
if resp.get("Response") == "Success":
... | Login to Asterisk Manager Interface. | entailment |
def executeCommand(self, command):
"""Send Action to Asterisk Manager Interface to execute CLI Command.
@param command: CLI command to execute.
@return: Command response string.
"""
self._sendAction("Command", (
("Command", command),
))
... | Send Action to Asterisk Manager Interface to execute CLI Command.
@param command: CLI command to execute.
@return: Command response string. | entailment |
def _initModuleList(self):
"""Query Asterisk Manager Interface to initialize internal list of
loaded modules.
CLI Command - core show modules
"""
if self.checkVersion('1.4'):
cmd = "module show"
else:
cmd = "show modules"
... | Query Asterisk Manager Interface to initialize internal list of
loaded modules.
CLI Command - core show modules | entailment |
def _initApplicationList(self):
"""Query Asterisk Manager Interface to initialize internal list of
available applications.
CLI Command - core show applications
"""
if self.checkVersion('1.4'):
cmd = "core show applications"
else:
... | Query Asterisk Manager Interface to initialize internal list of
available applications.
CLI Command - core show applications | entailment |
def _initChannelTypesList(self):
"""Query Asterisk Manager Interface to initialize internal list of
supported channel types.
CLI Command - core show applications
"""
if self.checkVersion('1.4'):
cmd = "core show channeltypes"
else:
... | Query Asterisk Manager Interface to initialize internal list of
supported channel types.
CLI Command - core show applications | entailment |
def hasModule(self, mod):
"""Returns True if mod is among the loaded modules.
@param mod: Module name.
@return: Boolean
"""
if self._modules is None:
self._initModuleList()
return mod in self._modules | Returns True if mod is among the loaded modules.
@param mod: Module name.
@return: Boolean | entailment |
def hasApplication(self, app):
"""Returns True if app is among the loaded modules.
@param app: Module name.
@return: Boolean
"""
if self._applications is None:
self._initApplicationList()
return app in self._applications | Returns True if app is among the loaded modules.
@param app: Module name.
@return: Boolean | entailment |
def hasChannelType(self, chan):
"""Returns True if chan is among the supported channel types.
@param app: Module name.
@return: Boolean
"""
if self._chantypes is None:
self._initChannelTypesList()
return chan in self._chantypes | Returns True if chan is among the supported channel types.
@param app: Module name.
@return: Boolean | entailment |
def getCodecList(self):
"""Query Asterisk Manager Interface for defined codecs.
CLI Command - core show codecs
@return: Dictionary - Short Name -> (Type, Long Name)
"""
if self.checkVersion('1.4'):
cmd = "core show codecs"
else:
... | Query Asterisk Manager Interface for defined codecs.
CLI Command - core show codecs
@return: Dictionary - Short Name -> (Type, Long Name) | entailment |
def getChannelStats(self, chantypes=('dahdi', 'zap', 'sip', 'iax2', 'local')):
"""Query Asterisk Manager Interface for Channel Stats.
CLI Command - core show channels
@return: Dictionary of statistics counters for channels.
Number of active channels for each channel type.
... | Query Asterisk Manager Interface for Channel Stats.
CLI Command - core show channels
@return: Dictionary of statistics counters for channels.
Number of active channels for each channel type. | entailment |
def getPeerStats(self, chantype):
"""Query Asterisk Manager Interface for SIP / IAX2 Peer Stats.
CLI Command - sip show peers
iax2 show peers
@param chantype: Must be 'sip' or 'iax2'.
@return: Dictionary of statistics counters for VoIP Peer... | Query Asterisk Manager Interface for SIP / IAX2 Peer Stats.
CLI Command - sip show peers
iax2 show peers
@param chantype: Must be 'sip' or 'iax2'.
@return: Dictionary of statistics counters for VoIP Peers. | entailment |
def getVoIPchanStats(self, chantype,
codec_list=('ulaw', 'alaw', 'gsm', 'g729')):
"""Query Asterisk Manager Interface for SIP / IAX2 Channel / Codec Stats.
CLI Commands - sip show channels
iax2 show channnels
@param chantype: M... | Query Asterisk Manager Interface for SIP / IAX2 Channel / Codec Stats.
CLI Commands - sip show channels
iax2 show channnels
@param chantype: Must be 'sip' or 'iax2'.
@param codec_list: List of codec names to parse.
(Codecs not... | entailment |
def getConferenceStats(self):
"""Query Asterisk Manager Interface for Conference Room Stats.
CLI Command - meetme list
@return: Dictionary of statistics counters for Conference Rooms.
"""
if not self.hasConference():
return None
if self.checkVersion... | Query Asterisk Manager Interface for Conference Room Stats.
CLI Command - meetme list
@return: Dictionary of statistics counters for Conference Rooms. | entailment |
def getVoicemailStats(self):
"""Query Asterisk Manager Interface for Voicemail Stats.
CLI Command - voicemail show users
@return: Dictionary of statistics counters for Voicemail Accounts.
"""
if not self.hasVoicemail():
return None
if self.checkVers... | Query Asterisk Manager Interface for Voicemail Stats.
CLI Command - voicemail show users
@return: Dictionary of statistics counters for Voicemail Accounts. | entailment |
def getTrunkStats(self, trunkList):
"""Query Asterisk Manager Interface for Trunk Stats.
CLI Command - core show channels
@param trunkList: List of tuples of one of the two following types:
(Trunk Name, Regular Expression)
(Trunk ... | Query Asterisk Manager Interface for Trunk Stats.
CLI Command - core show channels
@param trunkList: List of tuples of one of the two following types:
(Trunk Name, Regular Expression)
(Trunk Name, Regular Expression, MIN, MAX)
@re... | entailment |
def getQueueStats(self):
"""Query Asterisk Manager Interface for Queue Stats.
CLI Command: queue show
@return: Dictionary of queue stats.
"""
if not self.hasQueue():
return None
info_dict = {}
if self.checkVersion('1.4'):
... | Query Asterisk Manager Interface for Queue Stats.
CLI Command: queue show
@return: Dictionary of queue stats. | entailment |
def getFaxStatsCounters(self):
"""Query Asterisk Manager Interface for Fax Stats.
CLI Command - fax show stats
@return: Dictionary of fax stats.
"""
if not self.hasFax():
return None
info_dict = {}
cmdresp = self.executeComma... | Query Asterisk Manager Interface for Fax Stats.
CLI Command - fax show stats
@return: Dictionary of fax stats. | entailment |
def getFaxStatsSessions(self):
"""Query Asterisk Manager Interface for Fax Stats.
CLI Command - fax show sessions
@return: Dictionary of fax stats.
"""
if not self.hasFax():
return None
info_dict = {}
info_dict['total'] = 0
... | Query Asterisk Manager Interface for Fax Stats.
CLI Command - fax show sessions
@return: Dictionary of fax stats. | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
for iface in self._ifaceList:
if self._reqIfaceList is None or iface in self._reqIfaceList:
if (self.graphEnabled('wanpipe_traffic')
or self.graphEnabled('wanpipe_errors')):
sta... | Retrieve values for graphs. | entailment |
def simulate_list(nwords=16, nrec=10, ncats=4):
"""A function to simulate a list"""
# load wordpool
wp = pd.read_csv('data/cut_wordpool.csv')
# get one list
wp = wp[wp['GROUP']==np.random.choice(list(range(16)), 1)[0]].sample(16)
wp['COLOR'] = [[int(np.random.rand() * 255) for i in range(3)] ... | A function to simulate a list | entailment |
def retrieveVals(self):
"""Retrieve values for graphs."""
if self._genStats is None:
self._genStats = self._dbconn.getStats()
if self._genVars is None:
self._genVars = self._dbconn.getParams()
if self.hasGraph('mysql_connections'):
self.setGraphVal('my... | Retrieve values for graphs. | entailment |
def engineIncluded(self, name):
"""Utility method to check if a storage engine is included in graphs.
@param name: Name of storage engine.
@return: Returns True if included in graphs, False otherwise.
"""
if self._engines is None:
self._engin... | Utility method to check if a storage engine is included in graphs.
@param name: Name of storage engine.
@return: Returns True if included in graphs, False otherwise. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.