本文整理汇总了Python中twisted.internet.defer.succeed方法的典型用法代码示例。如果您正苦于以下问题:Python defer.succeed方法的具体用法?Python defer.succeed怎么用?Python defer.succeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.defer
的用法示例。
在下文中一共展示了defer.succeed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stddevSeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def stddevSeries(requestContext, *seriesLists):
"""
Takes one metric or a wildcard seriesList.
Draws the standard deviation of all metrics passed at each time.
Example:
.. code-block:: none
&target=stddevSeries(company.server.*.threads.busy)
"""
yield defer.succeed(None)
(seriesList, start, end, step) = normalize(seriesLists)
name = "stddevSeries(%s)" % formatPathExpressions(seriesList)
values = (safeStdDev(row) for row in izip(*seriesList))
series = TimeSeries(name, start, end, step, values)
series.pathExpression = name
returnValue([series])
示例2: minSeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def minSeries(requestContext, *seriesLists):
"""
Takes one metric or a wildcard seriesList.
For each datapoint from each metric passed in, pick the minimum value and graph it.
Example:
.. code-block:: none
&target=minSeries(Server*.connections.total)
"""
yield defer.succeed(None)
(seriesList, start, end, step) = normalize(seriesLists)
name = "minSeries(%s)" % formatPathExpressions(seriesList)
values = (safeMin(row) for row in izip(*seriesList))
series = TimeSeries(name, start, end, step, values)
series.pathExpression = name
returnValue([series])
示例3: maxSeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def maxSeries(requestContext, *seriesLists):
"""
Takes one metric or a wildcard seriesList.
For each datapoint from each metric passed in, pick the maximum value and graph it.
Example:
.. code-block:: none
&target=maxSeries(Server*.connections.total)
"""
yield defer.succeed(None)
(seriesList, start, end, step) = normalize(seriesLists)
name = "maxSeries(%s)" % formatPathExpressions(seriesList)
values = (safeMax(row) for row in izip(*seriesList))
series = TimeSeries(name, start, end, step, values)
series.pathExpression = name
returnValue([series])
示例4: rangeOfSeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def rangeOfSeries(requestContext, *seriesLists):
"""
Takes a wildcard seriesList.
Distills down a set of inputs into the range of the series
Example:
.. code-block:: none
&target=rangeOfSeries(Server*.connections.total)
"""
yield defer.succeed(None)
(seriesList, start, end, step) = normalize(seriesLists)
name = "rangeOfSeries(%s)" % formatPathExpressions(seriesList)
values = (safeSubtract(max(row), min(row)) for row in izip(*seriesList))
series = TimeSeries(name, start, end, step, values)
series.pathExpression = name
returnValue([series])
示例5: percentileOfSeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def percentileOfSeries(requestContext, seriesList, n, interpolate=False):
"""
percentileOfSeries returns a single series which is composed of the n-percentile
values taken across a wildcard series at each point. Unless `interpolate` is
set to True, percentile values are actual values contained in one of the
supplied series.
"""
yield defer.succeed(None)
if n <= 0:
raise ValueError(
'The requested percent is required to be greater than 0')
name = 'percentileOfSeries(%s,%g)' % (seriesList[0].pathExpression, n)
(start, end, step) = normalize([seriesList])[1:]
values = [_getPercentile(row, n, interpolate) for row in izip(*seriesList)]
resultSeries = TimeSeries(name, start, end, step, values)
resultSeries.pathExpression = name
returnValue([resultSeries])
示例6: multiplySeries
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def multiplySeries(requestContext, *seriesLists):
"""
Takes two or more series and multiplies their points. A constant may not be
used. To multiply by a constant, use the scale() function.
Example:
.. code-block:: none
&target=multiplySeries(Series.dividends,Series.divisors)
"""
yield defer.succeed(None)
(seriesList, start, end, step) = normalize(seriesLists)
if len(seriesList) == 1:
returnValue(seriesList)
name = "multiplySeries(%s)" % ','.join([s.name for s in seriesList])
product = imap(lambda x: safeMul(*x), izip(*seriesList))
resultSeries = TimeSeries(name, start, end, step, product)
resultSeries.pathExpression = name
returnValue([resultSeries])
示例7: scale
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def scale(requestContext, seriesList, factor):
"""
Takes one metric or a wildcard seriesList followed by a constant, and multiplies the datapoint
by the constant provided at each point.
Example:
.. code-block:: none
&target=scale(Server.instance01.threads.busy,10)
&target=scale(Server.instance*.threads.busy,10)
"""
yield defer.succeed(None)
for series in seriesList:
series.name = "scale(%s,%g)" % (series.name, float(factor))
series.pathExpression = series.name
for i, value in enumerate(series):
series[i] = safeMul(value, factor)
returnValue(seriesList)
示例8: pow
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def pow(requestContext, seriesList, factor):
"""
Takes one metric or a wildcard seriesList followed by a constant, and raises the datapoint
by the power of the constant provided at each point.
Example:
.. code-block:: none
&target=pow(Server.instance01.threads.busy,10)
&target=pow(Server.instance*.threads.busy,10)
"""
yield defer.succeed(None)
for series in seriesList:
series.name = "pow(%s,%g)" % (series.name, float(factor))
series.pathExpression = series.name
for i, value in enumerate(series):
series[i] = safePow(value, factor)
returnValue(seriesList)
示例9: squareRoot
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def squareRoot(requestContext, seriesList):
"""
Takes one metric or a wildcard seriesList, and computes the square root of each datapoint.
Example:
.. code-block:: none
&target=squareRoot(Server.instance01.threads.busy)
"""
yield defer.succeed(None)
for series in seriesList:
series.name = "squareRoot(%s)" % (series.name)
for i, value in enumerate(series):
series[i] = safePow(value, 0.5)
returnValue(seriesList)
示例10: invert
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def invert(requestContext, seriesList):
"""
Takes one metric or a wildcard seriesList, and inverts each datapoint (i.e. 1/x).
Example:
.. code-block:: none
&target=invert(Server.instance01.threads.busy)
"""
yield defer.succeed(None)
for series in seriesList:
series.name = "invert(%s)" % (series.name)
for i, value in enumerate(series):
series[i] = safePow(value, -1)
returnValue(seriesList)
示例11: absolute
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def absolute(requestContext, seriesList):
"""
Takes one metric or a wildcard seriesList and applies the mathematical abs function to each
datapoint transforming it to its absolute value.
Example:
.. code-block:: none
&target=absolute(Server.instance01.threads.busy)
&target=absolute(Server.instance*.threads.busy)
"""
yield defer.succeed(None)
for series in seriesList:
series.name = "absolute(%s)" % (series.name)
series.pathExpression = series.name
for i, value in enumerate(series):
series[i] = safeAbs(value)
returnValue(seriesList)
示例12: cumulative
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def cumulative(requestContext, seriesList, consolidationFunc='sum'):
"""
Takes one metric or a wildcard seriesList, and an optional function.
Valid functions are 'sum', 'average', 'min', and 'max'
Sets the consolidation function to 'sum' for the given metric seriesList.
Alias for :func:`consolidateBy(series, 'sum') <graphite.render.functions.consolidateBy>`
.. code-block:: none
&target=cumulative(Sales.widgets.largeBlue)
"""
yield defer.succeed(None)
result = yield consolidateBy(requestContext, seriesList, 'sum')
returnValue(result)
示例13: aliasByNode
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def aliasByNode(requestContext, seriesList, *nodes):
"""
Takes a seriesList and applies an alias derived from one or more "node"
portion/s of the target name. Node indices are 0 indexed.
.. code-block:: none
&target=aliasByNode(ganglia.*.cpu.load5,1)
"""
cb_pattern = re.compile(r"{([^,]+\,)*([^,])+}")
mp_pattern = re.compile(r"(?:.*\()?(?P<name>[-\w*\.]+)(?:,|\)?.*)?")
substitution = 'UNKNOWN'
yield defer.succeed(None)
if isinstance(nodes, int):
nodes = [nodes]
for series in seriesList:
curly_brackets = cb_pattern.search(series.name)
if curly_brackets:
substitution = curly_brackets.groups()[-1]
metric_pieces = mp_pattern.search(cb_pattern.sub(substitution, series.name)).groups()[0].split('.')
series.name = '.'.join(metric_pieces[n] for n in nodes)
returnValue(seriesList)
示例14: color
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def color(requestContext, seriesList, theColor):
"""
Assigns the given color to the seriesList
Example:
.. code-block:: none
&target=color(collectd.hostname.cpu.0.user, 'green')
&target=color(collectd.hostname.cpu.0.system, 'ff0000')
&target=color(collectd.hostname.cpu.0.idle, 'gray')
&target=color(collectd.hostname.cpu.0.idle, '6464ffaa')
"""
yield defer.succeed(None)
for series in seriesList:
series.color = theColor
returnValue(seriesList)
示例15: minimumAbove
# 需要导入模块: from twisted.internet import defer [as 别名]
# 或者: from twisted.internet.defer import succeed [as 别名]
def minimumAbove(requestContext, seriesList, n):
"""
Takes one metric or a wildcard seriesList followed by a constant n.
Draws only the metrics with a minimum value above n.
Example:
.. code-block:: none
&target=minimumAbove(system.interface.eth*.packetsSent,1000)
This would only display interfaces which sent more than 1000 packets/min.
"""
yield defer.succeed(None)
results = []
for series in seriesList:
if min(series) > n:
results.append(series)
returnValue(results)