repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
vxgmichel/aiostream | aiostream/stream/select.py | takewhile | async def takewhile(source, func):
"""Forward an asynchronous sequence while a condition is met.
The given function takes the item as an argument and returns a boolean
corresponding to the condition to meet. The function can either be
synchronous or asynchronous.
"""
iscorofunc = asyncio.iscoro... | python | async def takewhile(source, func):
"""Forward an asynchronous sequence while a condition is met.
The given function takes the item as an argument and returns a boolean
corresponding to the condition to meet. The function can either be
synchronous or asynchronous.
"""
iscorofunc = asyncio.iscoro... | [
"async",
"def",
"takewhile",
"(",
"source",
",",
"func",
")",
":",
"iscorofunc",
"=",
"asyncio",
".",
"iscoroutinefunction",
"(",
"func",
")",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"strea... | Forward an asynchronous sequence while a condition is met.
The given function takes the item as an argument and returns a boolean
corresponding to the condition to meet. The function can either be
synchronous or asynchronous. | [
"Forward",
"an",
"asynchronous",
"sequence",
"while",
"a",
"condition",
"is",
"met",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/select.py#L194-L209 |
vxgmichel/aiostream | aiostream/pipe.py | update_pipe_module | def update_pipe_module():
"""Populate the pipe module dynamically."""
module_dir = __all__
operators = stream.__dict__
for key, value in operators.items():
if getattr(value, 'pipe', None):
globals()[key] = value.pipe
if key not in module_dir:
module_dir.ap... | python | def update_pipe_module():
"""Populate the pipe module dynamically."""
module_dir = __all__
operators = stream.__dict__
for key, value in operators.items():
if getattr(value, 'pipe', None):
globals()[key] = value.pipe
if key not in module_dir:
module_dir.ap... | [
"def",
"update_pipe_module",
"(",
")",
":",
"module_dir",
"=",
"__all__",
"operators",
"=",
"stream",
".",
"__dict__",
"for",
"key",
",",
"value",
"in",
"operators",
".",
"items",
"(",
")",
":",
"if",
"getattr",
"(",
"value",
",",
"'pipe'",
",",
"None",
... | Populate the pipe module dynamically. | [
"Populate",
"the",
"pipe",
"module",
"dynamically",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/pipe.py#L8-L16 |
vxgmichel/aiostream | aiostream/stream/transform.py | enumerate | async def enumerate(source, start=0, step=1):
"""Generate ``(index, value)`` tuples from an asynchronous sequence.
This index is computed using a starting point and an increment,
respectively defaulting to ``0`` and ``1``.
"""
count = itertools.count(start, step)
async with streamcontext(source... | python | async def enumerate(source, start=0, step=1):
"""Generate ``(index, value)`` tuples from an asynchronous sequence.
This index is computed using a starting point and an increment,
respectively defaulting to ``0`` and ``1``.
"""
count = itertools.count(start, step)
async with streamcontext(source... | [
"async",
"def",
"enumerate",
"(",
"source",
",",
"start",
"=",
"0",
",",
"step",
"=",
"1",
")",
":",
"count",
"=",
"itertools",
".",
"count",
"(",
"start",
",",
"step",
")",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",... | Generate ``(index, value)`` tuples from an asynchronous sequence.
This index is computed using a starting point and an increment,
respectively defaulting to ``0`` and ``1``. | [
"Generate",
"(",
"index",
"value",
")",
"tuples",
"from",
"an",
"asynchronous",
"sequence",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/transform.py#L20-L29 |
vxgmichel/aiostream | aiostream/stream/transform.py | starmap | def starmap(source, func, ordered=True, task_limit=None):
"""Apply a given function to the unpacked elements of
an asynchronous sequence.
Each element is unpacked before applying the function.
The given function can either be synchronous or asynchronous.
The results can either be returned in or ou... | python | def starmap(source, func, ordered=True, task_limit=None):
"""Apply a given function to the unpacked elements of
an asynchronous sequence.
Each element is unpacked before applying the function.
The given function can either be synchronous or asynchronous.
The results can either be returned in or ou... | [
"def",
"starmap",
"(",
"source",
",",
"func",
",",
"ordered",
"=",
"True",
",",
"task_limit",
"=",
"None",
")",
":",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"func",
")",
":",
"async",
"def",
"starfunc",
"(",
"args",
")",
":",
"return",
"await... | Apply a given function to the unpacked elements of
an asynchronous sequence.
Each element is unpacked before applying the function.
The given function can either be synchronous or asynchronous.
The results can either be returned in or out of order, depending on
the corresponding ``ordered`` argume... | [
"Apply",
"a",
"given",
"function",
"to",
"the",
"unpacked",
"elements",
"of",
"an",
"asynchronous",
"sequence",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/transform.py#L33-L55 |
vxgmichel/aiostream | aiostream/stream/transform.py | cycle | async def cycle(source):
"""Iterate indefinitely over an asynchronous sequence.
Note: it does not perform any buffering, but re-iterate over
the same given sequence instead. If the sequence is not
re-iterable, the generator might end up looping indefinitely
without yielding any item.
"""
wh... | python | async def cycle(source):
"""Iterate indefinitely over an asynchronous sequence.
Note: it does not perform any buffering, but re-iterate over
the same given sequence instead. If the sequence is not
re-iterable, the generator might end up looping indefinitely
without yielding any item.
"""
wh... | [
"async",
"def",
"cycle",
"(",
"source",
")",
":",
"while",
"True",
":",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"streamer",
":",
"yield",
"item",
"# Prevent blocking while loop if the stream is e... | Iterate indefinitely over an asynchronous sequence.
Note: it does not perform any buffering, but re-iterate over
the same given sequence instead. If the sequence is not
re-iterable, the generator might end up looping indefinitely
without yielding any item. | [
"Iterate",
"indefinitely",
"over",
"an",
"asynchronous",
"sequence",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/transform.py#L59-L72 |
vxgmichel/aiostream | aiostream/stream/transform.py | chunks | async def chunks(source, n):
"""Generate chunks of size ``n`` from an asynchronous sequence.
The chunks are lists, and the last chunk might contain less than ``n``
elements.
"""
async with streamcontext(source) as streamer:
async for first in streamer:
xs = select.take(create.pr... | python | async def chunks(source, n):
"""Generate chunks of size ``n`` from an asynchronous sequence.
The chunks are lists, and the last chunk might contain less than ``n``
elements.
"""
async with streamcontext(source) as streamer:
async for first in streamer:
xs = select.take(create.pr... | [
"async",
"def",
"chunks",
"(",
"source",
",",
"n",
")",
":",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"first",
"in",
"streamer",
":",
"xs",
"=",
"select",
".",
"take",
"(",
"create",
".",
"preserve",
... | Generate chunks of size ``n`` from an asynchronous sequence.
The chunks are lists, and the last chunk might contain less than ``n``
elements. | [
"Generate",
"chunks",
"of",
"size",
"n",
"from",
"an",
"asynchronous",
"sequence",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/transform.py#L76-L85 |
vxgmichel/aiostream | examples/extra.py | random | async def random(offset=0., width=1., interval=0.1):
"""Generate a stream of random numbers."""
while True:
await asyncio.sleep(interval)
yield offset + width * random_module.random() | python | async def random(offset=0., width=1., interval=0.1):
"""Generate a stream of random numbers."""
while True:
await asyncio.sleep(interval)
yield offset + width * random_module.random() | [
"async",
"def",
"random",
"(",
"offset",
"=",
"0.",
",",
"width",
"=",
"1.",
",",
"interval",
"=",
"0.1",
")",
":",
"while",
"True",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"interval",
")",
"yield",
"offset",
"+",
"width",
"*",
"random_module",
"... | Generate a stream of random numbers. | [
"Generate",
"a",
"stream",
"of",
"random",
"numbers",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/examples/extra.py#L8-L12 |
vxgmichel/aiostream | examples/extra.py | power | async def power(source, exponent):
"""Raise the elements of an asynchronous sequence to the given power."""
async with streamcontext(source) as streamer:
async for item in streamer:
yield item ** exponent | python | async def power(source, exponent):
"""Raise the elements of an asynchronous sequence to the given power."""
async with streamcontext(source) as streamer:
async for item in streamer:
yield item ** exponent | [
"async",
"def",
"power",
"(",
"source",
",",
"exponent",
")",
":",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"streamer",
":",
"yield",
"item",
"**",
"exponent"
] | Raise the elements of an asynchronous sequence to the given power. | [
"Raise",
"the",
"elements",
"of",
"an",
"asynchronous",
"sequence",
"to",
"the",
"given",
"power",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/examples/extra.py#L16-L20 |
vxgmichel/aiostream | aiostream/stream/time.py | spaceout | async def spaceout(source, interval):
"""Make sure the elements of an asynchronous sequence are separated
in time by the given interval.
"""
timeout = 0
loop = asyncio.get_event_loop()
async with streamcontext(source) as streamer:
async for item in streamer:
delta = timeout -... | python | async def spaceout(source, interval):
"""Make sure the elements of an asynchronous sequence are separated
in time by the given interval.
"""
timeout = 0
loop = asyncio.get_event_loop()
async with streamcontext(source) as streamer:
async for item in streamer:
delta = timeout -... | [
"async",
"def",
"spaceout",
"(",
"source",
",",
"interval",
")",
":",
"timeout",
"=",
"0",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",... | Make sure the elements of an asynchronous sequence are separated
in time by the given interval. | [
"Make",
"sure",
"the",
"elements",
"of",
"an",
"asynchronous",
"sequence",
"are",
"separated",
"in",
"time",
"by",
"the",
"given",
"interval",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/time.py#L26-L38 |
vxgmichel/aiostream | aiostream/stream/time.py | timeout | async def timeout(source, timeout):
"""Raise a time-out if an element of the asynchronous sequence
takes too long to arrive.
Note: the timeout is not global but specific to each step of
the iteration.
"""
async with streamcontext(source) as streamer:
while True:
try:
... | python | async def timeout(source, timeout):
"""Raise a time-out if an element of the asynchronous sequence
takes too long to arrive.
Note: the timeout is not global but specific to each step of
the iteration.
"""
async with streamcontext(source) as streamer:
while True:
try:
... | [
"async",
"def",
"timeout",
"(",
"source",
",",
"timeout",
")",
":",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"while",
"True",
":",
"try",
":",
"item",
"=",
"await",
"wait_for",
"(",
"anext",
"(",
"streamer",
")",
","... | Raise a time-out if an element of the asynchronous sequence
takes too long to arrive.
Note: the timeout is not global but specific to each step of
the iteration. | [
"Raise",
"a",
"time",
"-",
"out",
"if",
"an",
"element",
"of",
"the",
"asynchronous",
"sequence",
"takes",
"too",
"long",
"to",
"arrive",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/time.py#L42-L56 |
vxgmichel/aiostream | aiostream/stream/time.py | delay | async def delay(source, delay):
"""Delay the iteration of an asynchronous sequence."""
await asyncio.sleep(delay)
async with streamcontext(source) as streamer:
async for item in streamer:
yield item | python | async def delay(source, delay):
"""Delay the iteration of an asynchronous sequence."""
await asyncio.sleep(delay)
async with streamcontext(source) as streamer:
async for item in streamer:
yield item | [
"async",
"def",
"delay",
"(",
"source",
",",
"delay",
")",
":",
"await",
"asyncio",
".",
"sleep",
"(",
"delay",
")",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"streamer",
":",
"yield",
"i... | Delay the iteration of an asynchronous sequence. | [
"Delay",
"the",
"iteration",
"of",
"an",
"asynchronous",
"sequence",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/time.py#L60-L65 |
vxgmichel/aiostream | aiostream/stream/combine.py | chain | async def chain(*sources):
"""Chain asynchronous sequences together, in the order they are given.
Note: the sequences are not iterated until it is required,
so if the operation is interrupted, the remaining sequences
will be left untouched.
"""
for source in sources:
async with streamco... | python | async def chain(*sources):
"""Chain asynchronous sequences together, in the order they are given.
Note: the sequences are not iterated until it is required,
so if the operation is interrupted, the remaining sequences
will be left untouched.
"""
for source in sources:
async with streamco... | [
"async",
"def",
"chain",
"(",
"*",
"sources",
")",
":",
"for",
"source",
"in",
"sources",
":",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",
":",
"async",
"for",
"item",
"in",
"streamer",
":",
"yield",
"item"
] | Chain asynchronous sequences together, in the order they are given.
Note: the sequences are not iterated until it is required,
so if the operation is interrupted, the remaining sequences
will be left untouched. | [
"Chain",
"asynchronous",
"sequences",
"together",
"in",
"the",
"order",
"they",
"are",
"given",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/combine.py#L18-L28 |
vxgmichel/aiostream | aiostream/stream/combine.py | zip | async def zip(*sources):
"""Combine and forward the elements of several asynchronous sequences.
Each generated value is a tuple of elements, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted.
Note: the different sequences are awaite... | python | async def zip(*sources):
"""Combine and forward the elements of several asynchronous sequences.
Each generated value is a tuple of elements, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted.
Note: the different sequences are awaite... | [
"async",
"def",
"zip",
"(",
"*",
"sources",
")",
":",
"async",
"with",
"AsyncExitStack",
"(",
")",
"as",
"stack",
":",
"# Handle resources",
"streamers",
"=",
"[",
"await",
"stack",
".",
"enter_async_context",
"(",
"streamcontext",
"(",
"source",
")",
")",
... | Combine and forward the elements of several asynchronous sequences.
Each generated value is a tuple of elements, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted.
Note: the different sequences are awaited in parrallel, so that their
... | [
"Combine",
"and",
"forward",
"the",
"elements",
"of",
"several",
"asynchronous",
"sequences",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/combine.py#L32-L54 |
vxgmichel/aiostream | aiostream/stream/combine.py | smap | async def smap(source, func, *more_sources):
"""Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted. The fu... | python | async def smap(source, func, *more_sources):
"""Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted. The fu... | [
"async",
"def",
"smap",
"(",
"source",
",",
"func",
",",
"*",
"more_sources",
")",
":",
"if",
"more_sources",
":",
"source",
"=",
"zip",
"(",
"source",
",",
"*",
"more_sources",
")",
"async",
"with",
"streamcontext",
"(",
"source",
")",
"as",
"streamer",... | Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted. The function is treated synchronously.
Note: if more ... | [
"Apply",
"a",
"given",
"function",
"to",
"the",
"elements",
"of",
"one",
"or",
"several",
"asynchronous",
"sequences",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/combine.py#L58-L73 |
vxgmichel/aiostream | aiostream/stream/combine.py | amap | def amap(source, corofn, *more_sources, ordered=True, task_limit=None):
"""Apply a given coroutine function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the short... | python | def amap(source, corofn, *more_sources, ordered=True, task_limit=None):
"""Apply a given coroutine function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the short... | [
"def",
"amap",
"(",
"source",
",",
"corofn",
",",
"*",
"more_sources",
",",
"ordered",
"=",
"True",
",",
"task_limit",
"=",
"None",
")",
":",
"def",
"func",
"(",
"*",
"args",
")",
":",
"return",
"create",
".",
"just",
"(",
"corofn",
"(",
"*",
"args... | Apply a given coroutine function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted.
The results can either be returned in or ou... | [
"Apply",
"a",
"given",
"coroutine",
"function",
"to",
"the",
"elements",
"of",
"one",
"or",
"several",
"asynchronous",
"sequences",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/combine.py#L77-L103 |
vxgmichel/aiostream | aiostream/stream/combine.py | map | def map(source, func, *more_sources, ordered=True, task_limit=None):
"""Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
seque... | python | def map(source, func, *more_sources, ordered=True, task_limit=None):
"""Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
seque... | [
"def",
"map",
"(",
"source",
",",
"func",
",",
"*",
"more_sources",
",",
"ordered",
"=",
"True",
",",
"task_limit",
"=",
"None",
")",
":",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"func",
")",
":",
"return",
"amap",
".",
"raw",
"(",
"source",
... | Apply a given function to the elements of one or several
asynchronous sequences.
Each element is used as a positional argument, using the same order as
their respective sources. The generation continues until the shortest
sequence is exhausted. The function can either be synchronous or
asynchronous... | [
"Apply",
"a",
"given",
"function",
"to",
"the",
"elements",
"of",
"one",
"or",
"several",
"asynchronous",
"sequences",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/combine.py#L107-L142 |
vxgmichel/aiostream | aiostream/stream/create.py | iterate | def iterate(it):
"""Generate values from a sychronous or asynchronous iterable."""
if is_async_iterable(it):
return from_async_iterable.raw(it)
if isinstance(it, Iterable):
return from_iterable.raw(it)
raise TypeError(
f"{type(it).__name__!r} object is not (async) iterable") | python | def iterate(it):
"""Generate values from a sychronous or asynchronous iterable."""
if is_async_iterable(it):
return from_async_iterable.raw(it)
if isinstance(it, Iterable):
return from_iterable.raw(it)
raise TypeError(
f"{type(it).__name__!r} object is not (async) iterable") | [
"def",
"iterate",
"(",
"it",
")",
":",
"if",
"is_async_iterable",
"(",
"it",
")",
":",
"return",
"from_async_iterable",
".",
"raw",
"(",
"it",
")",
"if",
"isinstance",
"(",
"it",
",",
"Iterable",
")",
":",
"return",
"from_iterable",
".",
"raw",
"(",
"i... | Generate values from a sychronous or asynchronous iterable. | [
"Generate",
"values",
"from",
"a",
"sychronous",
"or",
"asynchronous",
"iterable",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/create.py#L39-L46 |
vxgmichel/aiostream | aiostream/stream/create.py | repeat | def repeat(value, times=None, *, interval=0):
"""Generate the same value a given number of times.
If ``times`` is ``None``, the value is repeated indefinitely.
An optional interval can be given to space the values out.
"""
args = () if times is None else (times,)
it = itertools.repeat(value, *a... | python | def repeat(value, times=None, *, interval=0):
"""Generate the same value a given number of times.
If ``times`` is ``None``, the value is repeated indefinitely.
An optional interval can be given to space the values out.
"""
args = () if times is None else (times,)
it = itertools.repeat(value, *a... | [
"def",
"repeat",
"(",
"value",
",",
"times",
"=",
"None",
",",
"*",
",",
"interval",
"=",
"0",
")",
":",
"args",
"=",
"(",
")",
"if",
"times",
"is",
"None",
"else",
"(",
"times",
",",
")",
"it",
"=",
"itertools",
".",
"repeat",
"(",
"value",
",... | Generate the same value a given number of times.
If ``times`` is ``None``, the value is repeated indefinitely.
An optional interval can be given to space the values out. | [
"Generate",
"the",
"same",
"value",
"a",
"given",
"number",
"of",
"times",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/create.py#L96-L105 |
vxgmichel/aiostream | aiostream/stream/create.py | range | def range(*args, interval=0):
"""Generate a given range of numbers.
It supports the same arguments as the builtin function.
An optional interval can be given to space the values out.
"""
agen = from_iterable.raw(builtins.range(*args))
return time.spaceout.raw(agen, interval) if interval else ag... | python | def range(*args, interval=0):
"""Generate a given range of numbers.
It supports the same arguments as the builtin function.
An optional interval can be given to space the values out.
"""
agen = from_iterable.raw(builtins.range(*args))
return time.spaceout.raw(agen, interval) if interval else ag... | [
"def",
"range",
"(",
"*",
"args",
",",
"interval",
"=",
"0",
")",
":",
"agen",
"=",
"from_iterable",
".",
"raw",
"(",
"builtins",
".",
"range",
"(",
"*",
"args",
")",
")",
"return",
"time",
".",
"spaceout",
".",
"raw",
"(",
"agen",
",",
"interval",... | Generate a given range of numbers.
It supports the same arguments as the builtin function.
An optional interval can be given to space the values out. | [
"Generate",
"a",
"given",
"range",
"of",
"numbers",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/create.py#L111-L118 |
vxgmichel/aiostream | aiostream/stream/create.py | count | def count(start=0, step=1, *, interval=0):
"""Generate consecutive numbers indefinitely.
Optional starting point and increment can be defined,
respectively defaulting to ``0`` and ``1``.
An optional interval can be given to space the values out.
"""
agen = from_iterable.raw(itertools.count(sta... | python | def count(start=0, step=1, *, interval=0):
"""Generate consecutive numbers indefinitely.
Optional starting point and increment can be defined,
respectively defaulting to ``0`` and ``1``.
An optional interval can be given to space the values out.
"""
agen = from_iterable.raw(itertools.count(sta... | [
"def",
"count",
"(",
"start",
"=",
"0",
",",
"step",
"=",
"1",
",",
"*",
",",
"interval",
"=",
"0",
")",
":",
"agen",
"=",
"from_iterable",
".",
"raw",
"(",
"itertools",
".",
"count",
"(",
"start",
",",
"step",
")",
")",
"return",
"time",
".",
... | Generate consecutive numbers indefinitely.
Optional starting point and increment can be defined,
respectively defaulting to ``0`` and ``1``.
An optional interval can be given to space the values out. | [
"Generate",
"consecutive",
"numbers",
"indefinitely",
"."
] | train | https://github.com/vxgmichel/aiostream/blob/43bdf04ab19108a3f1b5a472062e1392a26cbcf8/aiostream/stream/create.py#L122-L131 |
edwardslabs/cleverwrap.py | cleverwrap/cleverwrap.py | CleverWrap.say | def say(self, text):
"""
Say something to www.cleverbot.com
:type text: string
Returns: string
"""
params = {
"input": text,
"key": self.key,
"cs": self.cs,
"conversation_id": self.convo_id,
"wrapper": "CleverW... | python | def say(self, text):
"""
Say something to www.cleverbot.com
:type text: string
Returns: string
"""
params = {
"input": text,
"key": self.key,
"cs": self.cs,
"conversation_id": self.convo_id,
"wrapper": "CleverW... | [
"def",
"say",
"(",
"self",
",",
"text",
")",
":",
"params",
"=",
"{",
"\"input\"",
":",
"text",
",",
"\"key\"",
":",
"self",
".",
"key",
",",
"\"cs\"",
":",
"self",
".",
"cs",
",",
"\"conversation_id\"",
":",
"self",
".",
"convo_id",
",",
"\"wrapper\... | Say something to www.cleverbot.com
:type text: string
Returns: string | [
"Say",
"something",
"to",
"www",
".",
"cleverbot",
".",
"com",
":",
"type",
"text",
":",
"string",
"Returns",
":",
"string"
] | train | https://github.com/edwardslabs/cleverwrap.py/blob/0c1e8279fe0f780fcf1ca1270cfb477c28c39e27/cleverwrap/cleverwrap.py#L45-L62 |
edwardslabs/cleverwrap.py | cleverwrap/cleverwrap.py | CleverWrap._send | def _send(self, params):
"""
Make the request to www.cleverbot.com
:type params: dict
Returns: dict
"""
# Get a response
try:
r = requests.get(self.url, params=params)
# catch errors, print then exit.
except requests.exceptions.RequestE... | python | def _send(self, params):
"""
Make the request to www.cleverbot.com
:type params: dict
Returns: dict
"""
# Get a response
try:
r = requests.get(self.url, params=params)
# catch errors, print then exit.
except requests.exceptions.RequestE... | [
"def",
"_send",
"(",
"self",
",",
"params",
")",
":",
"# Get a response",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"url",
",",
"params",
"=",
"params",
")",
"# catch errors, print then exit.",
"except",
"requests",
".",
"exceptions",
... | Make the request to www.cleverbot.com
:type params: dict
Returns: dict | [
"Make",
"the",
"request",
"to",
"www",
".",
"cleverbot",
".",
"com",
":",
"type",
"params",
":",
"dict",
"Returns",
":",
"dict"
] | train | https://github.com/edwardslabs/cleverwrap.py/blob/0c1e8279fe0f780fcf1ca1270cfb477c28c39e27/cleverwrap/cleverwrap.py#L65-L77 |
edwardslabs/cleverwrap.py | cleverwrap/cleverwrap.py | CleverWrap._process_reply | def _process_reply(self, reply):
""" take the cleverbot.com response and populate properties. """
self.cs = reply.get("cs", None)
self.count = int(reply.get("interaction_count", None))
self.output = reply.get("output", None)
self.convo_id = reply.get("conversation_id", None)
... | python | def _process_reply(self, reply):
""" take the cleverbot.com response and populate properties. """
self.cs = reply.get("cs", None)
self.count = int(reply.get("interaction_count", None))
self.output = reply.get("output", None)
self.convo_id = reply.get("conversation_id", None)
... | [
"def",
"_process_reply",
"(",
"self",
",",
"reply",
")",
":",
"self",
".",
"cs",
"=",
"reply",
".",
"get",
"(",
"\"cs\"",
",",
"None",
")",
"self",
".",
"count",
"=",
"int",
"(",
"reply",
".",
"get",
"(",
"\"interaction_count\"",
",",
"None",
")",
... | take the cleverbot.com response and populate properties. | [
"take",
"the",
"cleverbot",
".",
"com",
"response",
"and",
"populate",
"properties",
"."
] | train | https://github.com/edwardslabs/cleverwrap.py/blob/0c1e8279fe0f780fcf1ca1270cfb477c28c39e27/cleverwrap/cleverwrap.py#L80-L88 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/tracers.py | Tracer.end | def end(self):
'''Ends the tracer.
May be called in any state. Transitions the state to ended and releases
any SDK resources owned by this tracer (this includes only internal
resources, things like passed-in
:class:`oneagent.common.DbInfoHandle` need to be released manually).
... | python | def end(self):
'''Ends the tracer.
May be called in any state. Transitions the state to ended and releases
any SDK resources owned by this tracer (this includes only internal
resources, things like passed-in
:class:`oneagent.common.DbInfoHandle` need to be released manually).
... | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"self",
".",
"nsdk",
".",
"tracer_end",
"(",
"self",
".",
"handle",
")",
"self",
".",
"handle",
"=",
"None"
] | Ends the tracer.
May be called in any state. Transitions the state to ended and releases
any SDK resources owned by this tracer (this includes only internal
resources, things like passed-in
:class:`oneagent.common.DbInfoHandle` need to be released manually).
Prefer using the tr... | [
"Ends",
"the",
"tracer",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/tracers.py#L113-L126 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/tracers.py | Tracer.mark_failed | def mark_failed(self, clsname, msg):
'''Marks the tracer as failed with the given exception class name
:code:`clsname` and message :code:`msg`.
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this does not end the tracer! Once a
... | python | def mark_failed(self, clsname, msg):
'''Marks the tracer as failed with the given exception class name
:code:`clsname` and message :code:`msg`.
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this does not end the tracer! Once a
... | [
"def",
"mark_failed",
"(",
"self",
",",
"clsname",
",",
"msg",
")",
":",
"self",
".",
"nsdk",
".",
"tracer_error",
"(",
"self",
".",
"handle",
",",
"clsname",
",",
"msg",
")"
] | Marks the tracer as failed with the given exception class name
:code:`clsname` and message :code:`msg`.
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this does not end the tracer! Once a
tracer is marked as failed, attempts to ... | [
"Marks",
"the",
"tracer",
"as",
"failed",
"with",
"the",
"given",
"exception",
"class",
"name",
":",
"code",
":",
"clsname",
"and",
"message",
":",
"code",
":",
"msg",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/tracers.py#L128-L144 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/tracers.py | Tracer.mark_failed_exc | def mark_failed_exc(self, e_val=None, e_ty=None):
'''Marks the tracer as failed with the given exception :code:`e_val` of
type :code:`e_ty` (defaults to the current exception).
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this... | python | def mark_failed_exc(self, e_val=None, e_ty=None):
'''Marks the tracer as failed with the given exception :code:`e_val` of
type :code:`e_ty` (defaults to the current exception).
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this... | [
"def",
"mark_failed_exc",
"(",
"self",
",",
"e_val",
"=",
"None",
",",
"e_ty",
"=",
"None",
")",
":",
"_error_from_exc",
"(",
"self",
".",
"nsdk",
",",
"self",
".",
"handle",
",",
"e_val",
",",
"e_ty",
")"
] | Marks the tracer as failed with the given exception :code:`e_val` of
type :code:`e_ty` (defaults to the current exception).
May only be called in the started state and only if the tracer is not
already marked as failed. Note that this does not end the tracer! Once a
tracer is marked as ... | [
"Marks",
"the",
"tracer",
"as",
"failed",
"with",
"the",
"given",
"exception",
":",
"code",
":",
"e_val",
"of",
"type",
":",
"code",
":",
"e_ty",
"(",
"defaults",
"to",
"the",
"current",
"exception",
")",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/tracers.py#L146-L168 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | _get_kvc | def _get_kvc(kv_arg):
'''Returns a tuple keys, values, count for kv_arg (which can be a dict or a
tuple containing keys, values and optinally count.'''
if isinstance(kv_arg, Mapping):
return six.iterkeys(kv_arg), six.itervalues(kv_arg), len(kv_arg)
assert 2 <= len(kv_arg) <= 3, \
'Ar... | python | def _get_kvc(kv_arg):
'''Returns a tuple keys, values, count for kv_arg (which can be a dict or a
tuple containing keys, values and optinally count.'''
if isinstance(kv_arg, Mapping):
return six.iterkeys(kv_arg), six.itervalues(kv_arg), len(kv_arg)
assert 2 <= len(kv_arg) <= 3, \
'Ar... | [
"def",
"_get_kvc",
"(",
"kv_arg",
")",
":",
"if",
"isinstance",
"(",
"kv_arg",
",",
"Mapping",
")",
":",
"return",
"six",
".",
"iterkeys",
"(",
"kv_arg",
")",
",",
"six",
".",
"itervalues",
"(",
"kv_arg",
")",
",",
"len",
"(",
"kv_arg",
")",
"assert"... | Returns a tuple keys, values, count for kv_arg (which can be a dict or a
tuple containing keys, values and optinally count. | [
"Returns",
"a",
"tuple",
"keys",
"values",
"count",
"for",
"kv_arg",
"(",
"which",
"can",
"be",
"a",
"dict",
"or",
"a",
"tuple",
"containing",
"keys",
"values",
"and",
"optinally",
"count",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L57-L67 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.create_database_info | def create_database_info(
self,
name,
vendor,
channel):
'''Creates a database info with the given information for use with
:meth:`trace_sql_database_request`.
:param str name: The name (e.g., connection string) of the database.
:param str ... | python | def create_database_info(
self,
name,
vendor,
channel):
'''Creates a database info with the given information for use with
:meth:`trace_sql_database_request`.
:param str name: The name (e.g., connection string) of the database.
:param str ... | [
"def",
"create_database_info",
"(",
"self",
",",
"name",
",",
"vendor",
",",
"channel",
")",
":",
"return",
"DbInfoHandle",
"(",
"self",
".",
"_nsdk",
",",
"self",
".",
"_nsdk",
".",
"databaseinfo_create",
"(",
"name",
",",
"vendor",
",",
"channel",
".",
... | Creates a database info with the given information for use with
:meth:`trace_sql_database_request`.
:param str name: The name (e.g., connection string) of the database.
:param str vendor: The type of the database (e.g., sqlite, PostgreSQL,
MySQL).
:param Channel channel: The... | [
"Creates",
"a",
"database",
"info",
"with",
"the",
"given",
"information",
"for",
"use",
"with",
":",
"meth",
":",
"trace_sql_database_request",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L91-L108 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.create_web_application_info | def create_web_application_info(
self, virtual_host, application_id, context_root):
'''Creates a web application info for use with
:meth:`trace_incoming_web_request`.
See
<https://www.dynatrace.com/support/help/server-side-services/introduction/how-does-dynatrace-detect-and-... | python | def create_web_application_info(
self, virtual_host, application_id, context_root):
'''Creates a web application info for use with
:meth:`trace_incoming_web_request`.
See
<https://www.dynatrace.com/support/help/server-side-services/introduction/how-does-dynatrace-detect-and-... | [
"def",
"create_web_application_info",
"(",
"self",
",",
"virtual_host",
",",
"application_id",
",",
"context_root",
")",
":",
"return",
"WebapplicationInfoHandle",
"(",
"self",
".",
"_nsdk",
",",
"self",
".",
"_nsdk",
".",
"webapplicationinfo_create",
"(",
"virtual_... | Creates a web application info for use with
:meth:`trace_incoming_web_request`.
See
<https://www.dynatrace.com/support/help/server-side-services/introduction/how-does-dynatrace-detect-and-name-services/#web-request-services>
for more information about the meaning of the parameters.
... | [
"Creates",
"a",
"web",
"application",
"info",
"for",
"use",
"with",
":",
"meth",
":",
"trace_incoming_web_request",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L110-L133 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_sql_database_request | def trace_sql_database_request(self, database, sql):
'''Create a tracer for the given database info and SQL statement.
:param DbInfoHandle database: Database information (see
:meth:`create_database_info`).
:param str sql: The SQL statement to trace.
:rtype: tracers.DatabaseR... | python | def trace_sql_database_request(self, database, sql):
'''Create a tracer for the given database info and SQL statement.
:param DbInfoHandle database: Database information (see
:meth:`create_database_info`).
:param str sql: The SQL statement to trace.
:rtype: tracers.DatabaseR... | [
"def",
"trace_sql_database_request",
"(",
"self",
",",
"database",
",",
"sql",
")",
":",
"assert",
"isinstance",
"(",
"database",
",",
"DbInfoHandle",
")",
"return",
"tracers",
".",
"DatabaseRequestTracer",
"(",
"self",
".",
"_nsdk",
",",
"self",
".",
"_nsdk",... | Create a tracer for the given database info and SQL statement.
:param DbInfoHandle database: Database information (see
:meth:`create_database_info`).
:param str sql: The SQL statement to trace.
:rtype: tracers.DatabaseRequestTracer | [
"Create",
"a",
"tracer",
"for",
"the",
"given",
"database",
"info",
"and",
"SQL",
"statement",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L136-L147 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_incoming_web_request | def trace_incoming_web_request(
self,
webapp_info,
url,
method,
headers=None,
remote_address=None,
str_tag=None,
byte_tag=None):
'''Create a tracer for an incoming webrequest.
:param WebapplicationInfoHandle... | python | def trace_incoming_web_request(
self,
webapp_info,
url,
method,
headers=None,
remote_address=None,
str_tag=None,
byte_tag=None):
'''Create a tracer for an incoming webrequest.
:param WebapplicationInfoHandle... | [
"def",
"trace_incoming_web_request",
"(",
"self",
",",
"webapp_info",
",",
"url",
",",
"method",
",",
"headers",
"=",
"None",
",",
"remote_address",
"=",
"None",
",",
"str_tag",
"=",
"None",
",",
"byte_tag",
"=",
"None",
")",
":",
"assert",
"isinstance",
"... | Create a tracer for an incoming webrequest.
:param WebapplicationInfoHandle webapp_info: Web application
information (see :meth:`create_web_application_info`).
:param str url: The requested URL (including scheme, hostname/port,
path and query).
:param str method: The HTT... | [
"Create",
"a",
"tracer",
"for",
"an",
"incoming",
"webrequest",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L149-L217 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_outgoing_web_request | def trace_outgoing_web_request(self, url, method, headers=None):
'''Create a tracer for an outgoing webrequest.
:param str url: The request URL (including scheme, hostname/port, path and query).
:param str method: The HTTP method of the request (e.g., GET or POST).
:param headers: The H... | python | def trace_outgoing_web_request(self, url, method, headers=None):
'''Create a tracer for an outgoing webrequest.
:param str url: The request URL (including scheme, hostname/port, path and query).
:param str method: The HTTP method of the request (e.g., GET or POST).
:param headers: The H... | [
"def",
"trace_outgoing_web_request",
"(",
"self",
",",
"url",
",",
"method",
",",
"headers",
"=",
"None",
")",
":",
"result",
"=",
"tracers",
".",
"OutgoingWebRequestTracer",
"(",
"self",
".",
"_nsdk",
",",
"self",
".",
"_nsdk",
".",
"outgoingwebrequesttracer_... | Create a tracer for an outgoing webrequest.
:param str url: The request URL (including scheme, hostname/port, path and query).
:param str method: The HTTP method of the request (e.g., GET or POST).
:param headers: The HTTP headers of the request. Can be either a
dictionary mapping h... | [
"Create",
"a",
"tracer",
"for",
"an",
"outgoing",
"webrequest",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L219-L264 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_outgoing_remote_call | def trace_outgoing_remote_call(
self,
method,
service,
endpoint,
channel,
protocol_name=None):
'''Creates a tracer for outgoing remote calls.
:param str method: The name of the service method/operation.
:param str service: ... | python | def trace_outgoing_remote_call(
self,
method,
service,
endpoint,
channel,
protocol_name=None):
'''Creates a tracer for outgoing remote calls.
:param str method: The name of the service method/operation.
:param str service: ... | [
"def",
"trace_outgoing_remote_call",
"(",
"self",
",",
"method",
",",
"service",
",",
"endpoint",
",",
"channel",
",",
"protocol_name",
"=",
"None",
")",
":",
"result",
"=",
"tracers",
".",
"OutgoingRemoteCallTracer",
"(",
"self",
".",
"_nsdk",
",",
"self",
... | Creates a tracer for outgoing remote calls.
:param str method: The name of the service method/operation.
:param str service: The name of the service class/type.
:param str endpoint: A string identifying the "instance" of the the
service. See also `the general documentation on servic... | [
"Creates",
"a",
"tracer",
"for",
"outgoing",
"remote",
"calls",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L266-L303 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_incoming_remote_call | def trace_incoming_remote_call(
self,
method,
name,
endpoint,
protocol_name=None,
str_tag=None,
byte_tag=None):
'''Creates a tracer for incoming remote calls.
For the parameters, see :ref:`tagging` (:code:`str_tag` and
... | python | def trace_incoming_remote_call(
self,
method,
name,
endpoint,
protocol_name=None,
str_tag=None,
byte_tag=None):
'''Creates a tracer for incoming remote calls.
For the parameters, see :ref:`tagging` (:code:`str_tag` and
... | [
"def",
"trace_incoming_remote_call",
"(",
"self",
",",
"method",
",",
"name",
",",
"endpoint",
",",
"protocol_name",
"=",
"None",
",",
"str_tag",
"=",
"None",
",",
"byte_tag",
"=",
"None",
")",
":",
"result",
"=",
"tracers",
".",
"IncomingRemoteCallTracer",
... | Creates a tracer for incoming remote calls.
For the parameters, see :ref:`tagging` (:code:`str_tag` and
:code:`byte_tag`) and :meth:`trace_outgoing_remote_call` (all others).
:rtype: tracers.IncomingRemoteCallTracer | [
"Creates",
"a",
"tracer",
"for",
"incoming",
"remote",
"calls",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L305-L327 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.trace_in_process_link | def trace_in_process_link(self, link_bytes):
'''Creates a tracer for tracing asynchronous related processing in the same process.
For more information see :meth:`create_in_process_link`.
:param bytes link_bytes: An in-process link created using :meth:`create_in_process_link`.
:rtype: ... | python | def trace_in_process_link(self, link_bytes):
'''Creates a tracer for tracing asynchronous related processing in the same process.
For more information see :meth:`create_in_process_link`.
:param bytes link_bytes: An in-process link created using :meth:`create_in_process_link`.
:rtype: ... | [
"def",
"trace_in_process_link",
"(",
"self",
",",
"link_bytes",
")",
":",
"return",
"tracers",
".",
"InProcessLinkTracer",
"(",
"self",
".",
"_nsdk",
",",
"self",
".",
"_nsdk",
".",
"trace_in_process_link",
"(",
"link_bytes",
")",
")"
] | Creates a tracer for tracing asynchronous related processing in the same process.
For more information see :meth:`create_in_process_link`.
:param bytes link_bytes: An in-process link created using :meth:`create_in_process_link`.
:rtype: tracers.InProcessLinkTracer
.. versionadded:: 1... | [
"Creates",
"a",
"tracer",
"for",
"tracing",
"asynchronous",
"related",
"processing",
"in",
"the",
"same",
"process",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L357-L369 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/sdk/__init__.py | SDK.add_custom_request_attribute | def add_custom_request_attribute(self, key, value):
'''Adds a custom request attribute to the current active tracer.
:param str key: The name of the custom request attribute, the name is mandatory and
may not be None.
:param value: The value of the custom request attribu... | python | def add_custom_request_attribute(self, key, value):
'''Adds a custom request attribute to the current active tracer.
:param str key: The name of the custom request attribute, the name is mandatory and
may not be None.
:param value: The value of the custom request attribu... | [
"def",
"add_custom_request_attribute",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"self",
".",
"_nsdk",
".",
"customrequestattribute_add_integer",
"(",
"key",
",",
"value",
")",
"elif",
"isinstanc... | Adds a custom request attribute to the current active tracer.
:param str key: The name of the custom request attribute, the name is mandatory and
may not be None.
:param value: The value of the custom request attribute. Currently supported types
are integer, floa... | [
"Adds",
"a",
"custom",
"request",
"attribute",
"to",
"the",
"current",
"active",
"tracer",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/sdk/__init__.py#L430-L453 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/common.py | SDKHandleBase.close | def close(self):
'''Closes the handle, if it is still open.
Usually, you should prefer using the handle as a context manager to
calling :meth:`close` manually.'''
if self.handle is not None:
self.close_handle(self.nsdk, self.handle)
self.handle = None | python | def close(self):
'''Closes the handle, if it is still open.
Usually, you should prefer using the handle as a context manager to
calling :meth:`close` manually.'''
if self.handle is not None:
self.close_handle(self.nsdk, self.handle)
self.handle = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
"is",
"not",
"None",
":",
"self",
".",
"close_handle",
"(",
"self",
".",
"nsdk",
",",
"self",
".",
"handle",
")",
"self",
".",
"handle",
"=",
"None"
] | Closes the handle, if it is still open.
Usually, you should prefer using the handle as a context manager to
calling :meth:`close` manually. | [
"Closes",
"the",
"handle",
"if",
"it",
"is",
"still",
"open",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/common.py#L285-L292 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/_impl/native/sdkmockiface.py | TracerHandle.all_original_children | def all_original_children(self):
'''Yields all (direct and indirect) children with LINK_CHILD.'''
return chain.from_iterable(
c.all_nodes_in_subtree()
for lnk, c in self.children
if lnk == self.LINK_CHILD) | python | def all_original_children(self):
'''Yields all (direct and indirect) children with LINK_CHILD.'''
return chain.from_iterable(
c.all_nodes_in_subtree()
for lnk, c in self.children
if lnk == self.LINK_CHILD) | [
"def",
"all_original_children",
"(",
"self",
")",
":",
"return",
"chain",
".",
"from_iterable",
"(",
"c",
".",
"all_nodes_in_subtree",
"(",
")",
"for",
"lnk",
",",
"c",
"in",
"self",
".",
"children",
"if",
"lnk",
"==",
"self",
".",
"LINK_CHILD",
")"
] | Yields all (direct and indirect) children with LINK_CHILD. | [
"Yields",
"all",
"(",
"direct",
"and",
"indirect",
")",
"children",
"with",
"LINK_CHILD",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/_impl/native/sdkmockiface.py#L99-L104 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/__init__.py | sdkopts_from_commandline | def sdkopts_from_commandline(argv=None, remove=False, prefix='--dt_'):
'''Creates a SDK option list for use with the :code:`sdkopts` parameter of
:func:`.initialize` from a list :code:`argv` of command line parameters.
An element in :code:`argv` is treated as an SDK option if starts with
:code:`prefix`... | python | def sdkopts_from_commandline(argv=None, remove=False, prefix='--dt_'):
'''Creates a SDK option list for use with the :code:`sdkopts` parameter of
:func:`.initialize` from a list :code:`argv` of command line parameters.
An element in :code:`argv` is treated as an SDK option if starts with
:code:`prefix`... | [
"def",
"sdkopts_from_commandline",
"(",
"argv",
"=",
"None",
",",
"remove",
"=",
"False",
",",
"prefix",
"=",
"'--dt_'",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"if",
"not",
"remove",
":",
"return",
"[",
"param",
"... | Creates a SDK option list for use with the :code:`sdkopts` parameter of
:func:`.initialize` from a list :code:`argv` of command line parameters.
An element in :code:`argv` is treated as an SDK option if starts with
:code:`prefix`. The return value of this function will then contain the
remainder of tha... | [
"Creates",
"a",
"SDK",
"option",
"list",
"for",
"use",
"with",
"the",
":",
"code",
":",
"sdkopts",
"parameter",
"of",
":",
"func",
":",
".",
"initialize",
"from",
"a",
"list",
":",
"code",
":",
"argv",
"of",
"command",
"line",
"parameters",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/__init__.py#L116-L152 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/__init__.py | initialize | def initialize(sdkopts=(), sdklibname=None):
'''Attempts to initialize the SDK with the specified options.
Even if initialization fails, a dummy SDK will be available so that SDK
functions can be called but will do nothing.
If you call this function multiple times, you must call :func:`shutdown`
j... | python | def initialize(sdkopts=(), sdklibname=None):
'''Attempts to initialize the SDK with the specified options.
Even if initialization fails, a dummy SDK will be available so that SDK
functions can be called but will do nothing.
If you call this function multiple times, you must call :func:`shutdown`
j... | [
"def",
"initialize",
"(",
"sdkopts",
"=",
"(",
")",
",",
"sdklibname",
"=",
"None",
")",
":",
"global",
"_sdk_ref_count",
"#pylint:disable=global-statement",
"global",
"_sdk_instance",
"#pylint:disable=global-statement",
"with",
"_sdk_ref_lk",
":",
"logger",
".",
"deb... | Attempts to initialize the SDK with the specified options.
Even if initialization fails, a dummy SDK will be available so that SDK
functions can be called but will do nothing.
If you call this function multiple times, you must call :func:`shutdown`
just as many times. The options from all but the firs... | [
"Attempts",
"to",
"initialize",
"the",
"SDK",
"with",
"the",
"specified",
"options",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/__init__.py#L172-L205 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/__init__.py | shutdown | def shutdown():
'''Shut down the SDK.
:returns: An exception object if an error occurred, a falsy value otherwise.
:rtype: Exception
'''
global _sdk_ref_count #pylint:disable=global-statement
global _sdk_instance #pylint:disable=global-statement
global _should_shutdown #pylint:disable=glob... | python | def shutdown():
'''Shut down the SDK.
:returns: An exception object if an error occurred, a falsy value otherwise.
:rtype: Exception
'''
global _sdk_ref_count #pylint:disable=global-statement
global _sdk_instance #pylint:disable=global-statement
global _should_shutdown #pylint:disable=glob... | [
"def",
"shutdown",
"(",
")",
":",
"global",
"_sdk_ref_count",
"#pylint:disable=global-statement",
"global",
"_sdk_instance",
"#pylint:disable=global-statement",
"global",
"_should_shutdown",
"#pylint:disable=global-statement",
"with",
"_sdk_ref_lk",
":",
"logger",
".",
"debug",... | Shut down the SDK.
:returns: An exception object if an error occurred, a falsy value otherwise.
:rtype: Exception | [
"Shut",
"down",
"the",
"SDK",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/__init__.py#L266-L305 |
Dynatrace/OneAgent-SDK-for-Python | src/oneagent/_impl/util.py | error_from_exc | def error_from_exc(nsdk, tracer_h, e_val=None, e_ty=None):
"""Attach appropriate error information to tracer_h.
If e_val and e_ty are None, the current exception is used."""
if not tracer_h:
return
if e_ty is None and e_val is None:
e_ty, e_val = sys.exc_info()[:2]
if e_ty is None... | python | def error_from_exc(nsdk, tracer_h, e_val=None, e_ty=None):
"""Attach appropriate error information to tracer_h.
If e_val and e_ty are None, the current exception is used."""
if not tracer_h:
return
if e_ty is None and e_val is None:
e_ty, e_val = sys.exc_info()[:2]
if e_ty is None... | [
"def",
"error_from_exc",
"(",
"nsdk",
",",
"tracer_h",
",",
"e_val",
"=",
"None",
",",
"e_ty",
"=",
"None",
")",
":",
"if",
"not",
"tracer_h",
":",
"return",
"if",
"e_ty",
"is",
"None",
"and",
"e_val",
"is",
"None",
":",
"e_ty",
",",
"e_val",
"=",
... | Attach appropriate error information to tracer_h.
If e_val and e_ty are None, the current exception is used. | [
"Attach",
"appropriate",
"error",
"information",
"to",
"tracer_h",
"."
] | train | https://github.com/Dynatrace/OneAgent-SDK-for-Python/blob/f7b121b492f25b1c5b27316798e1a70b6be2bd01/src/oneagent/_impl/util.py#L28-L40 |
pinax/pinax-waitinglist | pinax/waitinglist/templatetags/pinax_waitinglist_tags.py | waitinglist_entry_form | def waitinglist_entry_form(context):
"""
Get a (new) form object to post a new comment.
Syntax::
{% waitinglist_entry_form as [varname] %}
"""
initial = {}
if "request" in context:
initial.update({
"referrer": context["request"].META.get("HTTP_REFERER", ""),
... | python | def waitinglist_entry_form(context):
"""
Get a (new) form object to post a new comment.
Syntax::
{% waitinglist_entry_form as [varname] %}
"""
initial = {}
if "request" in context:
initial.update({
"referrer": context["request"].META.get("HTTP_REFERER", ""),
... | [
"def",
"waitinglist_entry_form",
"(",
"context",
")",
":",
"initial",
"=",
"{",
"}",
"if",
"\"request\"",
"in",
"context",
":",
"initial",
".",
"update",
"(",
"{",
"\"referrer\"",
":",
"context",
"[",
"\"request\"",
"]",
".",
"META",
".",
"get",
"(",
"\"... | Get a (new) form object to post a new comment.
Syntax::
{% waitinglist_entry_form as [varname] %} | [
"Get",
"a",
"(",
"new",
")",
"form",
"object",
"to",
"post",
"a",
"new",
"comment",
"."
] | train | https://github.com/pinax/pinax-waitinglist/blob/bcdd5228d352ce8c7e566f78903c6c3762b67855/pinax/waitinglist/templatetags/pinax_waitinglist_tags.py#L9-L24 |
10gen/mongo-orchestration | mongo_orchestration/process.py | _host | def _host():
"""Get the Host from the most recent HTTP request."""
host_and_port = request.urlparts[1]
try:
host, _ = host_and_port.split(':')
except ValueError:
# No port yet. Host defaults to '127.0.0.1' in bottle.request.
return DEFAULT_BIND
return host or DEFAULT_BIND | python | def _host():
"""Get the Host from the most recent HTTP request."""
host_and_port = request.urlparts[1]
try:
host, _ = host_and_port.split(':')
except ValueError:
# No port yet. Host defaults to '127.0.0.1' in bottle.request.
return DEFAULT_BIND
return host or DEFAULT_BIND | [
"def",
"_host",
"(",
")",
":",
"host_and_port",
"=",
"request",
".",
"urlparts",
"[",
"1",
"]",
"try",
":",
"host",
",",
"_",
"=",
"host_and_port",
".",
"split",
"(",
"':'",
")",
"except",
"ValueError",
":",
"# No port yet. Host defaults to '127.0.0.1' in bott... | Get the Host from the most recent HTTP request. | [
"Get",
"the",
"Host",
"from",
"the",
"most",
"recent",
"HTTP",
"request",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L45-L53 |
10gen/mongo-orchestration | mongo_orchestration/process.py | wait_for | def wait_for(port_num, timeout):
"""waits while process starts.
Args:
port_num - port number
timeout - specify how long, in seconds, a command can take before times out.
return True if process started, return False if not
"""
logger.debug("wait for {port_num}".format(**locals(... | python | def wait_for(port_num, timeout):
"""waits while process starts.
Args:
port_num - port number
timeout - specify how long, in seconds, a command can take before times out.
return True if process started, return False if not
"""
logger.debug("wait for {port_num}".format(**locals(... | [
"def",
"wait_for",
"(",
"port_num",
",",
"timeout",
")",
":",
"logger",
".",
"debug",
"(",
"\"wait for {port_num}\"",
".",
"format",
"(",
"*",
"*",
"locals",
"(",
")",
")",
")",
"t_start",
"=",
"time",
".",
"time",
"(",
")",
"sleeps",
"=",
"0.1",
"wh... | waits while process starts.
Args:
port_num - port number
timeout - specify how long, in seconds, a command can take before times out.
return True if process started, return False if not | [
"waits",
"while",
"process",
"starts",
".",
"Args",
":",
"port_num",
"-",
"port",
"number",
"timeout",
"-",
"specify",
"how",
"long",
"in",
"seconds",
"a",
"command",
"can",
"take",
"before",
"times",
"out",
".",
"return",
"True",
"if",
"process",
"started... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L138-L158 |
10gen/mongo-orchestration | mongo_orchestration/process.py | repair_mongo | def repair_mongo(name, dbpath):
"""repair mongodb after usafe shutdown"""
log_file = os.path.join(dbpath, 'mongod.log')
cmd = [name, "--dbpath", dbpath, "--logpath", log_file, "--logappend",
"--repair"]
proc = subprocess.Popen(
cmd, universal_newlines=True,
stdout=subprocess.P... | python | def repair_mongo(name, dbpath):
"""repair mongodb after usafe shutdown"""
log_file = os.path.join(dbpath, 'mongod.log')
cmd = [name, "--dbpath", dbpath, "--logpath", log_file, "--logappend",
"--repair"]
proc = subprocess.Popen(
cmd, universal_newlines=True,
stdout=subprocess.P... | [
"def",
"repair_mongo",
"(",
"name",
",",
"dbpath",
")",
":",
"log_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dbpath",
",",
"'mongod.log'",
")",
"cmd",
"=",
"[",
"name",
",",
"\"--dbpath\"",
",",
"dbpath",
",",
"\"--logpath\"",
",",
"log_file",
"... | repair mongodb after usafe shutdown | [
"repair",
"mongodb",
"after",
"usafe",
"shutdown"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L161-L184 |
10gen/mongo-orchestration | mongo_orchestration/process.py | mprocess | def mprocess(name, config_path, port=None, timeout=180, silence_stdout=True):
"""start 'name' process with params from config_path.
Args:
name - process name or path
config_path - path to file where should be stored configuration
port - process's port
timeout - specify how long, ... | python | def mprocess(name, config_path, port=None, timeout=180, silence_stdout=True):
"""start 'name' process with params from config_path.
Args:
name - process name or path
config_path - path to file where should be stored configuration
port - process's port
timeout - specify how long, ... | [
"def",
"mprocess",
"(",
"name",
",",
"config_path",
",",
"port",
"=",
"None",
",",
"timeout",
"=",
"180",
",",
"silence_stdout",
"=",
"True",
")",
":",
"logger",
".",
"debug",
"(",
"\"mprocess(name={name!r}, config_path={config_path!r}, port={port!r}, \"",
"\"timeou... | start 'name' process with params from config_path.
Args:
name - process name or path
config_path - path to file where should be stored configuration
port - process's port
timeout - specify how long, in seconds, a command can take before times out.
if timeout <=0 - d... | [
"start",
"name",
"process",
"with",
"params",
"from",
"config_path",
".",
"Args",
":",
"name",
"-",
"process",
"name",
"or",
"path",
"config_path",
"-",
"path",
"to",
"file",
"where",
"should",
"be",
"stored",
"configuration",
"port",
"-",
"process",
"s",
... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L187-L237 |
10gen/mongo-orchestration | mongo_orchestration/process.py | wait_mprocess | def wait_mprocess(process, timeout):
"""Compatibility function for waiting on a process with a timeout.
Raises TimeoutError when the timeout is reached.
"""
if PY3:
try:
return process.wait(timeout=timeout)
except subprocess.TimeoutExpired as exc:
raise TimeoutEr... | python | def wait_mprocess(process, timeout):
"""Compatibility function for waiting on a process with a timeout.
Raises TimeoutError when the timeout is reached.
"""
if PY3:
try:
return process.wait(timeout=timeout)
except subprocess.TimeoutExpired as exc:
raise TimeoutEr... | [
"def",
"wait_mprocess",
"(",
"process",
",",
"timeout",
")",
":",
"if",
"PY3",
":",
"try",
":",
"return",
"process",
".",
"wait",
"(",
"timeout",
"=",
"timeout",
")",
"except",
"subprocess",
".",
"TimeoutExpired",
"as",
"exc",
":",
"raise",
"TimeoutError",... | Compatibility function for waiting on a process with a timeout.
Raises TimeoutError when the timeout is reached. | [
"Compatibility",
"function",
"for",
"waiting",
"on",
"a",
"process",
"with",
"a",
"timeout",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L240-L260 |
10gen/mongo-orchestration | mongo_orchestration/process.py | kill_mprocess | def kill_mprocess(process):
"""kill process
Args:
process - Popen object for process
"""
if process and proc_alive(process):
process.terminate()
process.communicate()
return not proc_alive(process) | python | def kill_mprocess(process):
"""kill process
Args:
process - Popen object for process
"""
if process and proc_alive(process):
process.terminate()
process.communicate()
return not proc_alive(process) | [
"def",
"kill_mprocess",
"(",
"process",
")",
":",
"if",
"process",
"and",
"proc_alive",
"(",
"process",
")",
":",
"process",
".",
"terminate",
"(",
")",
"process",
".",
"communicate",
"(",
")",
"return",
"not",
"proc_alive",
"(",
"process",
")"
] | kill process
Args:
process - Popen object for process | [
"kill",
"process",
"Args",
":",
"process",
"-",
"Popen",
"object",
"for",
"process"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L263-L271 |
10gen/mongo-orchestration | mongo_orchestration/process.py | cleanup_mprocess | def cleanup_mprocess(config_path, cfg):
"""remove all process's stuff
Args:
config_path - process's options file
cfg - process's config
"""
for key in ('keyFile', 'logPath', 'dbpath'):
remove_path(cfg.get(key, None))
isinstance(config_path, str) and os.path.exists(config_path) ... | python | def cleanup_mprocess(config_path, cfg):
"""remove all process's stuff
Args:
config_path - process's options file
cfg - process's config
"""
for key in ('keyFile', 'logPath', 'dbpath'):
remove_path(cfg.get(key, None))
isinstance(config_path, str) and os.path.exists(config_path) ... | [
"def",
"cleanup_mprocess",
"(",
"config_path",
",",
"cfg",
")",
":",
"for",
"key",
"in",
"(",
"'keyFile'",
",",
"'logPath'",
",",
"'dbpath'",
")",
":",
"remove_path",
"(",
"cfg",
".",
"get",
"(",
"key",
",",
"None",
")",
")",
"isinstance",
"(",
"config... | remove all process's stuff
Args:
config_path - process's options file
cfg - process's config | [
"remove",
"all",
"process",
"s",
"stuff",
"Args",
":",
"config_path",
"-",
"process",
"s",
"options",
"file",
"cfg",
"-",
"process",
"s",
"config"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L274-L282 |
10gen/mongo-orchestration | mongo_orchestration/process.py | remove_path | def remove_path(path):
"""remove path from file system
If path is None - do nothing"""
if path is None or not os.path.exists(path):
return
if platform.system() == 'Windows':
# Need to have write permission before deleting the file.
os.chmod(path, stat.S_IWRITE)
try:
i... | python | def remove_path(path):
"""remove path from file system
If path is None - do nothing"""
if path is None or not os.path.exists(path):
return
if platform.system() == 'Windows':
# Need to have write permission before deleting the file.
os.chmod(path, stat.S_IWRITE)
try:
i... | [
"def",
"remove_path",
"(",
"path",
")",
":",
"if",
"path",
"is",
"None",
"or",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Windows'",
":",
"# Need to have write permission b... | remove path from file system
If path is None - do nothing | [
"remove",
"path",
"from",
"file",
"system",
"If",
"path",
"is",
"None",
"-",
"do",
"nothing"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L285-L299 |
10gen/mongo-orchestration | mongo_orchestration/process.py | write_config | def write_config(params, config_path=None):
"""write mongo*'s config file
Args:
params - options wich file contains
config_path - path to the config_file, will create if None
Return config_path
where config_path - path to mongo*'s options file
"""
if config_path is None:
... | python | def write_config(params, config_path=None):
"""write mongo*'s config file
Args:
params - options wich file contains
config_path - path to the config_file, will create if None
Return config_path
where config_path - path to mongo*'s options file
"""
if config_path is None:
... | [
"def",
"write_config",
"(",
"params",
",",
"config_path",
"=",
"None",
")",
":",
"if",
"config_path",
"is",
"None",
":",
"config_path",
"=",
"tempfile",
".",
"mktemp",
"(",
"prefix",
"=",
"\"mongo-\"",
")",
"cfg",
"=",
"params",
".",
"copy",
"(",
")",
... | write mongo*'s config file
Args:
params - options wich file contains
config_path - path to the config_file, will create if None
Return config_path
where config_path - path to mongo*'s options file | [
"write",
"mongo",
"*",
"s",
"config",
"file",
"Args",
":",
"params",
"-",
"options",
"wich",
"file",
"contains",
"config_path",
"-",
"path",
"to",
"the",
"config_file",
"will",
"create",
"if",
"None",
"Return",
"config_path",
"where",
"config_path",
"-",
"pa... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L302-L333 |
10gen/mongo-orchestration | mongo_orchestration/process.py | read_config | def read_config(config_path):
"""read config_path and return options as dictionary"""
result = {}
with open(config_path, 'r') as fd:
for line in fd.readlines():
if '=' in line:
key, value = line.split('=', 1)
try:
result[key] = json.loa... | python | def read_config(config_path):
"""read config_path and return options as dictionary"""
result = {}
with open(config_path, 'r') as fd:
for line in fd.readlines():
if '=' in line:
key, value = line.split('=', 1)
try:
result[key] = json.loa... | [
"def",
"read_config",
"(",
"config_path",
")",
":",
"result",
"=",
"{",
"}",
"with",
"open",
"(",
"config_path",
",",
"'r'",
")",
"as",
"fd",
":",
"for",
"line",
"in",
"fd",
".",
"readlines",
"(",
")",
":",
"if",
"'='",
"in",
"line",
":",
"key",
... | read config_path and return options as dictionary | [
"read",
"config_path",
"and",
"return",
"options",
"as",
"dictionary"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L336-L347 |
10gen/mongo-orchestration | mongo_orchestration/process.py | PortPool.__check_port | def __check_port(self, port):
"""check port status
return True if port is free, False else
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((_host(), port))
return True
except socket.error:
return False
fina... | python | def __check_port(self, port):
"""check port status
return True if port is free, False else
"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.bind((_host(), port))
return True
except socket.error:
return False
fina... | [
"def",
"__check_port",
"(",
"self",
",",
"port",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"try",
":",
"s",
".",
"bind",
"(",
"(",
"_host",
"(",
")",
",",
"port",
")",
")",... | check port status
return True if port is free, False else | [
"check",
"port",
"status",
"return",
"True",
"if",
"port",
"is",
"free",
"False",
"else"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L81-L92 |
10gen/mongo-orchestration | mongo_orchestration/process.py | PortPool.release_port | def release_port(self, port):
"""release port"""
if port in self.__closed:
self.__closed.remove(port)
self.__ports.add(port) | python | def release_port(self, port):
"""release port"""
if port in self.__closed:
self.__closed.remove(port)
self.__ports.add(port) | [
"def",
"release_port",
"(",
"self",
",",
"port",
")",
":",
"if",
"port",
"in",
"self",
".",
"__closed",
":",
"self",
".",
"__closed",
".",
"remove",
"(",
"port",
")",
"self",
".",
"__ports",
".",
"add",
"(",
"port",
")"
] | release port | [
"release",
"port"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L94-L98 |
10gen/mongo-orchestration | mongo_orchestration/process.py | PortPool.port | def port(self, check=False):
"""return next opened port
Args:
check - check is port realy free
"""
if not self.__ports: # refresh ports if sequence is empty
self.refresh()
try:
port = self.__ports.pop()
if check:
whi... | python | def port(self, check=False):
"""return next opened port
Args:
check - check is port realy free
"""
if not self.__ports: # refresh ports if sequence is empty
self.refresh()
try:
port = self.__ports.pop()
if check:
whi... | [
"def",
"port",
"(",
"self",
",",
"check",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"__ports",
":",
"# refresh ports if sequence is empty",
"self",
".",
"refresh",
"(",
")",
"try",
":",
"port",
"=",
"self",
".",
"__ports",
".",
"pop",
"(",
")",... | return next opened port
Args:
check - check is port realy free | [
"return",
"next",
"opened",
"port",
"Args",
":",
"check",
"-",
"check",
"is",
"port",
"realy",
"free"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L100-L117 |
10gen/mongo-orchestration | mongo_orchestration/process.py | PortPool.refresh | def refresh(self, only_closed=False):
"""refresh ports status
Args:
only_closed - check status only for closed ports
"""
if only_closed:
opened = filter(self.__check_port, self.__closed)
self.__closed = self.__closed.difference(opened)
self._... | python | def refresh(self, only_closed=False):
"""refresh ports status
Args:
only_closed - check status only for closed ports
"""
if only_closed:
opened = filter(self.__check_port, self.__closed)
self.__closed = self.__closed.difference(opened)
self._... | [
"def",
"refresh",
"(",
"self",
",",
"only_closed",
"=",
"False",
")",
":",
"if",
"only_closed",
":",
"opened",
"=",
"filter",
"(",
"self",
".",
"__check_port",
",",
"self",
".",
"__closed",
")",
"self",
".",
"__closed",
"=",
"self",
".",
"__closed",
".... | refresh ports status
Args:
only_closed - check status only for closed ports | [
"refresh",
"ports",
"status",
"Args",
":",
"only_closed",
"-",
"check",
"status",
"only",
"for",
"closed",
"ports"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L119-L131 |
10gen/mongo-orchestration | mongo_orchestration/process.py | PortPool.change_range | def change_range(self, min_port=1025, max_port=2000, port_sequence=None):
"""change Pool port range"""
self.__init_range(min_port, max_port, port_sequence) | python | def change_range(self, min_port=1025, max_port=2000, port_sequence=None):
"""change Pool port range"""
self.__init_range(min_port, max_port, port_sequence) | [
"def",
"change_range",
"(",
"self",
",",
"min_port",
"=",
"1025",
",",
"max_port",
"=",
"2000",
",",
"port_sequence",
"=",
"None",
")",
":",
"self",
".",
"__init_range",
"(",
"min_port",
",",
"max_port",
",",
"port_sequence",
")"
] | change Pool port range | [
"change",
"Pool",
"port",
"range"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/process.py#L133-L135 |
10gen/mongo-orchestration | mongo_orchestration/apps/__init__.py | setup_versioned_routes | def setup_versioned_routes(routes, version=None):
"""Set up routes with a version prefix."""
prefix = '/' + version if version else ""
for r in routes:
path, method = r
route(prefix + path, method, routes[r]) | python | def setup_versioned_routes(routes, version=None):
"""Set up routes with a version prefix."""
prefix = '/' + version if version else ""
for r in routes:
path, method = r
route(prefix + path, method, routes[r]) | [
"def",
"setup_versioned_routes",
"(",
"routes",
",",
"version",
"=",
"None",
")",
":",
"prefix",
"=",
"'/'",
"+",
"version",
"if",
"version",
"else",
"\"\"",
"for",
"r",
"in",
"routes",
":",
"path",
",",
"method",
"=",
"r",
"route",
"(",
"prefix",
"+",... | Set up routes with a version prefix. | [
"Set",
"up",
"routes",
"with",
"a",
"version",
"prefix",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/apps/__init__.py#L39-L44 |
10gen/mongo-orchestration | mongo_orchestration/daemon.py | Daemon.daemonize_posix | def daemonize_posix(self):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
logger.info('daemonize_posix')
try:
pid =... | python | def daemonize_posix(self):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
logger.info('daemonize_posix')
try:
pid =... | [
"def",
"daemonize_posix",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'daemonize_posix'",
")",
"try",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
">",
"0",
":",
"logger",
".",
"debug",
"(",
"'forked first child, pid = %d'",
"%",
... | do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 | [
"do",
"the",
"UNIX",
"double",
"-",
"fork",
"magic",
"see",
"Stevens",
"Advanced",
"Programming",
"in",
"the",
"UNIX",
"Environment",
"for",
"details",
"(",
"ISBN",
"0201563177",
")",
"http",
":",
"//",
"www",
".",
"erlenstar",
".",
"demon",
".",
"co",
"... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/daemon.py#L70-L119 |
10gen/mongo-orchestration | mongo_orchestration/daemon.py | Daemon.start | def start(self):
"""
Start the daemon
"""
# Check for a pidfile to see if the daemon already runs
logger.info('Starting daemon')
try:
with open(self.pidfile, 'r') as fd:
pid = int(fd.read().strip())
except IOError:
pid = Non... | python | def start(self):
"""
Start the daemon
"""
# Check for a pidfile to see if the daemon already runs
logger.info('Starting daemon')
try:
with open(self.pidfile, 'r') as fd:
pid = int(fd.read().strip())
except IOError:
pid = Non... | [
"def",
"start",
"(",
"self",
")",
":",
"# Check for a pidfile to see if the daemon already runs",
"logger",
".",
"info",
"(",
"'Starting daemon'",
")",
"try",
":",
"with",
"open",
"(",
"self",
".",
"pidfile",
",",
"'r'",
")",
"as",
"fd",
":",
"pid",
"=",
"in... | Start the daemon | [
"Start",
"the",
"daemon"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/daemon.py#L125-L146 |
10gen/mongo-orchestration | mongo_orchestration/daemon.py | Daemon.stop | def stop(self):
"""
Stop the daemon
"""
# Get the pid from the pidfile
logger.debug("reading %s" % (self.pidfile,))
try:
with open(self.pidfile, 'r') as fd:
pid = int(fd.read().strip())
except IOError:
logger.exception("read... | python | def stop(self):
"""
Stop the daemon
"""
# Get the pid from the pidfile
logger.debug("reading %s" % (self.pidfile,))
try:
with open(self.pidfile, 'r') as fd:
pid = int(fd.read().strip())
except IOError:
logger.exception("read... | [
"def",
"stop",
"(",
"self",
")",
":",
"# Get the pid from the pidfile",
"logger",
".",
"debug",
"(",
"\"reading %s\"",
"%",
"(",
"self",
".",
"pidfile",
",",
")",
")",
"try",
":",
"with",
"open",
"(",
"self",
".",
"pidfile",
",",
"'r'",
")",
"as",
"fd"... | Stop the daemon | [
"Stop",
"the",
"daemon"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/daemon.py#L148-L181 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.cleanup | def cleanup(self):
"""remove all members without reconfig"""
for item in self.server_map:
self.member_del(item, reconfig=False)
self.server_map.clear() | python | def cleanup(self):
"""remove all members without reconfig"""
for item in self.server_map:
self.member_del(item, reconfig=False)
self.server_map.clear() | [
"def",
"cleanup",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
".",
"server_map",
":",
"self",
".",
"member_del",
"(",
"item",
",",
"reconfig",
"=",
"False",
")",
"self",
".",
"server_map",
".",
"clear",
"(",
")"
] | remove all members without reconfig | [
"remove",
"all",
"members",
"without",
"reconfig"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L154-L158 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.host2id | def host2id(self, hostname):
"""return member id by hostname"""
for key, value in self.server_map.items():
if value == hostname:
return key | python | def host2id(self, hostname):
"""return member id by hostname"""
for key, value in self.server_map.items():
if value == hostname:
return key | [
"def",
"host2id",
"(",
"self",
",",
"hostname",
")",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"server_map",
".",
"items",
"(",
")",
":",
"if",
"value",
"==",
"hostname",
":",
"return",
"key"
] | return member id by hostname | [
"return",
"member",
"id",
"by",
"hostname"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L164-L168 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.update_server_map | def update_server_map(self, config):
"""update server_map ({member_id:hostname})"""
self.server_map = dict([(member['_id'], member['host']) for member in config['members']]) | python | def update_server_map(self, config):
"""update server_map ({member_id:hostname})"""
self.server_map = dict([(member['_id'], member['host']) for member in config['members']]) | [
"def",
"update_server_map",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"server_map",
"=",
"dict",
"(",
"[",
"(",
"member",
"[",
"'_id'",
"]",
",",
"member",
"[",
"'host'",
"]",
")",
"for",
"member",
"in",
"config",
"[",
"'members'",
"]",
"]",... | update server_map ({member_id:hostname}) | [
"update",
"server_map",
"(",
"{",
"member_id",
":",
"hostname",
"}",
")"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L170-L172 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.repl_init | def repl_init(self, config):
"""create replica set by config
return True if replica set created successfuly, else False"""
self.update_server_map(config)
# init_server - server which can init replica set
init_server = [member['host'] for member in config['members']
... | python | def repl_init(self, config):
"""create replica set by config
return True if replica set created successfuly, else False"""
self.update_server_map(config)
# init_server - server which can init replica set
init_server = [member['host'] for member in config['members']
... | [
"def",
"repl_init",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"update_server_map",
"(",
"config",
")",
"# init_server - server which can init replica set",
"init_server",
"=",
"[",
"member",
"[",
"'host'",
"]",
"for",
"member",
"in",
"config",
"[",
"'me... | create replica set by config
return True if replica set created successfuly, else False | [
"create",
"replica",
"set",
"by",
"config",
"return",
"True",
"if",
"replica",
"set",
"created",
"successfuly",
"else",
"False"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L174-L198 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.reset | def reset(self):
"""Ensure all members are running and available."""
# Need to use self.server_map, in case no Servers are left running.
for member_id in self.server_map:
host = self.member_id_to_host(member_id)
server_id = self._servers.host_to_server_id(host)
... | python | def reset(self):
"""Ensure all members are running and available."""
# Need to use self.server_map, in case no Servers are left running.
for member_id in self.server_map:
host = self.member_id_to_host(member_id)
server_id = self._servers.host_to_server_id(host)
... | [
"def",
"reset",
"(",
"self",
")",
":",
"# Need to use self.server_map, in case no Servers are left running.",
"for",
"member_id",
"in",
"self",
".",
"server_map",
":",
"host",
"=",
"self",
".",
"member_id_to_host",
"(",
"member_id",
")",
"server_id",
"=",
"self",
".... | Ensure all members are running and available. | [
"Ensure",
"all",
"members",
"are",
"running",
"and",
"available",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L200-L213 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.repl_update | def repl_update(self, config):
"""Reconfig Replicaset with new config"""
cfg = config.copy()
cfg['version'] += 1
try:
result = self.run_command("replSetReconfig", cfg)
if int(result.get('ok', 0)) != 1:
return False
except pymongo.errors.Aut... | python | def repl_update(self, config):
"""Reconfig Replicaset with new config"""
cfg = config.copy()
cfg['version'] += 1
try:
result = self.run_command("replSetReconfig", cfg)
if int(result.get('ok', 0)) != 1:
return False
except pymongo.errors.Aut... | [
"def",
"repl_update",
"(",
"self",
",",
"config",
")",
":",
"cfg",
"=",
"config",
".",
"copy",
"(",
")",
"cfg",
"[",
"'version'",
"]",
"+=",
"1",
"try",
":",
"result",
"=",
"self",
".",
"run_command",
"(",
"\"replSetReconfig\"",
",",
"cfg",
")",
"if"... | Reconfig Replicaset with new config | [
"Reconfig",
"Replicaset",
"with",
"new",
"config"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L215-L227 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.info | def info(self):
"""return information about replica set"""
hosts = ','.join(x['host'] for x in self.members())
mongodb_uri = 'mongodb://' + hosts + '/?replicaSet=' + self.repl_id
result = {"id": self.repl_id,
"auth_key": self.auth_key,
"members": self.... | python | def info(self):
"""return information about replica set"""
hosts = ','.join(x['host'] for x in self.members())
mongodb_uri = 'mongodb://' + hosts + '/?replicaSet=' + self.repl_id
result = {"id": self.repl_id,
"auth_key": self.auth_key,
"members": self.... | [
"def",
"info",
"(",
"self",
")",
":",
"hosts",
"=",
"','",
".",
"join",
"(",
"x",
"[",
"'host'",
"]",
"for",
"x",
"in",
"self",
".",
"members",
"(",
")",
")",
"mongodb_uri",
"=",
"'mongodb://'",
"+",
"hosts",
"+",
"'/?replicaSet='",
"+",
"self",
".... | return information about replica set | [
"return",
"information",
"about",
"replica",
"set"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L229-L243 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.repl_member_add | def repl_member_add(self, params):
"""create new mongod instances and add it to the replica set.
Args:
params - mongod params
return True if operation success otherwise False
"""
repl_config = self.config
member_id = max([member['_id'] for member in repl_confi... | python | def repl_member_add(self, params):
"""create new mongod instances and add it to the replica set.
Args:
params - mongod params
return True if operation success otherwise False
"""
repl_config = self.config
member_id = max([member['_id'] for member in repl_confi... | [
"def",
"repl_member_add",
"(",
"self",
",",
"params",
")",
":",
"repl_config",
"=",
"self",
".",
"config",
"member_id",
"=",
"max",
"(",
"[",
"member",
"[",
"'_id'",
"]",
"for",
"member",
"in",
"repl_config",
"[",
"'members'",
"]",
"]",
")",
"+",
"1",
... | create new mongod instances and add it to the replica set.
Args:
params - mongod params
return True if operation success otherwise False | [
"create",
"new",
"mongod",
"instances",
"and",
"add",
"it",
"to",
"the",
"replica",
"set",
".",
"Args",
":",
"params",
"-",
"mongod",
"params",
"return",
"True",
"if",
"operation",
"success",
"otherwise",
"False"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L245-L258 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.run_command | def run_command(self, command, arg=None, is_eval=False, member_id=None):
"""run command on replica set
if member_id is specified command will be execute on this server
if member_id is not specified command will be execute on the primary
Args:
command - command string
... | python | def run_command(self, command, arg=None, is_eval=False, member_id=None):
"""run command on replica set
if member_id is specified command will be execute on this server
if member_id is not specified command will be execute on the primary
Args:
command - command string
... | [
"def",
"run_command",
"(",
"self",
",",
"command",
",",
"arg",
"=",
"None",
",",
"is_eval",
"=",
"False",
",",
"member_id",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"\"run_command({command}, {arg}, {is_eval}, {member_id})\"",
".",
"format",
"(",
"*"... | run command on replica set
if member_id is specified command will be execute on this server
if member_id is not specified command will be execute on the primary
Args:
command - command string
arg - command argument
is_eval - if True execute command as eval
... | [
"run",
"command",
"on",
"replica",
"set",
"if",
"member_id",
"is",
"specified",
"command",
"will",
"be",
"execute",
"on",
"this",
"server",
"if",
"member_id",
"is",
"not",
"specified",
"command",
"will",
"be",
"execute",
"on",
"the",
"primary"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L260-L280 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.config | def config(self):
"""return replica set config, use rs.conf() command"""
try:
admin = self.connection().admin
config = admin.command('replSetGetConfig')['config']
except pymongo.errors.OperationFailure:
# replSetGetConfig was introduced in 2.7.5.
c... | python | def config(self):
"""return replica set config, use rs.conf() command"""
try:
admin = self.connection().admin
config = admin.command('replSetGetConfig')['config']
except pymongo.errors.OperationFailure:
# replSetGetConfig was introduced in 2.7.5.
c... | [
"def",
"config",
"(",
"self",
")",
":",
"try",
":",
"admin",
"=",
"self",
".",
"connection",
"(",
")",
".",
"admin",
"config",
"=",
"admin",
".",
"command",
"(",
"'replSetGetConfig'",
")",
"[",
"'config'",
"]",
"except",
"pymongo",
".",
"errors",
".",
... | return replica set config, use rs.conf() command | [
"return",
"replica",
"set",
"config",
"use",
"rs",
".",
"conf",
"()",
"command"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L283-L291 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.member_create | def member_create(self, params, member_id):
"""start new mongod instances as part of replica set
Args:
params - member params
member_id - member index
return member config
"""
member_config = params.get('rsParams', {})
server_id = params.pop('serv... | python | def member_create(self, params, member_id):
"""start new mongod instances as part of replica set
Args:
params - member params
member_id - member index
return member config
"""
member_config = params.get('rsParams', {})
server_id = params.pop('serv... | [
"def",
"member_create",
"(",
"self",
",",
"params",
",",
"member_id",
")",
":",
"member_config",
"=",
"params",
".",
"get",
"(",
"'rsParams'",
",",
"{",
"}",
")",
"server_id",
"=",
"params",
".",
"pop",
"(",
"'server_id'",
",",
"None",
")",
"version",
... | start new mongod instances as part of replica set
Args:
params - member params
member_id - member index
return member config | [
"start",
"new",
"mongod",
"instances",
"as",
"part",
"of",
"replica",
"set",
"Args",
":",
"params",
"-",
"member",
"params",
"member_id",
"-",
"member",
"index"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L293-L321 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.member_del | def member_del(self, member_id, reconfig=True):
"""remove member from replica set
Args:
member_id - member index
reconfig - is need reconfig replica
return True if operation success otherwise False
"""
server_id = self._servers.host_to_server_id(
... | python | def member_del(self, member_id, reconfig=True):
"""remove member from replica set
Args:
member_id - member index
reconfig - is need reconfig replica
return True if operation success otherwise False
"""
server_id = self._servers.host_to_server_id(
... | [
"def",
"member_del",
"(",
"self",
",",
"member_id",
",",
"reconfig",
"=",
"True",
")",
":",
"server_id",
"=",
"self",
".",
"_servers",
".",
"host_to_server_id",
"(",
"self",
".",
"member_id_to_host",
"(",
"member_id",
")",
")",
"if",
"reconfig",
"and",
"me... | remove member from replica set
Args:
member_id - member index
reconfig - is need reconfig replica
return True if operation success otherwise False | [
"remove",
"member",
"from",
"replica",
"set",
"Args",
":",
"member_id",
"-",
"member",
"index",
"reconfig",
"-",
"is",
"need",
"reconfig",
"replica"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L323-L338 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.member_update | def member_update(self, member_id, params):
"""update member's values with reconfig replica
Args:
member_id - member index
params - updates member params
return True if operation success otherwise False
"""
config = self.config
config['members'][m... | python | def member_update(self, member_id, params):
"""update member's values with reconfig replica
Args:
member_id - member index
params - updates member params
return True if operation success otherwise False
"""
config = self.config
config['members'][m... | [
"def",
"member_update",
"(",
"self",
",",
"member_id",
",",
"params",
")",
":",
"config",
"=",
"self",
".",
"config",
"config",
"[",
"'members'",
"]",
"[",
"member_id",
"]",
".",
"update",
"(",
"params",
".",
"get",
"(",
"\"rsParams\"",
",",
"{",
"}",
... | update member's values with reconfig replica
Args:
member_id - member index
params - updates member params
return True if operation success otherwise False | [
"update",
"member",
"s",
"values",
"with",
"reconfig",
"replica",
"Args",
":",
"member_id",
"-",
"member",
"index",
"params",
"-",
"updates",
"member",
"params"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L340-L350 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.member_info | def member_info(self, member_id):
"""return information about member"""
server_id = self._servers.host_to_server_id(
self.member_id_to_host(member_id))
server_info = self._servers.info(server_id)
result = {'_id': member_id, 'server_id': server_id,
'mongodb_u... | python | def member_info(self, member_id):
"""return information about member"""
server_id = self._servers.host_to_server_id(
self.member_id_to_host(member_id))
server_info = self._servers.info(server_id)
result = {'_id': member_id, 'server_id': server_id,
'mongodb_u... | [
"def",
"member_info",
"(",
"self",
",",
"member_id",
")",
":",
"server_id",
"=",
"self",
".",
"_servers",
".",
"host_to_server_id",
"(",
"self",
".",
"member_id_to_host",
"(",
"member_id",
")",
")",
"server_info",
"=",
"self",
".",
"_servers",
".",
"info",
... | return information about member | [
"return",
"information",
"about",
"member"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L352-L381 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.member_command | def member_command(self, member_id, command):
"""apply command (start/stop/restart) to member instance of replica set
Args:
member_id - member index
command - string command (start/stop/restart)
return True if operation success otherwise False
"""
server_... | python | def member_command(self, member_id, command):
"""apply command (start/stop/restart) to member instance of replica set
Args:
member_id - member index
command - string command (start/stop/restart)
return True if operation success otherwise False
"""
server_... | [
"def",
"member_command",
"(",
"self",
",",
"member_id",
",",
"command",
")",
":",
"server_id",
"=",
"self",
".",
"_servers",
".",
"host_to_server_id",
"(",
"self",
".",
"member_id_to_host",
"(",
"member_id",
")",
")",
"return",
"self",
".",
"_servers",
".",
... | apply command (start/stop/restart) to member instance of replica set
Args:
member_id - member index
command - string command (start/stop/restart)
return True if operation success otherwise False | [
"apply",
"command",
"(",
"start",
"/",
"stop",
"/",
"restart",
")",
"to",
"member",
"instance",
"of",
"replica",
"set",
"Args",
":",
"member_id",
"-",
"member",
"index",
"command",
"-",
"string",
"command",
"(",
"start",
"/",
"stop",
"/",
"restart",
")"
... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L383-L393 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.members | def members(self):
"""return list of members information"""
result = list()
for member in self.run_command(command="replSetGetStatus", is_eval=False)['members']:
result.append({
"_id": member['_id'],
"host": member["name"],
"server_id":... | python | def members(self):
"""return list of members information"""
result = list()
for member in self.run_command(command="replSetGetStatus", is_eval=False)['members']:
result.append({
"_id": member['_id'],
"host": member["name"],
"server_id":... | [
"def",
"members",
"(",
"self",
")",
":",
"result",
"=",
"list",
"(",
")",
"for",
"member",
"in",
"self",
".",
"run_command",
"(",
"command",
"=",
"\"replSetGetStatus\"",
",",
"is_eval",
"=",
"False",
")",
"[",
"'members'",
"]",
":",
"result",
".",
"app... | return list of members information | [
"return",
"list",
"of",
"members",
"information"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L395-L405 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.get_members_in_state | def get_members_in_state(self, state):
"""return all members of replica set in specific state"""
members = self.run_command(command='replSetGetStatus', is_eval=False)['members']
return [member['name'] for member in members if member['state'] == state] | python | def get_members_in_state(self, state):
"""return all members of replica set in specific state"""
members = self.run_command(command='replSetGetStatus', is_eval=False)['members']
return [member['name'] for member in members if member['state'] == state] | [
"def",
"get_members_in_state",
"(",
"self",
",",
"state",
")",
":",
"members",
"=",
"self",
".",
"run_command",
"(",
"command",
"=",
"'replSetGetStatus'",
",",
"is_eval",
"=",
"False",
")",
"[",
"'members'",
"]",
"return",
"[",
"member",
"[",
"'name'",
"]"... | return all members of replica set in specific state | [
"return",
"all",
"members",
"of",
"replica",
"set",
"in",
"specific",
"state"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L412-L415 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet._authenticate_client | def _authenticate_client(self, client):
"""Authenticate the client if necessary."""
if self.login and not self.restart_required:
try:
db = client[self.auth_source]
if self.x509_extra_user:
db.authenticate(
DEFAULT_SU... | python | def _authenticate_client(self, client):
"""Authenticate the client if necessary."""
if self.login and not self.restart_required:
try:
db = client[self.auth_source]
if self.x509_extra_user:
db.authenticate(
DEFAULT_SU... | [
"def",
"_authenticate_client",
"(",
"self",
",",
"client",
")",
":",
"if",
"self",
".",
"login",
"and",
"not",
"self",
".",
"restart_required",
":",
"try",
":",
"db",
"=",
"client",
"[",
"self",
".",
"auth_source",
"]",
"if",
"self",
".",
"x509_extra_use... | Authenticate the client if necessary. | [
"Authenticate",
"the",
"client",
"if",
"necessary",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L417-L434 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.connection | def connection(self, hostname=None, read_preference=pymongo.ReadPreference.PRIMARY, timeout=300):
"""return MongoReplicaSetClient object if hostname specified
return MongoClient object if hostname doesn't specified
Args:
hostname - connection uri
read_preference - default... | python | def connection(self, hostname=None, read_preference=pymongo.ReadPreference.PRIMARY, timeout=300):
"""return MongoReplicaSetClient object if hostname specified
return MongoClient object if hostname doesn't specified
Args:
hostname - connection uri
read_preference - default... | [
"def",
"connection",
"(",
"self",
",",
"hostname",
"=",
"None",
",",
"read_preference",
"=",
"pymongo",
".",
"ReadPreference",
".",
"PRIMARY",
",",
"timeout",
"=",
"300",
")",
":",
"logger",
".",
"debug",
"(",
"\"connection({hostname}, {read_preference}, {timeout}... | return MongoReplicaSetClient object if hostname specified
return MongoClient object if hostname doesn't specified
Args:
hostname - connection uri
read_preference - default PRIMARY
timeout - specify how long, in seconds, a command can take before server times out. | [
"return",
"MongoReplicaSetClient",
"object",
"if",
"hostname",
"specified",
"return",
"MongoClient",
"object",
"if",
"hostname",
"doesn",
"t",
"specified",
"Args",
":",
"hostname",
"-",
"connection",
"uri",
"read_preference",
"-",
"default",
"PRIMARY",
"timeout",
"-... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L436-L475 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.secondaries | def secondaries(self):
"""return list of secondaries members"""
return [
{
"_id": self.host2id(member),
"host": member,
"server_id": self._servers.host_to_server_id(member)
}
for member in self.get_members_in_state(2)
... | python | def secondaries(self):
"""return list of secondaries members"""
return [
{
"_id": self.host2id(member),
"host": member,
"server_id": self._servers.host_to_server_id(member)
}
for member in self.get_members_in_state(2)
... | [
"def",
"secondaries",
"(",
"self",
")",
":",
"return",
"[",
"{",
"\"_id\"",
":",
"self",
".",
"host2id",
"(",
"member",
")",
",",
"\"host\"",
":",
"member",
",",
"\"server_id\"",
":",
"self",
".",
"_servers",
".",
"host_to_server_id",
"(",
"member",
")",... | return list of secondaries members | [
"return",
"list",
"of",
"secondaries",
"members"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L477-L486 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.arbiters | def arbiters(self):
"""return list of arbiters"""
return [
{
"_id": self.host2id(member),
"host": member,
"server_id": self._servers.host_to_server_id(member)
}
for member in self.get_members_in_state(7)
] | python | def arbiters(self):
"""return list of arbiters"""
return [
{
"_id": self.host2id(member),
"host": member,
"server_id": self._servers.host_to_server_id(member)
}
for member in self.get_members_in_state(7)
] | [
"def",
"arbiters",
"(",
"self",
")",
":",
"return",
"[",
"{",
"\"_id\"",
":",
"self",
".",
"host2id",
"(",
"member",
")",
",",
"\"host\"",
":",
"member",
",",
"\"server_id\"",
":",
"self",
".",
"_servers",
".",
"host_to_server_id",
"(",
"member",
")",
... | return list of arbiters | [
"return",
"list",
"of",
"arbiters"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L488-L497 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.hidden | def hidden(self):
"""return list of hidden members"""
members = [self.member_info(item["_id"]) for item in self.members()]
result = []
for member in members:
if member['rsInfo'].get('hidden'):
server_id = member['server_id']
result.append({
... | python | def hidden(self):
"""return list of hidden members"""
members = [self.member_info(item["_id"]) for item in self.members()]
result = []
for member in members:
if member['rsInfo'].get('hidden'):
server_id = member['server_id']
result.append({
... | [
"def",
"hidden",
"(",
"self",
")",
":",
"members",
"=",
"[",
"self",
".",
"member_info",
"(",
"item",
"[",
"\"_id\"",
"]",
")",
"for",
"item",
"in",
"self",
".",
"members",
"(",
")",
"]",
"result",
"=",
"[",
"]",
"for",
"member",
"in",
"members",
... | return list of hidden members | [
"return",
"list",
"of",
"hidden",
"members"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L499-L510 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.passives | def passives(self):
"""return list of passive servers"""
servers = self.run_command('ismaster').get('passives', [])
return [member for member in self.members() if member['host'] in servers] | python | def passives(self):
"""return list of passive servers"""
servers = self.run_command('ismaster').get('passives', [])
return [member for member in self.members() if member['host'] in servers] | [
"def",
"passives",
"(",
"self",
")",
":",
"servers",
"=",
"self",
".",
"run_command",
"(",
"'ismaster'",
")",
".",
"get",
"(",
"'passives'",
",",
"[",
"]",
")",
"return",
"[",
"member",
"for",
"member",
"in",
"self",
".",
"members",
"(",
")",
"if",
... | return list of passive servers | [
"return",
"list",
"of",
"passive",
"servers"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L512-L515 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.wait_while_reachable | def wait_while_reachable(self, servers, timeout=60):
"""wait while all servers be reachable
Args:
servers - list of servers
"""
t_start = time.time()
while True:
try:
for server in servers:
# TODO: use state code to chec... | python | def wait_while_reachable(self, servers, timeout=60):
"""wait while all servers be reachable
Args:
servers - list of servers
"""
t_start = time.time()
while True:
try:
for server in servers:
# TODO: use state code to chec... | [
"def",
"wait_while_reachable",
"(",
"self",
",",
"servers",
",",
"timeout",
"=",
"60",
")",
":",
"t_start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"try",
":",
"for",
"server",
"in",
"servers",
":",
"# TODO: use state code to check if serve... | wait while all servers be reachable
Args:
servers - list of servers | [
"wait",
"while",
"all",
"servers",
"be",
"reachable",
"Args",
":",
"servers",
"-",
"list",
"of",
"servers"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L522-L541 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.waiting_member_state | def waiting_member_state(self, timeout=300):
"""Wait for all RS members to be in an acceptable state."""
t_start = time.time()
while not self.check_member_state():
if time.time() - t_start > timeout:
return False
time.sleep(0.1)
return True | python | def waiting_member_state(self, timeout=300):
"""Wait for all RS members to be in an acceptable state."""
t_start = time.time()
while not self.check_member_state():
if time.time() - t_start > timeout:
return False
time.sleep(0.1)
return True | [
"def",
"waiting_member_state",
"(",
"self",
",",
"timeout",
"=",
"300",
")",
":",
"t_start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"check_member_state",
"(",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"t_start",
">... | Wait for all RS members to be in an acceptable state. | [
"Wait",
"for",
"all",
"RS",
"members",
"to",
"be",
"in",
"an",
"acceptable",
"state",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L543-L550 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.waiting_config_state | def waiting_config_state(self, timeout=300):
"""waiting while real state equal config state
Args:
timeout - specify how long, in seconds, a command can take before server times out.
return True if operation success otherwise False
"""
t_start = time.time()
wh... | python | def waiting_config_state(self, timeout=300):
"""waiting while real state equal config state
Args:
timeout - specify how long, in seconds, a command can take before server times out.
return True if operation success otherwise False
"""
t_start = time.time()
wh... | [
"def",
"waiting_config_state",
"(",
"self",
",",
"timeout",
"=",
"300",
")",
":",
"t_start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"not",
"self",
".",
"check_config_state",
"(",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"t_start",
">... | waiting while real state equal config state
Args:
timeout - specify how long, in seconds, a command can take before server times out.
return True if operation success otherwise False | [
"waiting",
"while",
"real",
"state",
"equal",
"config",
"state",
"Args",
":",
"timeout",
"-",
"specify",
"how",
"long",
"in",
"seconds",
"a",
"command",
"can",
"take",
"before",
"server",
"times",
"out",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L552-L564 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.check_member_state | def check_member_state(self):
"""Verify that all RS members have an acceptable state."""
bad_states = (0, 3, 4, 5, 6, 9)
try:
rs_status = self.run_command('replSetGetStatus')
bad_members = [member for member in rs_status['members']
if member['st... | python | def check_member_state(self):
"""Verify that all RS members have an acceptable state."""
bad_states = (0, 3, 4, 5, 6, 9)
try:
rs_status = self.run_command('replSetGetStatus')
bad_members = [member for member in rs_status['members']
if member['st... | [
"def",
"check_member_state",
"(",
"self",
")",
":",
"bad_states",
"=",
"(",
"0",
",",
"3",
",",
"4",
",",
"5",
",",
"6",
",",
"9",
")",
"try",
":",
"rs_status",
"=",
"self",
".",
"run_command",
"(",
"'replSetGetStatus'",
")",
"bad_members",
"=",
"[",... | Verify that all RS members have an acceptable state. | [
"Verify",
"that",
"all",
"RS",
"members",
"have",
"an",
"acceptable",
"state",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L566-L579 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.check_config_state | def check_config_state(self):
"""Return True if real state equal config state otherwise False."""
config = self.config
self.update_server_map(config)
for member in config['members']:
cfg_member_info = self.default_params.copy()
cfg_member_info.update(member)
... | python | def check_config_state(self):
"""Return True if real state equal config state otherwise False."""
config = self.config
self.update_server_map(config)
for member in config['members']:
cfg_member_info = self.default_params.copy()
cfg_member_info.update(member)
... | [
"def",
"check_config_state",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"config",
"self",
".",
"update_server_map",
"(",
"config",
")",
"for",
"member",
"in",
"config",
"[",
"'members'",
"]",
":",
"cfg_member_info",
"=",
"self",
".",
"default_params"... | Return True if real state equal config state otherwise False. | [
"Return",
"True",
"if",
"real",
"state",
"equal",
"config",
"state",
"otherwise",
"False",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L581-L604 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSet.restart | def restart(self, timeout=300, config_callback=None):
"""Restart each member of the replica set."""
for member_id in self.server_map:
host = self.server_map[member_id]
server_id = self._servers.host_to_server_id(host)
server = self._servers._storage[server_id]
... | python | def restart(self, timeout=300, config_callback=None):
"""Restart each member of the replica set."""
for member_id in self.server_map:
host = self.server_map[member_id]
server_id = self._servers.host_to_server_id(host)
server = self._servers._storage[server_id]
... | [
"def",
"restart",
"(",
"self",
",",
"timeout",
"=",
"300",
",",
"config_callback",
"=",
"None",
")",
":",
"for",
"member_id",
"in",
"self",
".",
"server_map",
":",
"host",
"=",
"self",
".",
"server_map",
"[",
"member_id",
"]",
"server_id",
"=",
"self",
... | Restart each member of the replica set. | [
"Restart",
"each",
"member",
"of",
"the",
"replica",
"set",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L606-L613 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.set_settings | def set_settings(self, releases=None, default_release=None):
"""set path to storage"""
super(ReplicaSets, self).set_settings(releases, default_release)
Servers().set_settings(releases, default_release) | python | def set_settings(self, releases=None, default_release=None):
"""set path to storage"""
super(ReplicaSets, self).set_settings(releases, default_release)
Servers().set_settings(releases, default_release) | [
"def",
"set_settings",
"(",
"self",
",",
"releases",
"=",
"None",
",",
"default_release",
"=",
"None",
")",
":",
"super",
"(",
"ReplicaSets",
",",
"self",
")",
".",
"set_settings",
"(",
"releases",
",",
"default_release",
")",
"Servers",
"(",
")",
".",
"... | set path to storage | [
"set",
"path",
"to",
"storage"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L623-L626 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.create | def create(self, rs_params):
"""create new replica set
Args:
rs_params - replica set configuration
Return repl_id which can use to take the replica set
"""
repl_id = rs_params.get('id', None)
if repl_id is not None and repl_id in self:
raise Replica... | python | def create(self, rs_params):
"""create new replica set
Args:
rs_params - replica set configuration
Return repl_id which can use to take the replica set
"""
repl_id = rs_params.get('id', None)
if repl_id is not None and repl_id in self:
raise Replica... | [
"def",
"create",
"(",
"self",
",",
"rs_params",
")",
":",
"repl_id",
"=",
"rs_params",
".",
"get",
"(",
"'id'",
",",
"None",
")",
"if",
"repl_id",
"is",
"not",
"None",
"and",
"repl_id",
"in",
"self",
":",
"raise",
"ReplicaSetError",
"(",
"\"replica set w... | create new replica set
Args:
rs_params - replica set configuration
Return repl_id which can use to take the replica set | [
"create",
"new",
"replica",
"set",
"Args",
":",
"rs_params",
"-",
"replica",
"set",
"configuration",
"Return",
"repl_id",
"which",
"can",
"use",
"to",
"take",
"the",
"replica",
"set"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L633-L645 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.primary | def primary(self, repl_id):
"""find and return primary hostname
Args:
repl_id - replica set identity
"""
repl = self[repl_id]
primary = repl.primary()
return repl.member_info(repl.host2id(primary)) | python | def primary(self, repl_id):
"""find and return primary hostname
Args:
repl_id - replica set identity
"""
repl = self[repl_id]
primary = repl.primary()
return repl.member_info(repl.host2id(primary)) | [
"def",
"primary",
"(",
"self",
",",
"repl_id",
")",
":",
"repl",
"=",
"self",
"[",
"repl_id",
"]",
"primary",
"=",
"repl",
".",
"primary",
"(",
")",
"return",
"repl",
".",
"member_info",
"(",
"repl",
".",
"host2id",
"(",
"primary",
")",
")"
] | find and return primary hostname
Args:
repl_id - replica set identity | [
"find",
"and",
"return",
"primary",
"hostname",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L654-L661 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.remove | def remove(self, repl_id):
"""remove replica set with kill members
Args:
repl_id - replica set identity
return True if operation success otherwise False
"""
repl = self._storage.pop(repl_id)
repl.cleanup()
del(repl) | python | def remove(self, repl_id):
"""remove replica set with kill members
Args:
repl_id - replica set identity
return True if operation success otherwise False
"""
repl = self._storage.pop(repl_id)
repl.cleanup()
del(repl) | [
"def",
"remove",
"(",
"self",
",",
"repl_id",
")",
":",
"repl",
"=",
"self",
".",
"_storage",
".",
"pop",
"(",
"repl_id",
")",
"repl",
".",
"cleanup",
"(",
")",
"del",
"(",
"repl",
")"
] | remove replica set with kill members
Args:
repl_id - replica set identity
return True if operation success otherwise False | [
"remove",
"replica",
"set",
"with",
"kill",
"members",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity",
"return",
"True",
"if",
"operation",
"success",
"otherwise",
"False"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L663-L671 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.command | def command(self, rs_id, command, *args):
"""Call a ReplicaSet method."""
rs = self._storage[rs_id]
try:
return getattr(rs, command)(*args)
except AttributeError:
raise ValueError("Cannot issue the command %r to ReplicaSet %s"
% (comma... | python | def command(self, rs_id, command, *args):
"""Call a ReplicaSet method."""
rs = self._storage[rs_id]
try:
return getattr(rs, command)(*args)
except AttributeError:
raise ValueError("Cannot issue the command %r to ReplicaSet %s"
% (comma... | [
"def",
"command",
"(",
"self",
",",
"rs_id",
",",
"command",
",",
"*",
"args",
")",
":",
"rs",
"=",
"self",
".",
"_storage",
"[",
"rs_id",
"]",
"try",
":",
"return",
"getattr",
"(",
"rs",
",",
"command",
")",
"(",
"*",
"args",
")",
"except",
"Att... | Call a ReplicaSet method. | [
"Call",
"a",
"ReplicaSet",
"method",
"."
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L708-L715 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.member_del | def member_del(self, repl_id, member_id):
"""remove member from replica set (reconfig replica)
Args:
repl_id - replica set identity
member_id - member index
"""
repl = self[repl_id]
result = repl.member_del(member_id)
self[repl_id] = repl
r... | python | def member_del(self, repl_id, member_id):
"""remove member from replica set (reconfig replica)
Args:
repl_id - replica set identity
member_id - member index
"""
repl = self[repl_id]
result = repl.member_del(member_id)
self[repl_id] = repl
r... | [
"def",
"member_del",
"(",
"self",
",",
"repl_id",
",",
"member_id",
")",
":",
"repl",
"=",
"self",
"[",
"repl_id",
"]",
"result",
"=",
"repl",
".",
"member_del",
"(",
"member_id",
")",
"self",
"[",
"repl_id",
"]",
"=",
"repl",
"return",
"result"
] | remove member from replica set (reconfig replica)
Args:
repl_id - replica set identity
member_id - member index | [
"remove",
"member",
"from",
"replica",
"set",
"(",
"reconfig",
"replica",
")",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity",
"member_id",
"-",
"member",
"index"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L717-L726 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.member_add | def member_add(self, repl_id, params):
"""create instance and add it to existing replcia
Args:
repl_id - replica set identity
params - member params
return True if operation success otherwise False
"""
repl = self[repl_id]
member_id = repl.repl_me... | python | def member_add(self, repl_id, params):
"""create instance and add it to existing replcia
Args:
repl_id - replica set identity
params - member params
return True if operation success otherwise False
"""
repl = self[repl_id]
member_id = repl.repl_me... | [
"def",
"member_add",
"(",
"self",
",",
"repl_id",
",",
"params",
")",
":",
"repl",
"=",
"self",
"[",
"repl_id",
"]",
"member_id",
"=",
"repl",
".",
"repl_member_add",
"(",
"params",
")",
"self",
"[",
"repl_id",
"]",
"=",
"repl",
"return",
"member_id"
] | create instance and add it to existing replcia
Args:
repl_id - replica set identity
params - member params
return True if operation success otherwise False | [
"create",
"instance",
"and",
"add",
"it",
"to",
"existing",
"replcia",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity",
"params",
"-",
"member",
"params"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L728-L739 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.member_command | def member_command(self, repl_id, member_id, command):
"""apply command(start, stop, restart) to the member of replica set
Args:
repl_id - replica set identity
member_id - member index
command - command: start, stop, restart
return True if operation success o... | python | def member_command(self, repl_id, member_id, command):
"""apply command(start, stop, restart) to the member of replica set
Args:
repl_id - replica set identity
member_id - member index
command - command: start, stop, restart
return True if operation success o... | [
"def",
"member_command",
"(",
"self",
",",
"repl_id",
",",
"member_id",
",",
"command",
")",
":",
"repl",
"=",
"self",
"[",
"repl_id",
"]",
"result",
"=",
"repl",
".",
"member_command",
"(",
"member_id",
",",
"command",
")",
"self",
"[",
"repl_id",
"]",
... | apply command(start, stop, restart) to the member of replica set
Args:
repl_id - replica set identity
member_id - member index
command - command: start, stop, restart
return True if operation success otherwise False | [
"apply",
"command",
"(",
"start",
"stop",
"restart",
")",
"to",
"the",
"member",
"of",
"replica",
"set",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity",
"member_id",
"-",
"member",
"index",
"command",
"-",
"command",
":",
"start",
"stop",
"resta... | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L741-L753 |
10gen/mongo-orchestration | mongo_orchestration/replica_sets.py | ReplicaSets.member_update | def member_update(self, repl_id, member_id, params):
"""apply new params to replica set member
Args:
repl_id - replica set identity
member_id - member index
params - new member's params
return True if operation success otherwise False
"""
repl... | python | def member_update(self, repl_id, member_id, params):
"""apply new params to replica set member
Args:
repl_id - replica set identity
member_id - member index
params - new member's params
return True if operation success otherwise False
"""
repl... | [
"def",
"member_update",
"(",
"self",
",",
"repl_id",
",",
"member_id",
",",
"params",
")",
":",
"repl",
"=",
"self",
"[",
"repl_id",
"]",
"result",
"=",
"repl",
".",
"member_update",
"(",
"member_id",
",",
"params",
")",
"self",
"[",
"repl_id",
"]",
"=... | apply new params to replica set member
Args:
repl_id - replica set identity
member_id - member index
params - new member's params
return True if operation success otherwise False | [
"apply",
"new",
"params",
"to",
"replica",
"set",
"member",
"Args",
":",
"repl_id",
"-",
"replica",
"set",
"identity",
"member_id",
"-",
"member",
"index",
"params",
"-",
"new",
"member",
"s",
"params"
] | train | https://github.com/10gen/mongo-orchestration/blob/81fd2224205922ea2178b08190b53a33aec47261/mongo_orchestration/replica_sets.py#L755-L767 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.