repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
dcos/shakedown
shakedown/dcos/task.py
wait_for_task
def wait_for_task(service, task, timeout_sec=120): """Waits for a task which was launched to be launched""" return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
python
def wait_for_task(service, task, timeout_sec=120): """Waits for a task which was launched to be launched""" return time_wait(lambda: task_predicate(service, task), timeout_seconds=timeout_sec)
[ "def", "wait_for_task", "(", "service", ",", "task", ",", "timeout_sec", "=", "120", ")", ":", "return", "time_wait", "(", "lambda", ":", "task_predicate", "(", "service", ",", "task", ")", ",", "timeout_seconds", "=", "timeout_sec", ")" ]
Waits for a task which was launched to be launched
[ "Waits", "for", "a", "task", "which", "was", "launched", "to", "be", "launched" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L118-L120
train
dcos/shakedown
shakedown/dcos/task.py
wait_for_task_property
def wait_for_task_property(service, task, prop, timeout_sec=120): """Waits for a task to have the specified property""" return time_wait(lambda: task_property_present_predicate(service, task, prop), timeout_seconds=timeout_sec)
python
def wait_for_task_property(service, task, prop, timeout_sec=120): """Waits for a task to have the specified property""" return time_wait(lambda: task_property_present_predicate(service, task, prop), timeout_seconds=timeout_sec)
[ "def", "wait_for_task_property", "(", "service", ",", "task", ",", "prop", ",", "timeout_sec", "=", "120", ")", ":", "return", "time_wait", "(", "lambda", ":", "task_property_present_predicate", "(", "service", ",", "task", ",", "prop", ")", ",", "timeout_seco...
Waits for a task to have the specified property
[ "Waits", "for", "a", "task", "to", "have", "the", "specified", "property" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L123-L125
train
dcos/shakedown
shakedown/dcos/file.py
copy_file
def copy_file( host, file_path, remote_path='.', username=None, key_path=None, action='put' ): """ Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param fi...
python
def copy_file( host, file_path, remote_path='.', username=None, key_path=None, action='put' ): """ Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param fi...
[ "def", "copy_file", "(", "host", ",", "file_path", ",", "remote_path", "=", "'.'", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "action", "=", "'put'", ")", ":", "if", "not", "username", ":", "username", "=", "shakedown", ".", "cli"...
Copy a file via SCP, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param file_path: the local path to the file to be copied :type file_path: str :param remote_path: the remote path to copy the file to :...
[ "Copy", "a", "file", "via", "SCP", "proxied", "through", "the", "mesos", "master" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/file.py#L10-L66
train
dcos/shakedown
shakedown/dcos/cluster.py
__metadata_helper
def __metadata_helper(json_path): """ Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None """ url = shakedown.dcos_url_path('dcos-metadata/{}'.format(json_path)) try: ...
python
def __metadata_helper(json_path): """ Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None """ url = shakedown.dcos_url_path('dcos-metadata/{}'.format(json_path)) try: ...
[ "def", "__metadata_helper", "(", "json_path", ")", ":", "url", "=", "shakedown", ".", "dcos_url_path", "(", "'dcos-metadata/{}'", ".", "format", "(", "json_path", ")", ")", "try", ":", "response", "=", "dcos", ".", "http", ".", "request", "(", "'get'", ","...
Returns json for specific cluster metadata. Important to realize that this was introduced in dcos-1.9. Clusters prior to 1.9 and missing metadata will return None
[ "Returns", "json", "for", "specific", "cluster", "metadata", ".", "Important", "to", "realize", "that", "this", "was", "introduced", "in", "dcos", "-", "1", ".", "9", ".", "Clusters", "prior", "to", "1", ".", "9", "and", "missing", "metadata", "will", "r...
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/cluster.py#L93-L107
train
openstax/cnx-easybake
cnxeasybake/oven.py
log_decl_method
def log_decl_method(func): """Decorate do_declartion methods for debug logging.""" from functools import wraps @wraps(func) def with_logging(*args, **kwargs): self = args[0] decl = args[2] log(DEBUG, u" {}: {} {}".format( self.state['current_step'], decl.name, ...
python
def log_decl_method(func): """Decorate do_declartion methods for debug logging.""" from functools import wraps @wraps(func) def with_logging(*args, **kwargs): self = args[0] decl = args[2] log(DEBUG, u" {}: {} {}".format( self.state['current_step'], decl.name, ...
[ "def", "log_decl_method", "(", "func", ")", ":", "from", "functools", "import", "wraps", "@", "wraps", "(", "func", ")", "def", "with_logging", "(", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "decl", "=", "args", ...
Decorate do_declartion methods for debug logging.
[ "Decorate", "do_declartion", "methods", "for", "debug", "logging", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L59-L71
train
openstax/cnx-easybake
cnxeasybake/oven.py
css_to_func
def css_to_func(css, flags, css_namespaces, lang): """Convert a css selector to an xpath, supporting pseudo elements.""" from cssselect import parse, HTMLTranslator from cssselect.parser import FunctionalPseudoElement # FIXME HACK need lessc to support functional-pseudo-selectors instead # of mark...
python
def css_to_func(css, flags, css_namespaces, lang): """Convert a css selector to an xpath, supporting pseudo elements.""" from cssselect import parse, HTMLTranslator from cssselect.parser import FunctionalPseudoElement # FIXME HACK need lessc to support functional-pseudo-selectors instead # of mark...
[ "def", "css_to_func", "(", "css", ",", "flags", ",", "css_namespaces", ",", "lang", ")", ":", "from", "cssselect", "import", "parse", ",", "HTMLTranslator", "from", "cssselect", ".", "parser", "import", "FunctionalPseudoElement", "if", "not", "(", "css", ")", ...
Convert a css selector to an xpath, supporting pseudo elements.
[ "Convert", "a", "css", "selector", "to", "an", "xpath", "supporting", "pseudo", "elements", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1335-L1387
train
openstax/cnx-easybake
cnxeasybake/oven.py
append_string
def append_string(t, string): """Append a string to a node, as text or tail of last child.""" node = t.tree if string: if len(node) == 0: if node.text is not None: node.text += string else: node.text = string else: # Get last child ...
python
def append_string(t, string): """Append a string to a node, as text or tail of last child.""" node = t.tree if string: if len(node) == 0: if node.text is not None: node.text += string else: node.text = string else: # Get last child ...
[ "def", "append_string", "(", "t", ",", "string", ")", ":", "node", "=", "t", ".", "tree", "if", "string", ":", "if", "len", "(", "node", ")", "==", "0", ":", "if", "node", ".", "text", "is", "not", "None", ":", "node", ".", "text", "+=", "strin...
Append a string to a node, as text or tail of last child.
[ "Append", "a", "string", "to", "a", "node", "as", "text", "or", "tail", "of", "last", "child", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1390-L1404
train
openstax/cnx-easybake
cnxeasybake/oven.py
prepend_string
def prepend_string(t, string): """Prepend a string to a target node as text.""" node = t.tree if node.text is not None: node.text += string else: node.text = string
python
def prepend_string(t, string): """Prepend a string to a target node as text.""" node = t.tree if node.text is not None: node.text += string else: node.text = string
[ "def", "prepend_string", "(", "t", ",", "string", ")", ":", "node", "=", "t", ".", "tree", "if", "node", ".", "text", "is", "not", "None", ":", "node", ".", "text", "+=", "string", "else", ":", "node", ".", "text", "=", "string" ]
Prepend a string to a target node as text.
[ "Prepend", "a", "string", "to", "a", "target", "node", "as", "text", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1407-L1413
train
openstax/cnx-easybake
cnxeasybake/oven.py
grouped_insert
def grouped_insert(t, value): """Insert value into the target tree 't' with correct grouping.""" collator = Collator.createInstance(Locale(t.lang) if t.lang else Locale()) if value.tail is not None: val_prev = value.getprevious() if val_prev is not None: val_prev.tail = (val_prev...
python
def grouped_insert(t, value): """Insert value into the target tree 't' with correct grouping.""" collator = Collator.createInstance(Locale(t.lang) if t.lang else Locale()) if value.tail is not None: val_prev = value.getprevious() if val_prev is not None: val_prev.tail = (val_prev...
[ "def", "grouped_insert", "(", "t", ",", "value", ")", ":", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "t", ".", "lang", ")", "if", "t", ".", "lang", "else", "Locale", "(", ")", ")", "if", "value", ".", "tail", "is", "no...
Insert value into the target tree 't' with correct grouping.
[ "Insert", "value", "into", "the", "target", "tree", "t", "with", "correct", "grouping", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1416-L1479
train
openstax/cnx-easybake
cnxeasybake/oven.py
insert_sort
def insert_sort(node, target): """Insert node into sorted position in target tree. Uses sort function and language from target""" sort = target.sort lang = target.lang collator = Collator.createInstance(Locale(lang) if lang else Locale()) for child in target.tree: if collator.compare(so...
python
def insert_sort(node, target): """Insert node into sorted position in target tree. Uses sort function and language from target""" sort = target.sort lang = target.lang collator = Collator.createInstance(Locale(lang) if lang else Locale()) for child in target.tree: if collator.compare(so...
[ "def", "insert_sort", "(", "node", ",", "target", ")", ":", "sort", "=", "target", ".", "sort", "lang", "=", "target", ".", "lang", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "lang", ")", "if", "lang", "else", "Locale", "("...
Insert node into sorted position in target tree. Uses sort function and language from target
[ "Insert", "node", "into", "sorted", "position", "in", "target", "tree", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1482-L1494
train
openstax/cnx-easybake
cnxeasybake/oven.py
insert_group
def insert_group(node, target): """Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group. """ gr...
python
def insert_group(node, target): """Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group. """ gr...
[ "def", "insert_group", "(", "node", ",", "target", ")", ":", "group", "=", "target", ".", "sort", "lang", "=", "target", ".", "lang", "collator", "=", "Collator", ".", "createInstance", "(", "Locale", "(", "lang", ")", "if", "lang", "else", "Locale", "...
Insert node into in target tree, in appropriate group. Uses group and lang from target function. This assumes the node and target share a structure of a first child that determines the grouping, and a second child that will be accumulated in the group.
[ "Insert", "node", "into", "in", "target", "tree", "in", "appropriate", "group", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1497-L1518
train
openstax/cnx-easybake
cnxeasybake/oven.py
create_group
def create_group(value): """Create the group wrapper node.""" node = etree.Element('div', attrib={'class': 'group-by'}) span = etree.Element('span', attrib={'class': 'group-label'}) span.text = value node.append(span) return node
python
def create_group(value): """Create the group wrapper node.""" node = etree.Element('div', attrib={'class': 'group-by'}) span = etree.Element('span', attrib={'class': 'group-label'}) span.text = value node.append(span) return node
[ "def", "create_group", "(", "value", ")", ":", "node", "=", "etree", ".", "Element", "(", "'div'", ",", "attrib", "=", "{", "'class'", ":", "'group-by'", "}", ")", "span", "=", "etree", ".", "Element", "(", "'span'", ",", "attrib", "=", "{", "'class'...
Create the group wrapper node.
[ "Create", "the", "group", "wrapper", "node", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1521-L1527
train
openstax/cnx-easybake
cnxeasybake/oven.py
_extract_sel_info
def _extract_sel_info(sel): """Recurse down parsed tree, return pseudo class info""" from cssselect2.parser import (CombinedSelector, CompoundSelector, PseudoClassSelector, FunctionalPseudoClassSelector) steps = [] extras = [] if ...
python
def _extract_sel_info(sel): """Recurse down parsed tree, return pseudo class info""" from cssselect2.parser import (CombinedSelector, CompoundSelector, PseudoClassSelector, FunctionalPseudoClassSelector) steps = [] extras = [] if ...
[ "def", "_extract_sel_info", "(", "sel", ")", ":", "from", "cssselect2", ".", "parser", "import", "(", "CombinedSelector", ",", "CompoundSelector", ",", "PseudoClassSelector", ",", "FunctionalPseudoClassSelector", ")", "steps", "=", "[", "]", "extras", "=", "[", ...
Recurse down parsed tree, return pseudo class info
[ "Recurse", "down", "parsed", "tree", "return", "pseudo", "class", "info" ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1530-L1553
train
openstax/cnx-easybake
cnxeasybake/oven.py
_to_roman
def _to_roman(num): """Convert integer to roman numerals.""" roman_numeral_map = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ...
python
def _to_roman(num): """Convert integer to roman numerals.""" roman_numeral_map = ( ('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ...
[ "def", "_to_roman", "(", "num", ")", ":", "roman_numeral_map", "=", "(", "(", "'M'", ",", "1000", ")", ",", "(", "'CM'", ",", "900", ")", ",", "(", "'D'", ",", "500", ")", ",", "(", "'CD'", ",", "400", ")", ",", "(", "'C'", ",", "100", ")", ...
Convert integer to roman numerals.
[ "Convert", "integer", "to", "roman", "numerals", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1570-L1595
train
openstax/cnx-easybake
cnxeasybake/oven.py
copy_w_id_suffix
def copy_w_id_suffix(elem, suffix="_copy"): """Make a deep copy of the provided tree, altering ids.""" mycopy = deepcopy(elem) for id_elem in mycopy.xpath('//*[@id]'): id_elem.set('id', id_elem.get('id') + suffix) return mycopy
python
def copy_w_id_suffix(elem, suffix="_copy"): """Make a deep copy of the provided tree, altering ids.""" mycopy = deepcopy(elem) for id_elem in mycopy.xpath('//*[@id]'): id_elem.set('id', id_elem.get('id') + suffix) return mycopy
[ "def", "copy_w_id_suffix", "(", "elem", ",", "suffix", "=", "\"_copy\"", ")", ":", "mycopy", "=", "deepcopy", "(", "elem", ")", "for", "id_elem", "in", "mycopy", ".", "xpath", "(", "'//*[@id]'", ")", ":", "id_elem", ".", "set", "(", "'id'", ",", "id_el...
Make a deep copy of the provided tree, altering ids.
[ "Make", "a", "deep", "copy", "of", "the", "provided", "tree", "altering", "ids", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1598-L1603
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.generate_id
def generate_id(self): """Generate a fresh id""" if self.use_repeatable_ids: self.repeatable_id_counter += 1 return 'autobaked-{}'.format(self.repeatable_id_counter) else: return str(uuid4())
python
def generate_id(self): """Generate a fresh id""" if self.use_repeatable_ids: self.repeatable_id_counter += 1 return 'autobaked-{}'.format(self.repeatable_id_counter) else: return str(uuid4())
[ "def", "generate_id", "(", "self", ")", ":", "if", "self", ".", "use_repeatable_ids", ":", "self", ".", "repeatable_id_counter", "+=", "1", "return", "'autobaked-{}'", ".", "format", "(", "self", ".", "repeatable_id_counter", ")", "else", ":", "return", "str",...
Generate a fresh id
[ "Generate", "a", "fresh", "id" ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L152-L158
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.clear_state
def clear_state(self): """Clear the recipe state.""" self.state = {} self.state['steps'] = [] self.state['current_step'] = None self.state['scope'] = [] self.state['counters'] = {} self.state['strings'] = {} for step in self.matchers: self.stat...
python
def clear_state(self): """Clear the recipe state.""" self.state = {} self.state['steps'] = [] self.state['current_step'] = None self.state['scope'] = [] self.state['counters'] = {} self.state['strings'] = {} for step in self.matchers: self.stat...
[ "def", "clear_state", "(", "self", ")", ":", "self", ".", "state", "=", "{", "}", "self", ".", "state", "[", "'steps'", "]", "=", "[", "]", "self", ".", "state", "[", "'current_step'", "]", "=", "None", "self", ".", "state", "[", "'scope'", "]", ...
Clear the recipe state.
[ "Clear", "the", "recipe", "state", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L160-L175
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.record_coverage_zero
def record_coverage_zero(self, rule, offset): """Add entry to coverage saying this selector was parsed""" self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
python
def record_coverage_zero(self, rule, offset): """Add entry to coverage saying this selector was parsed""" self.coverage_lines.append('DA:{},0'.format(rule.source_line + offset))
[ "def", "record_coverage_zero", "(", "self", ",", "rule", ",", "offset", ")", ":", "self", ".", "coverage_lines", ".", "append", "(", "'DA:{},0'", ".", "format", "(", "rule", ".", "source_line", "+", "offset", ")", ")" ]
Add entry to coverage saying this selector was parsed
[ "Add", "entry", "to", "coverage", "saying", "this", "selector", "was", "parsed" ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L384-L386
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.record_coverage
def record_coverage(self, rule): """Add entry to coverage saying this selector was matched""" log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8')) self.coverage_lines.append('DA:{},1'.format(rule[0]))
python
def record_coverage(self, rule): """Add entry to coverage saying this selector was matched""" log(DEBUG, u'Rule ({}): {}'.format(*rule).encode('utf-8')) self.coverage_lines.append('DA:{},1'.format(rule[0]))
[ "def", "record_coverage", "(", "self", ",", "rule", ")", ":", "log", "(", "DEBUG", ",", "u'Rule ({}): {}'", ".", "format", "(", "*", "rule", ")", ".", "encode", "(", "'utf-8'", ")", ")", "self", ".", "coverage_lines", ".", "append", "(", "'DA:{},1'", "...
Add entry to coverage saying this selector was matched
[ "Add", "entry", "to", "coverage", "saying", "this", "selector", "was", "matched" ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L388-L391
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.push_target_elem
def push_target_elem(self, element, pseudo=None): """Place target element onto action stack.""" actions = self.state[self.state['current_step']]['actions'] if len(actions) > 0 and actions[-1][0] == 'target': actions.pop() actions.append(('target', Target(element.etree_element...
python
def push_target_elem(self, element, pseudo=None): """Place target element onto action stack.""" actions = self.state[self.state['current_step']]['actions'] if len(actions) > 0 and actions[-1][0] == 'target': actions.pop() actions.append(('target', Target(element.etree_element...
[ "def", "push_target_elem", "(", "self", ",", "element", ",", "pseudo", "=", "None", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "if", "len", "(", "actions", ")", "...
Place target element onto action stack.
[ "Place", "target", "element", "onto", "action", "stack", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L580-L587
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.push_pending_elem
def push_pending_elem(self, element, pseudo): """Create and place pending target element onto stack.""" self.push_target_elem(element, pseudo) elem = etree.Element('div') actions = self.state[self.state['current_step']]['actions'] actions.append(('move', elem)) actions.ap...
python
def push_pending_elem(self, element, pseudo): """Create and place pending target element onto stack.""" self.push_target_elem(element, pseudo) elem = etree.Element('div') actions = self.state[self.state['current_step']]['actions'] actions.append(('move', elem)) actions.ap...
[ "def", "push_pending_elem", "(", "self", ",", "element", ",", "pseudo", ")", ":", "self", ".", "push_target_elem", "(", "element", ",", "pseudo", ")", "elem", "=", "etree", ".", "Element", "(", "'div'", ")", "actions", "=", "self", ".", "state", "[", "...
Create and place pending target element onto stack.
[ "Create", "and", "place", "pending", "target", "element", "onto", "stack", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L589-L595
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.pop_pending_if_empty
def pop_pending_if_empty(self, element): """Remove empty wrapper element.""" actions = self.state[self.state['current_step']]['actions'] elem = self.current_target().tree if actions[-1][0] == ('target') and actions[-1][1].tree == elem: actions.pop() actions.pop() ...
python
def pop_pending_if_empty(self, element): """Remove empty wrapper element.""" actions = self.state[self.state['current_step']]['actions'] elem = self.current_target().tree if actions[-1][0] == ('target') and actions[-1][1].tree == elem: actions.pop() actions.pop() ...
[ "def", "pop_pending_if_empty", "(", "self", ",", "element", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "elem", "=", "self", ".", "current_target", "(", ")", ".", "t...
Remove empty wrapper element.
[ "Remove", "empty", "wrapper", "element", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L597-L604
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.current_target
def current_target(self): """Return current target.""" actions = self.state[self.state['current_step']]['actions'] for action, value in reversed(actions): if action == 'target': return value
python
def current_target(self): """Return current target.""" actions = self.state[self.state['current_step']]['actions'] for action, value in reversed(actions): if action == 'target': return value
[ "def", "current_target", "(", "self", ")", ":", "actions", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "[", "'actions'", "]", "for", "action", ",", "value", "in", "reversed", "(", "actions", ")", ":", "if", ...
Return current target.
[ "Return", "current", "target", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L606-L611
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.find_method
def find_method(self, decl): """Find class method to call for declaration based on name.""" name = decl.name method = None try: method = getattr(self, u'do_{}'.format( (name).replace('-', '_'))) except AttributeError: if name.s...
python
def find_method(self, decl): """Find class method to call for declaration based on name.""" name = decl.name method = None try: method = getattr(self, u'do_{}'.format( (name).replace('-', '_'))) except AttributeError: if name.s...
[ "def", "find_method", "(", "self", ",", "decl", ")", ":", "name", "=", "decl", ".", "name", "method", "=", "None", "try", ":", "method", "=", "getattr", "(", "self", ",", "u'do_{}'", ".", "format", "(", "(", "name", ")", ".", "replace", "(", "'-'",...
Find class method to call for declaration based on name.
[ "Find", "class", "method", "to", "call", "for", "declaration", "based", "on", "name", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L614-L633
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.lookup
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
python
def lookup(self, vtype, vname, target_id=None): """Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is retu...
[ "def", "lookup", "(", "self", ",", "vtype", ",", "vname", ",", "target_id", "=", "None", ")", ":", "nullvals", "=", "{", "'strings'", ":", "''", ",", "'counters'", ":", "0", ",", "'pending'", ":", "(", "None", ",", "None", ")", "}", "nullval", "=",...
Return value of vname from the variable store vtype. Valid vtypes are `strings` 'counters', and `pending`. If the value is not found in the current steps store, earlier steps will be checked. If not found, '', 0, or (None, None) is returned.
[ "Return", "value", "of", "vname", "from", "the", "variable", "store", "vtype", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L635-L675
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.counter_style
def counter_style(self, val, style): """Return counter value in given style.""" if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(...
python
def counter_style(self, val, style): """Return counter value in given style.""" if style == 'decimal-leading-zero': if val < 10: valstr = "0{}".format(val) else: valstr = str(val) elif style == 'lower-roman': valstr = _to_roman(...
[ "def", "counter_style", "(", "self", ",", "val", ",", "style", ")", ":", "if", "style", "==", "'decimal-leading-zero'", ":", "if", "val", "<", "10", ":", "valstr", "=", "\"0{}\"", ".", "format", "(", "val", ")", "else", ":", "valstr", "=", "str", "("...
Return counter value in given style.
[ "Return", "counter", "value", "in", "given", "style", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L677-L707
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_counter_reset
def do_counter_reset(self, element, decl, pseudo): """Clear specified counters.""" step = self.state[self.state['current_step']] counter_name = '' for term in decl.value: if type(term) is ast.WhitespaceToken: continue elif type(term) is ast.IdentT...
python
def do_counter_reset(self, element, decl, pseudo): """Clear specified counters.""" step = self.state[self.state['current_step']] counter_name = '' for term in decl.value: if type(term) is ast.WhitespaceToken: continue elif type(term) is ast.IdentT...
[ "def", "do_counter_reset", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "counter_name", "=", "''", "for", "term", "in", "decl", ".", ...
Clear specified counters.
[ "Clear", "specified", "counters", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L936-L963
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_node_set
def do_node_set(self, element, decl, pseudo): """Implement node-set declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree _, valstep = self.lookup('pending', target) if not valstep: ...
python
def do_node_set(self, element, decl, pseudo): """Implement node-set declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree _, valstep = self.lookup('pending', target) if not valstep: ...
[ "def", "do_node_set", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "target", "=", "serialize", "(", "decl", ".", "value", ")", ".", "strip", "(", ")", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'curren...
Implement node-set declaration.
[ "Implement", "node", "-", "set", "declaration", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1008-L1017
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_move_to
def do_move_to(self, element, decl, pseudo): """Implement move-to declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree # Find if the current node already has a move, and remove it. actions...
python
def do_move_to(self, element, decl, pseudo): """Implement move-to declaration.""" target = serialize(decl.value).strip() step = self.state[self.state['current_step']] elem = self.current_target().tree # Find if the current node already has a move, and remove it. actions...
[ "def", "do_move_to", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "target", "=", "serialize", "(", "decl", ".", "value", ")", ".", "strip", "(", ")", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current...
Implement move-to declaration.
[ "Implement", "move", "-", "to", "declaration", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1032-L1050
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_container
def do_container(self, element, decl, pseudo): """Implement setting tag for new wrapper element.""" value = serialize(decl.value).strip() if '|' in value: namespace, tag = value.split('|', 1) try: namespace = self.css_namespaces[namespace] ex...
python
def do_container(self, element, decl, pseudo): """Implement setting tag for new wrapper element.""" value = serialize(decl.value).strip() if '|' in value: namespace, tag = value.split('|', 1) try: namespace = self.css_namespaces[namespace] ex...
[ "def", "do_container", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "value", "=", "serialize", "(", "decl", ".", "value", ")", ".", "strip", "(", ")", "if", "'|'", "in", "value", ":", "namespace", ",", "tag", "=", "value", "."...
Implement setting tag for new wrapper element.
[ "Implement", "setting", "tag", "for", "new", "wrapper", "element", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1053-L1071
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_class
def do_class(self, element, decl, pseudo): """Implement class declaration - pre-match.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', ('class', strval)))
python
def do_class(self, element, decl, pseudo): """Implement class declaration - pre-match.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', ('class', strval)))
[ "def", "do_class", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "actions", "=", "step", "[", "'actions'", "]", "strval", "=", "self",...
Implement class declaration - pre-match.
[ "Implement", "class", "declaration", "-", "pre", "-", "match", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1074-L1079
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_attr_any
def do_attr_any(self, element, decl, pseudo): """Implement generic attribute setting.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', (decl.name[5:], strval)))
python
def do_attr_any(self, element, decl, pseudo): """Implement generic attribute setting.""" step = self.state[self.state['current_step']] actions = step['actions'] strval = self.eval_string_value(element, decl.value) actions.append(('attrib', (decl.name[5:], strval)))
[ "def", "do_attr_any", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "step", "=", "self", ".", "state", "[", "self", ".", "state", "[", "'current_step'", "]", "]", "actions", "=", "step", "[", "'actions'", "]", "strval", "=", "sel...
Implement generic attribute setting.
[ "Implement", "generic", "attribute", "setting", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1082-L1087
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_group_by
def do_group_by(self, element, decl, pseudo): """Implement group-by declaration - pre-match.""" sort_css = groupby_css = flags = '' if ',' in decl.value: if decl.value.count(',') == 2: sort_css, groupby_css, flags = \ map(serialize, split(decl....
python
def do_group_by(self, element, decl, pseudo): """Implement group-by declaration - pre-match.""" sort_css = groupby_css = flags = '' if ',' in decl.value: if decl.value.count(',') == 2: sort_css, groupby_css, flags = \ map(serialize, split(decl....
[ "def", "do_group_by", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "sort_css", "=", "groupby_css", "=", "flags", "=", "''", "if", "','", "in", "decl", ".", "value", ":", "if", "decl", ".", "value", ".", "count", "(", "','", ")...
Implement group-by declaration - pre-match.
[ "Implement", "group", "-", "by", "declaration", "-", "pre", "-", "match", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1250-L1283
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_sort_by
def do_sort_by(self, element, decl, pseudo): """Implement sort-by declaration - pre-match.""" if ',' in decl.value: css, flags = split(decl.value, ',') else: css = decl.value flags = None sort = css_to_func(serialize(css), serialize(flags or ''), ...
python
def do_sort_by(self, element, decl, pseudo): """Implement sort-by declaration - pre-match.""" if ',' in decl.value: css, flags = split(decl.value, ',') else: css = decl.value flags = None sort = css_to_func(serialize(css), serialize(flags or ''), ...
[ "def", "do_sort_by", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "if", "','", "in", "decl", ".", "value", ":", "css", ",", "flags", "=", "split", "(", "decl", ".", "value", ",", "','", ")", "else", ":", "css", "=", "decl", ...
Implement sort-by declaration - pre-match.
[ "Implement", "sort", "-", "by", "declaration", "-", "pre", "-", "match", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1286-L1310
train
openstax/cnx-easybake
cnxeasybake/oven.py
Oven.do_pass
def do_pass(self, element, decl, pseudo): """No longer valid way to set processing pass.""" log(WARN, u"Old-style pass as declaration not allowed.{}" .format(decl.value).encpde('utf-8'))
python
def do_pass(self, element, decl, pseudo): """No longer valid way to set processing pass.""" log(WARN, u"Old-style pass as declaration not allowed.{}" .format(decl.value).encpde('utf-8'))
[ "def", "do_pass", "(", "self", ",", "element", ",", "decl", ",", "pseudo", ")", ":", "log", "(", "WARN", ",", "u\"Old-style pass as declaration not allowed.{}\"", ".", "format", "(", "decl", ".", "value", ")", ".", "encpde", "(", "'utf-8'", ")", ")" ]
No longer valid way to set processing pass.
[ "No", "longer", "valid", "way", "to", "set", "processing", "pass", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/oven.py#L1313-L1316
train
dcos/shakedown
shakedown/dcos/command.py
connection_cache
def connection_cache(func: callable): """Connection cache for SSH sessions. This is to prevent opening a new, expensive connection on every command run.""" cache = dict() lock = RLock() @wraps(func) def func_wrapper(host: str, username: str, *args, **kwargs): key = "{h}-{u}".format(h=h...
python
def connection_cache(func: callable): """Connection cache for SSH sessions. This is to prevent opening a new, expensive connection on every command run.""" cache = dict() lock = RLock() @wraps(func) def func_wrapper(host: str, username: str, *args, **kwargs): key = "{h}-{u}".format(h=h...
[ "def", "connection_cache", "(", "func", ":", "callable", ")", ":", "cache", "=", "dict", "(", ")", "lock", "=", "RLock", "(", ")", "@", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "host", ":", "str", ",", "username", ":", "str", ",", "*"...
Connection cache for SSH sessions. This is to prevent opening a new, expensive connection on every command run.
[ "Connection", "cache", "for", "SSH", "sessions", ".", "This", "is", "to", "prevent", "opening", "a", "new", "expensive", "connection", "on", "every", "command", "run", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L15-L66
train
dcos/shakedown
shakedown/dcos/command.py
_get_connection
def _get_connection(host, username: str, key_path: str) \ -> paramiko.Transport or None: """Return an authenticated SSH connection. :param host: host or IP of the machine :type host: str :param username: SSH username :type username: str :param key_path: path to the SSH private key for S...
python
def _get_connection(host, username: str, key_path: str) \ -> paramiko.Transport or None: """Return an authenticated SSH connection. :param host: host or IP of the machine :type host: str :param username: SSH username :type username: str :param key_path: path to the SSH private key for S...
[ "def", "_get_connection", "(", "host", ",", "username", ":", "str", ",", "key_path", ":", "str", ")", "->", "paramiko", ".", "Transport", "or", "None", ":", "if", "not", "username", ":", "username", "=", "shakedown", ".", "cli", ".", "ssh_user", "if", ...
Return an authenticated SSH connection. :param host: host or IP of the machine :type host: str :param username: SSH username :type username: str :param key_path: path to the SSH private key for SSH auth :type key_path: str :return: SSH connection :rtype: paramiko.Transport or None
[ "Return", "an", "authenticated", "SSH", "connection", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L70-L99
train
dcos/shakedown
shakedown/dcos/command.py
run_command
def run_command( host, command, username=None, key_path=None, noisy=True ): """ Run a command via SSH, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param command: the command to exe...
python
def run_command( host, command, username=None, key_path=None, noisy=True ): """ Run a command via SSH, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param command: the command to exe...
[ "def", "run_command", "(", "host", ",", "command", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "noisy", "=", "True", ")", ":", "with", "HostSession", "(", "host", ",", "username", ",", "key_path", ",", "noisy", ")", "as", "s", ":...
Run a command via SSH, proxied through the mesos master :param host: host or IP of the machine to execute the command on :type host: str :param command: the command to execute :type command: str :param username: SSH username :type username: str :param key_path: p...
[ "Run", "a", "command", "via", "SSH", "proxied", "through", "the", "mesos", "master" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L102-L131
train
dcos/shakedown
shakedown/dcos/command.py
run_command_on_master
def run_command_on_master( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos master """ return run_command(shakedown.master_ip(), command, username, key_path, noisy)
python
def run_command_on_master( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos master """ return run_command(shakedown.master_ip(), command, username, key_path, noisy)
[ "def", "run_command_on_master", "(", "command", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "noisy", "=", "True", ")", ":", "return", "run_command", "(", "shakedown", ".", "master_ip", "(", ")", ",", "command", ",", "username", ",", ...
Run a command on the Mesos master
[ "Run", "a", "command", "on", "the", "Mesos", "master" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L134-L143
train
dcos/shakedown
shakedown/dcos/command.py
run_command_on_leader
def run_command_on_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos leader. Important for Multi-Master. """ return run_command(shakedown.master_leader_ip(), command, username, key_path, noisy)
python
def run_command_on_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Mesos leader. Important for Multi-Master. """ return run_command(shakedown.master_leader_ip(), command, username, key_path, noisy)
[ "def", "run_command_on_leader", "(", "command", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "noisy", "=", "True", ")", ":", "return", "run_command", "(", "shakedown", ".", "master_leader_ip", "(", ")", ",", "command", ",", "username", ...
Run a command on the Mesos leader. Important for Multi-Master.
[ "Run", "a", "command", "on", "the", "Mesos", "leader", ".", "Important", "for", "Multi", "-", "Master", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L146-L155
train
dcos/shakedown
shakedown/dcos/command.py
run_command_on_marathon_leader
def run_command_on_marathon_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Marathon leader """ return run_command(shakedown.marathon_leader_ip(), command, username, key_path, noisy)
python
def run_command_on_marathon_leader( command, username=None, key_path=None, noisy=True ): """ Run a command on the Marathon leader """ return run_command(shakedown.marathon_leader_ip(), command, username, key_path, noisy)
[ "def", "run_command_on_marathon_leader", "(", "command", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "noisy", "=", "True", ")", ":", "return", "run_command", "(", "shakedown", ".", "marathon_leader_ip", "(", ")", ",", "command", ",", "us...
Run a command on the Marathon leader
[ "Run", "a", "command", "on", "the", "Marathon", "leader" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L158-L167
train
dcos/shakedown
shakedown/dcos/command.py
run_command_on_agent
def run_command_on_agent( host, command, username=None, key_path=None, noisy=True ): """ Run a command on a Mesos agent, proxied through the master """ return run_command(host, command, username, key_path, noisy)
python
def run_command_on_agent( host, command, username=None, key_path=None, noisy=True ): """ Run a command on a Mesos agent, proxied through the master """ return run_command(host, command, username, key_path, noisy)
[ "def", "run_command_on_agent", "(", "host", ",", "command", ",", "username", "=", "None", ",", "key_path", "=", "None", ",", "noisy", "=", "True", ")", ":", "return", "run_command", "(", "host", ",", "command", ",", "username", ",", "key_path", ",", "noi...
Run a command on a Mesos agent, proxied through the master
[ "Run", "a", "command", "on", "a", "Mesos", "agent", "proxied", "through", "the", "master" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/command.py#L170-L180
train
dcos/shakedown
shakedown/dcos/master.py
get_all_masters
def get_all_masters(): """ Returns the json object that represents each of the masters. """ masters = [] for master in __master_zk_nodes_keys(): master_zk_str = get_zk_node_data(master)['str'] masters.append(json.loads(master_zk_str)) return masters
python
def get_all_masters(): """ Returns the json object that represents each of the masters. """ masters = [] for master in __master_zk_nodes_keys(): master_zk_str = get_zk_node_data(master)['str'] masters.append(json.loads(master_zk_str)) return masters
[ "def", "get_all_masters", "(", ")", ":", "masters", "=", "[", "]", "for", "master", "in", "__master_zk_nodes_keys", "(", ")", ":", "master_zk_str", "=", "get_zk_node_data", "(", "master", ")", "[", "'str'", "]", "masters", ".", "append", "(", "json", ".", ...
Returns the json object that represents each of the masters.
[ "Returns", "the", "json", "object", "that", "represents", "each", "of", "the", "masters", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/master.py#L93-L101
train
dcos/shakedown
shakedown/dcos/agent.py
get_public_agents_public_ip
def get_public_agents_public_ip(): """Provides a list public IPs for public agents in the cluster""" public_ip_list = [] agents = get_public_agents() for agent in agents: status, public_ip = shakedown.run_command_on_agent(agent, "/opt/mesosphere/bin/detect_ip_public") public_ip_list.appe...
python
def get_public_agents_public_ip(): """Provides a list public IPs for public agents in the cluster""" public_ip_list = [] agents = get_public_agents() for agent in agents: status, public_ip = shakedown.run_command_on_agent(agent, "/opt/mesosphere/bin/detect_ip_public") public_ip_list.appe...
[ "def", "get_public_agents_public_ip", "(", ")", ":", "public_ip_list", "=", "[", "]", "agents", "=", "get_public_agents", "(", ")", "for", "agent", "in", "agents", ":", "status", ",", "public_ip", "=", "shakedown", ".", "run_command_on_agent", "(", "agent", ",...
Provides a list public IPs for public agents in the cluster
[ "Provides", "a", "list", "public", "IPs", "for", "public", "agents", "in", "the", "cluster" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/agent.py#L11-L19
train
dcos/shakedown
shakedown/dcos/agent.py
partition_agent
def partition_agent(host): """ Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster """ network.save_iptables(host) network.flush_all_rules(host) network.allow_all_traffic(host) network.run_iptabl...
python
def partition_agent(host): """ Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster """ network.save_iptables(host) network.flush_all_rules(host) network.allow_all_traffic(host) network.run_iptabl...
[ "def", "partition_agent", "(", "host", ")", ":", "network", ".", "save_iptables", "(", "host", ")", "network", ".", "flush_all_rules", "(", "host", ")", "network", ".", "allow_all_traffic", "(", "host", ")", "network", ".", "run_iptables", "(", "host", ",", ...
Partition a node from all network traffic except for SSH and loopback :param hostname: host or IP of the machine to partition from the cluster
[ "Partition", "a", "node", "from", "all", "network", "traffic", "except", "for", "SSH", "and", "loopback" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/agent.py#L78-L90
train
dcos/shakedown
shakedown/dcos/agent.py
kill_process_on_host
def kill_process_on_host( hostname, pattern ): """ Kill the process matching pattern at ip :param hostname: the hostname or ip address of the host on which the process will be killed :param pattern: a regular expression matching the name of the process to kill """ status, stdout = ...
python
def kill_process_on_host( hostname, pattern ): """ Kill the process matching pattern at ip :param hostname: the hostname or ip address of the host on which the process will be killed :param pattern: a regular expression matching the name of the process to kill """ status, stdout = ...
[ "def", "kill_process_on_host", "(", "hostname", ",", "pattern", ")", ":", "status", ",", "stdout", "=", "run_command_on_agent", "(", "hostname", ",", "\"ps aux | grep -v grep | grep '{}'\"", ".", "format", "(", "pattern", ")", ")", "pids", "=", "[", "p", ".", ...
Kill the process matching pattern at ip :param hostname: the hostname or ip address of the host on which the process will be killed :param pattern: a regular expression matching the name of the process to kill
[ "Kill", "the", "process", "matching", "pattern", "at", "ip" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/agent.py#L113-L131
train
dcos/shakedown
shakedown/dcos/agent.py
kill_process_from_pid_file_on_host
def kill_process_from_pid_file_on_host(hostname, pid_file='app.pid'): """ Retrieves the PID of a process from a pid file on host and kills it. :param hostname: the hostname or ip address of the host on which the process will be killed :param pid_file: pid file to use holding the pid number to kill """ ...
python
def kill_process_from_pid_file_on_host(hostname, pid_file='app.pid'): """ Retrieves the PID of a process from a pid file on host and kills it. :param hostname: the hostname or ip address of the host on which the process will be killed :param pid_file: pid file to use holding the pid number to kill """ ...
[ "def", "kill_process_from_pid_file_on_host", "(", "hostname", ",", "pid_file", "=", "'app.pid'", ")", ":", "status", ",", "pid", "=", "run_command_on_agent", "(", "hostname", ",", "'cat {}'", ".", "format", "(", "pid_file", ")", ")", "status", ",", "stdout", "...
Retrieves the PID of a process from a pid file on host and kills it. :param hostname: the hostname or ip address of the host on which the process will be killed :param pid_file: pid file to use holding the pid number to kill
[ "Retrieves", "the", "PID", "of", "a", "process", "from", "a", "pid", "file", "on", "host", "and", "kills", "it", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/agent.py#L134-L146
train
dcos/shakedown
shakedown/dcos/spinner.py
wait_for
def wait_for( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=False, required_consecutive_success_count=1): """ waits or spins for a predicate, returning the result. Predicate is a function that r...
python
def wait_for( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=False, required_consecutive_success_count=1): """ waits or spins for a predicate, returning the result. Predicate is a function that r...
[ "def", "wait_for", "(", "predicate", ",", "timeout_seconds", "=", "120", ",", "sleep_seconds", "=", "1", ",", "ignore_exceptions", "=", "True", ",", "inverse_predicate", "=", "False", ",", "noisy", "=", "False", ",", "required_consecutive_success_count", "=", "1...
waits or spins for a predicate, returning the result. Predicate is a function that returns a truthy or falsy value. An exception in the function will be returned. A timeout will throw a TimeoutExpired Exception.
[ "waits", "or", "spins", "for", "a", "predicate", "returning", "the", "result", ".", "Predicate", "is", "a", "function", "that", "returns", "a", "truthy", "or", "falsy", "value", ".", "An", "exception", "in", "the", "function", "will", "be", "returned", "."...
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/spinner.py#L12-L60
train
dcos/shakedown
shakedown/dcos/spinner.py
__stringify_predicate
def __stringify_predicate(predicate): """ Reflection of function name and parameters of the predicate being used. """ funname = getsource(predicate).strip().split(' ')[2].rstrip(',') params = 'None' # if args dig in the stack if '()' not in funname: stack = getouterframes(currentframe()...
python
def __stringify_predicate(predicate): """ Reflection of function name and parameters of the predicate being used. """ funname = getsource(predicate).strip().split(' ')[2].rstrip(',') params = 'None' # if args dig in the stack if '()' not in funname: stack = getouterframes(currentframe()...
[ "def", "__stringify_predicate", "(", "predicate", ")", ":", "funname", "=", "getsource", "(", "predicate", ")", ".", "strip", "(", ")", ".", "split", "(", "' '", ")", "[", "2", "]", ".", "rstrip", "(", "','", ")", "params", "=", "'None'", "if", "'()'...
Reflection of function name and parameters of the predicate being used.
[ "Reflection", "of", "function", "name", "and", "parameters", "of", "the", "predicate", "being", "used", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/spinner.py#L63-L76
train
dcos/shakedown
shakedown/dcos/spinner.py
time_wait
def time_wait( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=True, required_consecutive_success_count=1): """ waits or spins for a predicate and returns the time of the wait. An exception in the function will be returned. ...
python
def time_wait( predicate, timeout_seconds=120, sleep_seconds=1, ignore_exceptions=True, inverse_predicate=False, noisy=True, required_consecutive_success_count=1): """ waits or spins for a predicate and returns the time of the wait. An exception in the function will be returned. ...
[ "def", "time_wait", "(", "predicate", ",", "timeout_seconds", "=", "120", ",", "sleep_seconds", "=", "1", ",", "ignore_exceptions", "=", "True", ",", "inverse_predicate", "=", "False", ",", "noisy", "=", "True", ",", "required_consecutive_success_count", "=", "1...
waits or spins for a predicate and returns the time of the wait. An exception in the function will be returned. A timeout will throw a TimeoutExpired Exception.
[ "waits", "or", "spins", "for", "a", "predicate", "and", "returns", "the", "time", "of", "the", "wait", ".", "An", "exception", "in", "the", "function", "will", "be", "returned", ".", "A", "timeout", "will", "throw", "a", "TimeoutExpired", "Exception", "." ...
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/spinner.py#L79-L94
train
dcos/shakedown
shakedown/dcos/spinner.py
wait_while_exceptions
def wait_while_exceptions( predicate, timeout_seconds=120, sleep_seconds=1, noisy=False): """ waits for a predicate, ignoring exceptions, returning the result. Predicate is a function. Exceptions will trigger the sleep and retry; any non-exception result will ...
python
def wait_while_exceptions( predicate, timeout_seconds=120, sleep_seconds=1, noisy=False): """ waits for a predicate, ignoring exceptions, returning the result. Predicate is a function. Exceptions will trigger the sleep and retry; any non-exception result will ...
[ "def", "wait_while_exceptions", "(", "predicate", ",", "timeout_seconds", "=", "120", ",", "sleep_seconds", "=", "1", ",", "noisy", "=", "False", ")", ":", "start_time", "=", "time_module", ".", "time", "(", ")", "timeout", "=", "Deadline", ".", "create_dead...
waits for a predicate, ignoring exceptions, returning the result. Predicate is a function. Exceptions will trigger the sleep and retry; any non-exception result will be returned. A timeout will throw a TimeoutExpired Exception.
[ "waits", "for", "a", "predicate", "ignoring", "exceptions", "returning", "the", "result", ".", "Predicate", "is", "a", "function", ".", "Exceptions", "will", "trigger", "the", "sleep", "and", "retry", ";", "any", "non", "-", "exception", "result", "will", "b...
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/spinner.py#L97-L128
train
dcos/shakedown
shakedown/dcos/spinner.py
elapse_time
def elapse_time(start, end=None, precision=3): """ Simple time calculation utility. Given a start time, it will provide an elapse time. """ if end is None: end = time_module.time() return round(end-start, precision)
python
def elapse_time(start, end=None, precision=3): """ Simple time calculation utility. Given a start time, it will provide an elapse time. """ if end is None: end = time_module.time() return round(end-start, precision)
[ "def", "elapse_time", "(", "start", ",", "end", "=", "None", ",", "precision", "=", "3", ")", ":", "if", "end", "is", "None", ":", "end", "=", "time_module", ".", "time", "(", ")", "return", "round", "(", "end", "-", "start", ",", "precision", ")" ...
Simple time calculation utility. Given a start time, it will provide an elapse time.
[ "Simple", "time", "calculation", "utility", ".", "Given", "a", "start", "time", "it", "will", "provide", "an", "elapse", "time", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/spinner.py#L131-L136
train
dcos/shakedown
shakedown/cli/helpers.py
set_config_defaults
def set_config_defaults(args): """ Set configuration defaults :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict """ defaults = { 'fail': 'fast', 'stdout': 'fail' } for key in defaults: if not args[k...
python
def set_config_defaults(args): """ Set configuration defaults :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict """ defaults = { 'fail': 'fast', 'stdout': 'fail' } for key in defaults: if not args[k...
[ "def", "set_config_defaults", "(", "args", ")", ":", "defaults", "=", "{", "'fail'", ":", "'fast'", ",", "'stdout'", ":", "'fail'", "}", "for", "key", "in", "defaults", ":", "if", "not", "args", "[", "key", "]", ":", "args", "[", "key", "]", "=", "...
Set configuration defaults :param args: a dict of arguments :type args: dict :return: a dict of arguments :rtype: dict
[ "Set", "configuration", "defaults" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/helpers.py#L35-L54
train
dcos/shakedown
shakedown/cli/helpers.py
banner
def banner(): """ Display a product banner :return: a delightful Mesosphere logo rendered in unicode :rtype: str """ banner_dict = { 'a0': click.style(chr(9601), fg='magenta'), 'a1': click.style(chr(9601), fg='magenta', bold=True), 'b0': click.style(chr(9616), fg='m...
python
def banner(): """ Display a product banner :return: a delightful Mesosphere logo rendered in unicode :rtype: str """ banner_dict = { 'a0': click.style(chr(9601), fg='magenta'), 'a1': click.style(chr(9601), fg='magenta', bold=True), 'b0': click.style(chr(9616), fg='m...
[ "def", "banner", "(", ")", ":", "banner_dict", "=", "{", "'a0'", ":", "click", ".", "style", "(", "chr", "(", "9601", ")", ",", "fg", "=", "'magenta'", ")", ",", "'a1'", ":", "click", ".", "style", "(", "chr", "(", "9601", ")", ",", "fg", "=", ...
Display a product banner :return: a delightful Mesosphere logo rendered in unicode :rtype: str
[ "Display", "a", "product", "banner" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/helpers.py#L75-L121
train
dcos/shakedown
shakedown/cli/helpers.py
decorate
def decorate(text, style): """ Console decoration style definitions :param text: the text string to decorate :type text: str :param style: the style used to decorate the string :type style: str :return: a decorated string :rtype: str """ return { 's...
python
def decorate(text, style): """ Console decoration style definitions :param text: the text string to decorate :type text: str :param style: the style used to decorate the string :type style: str :return: a decorated string :rtype: str """ return { 's...
[ "def", "decorate", "(", "text", ",", "style", ")", ":", "return", "{", "'step-maj'", ":", "click", ".", "style", "(", "\"\\n\"", "+", "'> '", "+", "text", ",", "fg", "=", "'yellow'", ",", "bold", "=", "True", ")", ",", "'step-min'", ":", "click", "...
Console decoration style definitions :param text: the text string to decorate :type text: str :param style: the style used to decorate the string :type style: str :return: a decorated string :rtype: str
[ "Console", "decoration", "style", "definitions" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/helpers.py#L124-L150
train
dcos/shakedown
shakedown/cli/helpers.py
echo
def echo(text, **kwargs): """ Print results to the console :param text: the text string to print :type text: str :return: a string :rtype: str """ if shakedown.cli.quiet: return if not 'n' in kwargs: kwargs['n'] = True if 'd' in kwargs: te...
python
def echo(text, **kwargs): """ Print results to the console :param text: the text string to print :type text: str :return: a string :rtype: str """ if shakedown.cli.quiet: return if not 'n' in kwargs: kwargs['n'] = True if 'd' in kwargs: te...
[ "def", "echo", "(", "text", ",", "**", "kwargs", ")", ":", "if", "shakedown", ".", "cli", ".", "quiet", ":", "return", "if", "not", "'n'", "in", "kwargs", ":", "kwargs", "[", "'n'", "]", "=", "True", "if", "'d'", "in", "kwargs", ":", "text", "=",...
Print results to the console :param text: the text string to print :type text: str :return: a string :rtype: str
[ "Print", "results", "to", "the", "console" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/helpers.py#L153-L178
train
dcos/shakedown
shakedown/dcos/security.py
add_user
def add_user(uid, password, desc=None): """ Adds user to the DCOS Enterprise. If not description is provided the uid will be used for the description. :param uid: user id :type uid: str :param password: password :type password: str :param desc: description of user ...
python
def add_user(uid, password, desc=None): """ Adds user to the DCOS Enterprise. If not description is provided the uid will be used for the description. :param uid: user id :type uid: str :param password: password :type password: str :param desc: description of user ...
[ "def", "add_user", "(", "uid", ",", "password", ",", "desc", "=", "None", ")", ":", "try", ":", "desc", "=", "uid", "if", "desc", "is", "None", "else", "desc", "user_object", "=", "{", "\"description\"", ":", "desc", ",", "\"password\"", ":", "password...
Adds user to the DCOS Enterprise. If not description is provided the uid will be used for the description. :param uid: user id :type uid: str :param password: password :type password: str :param desc: description of user :type desc: str
[ "Adds", "user", "to", "the", "DCOS", "Enterprise", ".", "If", "not", "description", "is", "provided", "the", "uid", "will", "be", "used", "for", "the", "description", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L17-L37
train
dcos/shakedown
shakedown/dcos/security.py
get_user
def get_user(uid): """ Returns a user from the DCOS Enterprise. It returns None if none exists. :param uid: user id :type uid: str :return: User :rtype: dict """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.get(acl_url) return ...
python
def get_user(uid): """ Returns a user from the DCOS Enterprise. It returns None if none exists. :param uid: user id :type uid: str :return: User :rtype: dict """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.get(acl_url) return ...
[ "def", "get_user", "(", "uid", ")", ":", "try", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'users/{}'", ".", "format", "(", "uid", ")", ")", "r", "=", "http", ".", "get", "(", "acl_url", ")", "return", "r", ".", "json", "(",...
Returns a user from the DCOS Enterprise. It returns None if none exists. :param uid: user id :type uid: str :return: User :rtype: dict
[ "Returns", "a", "user", "from", "the", "DCOS", "Enterprise", ".", "It", "returns", "None", "if", "none", "exists", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L40-L57
train
dcos/shakedown
shakedown/dcos/security.py
remove_user
def remove_user(uid): """ Removes a user from the DCOS Enterprise. :param uid: user id :type uid: str """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.delete(acl_url) assert r.status_code == 204 except DCOSHTTPException as e: # does...
python
def remove_user(uid): """ Removes a user from the DCOS Enterprise. :param uid: user id :type uid: str """ try: acl_url = urljoin(_acl_url(), 'users/{}'.format(uid)) r = http.delete(acl_url) assert r.status_code == 204 except DCOSHTTPException as e: # does...
[ "def", "remove_user", "(", "uid", ")", ":", "try", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'users/{}'", ".", "format", "(", "uid", ")", ")", "r", "=", "http", ".", "delete", "(", "acl_url", ")", "assert", "r", ".", "status_...
Removes a user from the DCOS Enterprise. :param uid: user id :type uid: str
[ "Removes", "a", "user", "from", "the", "DCOS", "Enterprise", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L60-L73
train
dcos/shakedown
shakedown/dcos/security.py
remove_user_permission
def remove_user_permission(rid, uid, action='full'): """ Removes user permission on a given resource. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full :type action: str """ rid = rid....
python
def remove_user_permission(rid, uid, action='full'): """ Removes user permission on a given resource. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full :type action: str """ rid = rid....
[ "def", "remove_user_permission", "(", "rid", ",", "uid", ",", "action", "=", "'full'", ")", ":", "rid", "=", "rid", ".", "replace", "(", "'/'", ",", "'%252F'", ")", "try", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'acls/{}/users/...
Removes user permission on a given resource. :param uid: user id :type uid: str :param rid: resource ID :type rid: str :param action: read, write, update, delete or full :type action: str
[ "Removes", "user", "permission", "on", "a", "given", "resource", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L117-L135
train
dcos/shakedown
shakedown/dcos/security.py
no_user
def no_user(): """ Provides a context with no logged in user. """ o_token = dcos_acs_token() dcos.config.set_val('core.dcos_acs_token', '') yield dcos.config.set_val('core.dcos_acs_token', o_token)
python
def no_user(): """ Provides a context with no logged in user. """ o_token = dcos_acs_token() dcos.config.set_val('core.dcos_acs_token', '') yield dcos.config.set_val('core.dcos_acs_token', o_token)
[ "def", "no_user", "(", ")", ":", "o_token", "=", "dcos_acs_token", "(", ")", "dcos", ".", "config", ".", "set_val", "(", "'core.dcos_acs_token'", ",", "''", ")", "yield", "dcos", ".", "config", ".", "set_val", "(", "'core.dcos_acs_token'", ",", "o_token", ...
Provides a context with no logged in user.
[ "Provides", "a", "context", "with", "no", "logged", "in", "user", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L139-L145
train
dcos/shakedown
shakedown/dcos/security.py
new_dcos_user
def new_dcos_user(user_id, password): """ Provides a context with a newly created user. """ o_token = dcos_acs_token() shakedown.add_user(user_id, password, user_id) token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set...
python
def new_dcos_user(user_id, password): """ Provides a context with a newly created user. """ o_token = dcos_acs_token() shakedown.add_user(user_id, password, user_id) token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set...
[ "def", "new_dcos_user", "(", "user_id", ",", "password", ")", ":", "o_token", "=", "dcos_acs_token", "(", ")", "shakedown", ".", "add_user", "(", "user_id", ",", "password", ",", "user_id", ")", "token", "=", "shakedown", ".", "authenticate", "(", "user_id",...
Provides a context with a newly created user.
[ "Provides", "a", "context", "with", "a", "newly", "created", "user", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L149-L159
train
dcos/shakedown
shakedown/dcos/security.py
dcos_user
def dcos_user(user_id, password): """ Provides a context with user otherthan super """ o_token = dcos_acs_token() token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set_val('core.dcos_acs_token', o_token)
python
def dcos_user(user_id, password): """ Provides a context with user otherthan super """ o_token = dcos_acs_token() token = shakedown.authenticate(user_id, password) dcos.config.set_val('core.dcos_acs_token', token) yield dcos.config.set_val('core.dcos_acs_token', o_token)
[ "def", "dcos_user", "(", "user_id", ",", "password", ")", ":", "o_token", "=", "dcos_acs_token", "(", ")", "token", "=", "shakedown", ".", "authenticate", "(", "user_id", ",", "password", ")", "dcos", ".", "config", ".", "set_val", "(", "'core.dcos_acs_token...
Provides a context with user otherthan super
[ "Provides", "a", "context", "with", "user", "otherthan", "super" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L163-L172
train
dcos/shakedown
shakedown/dcos/security.py
add_group
def add_group(id, description=None): """ Adds group to the DCOS Enterprise. If not description is provided the id will be used for the description. :param id: group id :type id: str :param desc: description of user :type desc: str """ if not description: de...
python
def add_group(id, description=None): """ Adds group to the DCOS Enterprise. If not description is provided the id will be used for the description. :param id: group id :type id: str :param desc: description of user :type desc: str """ if not description: de...
[ "def", "add_group", "(", "id", ",", "description", "=", "None", ")", ":", "if", "not", "description", ":", "description", "=", "id", "data", "=", "{", "'description'", ":", "description", "}", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", ...
Adds group to the DCOS Enterprise. If not description is provided the id will be used for the description. :param id: group id :type id: str :param desc: description of user :type desc: str
[ "Adds", "group", "to", "the", "DCOS", "Enterprise", ".", "If", "not", "description", "is", "provided", "the", "id", "will", "be", "used", "for", "the", "description", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L175-L196
train
dcos/shakedown
shakedown/dcos/security.py
get_group
def get_group(id): """ Returns a group from the DCOS Enterprise. It returns None if none exists. :param id: group id :type id: str :return: Group :rtype: dict """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.get(acl_url) return r.j...
python
def get_group(id): """ Returns a group from the DCOS Enterprise. It returns None if none exists. :param id: group id :type id: str :return: Group :rtype: dict """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.get(acl_url) return r.j...
[ "def", "get_group", "(", "id", ")", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'groups/{}'", ".", "format", "(", "id", ")", ")", "try", ":", "r", "=", "http", ".", "get", "(", "acl_url", ")", "return", "r", ".", "json", "(",...
Returns a group from the DCOS Enterprise. It returns None if none exists. :param id: group id :type id: str :return: Group :rtype: dict
[ "Returns", "a", "group", "from", "the", "DCOS", "Enterprise", ".", "It", "returns", "None", "if", "none", "exists", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L199-L213
train
dcos/shakedown
shakedown/dcos/security.py
remove_group
def remove_group(id): """ Removes a group from the DCOS Enterprise. The group is removed regardless of associated users. :param id: group id :type id: str """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.delete(acl_url) print(r.status_code...
python
def remove_group(id): """ Removes a group from the DCOS Enterprise. The group is removed regardless of associated users. :param id: group id :type id: str """ acl_url = urljoin(_acl_url(), 'groups/{}'.format(id)) try: r = http.delete(acl_url) print(r.status_code...
[ "def", "remove_group", "(", "id", ")", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'groups/{}'", ".", "format", "(", "id", ")", ")", "try", ":", "r", "=", "http", ".", "delete", "(", "acl_url", ")", "print", "(", "r", ".", "s...
Removes a group from the DCOS Enterprise. The group is removed regardless of associated users. :param id: group id :type id: str
[ "Removes", "a", "group", "from", "the", "DCOS", "Enterprise", ".", "The", "group", "is", "removed", "regardless", "of", "associated", "users", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L216-L229
train
dcos/shakedown
shakedown/dcos/security.py
add_user_to_group
def add_user_to_group(uid, gid, exist_ok=True): """ Adds a user to a group within DCOS Enterprise. The group and user must exist. :param uid: user id :type uid: str :param gid: group id :type gid: str :param exist_ok: True if it is ok for the relationship to pre-exi...
python
def add_user_to_group(uid, gid, exist_ok=True): """ Adds a user to a group within DCOS Enterprise. The group and user must exist. :param uid: user id :type uid: str :param gid: group id :type gid: str :param exist_ok: True if it is ok for the relationship to pre-exi...
[ "def", "add_user_to_group", "(", "uid", ",", "gid", ",", "exist_ok", "=", "True", ")", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'groups/{}/users/{}'", ".", "format", "(", "gid", ",", "uid", ")", ")", "try", ":", "r", "=", "htt...
Adds a user to a group within DCOS Enterprise. The group and user must exist. :param uid: user id :type uid: str :param gid: group id :type gid: str :param exist_ok: True if it is ok for the relationship to pre-exist. :type exist_ok: bool
[ "Adds", "a", "user", "to", "a", "group", "within", "DCOS", "Enterprise", ".", "The", "group", "and", "user", "must", "exist", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L232-L251
train
dcos/shakedown
shakedown/dcos/security.py
remove_user_from_group
def remove_user_from_group(uid, gid): """ Removes a user from a group within DCOS Enterprise. :param uid: user id :type uid: str :param gid: group id :type gid: str """ acl_url = urljoin(_acl_url(), 'groups/{}/users/{}'.format(gid, uid)) try: r = http.delete(acl_...
python
def remove_user_from_group(uid, gid): """ Removes a user from a group within DCOS Enterprise. :param uid: user id :type uid: str :param gid: group id :type gid: str """ acl_url = urljoin(_acl_url(), 'groups/{}/users/{}'.format(gid, uid)) try: r = http.delete(acl_...
[ "def", "remove_user_from_group", "(", "uid", ",", "gid", ")", ":", "acl_url", "=", "urljoin", "(", "_acl_url", "(", ")", ",", "'groups/{}/users/{}'", ".", "format", "(", "gid", ",", "uid", ")", ")", "try", ":", "r", "=", "http", ".", "delete", "(", "...
Removes a user from a group within DCOS Enterprise. :param uid: user id :type uid: str :param gid: group id :type gid: str
[ "Removes", "a", "user", "from", "a", "group", "within", "DCOS", "Enterprise", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/security.py#L254-L267
train
openstax/cnx-easybake
cnxeasybake/scripts/main.py
easybake
def easybake(css_in, html_in=sys.stdin, html_out=sys.stdout, last_step=None, coverage_file=None, use_repeatable_ids=False): """Process the given HTML file stream with the css stream.""" html_doc = etree.parse(html_in) oven = Oven(css_in, use_repeatable_ids) oven.bake(html_doc, last_step) ...
python
def easybake(css_in, html_in=sys.stdin, html_out=sys.stdout, last_step=None, coverage_file=None, use_repeatable_ids=False): """Process the given HTML file stream with the css stream.""" html_doc = etree.parse(html_in) oven = Oven(css_in, use_repeatable_ids) oven.bake(html_doc, last_step) ...
[ "def", "easybake", "(", "css_in", ",", "html_in", "=", "sys", ".", "stdin", ",", "html_out", "=", "sys", ".", "stdout", ",", "last_step", "=", "None", ",", "coverage_file", "=", "None", ",", "use_repeatable_ids", "=", "False", ")", ":", "html_doc", "=", ...
Process the given HTML file stream with the css stream.
[ "Process", "the", "given", "HTML", "file", "stream", "with", "the", "css", "stream", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/scripts/main.py#L15-L30
train
openstax/cnx-easybake
cnxeasybake/scripts/main.py
main
def main(argv=None): """Commandline script wrapping Baker.""" parser = argparse.ArgumentParser(description="Process raw HTML to baked" " (embedded numbering and" " collation)") parser.add_argument('-v', '--vers...
python
def main(argv=None): """Commandline script wrapping Baker.""" parser = argparse.ArgumentParser(description="Process raw HTML to baked" " (embedded numbering and" " collation)") parser.add_argument('-v', '--vers...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Process raw HTML to baked\"", "\" (embedded numbering and\"", "\" collation)\"", ")", "parser", ".", "add_argument", "(", "'-v'", ",", ...
Commandline script wrapping Baker.
[ "Commandline", "script", "wrapping", "Baker", "." ]
f8edf018fb7499f6f18af0145c326b93a737a782
https://github.com/openstax/cnx-easybake/blob/f8edf018fb7499f6f18af0145c326b93a737a782/cnxeasybake/scripts/main.py#L44-L99
train
dcos/shakedown
shakedown/dcos/marathon.py
mom_version
def mom_version(name='marathon-user'): """Returns the version of marathon on marathon. """ if service_available_predicate(name): with marathon_on_marathon(name): return marathon_version() else: # We can either skip the corresponding test by returning False # or ra...
python
def mom_version(name='marathon-user'): """Returns the version of marathon on marathon. """ if service_available_predicate(name): with marathon_on_marathon(name): return marathon_version() else: # We can either skip the corresponding test by returning False # or ra...
[ "def", "mom_version", "(", "name", "=", "'marathon-user'", ")", ":", "if", "service_available_predicate", "(", "name", ")", ":", "with", "marathon_on_marathon", "(", "name", ")", ":", "return", "marathon_version", "(", ")", "else", ":", "print", "(", "'WARN: {...
Returns the version of marathon on marathon.
[ "Returns", "the", "version", "of", "marathon", "on", "marathon", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/marathon.py#L33-L43
train
dcos/shakedown
shakedown/dcos/helpers.py
get_transport
def get_transport(host, username, key): """ Create a transport object :param host: the hostname to connect to :type host: str :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return:...
python
def get_transport(host, username, key): """ Create a transport object :param host: the hostname to connect to :type host: str :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return:...
[ "def", "get_transport", "(", "host", ",", "username", ",", "key", ")", ":", "if", "host", "==", "shakedown", ".", "master_ip", "(", ")", ":", "transport", "=", "paramiko", ".", "Transport", "(", "host", ")", "else", ":", "transport_master", "=", "paramik...
Create a transport object :param host: the hostname to connect to :type host: str :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return: a transport object :rtype: paramiko.Tra...
[ "Create", "a", "transport", "object" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/helpers.py#L11-L43
train
dcos/shakedown
shakedown/dcos/helpers.py
start_transport
def start_transport(transport, username, key): """ Begin a transport client and authenticate it :param transport: the transport object to start :type transport: paramiko.Transport :param username: SSH username :type username: str :param key: key object used for authenticatio...
python
def start_transport(transport, username, key): """ Begin a transport client and authenticate it :param transport: the transport object to start :type transport: paramiko.Transport :param username: SSH username :type username: str :param key: key object used for authenticatio...
[ "def", "start_transport", "(", "transport", ",", "username", ",", "key", ")", ":", "transport", ".", "start_client", "(", ")", "agent", "=", "paramiko", ".", "agent", ".", "Agent", "(", ")", "keys", "=", "itertools", ".", "chain", "(", "(", "key", ",",...
Begin a transport client and authenticate it :param transport: the transport object to start :type transport: paramiko.Transport :param username: SSH username :type username: str :param key: key object used for authentication :type key: paramiko.RSAKey :return: ...
[ "Begin", "a", "transport", "client", "and", "authenticate", "it" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/helpers.py#L46-L73
train
dcos/shakedown
shakedown/dcos/helpers.py
validate_key
def validate_key(key_path): """ Validate a key :param key_path: path to a key to use for authentication :type key_path: str :return: key object used for authentication :rtype: paramiko.RSAKey """ key_path = os.path.expanduser(key_path) if not os.path.isfile(key_path):...
python
def validate_key(key_path): """ Validate a key :param key_path: path to a key to use for authentication :type key_path: str :return: key object used for authentication :rtype: paramiko.RSAKey """ key_path = os.path.expanduser(key_path) if not os.path.isfile(key_path):...
[ "def", "validate_key", "(", "key_path", ")", ":", "key_path", "=", "os", ".", "path", ".", "expanduser", "(", "key_path", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "key_path", ")", ":", "return", "False", "return", "paramiko", ".", "RSAK...
Validate a key :param key_path: path to a key to use for authentication :type key_path: str :return: key object used for authentication :rtype: paramiko.RSAKey
[ "Validate", "a", "key" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/helpers.py#L86-L101
train
dcos/shakedown
shakedown/dcos/service.py
get_marathon_task
def get_marathon_task( task_name, inactive=False, completed=False ): """ Get a dictionary describing a named marathon task """ return get_service_task('marathon', task_name, inactive, completed)
python
def get_marathon_task( task_name, inactive=False, completed=False ): """ Get a dictionary describing a named marathon task """ return get_service_task('marathon', task_name, inactive, completed)
[ "def", "get_marathon_task", "(", "task_name", ",", "inactive", "=", "False", ",", "completed", "=", "False", ")", ":", "return", "get_service_task", "(", "'marathon'", ",", "task_name", ",", "inactive", ",", "completed", ")" ]
Get a dictionary describing a named marathon task
[ "Get", "a", "dictionary", "describing", "a", "named", "marathon", "task" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L161-L169
train
dcos/shakedown
shakedown/dcos/service.py
get_mesos_task
def get_mesos_task(task_name): """ Get a mesos task with a specific task name """ tasks = get_mesos_tasks() if tasks is not None: for task in tasks: if task['name'] == task_name: return task return None
python
def get_mesos_task(task_name): """ Get a mesos task with a specific task name """ tasks = get_mesos_tasks() if tasks is not None: for task in tasks: if task['name'] == task_name: return task return None
[ "def", "get_mesos_task", "(", "task_name", ")", ":", "tasks", "=", "get_mesos_tasks", "(", ")", "if", "tasks", "is", "not", "None", ":", "for", "task", "in", "tasks", ":", "if", "task", "[", "'name'", "]", "==", "task_name", ":", "return", "task", "ret...
Get a mesos task with a specific task name
[ "Get", "a", "mesos", "task", "with", "a", "specific", "task", "name" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L172-L181
train
dcos/shakedown
shakedown/dcos/service.py
service_healthy
def service_healthy(service_name, app_id=None): """ Check whether a named service is healthy :param service_name: the service name :type service_name: str :param app_id: app_id to filter :type app_id: str :return: True if healthy, False otherwise :rtype: bool ""...
python
def service_healthy(service_name, app_id=None): """ Check whether a named service is healthy :param service_name: the service name :type service_name: str :param app_id: app_id to filter :type app_id: str :return: True if healthy, False otherwise :rtype: bool ""...
[ "def", "service_healthy", "(", "service_name", ",", "app_id", "=", "None", ")", ":", "marathon_client", "=", "marathon", ".", "create_client", "(", ")", "apps", "=", "marathon_client", ".", "get_apps_for_framework", "(", "service_name", ")", "if", "apps", ":", ...
Check whether a named service is healthy :param service_name: the service name :type service_name: str :param app_id: app_id to filter :type app_id: str :return: True if healthy, False otherwise :rtype: bool
[ "Check", "whether", "a", "named", "service", "is", "healthy" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L221-L247
train
dcos/shakedown
shakedown/dcos/service.py
delete_persistent_data
def delete_persistent_data(role, zk_node): """ Deletes any persistent data associated with the specified role, and zk node. :param role: the mesos role to delete, or None to omit this :type role: str :param zk_node: the zookeeper node to be deleted, or None to skip this deletion :ty...
python
def delete_persistent_data(role, zk_node): """ Deletes any persistent data associated with the specified role, and zk node. :param role: the mesos role to delete, or None to omit this :type role: str :param zk_node: the zookeeper node to be deleted, or None to skip this deletion :ty...
[ "def", "delete_persistent_data", "(", "role", ",", "zk_node", ")", ":", "if", "role", ":", "destroy_volumes", "(", "role", ")", "unreserve_resources", "(", "role", ")", "if", "zk_node", ":", "delete_zk_node", "(", "zk_node", ")" ]
Deletes any persistent data associated with the specified role, and zk node. :param role: the mesos role to delete, or None to omit this :type role: str :param zk_node: the zookeeper node to be deleted, or None to skip this deletion :type zk_node: str
[ "Deletes", "any", "persistent", "data", "associated", "with", "the", "specified", "role", "and", "zk", "node", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L266-L279
train
dcos/shakedown
shakedown/dcos/service.py
destroy_volumes
def destroy_volumes(role): """ Destroys all volumes on all the slaves in the cluster for the role. """ state = dcos_agents_state() if not state or 'slaves' not in state.keys(): return False all_success = True for agent in state['slaves']: if not destroy_volume(agent, role): ...
python
def destroy_volumes(role): """ Destroys all volumes on all the slaves in the cluster for the role. """ state = dcos_agents_state() if not state or 'slaves' not in state.keys(): return False all_success = True for agent in state['slaves']: if not destroy_volume(agent, role): ...
[ "def", "destroy_volumes", "(", "role", ")", ":", "state", "=", "dcos_agents_state", "(", ")", "if", "not", "state", "or", "'slaves'", "not", "in", "state", ".", "keys", "(", ")", ":", "return", "False", "all_success", "=", "True", "for", "agent", "in", ...
Destroys all volumes on all the slaves in the cluster for the role.
[ "Destroys", "all", "volumes", "on", "all", "the", "slaves", "in", "the", "cluster", "for", "the", "role", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L282-L292
train
dcos/shakedown
shakedown/dcos/service.py
destroy_volume
def destroy_volume(agent, role): """ Deletes the volumes on the specific agent for the role """ volumes = [] agent_id = agent['id'] reserved_resources_full = agent.get('reserved_resources_full', None) if not reserved_resources_full: # doesn't exist return True reserved_reso...
python
def destroy_volume(agent, role): """ Deletes the volumes on the specific agent for the role """ volumes = [] agent_id = agent['id'] reserved_resources_full = agent.get('reserved_resources_full', None) if not reserved_resources_full: # doesn't exist return True reserved_reso...
[ "def", "destroy_volume", "(", "agent", ",", "role", ")", ":", "volumes", "=", "[", "]", "agent_id", "=", "agent", "[", "'id'", "]", "reserved_resources_full", "=", "agent", ".", "get", "(", "'reserved_resources_full'", ",", "None", ")", "if", "not", "reser...
Deletes the volumes on the specific agent for the role
[ "Deletes", "the", "volumes", "on", "the", "specific", "agent", "for", "the", "role" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L295-L337
train
dcos/shakedown
shakedown/dcos/service.py
unreserve_resources
def unreserve_resources(role): """ Unreserves all the resources for all the slaves for the role. """ state = dcos_agents_state() if not state or 'slaves' not in state.keys(): return False all_success = True for agent in state['slaves']: if not unreserve_resource(agent, role): ...
python
def unreserve_resources(role): """ Unreserves all the resources for all the slaves for the role. """ state = dcos_agents_state() if not state or 'slaves' not in state.keys(): return False all_success = True for agent in state['slaves']: if not unreserve_resource(agent, role): ...
[ "def", "unreserve_resources", "(", "role", ")", ":", "state", "=", "dcos_agents_state", "(", ")", "if", "not", "state", "or", "'slaves'", "not", "in", "state", ".", "keys", "(", ")", ":", "return", "False", "all_success", "=", "True", "for", "agent", "in...
Unreserves all the resources for all the slaves for the role.
[ "Unreserves", "all", "the", "resources", "for", "all", "the", "slaves", "for", "the", "role", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L340-L350
train
dcos/shakedown
shakedown/dcos/service.py
wait_for_service_endpoint
def wait_for_service_endpoint(service_name, timeout_sec=120): """Checks the service url if available it returns true, on expiration it returns false""" master_count = len(get_all_masters()) return time_wait(lambda: service_available_predicate(service_name), timeout_seconds=timeout_...
python
def wait_for_service_endpoint(service_name, timeout_sec=120): """Checks the service url if available it returns true, on expiration it returns false""" master_count = len(get_all_masters()) return time_wait(lambda: service_available_predicate(service_name), timeout_seconds=timeout_...
[ "def", "wait_for_service_endpoint", "(", "service_name", ",", "timeout_sec", "=", "120", ")", ":", "master_count", "=", "len", "(", "get_all_masters", "(", ")", ")", "return", "time_wait", "(", "lambda", ":", "service_available_predicate", "(", "service_name", ")"...
Checks the service url if available it returns true, on expiration it returns false
[ "Checks", "the", "service", "url", "if", "available", "it", "returns", "true", "on", "expiration", "it", "returns", "false" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L410-L417
train
dcos/shakedown
shakedown/dcos/service.py
task_states_predicate
def task_states_predicate(service_name, expected_task_count, expected_task_states): """ Returns whether the provided service_names's tasks have expected_task_count tasks in any of expected_task_states. For example, if service 'foo' has 5 tasks which are TASK_STAGING or TASK_RUNNING. :param ...
python
def task_states_predicate(service_name, expected_task_count, expected_task_states): """ Returns whether the provided service_names's tasks have expected_task_count tasks in any of expected_task_states. For example, if service 'foo' has 5 tasks which are TASK_STAGING or TASK_RUNNING. :param ...
[ "def", "task_states_predicate", "(", "service_name", ",", "expected_task_count", ",", "expected_task_states", ")", ":", "try", ":", "tasks", "=", "get_service_tasks", "(", "service_name", ")", "except", "(", "DCOSConnectionError", ",", "DCOSHTTPException", ")", ":", ...
Returns whether the provided service_names's tasks have expected_task_count tasks in any of expected_task_states. For example, if service 'foo' has 5 tasks which are TASK_STAGING or TASK_RUNNING. :param service_name: the service name :type service_name: str :param expected_task_...
[ "Returns", "whether", "the", "provided", "service_names", "s", "tasks", "have", "expected_task_count", "tasks", "in", "any", "of", "expected_task_states", ".", "For", "example", "if", "service", "foo", "has", "5", "tasks", "which", "are", "TASK_STAGING", "or", "...
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L427-L459
train
dcos/shakedown
shakedown/dcos/service.py
tasks_all_replaced_predicate
def tasks_all_replaced_predicate( service_name, old_task_ids, task_predicate=None ): """ Returns whether ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids...
python
def tasks_all_replaced_predicate( service_name, old_task_ids, task_predicate=None ): """ Returns whether ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids...
[ "def", "tasks_all_replaced_predicate", "(", "service_name", ",", "old_task_ids", ",", "task_predicate", "=", "None", ")", ":", "try", ":", "task_ids", "=", "get_service_task_ids", "(", "service_name", ",", "task_predicate", ")", "except", "DCOSHTTPException", ":", "...
Returns whether ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by get_service_task_ids :type old_task_ids: [str] :param task_predicate: filter to use w...
[ "Returns", "whether", "ALL", "of", "old_task_ids", "have", "been", "replaced", "with", "new", "tasks" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L507-L537
train
dcos/shakedown
shakedown/dcos/service.py
tasks_missing_predicate
def tasks_missing_predicate( service_name, old_task_ids, task_predicate=None ): """ Returns whether any of old_task_ids are no longer present :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by g...
python
def tasks_missing_predicate( service_name, old_task_ids, task_predicate=None ): """ Returns whether any of old_task_ids are no longer present :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by g...
[ "def", "tasks_missing_predicate", "(", "service_name", ",", "old_task_ids", ",", "task_predicate", "=", "None", ")", ":", "try", ":", "task_ids", "=", "get_service_task_ids", "(", "service_name", ",", "task_predicate", ")", "except", "DCOSHTTPException", ":", "print...
Returns whether any of old_task_ids are no longer present :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by get_service_task_ids :type old_task_ids: [str] :param task_predicate: filter to use when searchin...
[ "Returns", "whether", "any", "of", "old_task_ids", "are", "no", "longer", "present" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L540-L568
train
dcos/shakedown
shakedown/dcos/service.py
wait_for_service_tasks_all_changed
def wait_for_service_tasks_all_changed( service_name, old_task_ids, task_predicate=None, timeout_sec=120 ): """ Returns once ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_id...
python
def wait_for_service_tasks_all_changed( service_name, old_task_ids, task_predicate=None, timeout_sec=120 ): """ Returns once ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_id...
[ "def", "wait_for_service_tasks_all_changed", "(", "service_name", ",", "old_task_ids", ",", "task_predicate", "=", "None", ",", "timeout_sec", "=", "120", ")", ":", "return", "time_wait", "(", "lambda", ":", "tasks_all_replaced_predicate", "(", "service_name", ",", ...
Returns once ALL of old_task_ids have been replaced with new tasks :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by get_service_task_ids :type old_task_ids: [str] :param task_predicate: filter to use when...
[ "Returns", "once", "ALL", "of", "old_task_ids", "have", "been", "replaced", "with", "new", "tasks" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L571-L593
train
dcos/shakedown
shakedown/dcos/service.py
wait_for_service_tasks_all_unchanged
def wait_for_service_tasks_all_unchanged( service_name, old_task_ids, task_predicate=None, timeout_sec=30 ): """ Returns after verifying that NONE of old_task_ids have been removed or replaced from the service :param service_name: the service name :type service_name:...
python
def wait_for_service_tasks_all_unchanged( service_name, old_task_ids, task_predicate=None, timeout_sec=30 ): """ Returns after verifying that NONE of old_task_ids have been removed or replaced from the service :param service_name: the service name :type service_name:...
[ "def", "wait_for_service_tasks_all_unchanged", "(", "service_name", ",", "old_task_ids", ",", "task_predicate", "=", "None", ",", "timeout_sec", "=", "30", ")", ":", "try", ":", "time_wait", "(", "lambda", ":", "tasks_missing_predicate", "(", "service_name", ",", ...
Returns after verifying that NONE of old_task_ids have been removed or replaced from the service :param service_name: the service name :type service_name: str :param old_task_ids: list of original task ids as returned by get_service_task_ids :type old_task_ids: [str] :param task...
[ "Returns", "after", "verifying", "that", "NONE", "of", "old_task_ids", "have", "been", "removed", "or", "replaced", "from", "the", "service" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/service.py#L596-L623
train
dcos/shakedown
shakedown/dcos/docker.py
distribute_docker_credentials_to_private_agents
def distribute_docker_credentials_to_private_agents( username, password, file_name='docker.tar.gz'): """ Create and distributes a docker credentials file to all private agents :param username: docker username :type username: str :param password: docker password ...
python
def distribute_docker_credentials_to_private_agents( username, password, file_name='docker.tar.gz'): """ Create and distributes a docker credentials file to all private agents :param username: docker username :type username: str :param password: docker password ...
[ "def", "distribute_docker_credentials_to_private_agents", "(", "username", ",", "password", ",", "file_name", "=", "'docker.tar.gz'", ")", ":", "create_docker_credentials_file", "(", "username", ",", "password", ",", "file_name", ")", "try", ":", "__distribute_docker_cred...
Create and distributes a docker credentials file to all private agents :param username: docker username :type username: str :param password: docker password :type password: str :param file_name: credentials file name `docker.tar.gz` by default :type file_name: str
[ "Create", "and", "distributes", "a", "docker", "credentials", "file", "to", "all", "private", "agents" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/docker.py#L117-L136
train
dcos/shakedown
shakedown/dcos/docker.py
prefetch_docker_image_on_private_agents
def prefetch_docker_image_on_private_agents( image, timeout=timedelta(minutes=5).total_seconds()): """ Given a docker image. An app with the image is scale across the private agents to ensure that the image is prefetched to all nodes. :param image: docker image name :type im...
python
def prefetch_docker_image_on_private_agents( image, timeout=timedelta(minutes=5).total_seconds()): """ Given a docker image. An app with the image is scale across the private agents to ensure that the image is prefetched to all nodes. :param image: docker image name :type im...
[ "def", "prefetch_docker_image_on_private_agents", "(", "image", ",", "timeout", "=", "timedelta", "(", "minutes", "=", "5", ")", ".", "total_seconds", "(", ")", ")", ":", "agents", "=", "len", "(", "shakedown", ".", "get_private_agents", "(", ")", ")", "app"...
Given a docker image. An app with the image is scale across the private agents to ensure that the image is prefetched to all nodes. :param image: docker image name :type image: str :param timeout: timeout for deployment wait in secs (default: 5m) :type password: int
[ "Given", "a", "docker", "image", ".", "An", "app", "with", "the", "image", "is", "scale", "across", "the", "private", "agents", "to", "ensure", "that", "the", "image", "is", "prefetched", "to", "all", "nodes", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/docker.py#L139-L168
train
dcos/shakedown
shakedown/dcos/package.py
_get_options
def _get_options(options_file=None): """ Read in options_file as JSON. :param options_file: filename to return :type options_file: str :return: options as dictionary :rtype: dict """ if options_file is not None: with open(options_file, 'r') as opt_file: ...
python
def _get_options(options_file=None): """ Read in options_file as JSON. :param options_file: filename to return :type options_file: str :return: options as dictionary :rtype: dict """ if options_file is not None: with open(options_file, 'r') as opt_file: ...
[ "def", "_get_options", "(", "options_file", "=", "None", ")", ":", "if", "options_file", "is", "not", "None", ":", "with", "open", "(", "options_file", ",", "'r'", ")", "as", "opt_file", ":", "options", "=", "json", ".", "loads", "(", "opt_file", ".", ...
Read in options_file as JSON. :param options_file: filename to return :type options_file: str :return: options as dictionary :rtype: dict
[ "Read", "in", "options_file", "as", "JSON", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/package.py#L10-L25
train
dcos/shakedown
shakedown/dcos/package.py
package_installed
def package_installed(package_name, service_name=None): """ Check whether the package package_name is currently installed. :param package_name: package name :type package_name: str :param service_name: service_name :type service_name: str :return: True if installed, False o...
python
def package_installed(package_name, service_name=None): """ Check whether the package package_name is currently installed. :param package_name: package name :type package_name: str :param service_name: service_name :type service_name: str :return: True if installed, False o...
[ "def", "package_installed", "(", "package_name", ",", "service_name", "=", "None", ")", ":", "package_manager", "=", "_get_package_manager", "(", ")", "app_installed", "=", "len", "(", "package_manager", ".", "installed_apps", "(", "package_name", ",", "service_name...
Check whether the package package_name is currently installed. :param package_name: package name :type package_name: str :param service_name: service_name :type service_name: str :return: True if installed, False otherwise :rtype: bool
[ "Check", "whether", "the", "package", "package_name", "is", "currently", "installed", "." ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/package.py#L172-L194
train
dcos/shakedown
shakedown/dcos/package.py
add_package_repo
def add_package_repo( repo_name, repo_url, index=None, wait_for_package=None, expect_prev_version=None): """ Add a repository to the list of package sources :param repo_name: name of the repository to add :type repo_name: str :param repo_url: location...
python
def add_package_repo( repo_name, repo_url, index=None, wait_for_package=None, expect_prev_version=None): """ Add a repository to the list of package sources :param repo_name: name of the repository to add :type repo_name: str :param repo_url: location...
[ "def", "add_package_repo", "(", "repo_name", ",", "repo_url", ",", "index", "=", "None", ",", "wait_for_package", "=", "None", ",", "expect_prev_version", "=", "None", ")", ":", "package_manager", "=", "_get_package_manager", "(", ")", "if", "wait_for_package", ...
Add a repository to the list of package sources :param repo_name: name of the repository to add :type repo_name: str :param repo_url: location of the repository to add :type repo_url: str :param index: index (precedence) for this repository :type index: int :para...
[ "Add", "a", "repository", "to", "the", "list", "of", "package", "sources" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/package.py#L352-L383
train
dcos/shakedown
shakedown/dcos/package.py
remove_package_repo
def remove_package_repo(repo_name, wait_for_package=None): """ Remove a repository from the list of package sources :param repo_name: name of the repository to remove :type repo_name: str :param wait_for_package: the package whose version should change after the repo is removed :typ...
python
def remove_package_repo(repo_name, wait_for_package=None): """ Remove a repository from the list of package sources :param repo_name: name of the repository to remove :type repo_name: str :param wait_for_package: the package whose version should change after the repo is removed :typ...
[ "def", "remove_package_repo", "(", "repo_name", ",", "wait_for_package", "=", "None", ")", ":", "package_manager", "=", "_get_package_manager", "(", ")", "if", "wait_for_package", ":", "prev_version", "=", "package_manager", ".", "get_package_version", "(", "wait_for_...
Remove a repository from the list of package sources :param repo_name: name of the repository to remove :type repo_name: str :param wait_for_package: the package whose version should change after the repo is removed :type wait_for_package: str, or None :returns: True if success...
[ "Remove", "a", "repository", "from", "the", "list", "of", "package", "sources" ]
e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e
https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/package.py#L386-L408
train
makinacorpus/landez
landez/sources.py
TileDownloader.tile
def tile(self, z, x, y): """ Download the specified tile from `tiles_url` """ logger.debug(_("Download tile %s") % ((z, x, y),)) # Render each keyword in URL ({s}, {x}, {y}, {z}, {size} ... ) size = self.tilesize s = self.tiles_subdomains[(x + y) % len(self.tiles_...
python
def tile(self, z, x, y): """ Download the specified tile from `tiles_url` """ logger.debug(_("Download tile %s") % ((z, x, y),)) # Render each keyword in URL ({s}, {x}, {y}, {z}, {size} ... ) size = self.tilesize s = self.tiles_subdomains[(x + y) % len(self.tiles_...
[ "def", "tile", "(", "self", ",", "z", ",", "x", ",", "y", ")", ":", "logger", ".", "debug", "(", "_", "(", "\"Download tile %s\"", ")", "%", "(", "(", "z", ",", "x", ",", "y", ")", ",", ")", ")", "size", "=", "self", ".", "tilesize", "s", "...
Download the specified tile from `tiles_url`
[ "Download", "the", "specified", "tile", "from", "tiles_url" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L163-L192
train
makinacorpus/landez
landez/proj.py
GoogleProjection.project
def project(self, lng_lat): """ Returns the coordinates in meters from WGS84 """ (lng, lat) = lng_lat x = lng * DEG_TO_RAD lat = max(min(MAX_LATITUDE, lat), -MAX_LATITUDE) y = lat * DEG_TO_RAD y = log(tan((pi / 4) + (y / 2))) return (x*EARTH_RADIUS...
python
def project(self, lng_lat): """ Returns the coordinates in meters from WGS84 """ (lng, lat) = lng_lat x = lng * DEG_TO_RAD lat = max(min(MAX_LATITUDE, lat), -MAX_LATITUDE) y = lat * DEG_TO_RAD y = log(tan((pi / 4) + (y / 2))) return (x*EARTH_RADIUS...
[ "def", "project", "(", "self", ",", "lng_lat", ")", ":", "(", "lng", ",", "lat", ")", "=", "lng_lat", "x", "=", "lng", "*", "DEG_TO_RAD", "lat", "=", "max", "(", "min", "(", "MAX_LATITUDE", ",", "lat", ")", ",", "-", "MAX_LATITUDE", ")", "y", "="...
Returns the coordinates in meters from WGS84
[ "Returns", "the", "coordinates", "in", "meters", "from", "WGS84" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/proj.py#L84-L93
train
makinacorpus/landez
landez/tiles.py
TilesManager.add_filter
def add_filter(self, filter_): """ Add an image filter for post-processing """ assert has_pil, _("Cannot add filters without python PIL") self.cache.basename += filter_.basename self._filters.append(filter_)
python
def add_filter(self, filter_): """ Add an image filter for post-processing """ assert has_pil, _("Cannot add filters without python PIL") self.cache.basename += filter_.basename self._filters.append(filter_)
[ "def", "add_filter", "(", "self", ",", "filter_", ")", ":", "assert", "has_pil", ",", "_", "(", "\"Cannot add filters without python PIL\"", ")", "self", ".", "cache", ".", "basename", "+=", "filter_", ".", "basename", "self", ".", "_filters", ".", "append", ...
Add an image filter for post-processing
[ "Add", "an", "image", "filter", "for", "post", "-", "processing" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L158-L162
train
makinacorpus/landez
landez/tiles.py
TilesManager.grid
def grid(self, z_x_y): """ Return the UTFGrid content """ # sources.py -> MapnikRenderer -> grid (z, x, y) = z_x_y content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer) return content
python
def grid(self, z_x_y): """ Return the UTFGrid content """ # sources.py -> MapnikRenderer -> grid (z, x, y) = z_x_y content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer) return content
[ "def", "grid", "(", "self", ",", "z_x_y", ")", ":", "(", "z", ",", "x", ",", "y", ")", "=", "z_x_y", "content", "=", "self", ".", "reader", ".", "grid", "(", "z", ",", "x", ",", "y", ",", "self", ".", "grid_fields", ",", "self", ".", "grid_la...
Return the UTFGrid content
[ "Return", "the", "UTFGrid", "content" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L188-L193
train
makinacorpus/landez
landez/tiles.py
TilesManager._blend_layers
def _blend_layers(self, imagecontent, z_x_y): """ Merge tiles of all layers into the specified tile path """ (z, x, y) = z_x_y result = self._tile_image(imagecontent) # Paste each layer for (layer, opacity) in self._layers: try: # Prepa...
python
def _blend_layers(self, imagecontent, z_x_y): """ Merge tiles of all layers into the specified tile path """ (z, x, y) = z_x_y result = self._tile_image(imagecontent) # Paste each layer for (layer, opacity) in self._layers: try: # Prepa...
[ "def", "_blend_layers", "(", "self", ",", "imagecontent", ",", "z_x_y", ")", ":", "(", "z", ",", "x", ",", "y", ")", "=", "z_x_y", "result", "=", "self", ".", "_tile_image", "(", "imagecontent", ")", "for", "(", "layer", ",", "opacity", ")", "in", ...
Merge tiles of all layers into the specified tile path
[ "Merge", "tiles", "of", "all", "layers", "into", "the", "specified", "tile", "path" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L196-L219
train
makinacorpus/landez
landez/tiles.py
TilesManager._tile_image
def _tile_image(self, data): """ Tile binary content as PIL Image. """ image = Image.open(BytesIO(data)) return image.convert('RGBA')
python
def _tile_image(self, data): """ Tile binary content as PIL Image. """ image = Image.open(BytesIO(data)) return image.convert('RGBA')
[ "def", "_tile_image", "(", "self", ",", "data", ")", ":", "image", "=", "Image", ".", "open", "(", "BytesIO", "(", "data", ")", ")", "return", "image", ".", "convert", "(", "'RGBA'", ")" ]
Tile binary content as PIL Image.
[ "Tile", "binary", "content", "as", "PIL", "Image", "." ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L221-L226
train
makinacorpus/landez
landez/tiles.py
MBTilesBuilder.zoomlevels
def zoomlevels(self): """ Return the list of covered zoom levels, in ascending order """ zooms = set() for coverage in self._bboxes: for zoom in coverage[1]: zooms.add(zoom) return sorted(zooms)
python
def zoomlevels(self): """ Return the list of covered zoom levels, in ascending order """ zooms = set() for coverage in self._bboxes: for zoom in coverage[1]: zooms.add(zoom) return sorted(zooms)
[ "def", "zoomlevels", "(", "self", ")", ":", "zooms", "=", "set", "(", ")", "for", "coverage", "in", "self", ".", "_bboxes", ":", "for", "zoom", "in", "coverage", "[", "1", "]", ":", "zooms", ".", "add", "(", "zoom", ")", "return", "sorted", "(", ...
Return the list of covered zoom levels, in ascending order
[ "Return", "the", "list", "of", "covered", "zoom", "levels", "in", "ascending", "order" ]
6e5c71ded6071158e7943df204cd7bd1ed623a30
https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L263-L271
train