repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
contentful/contentful-management.py
contentful_management/resource_builder.py
ResourceBuilder.build
def build(self): """ Creates the objects from the JSON response. """ if self.json['sys']['type'] == 'Array': return self._build_array() return self._build_item(self.json)
python
def build(self): """ Creates the objects from the JSON response. """ if self.json['sys']['type'] == 'Array': return self._build_array() return self._build_item(self.json)
[ "def", "build", "(", "self", ")", ":", "if", "self", ".", "json", "[", "'sys'", "]", "[", "'type'", "]", "==", "'Array'", ":", "return", "self", ".", "_build_array", "(", ")", "return", "self", ".", "_build_item", "(", "self", ".", "json", ")" ]
Creates the objects from the JSON response.
[ "Creates", "the", "objects", "from", "the", "JSON", "response", "." ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/resource_builder.py#L47-L54
train
contentful/contentful-management.py
contentful_management/content_type_resource_proxy.py
ContentTypeResourceProxy.create
def create(self, resource_id=None, attributes=None): """ Creates a resource with a given ID (optional) and attributes for the current content type. """ return self.proxy.create(resource_id=resource_id, attributes=attributes)
python
def create(self, resource_id=None, attributes=None): """ Creates a resource with a given ID (optional) and attributes for the current content type. """ return self.proxy.create(resource_id=resource_id, attributes=attributes)
[ "def", "create", "(", "self", ",", "resource_id", "=", "None", ",", "attributes", "=", "None", ")", ":", "return", "self", ".", "proxy", ".", "create", "(", "resource_id", "=", "resource_id", ",", "attributes", "=", "attributes", ")" ]
Creates a resource with a given ID (optional) and attributes for the current content type.
[ "Creates", "a", "resource", "with", "a", "given", "ID", "(", "optional", ")", "and", "attributes", "for", "the", "current", "content", "type", "." ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_resource_proxy.py#L43-L48
train
contentful/contentful-management.py
contentful_management/space_resource_proxy.py
SpaceResourceProxy.find
def find(self, resource_id, query=None): """ Finds a single resource by ID related to the current space. """ return self.proxy.find(resource_id, query=query)
python
def find(self, resource_id, query=None): """ Finds a single resource by ID related to the current space. """ return self.proxy.find(resource_id, query=query)
[ "def", "find", "(", "self", ",", "resource_id", ",", "query", "=", "None", ")", ":", "return", "self", ".", "proxy", ".", "find", "(", "resource_id", ",", "query", "=", "query", ")" ]
Finds a single resource by ID related to the current space.
[ "Finds", "a", "single", "resource", "by", "ID", "related", "to", "the", "current", "space", "." ]
707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/space_resource_proxy.py#L36-L41
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_ngroups
def get_ngroups(self, field=None): ''' Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_f...
python
def get_ngroups(self, field=None): ''' Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_f...
[ "def", "get_ngroups", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "if", "'ngroups'", "in", "self", ".", "data", "[", "'grouped'", "]", "[", "f...
Returns ngroups count if it was specified in the query, otherwise ValueError. If grouping on more than one field, provide the field argument to specify which count you are looking for.
[ "Returns", "ngroups", "count", "if", "it", "was", "specified", "in", "the", "query", "otherwise", "ValueError", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L77-L86
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_groups_count
def get_groups_count(self, field=None): ''' Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_field(field) if 'ma...
python
def get_groups_count(self, field=None): ''' Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for. ''' field = field if field else self._determine_group_field(field) if 'ma...
[ "def", "get_groups_count", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "if", "'matches'", "in", "self", ".", "data", "[", "'grouped'", "]", "[",...
Returns 'matches' from group response. If grouping on more than one field, provide the field argument to specify which count you are looking for.
[ "Returns", "matches", "from", "group", "response", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L89-L98
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_flat_groups
def get_flat_groups(self, field=None): ''' Flattens the group response and just returns a list of documents. ''' field = field if field else self._determine_group_field(field) temp_groups = self.data['grouped'][field]['groups'] return [y for x in temp_groups for y in x['d...
python
def get_flat_groups(self, field=None): ''' Flattens the group response and just returns a list of documents. ''' field = field if field else self._determine_group_field(field) temp_groups = self.data['grouped'][field]['groups'] return [y for x in temp_groups for y in x['d...
[ "def", "get_flat_groups", "(", "self", ",", "field", "=", "None", ")", ":", "field", "=", "field", "if", "field", "else", "self", ".", "_determine_group_field", "(", "field", ")", "temp_groups", "=", "self", ".", "data", "[", "'grouped'", "]", "[", "fiel...
Flattens the group response and just returns a list of documents.
[ "Flattens", "the", "group", "response", "and", "just", "returns", "a", "list", "of", "documents", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L101-L107
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facets
def get_facets(self): ''' Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_resul...
python
def get_facets(self): ''' Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_resul...
[ "def", "get_facets", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facets'", ")", ":", "self", ".", "facets", "=", "{", "}", "data", "=", "self", ".", "data", "if", "'facet_counts'", "in", "data", ".", "keys", "(", ")", "and", ...
Returns a dictionary of facets:: >>> res = solr.query('SolrClient_unittest',{ 'q':'product_name:Lorem', 'facet':True, 'facet.field':'facet_test', })... ... ... ... >>> res.get_results_count() 4 >>> r...
[ "Returns", "a", "dictionary", "of", "facets", "::" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L110-L138
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facets_ranges
def get_facets_ranges(self): ''' Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, ...
python
def get_facets_ranges(self): ''' Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, ...
[ "def", "get_facets_ranges", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facet_ranges'", ")", ":", "self", ".", "facet_ranges", "=", "{", "}", "data", "=", "self", ".", "data", "if", "'facet_counts'", "in", "data", ".", "keys", "(...
Returns query facet ranges :: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':True, 'facet.range':'price', 'facet.range.start':0, 'facet.range.end':100, 'facet.range.gap':10 }) ...
[ "Returns", "query", "facet", "ranges", "::" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L150-L179
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_pivot
def get_facet_pivot(self): ''' Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. The...
python
def get_facet_pivot(self): ''' Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. The...
[ "def", "get_facet_pivot", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'facet_pivot'", ")", ":", "self", ".", "facet_pivot", "=", "{", "}", "if", "'facet_counts'", "in", "self", ".", "data", ".", "keys", "(", ")", ":", "pivots", ...
Parses facet pivot response. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'fq':'price:[50 TO *]', 'facet':True, 'facet.pivot':'facet_test,price' #Note how there is no space between fields. They are just separated by commas }) ...
[ "Parses", "facet", "pivot", "response", ".", "Example", "::", ">>>", "res", "=", "solr", ".", "query", "(", "SolrClient_unittest", "{", "q", ":", "*", ":", "*", "fq", ":", "price", ":", "[", "50", "TO", "*", "]", "facet", ":", "True", "facet", ".",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L182-L207
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_field_values_as_list
def get_field_values_as_list(self,field): ''' :param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as...
python
def get_field_values_as_list(self,field): ''' :param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as...
[ "def", "get_field_values_as_list", "(", "self", ",", "field", ")", ":", "return", "[", "doc", "[", "field", "]", "for", "doc", "in", "self", ".", "docs", "if", "field", "in", "doc", "]" ]
:param str field: The name of the field for which to pull in values. Will parse the query results (must be ungrouped) and return all values of 'field' as a list. Note that these are not unique values. Example:: >>> r.get_field_values_as_list('product_name_exact') ['Mauris risus risus l...
[ ":", "param", "str", "field", ":", "The", "name", "of", "the", "field", "for", "which", "to", "pull", "in", "values", ".", "Will", "parse", "the", "query", "results", "(", "must", "be", "ungrouped", ")", "and", "return", "all", "values", "of", "field",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L222-L231
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_first_field_values_as_list
def get_first_field_values_as_list(self, field): ''' :param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value. ''' for doc in self.docs: if field in doc.keys(...
python
def get_first_field_values_as_list(self, field): ''' :param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value. ''' for doc in self.docs: if field in doc.keys(...
[ "def", "get_first_field_values_as_list", "(", "self", ",", "field", ")", ":", "for", "doc", "in", "self", ".", "docs", ":", "if", "field", "in", "doc", ".", "keys", "(", ")", ":", "return", "doc", "[", "field", "]", "raise", "SolrResponseError", "(", "...
:param str field: The name of the field for lookup. Goes through all documents returned looking for specified field. At first encounter will return the field's value.
[ ":", "param", "str", "field", ":", "The", "name", "of", "the", "field", "for", "lookup", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L270-L279
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_values_as_list
def get_facet_values_as_list(self, field): ''' :param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', ...
python
def get_facet_values_as_list(self, field): ''' :param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', ...
[ "def", "get_facet_values_as_list", "(", "self", ",", "field", ")", ":", "facets", "=", "self", ".", "get_facets", "(", ")", "out", "=", "[", "]", "if", "field", "in", "facets", ".", "keys", "(", ")", ":", "for", "facetfield", "in", "facets", "[", "fi...
:param str field: Name of facet field to retrieve values from. Returns facet values as list for a given field. Example:: >>> res = solr.query('SolrClient_unittest',{ 'q':'*:*', 'facet':'true', 'facet.field':'facet_test', }) >>...
[ ":", "param", "str", "field", ":", "Name", "of", "facet", "field", "to", "retrieve", "values", "from", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L281-L305
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_facet_keys_as_list
def get_facet_keys_as_list(self,field): ''' :param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', '...
python
def get_facet_keys_as_list(self,field): ''' :param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', '...
[ "def", "get_facet_keys_as_list", "(", "self", ",", "field", ")", ":", "facets", "=", "self", ".", "get_facets", "(", ")", "if", "facets", "==", "-", "1", ":", "return", "facets", "if", "field", "in", "facets", ".", "keys", "(", ")", ":", "return", "[...
:param str field: Name of facet field to retrieve keys from. Similar to get_facet_values_as_list but returns the list of keys as a list instead. Example:: >>> r.get_facet_keys_as_list('facet_test') ['Lorem', 'ipsum', 'amet,', 'dolor', 'sit']
[ ":", "param", "str", "field", ":", "Name", "of", "facet", "field", "to", "retrieve", "keys", "from", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L307-L322
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.json_facet
def json_facet(self, field=None): ''' EXPERIMENTAL Tried to kick back the json.fact output. ''' facets = self.data['facets'] if field is None: temp_fields = [x for x in facets.keys() if x != 'count'] if len(temp_fields) != 1: raise...
python
def json_facet(self, field=None): ''' EXPERIMENTAL Tried to kick back the json.fact output. ''' facets = self.data['facets'] if field is None: temp_fields = [x for x in facets.keys() if x != 'count'] if len(temp_fields) != 1: raise...
[ "def", "json_facet", "(", "self", ",", "field", "=", "None", ")", ":", "facets", "=", "self", ".", "data", "[", "'facets'", "]", "if", "field", "is", "None", ":", "temp_fields", "=", "[", "x", "for", "x", "in", "facets", ".", "keys", "(", ")", "i...
EXPERIMENTAL Tried to kick back the json.fact output.
[ "EXPERIMENTAL" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L331-L347
train
moonlitesolutions/SolrClient
SolrClient/solrresp.py
SolrResponse.get_jsonfacet_counts_as_dict
def get_jsonfacet_counts_as_dict(self, field, data=None): ''' EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, ...
python
def get_jsonfacet_counts_as_dict(self, field, data=None): ''' EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, ...
[ "def", "get_jsonfacet_counts_as_dict", "(", "self", ",", "field", ",", "data", "=", "None", ")", ":", "data", "=", "data", "if", "data", "else", "self", ".", "data", "[", "'facets'", "]", "if", "field", "not", "in", "data", ":", "raise", "ValueError", ...
EXPERIMENTAL Takes facets and returns then as a dictionary that is easier to work with, for example, if you are getting something this:: {'facets': {'count': 50, 'test': {'buckets': [{'count': 10, 'pr': {'buckets': [{'count': 2, 'unique': 1, 'val': 79}, ...
[ "EXPERIMENTAL", "Takes", "facets", "and", "returns", "then", "as", "a", "dictionary", "that", "is", "easier", "to", "work", "with", "for", "example", "if", "you", "are", "getting", "something", "this", "::" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L349-L394
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._gen_file_name
def _gen_file_name(self): ''' Generates a random file name based on self._output_filename_pattern for the output to do file. ''' date = datetime.datetime.now() dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date...
python
def _gen_file_name(self): ''' Generates a random file name based on self._output_filename_pattern for the output to do file. ''' date = datetime.datetime.now() dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date...
[ "def", "_gen_file_name", "(", "self", ")", ":", "date", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "dt", "=", "\"{}-{}-{}-{}-{}-{}-{}\"", ".", "format", "(", "str", "(", "date", ".", "year", ")", ",", "str", "(", "date", ".", "month", ")...
Generates a random file name based on self._output_filename_pattern for the output to do file.
[ "Generates", "a", "random", "file", "name", "based", "on", "self", ".", "_output_filename_pattern", "for", "the", "output", "to", "do", "file", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L74-L80
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.add
def add(self, item=None, finalize=False, callback=None): ''' Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely disc...
python
def add(self, item=None, finalize=False, callback=None): ''' Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely disc...
[ "def", "add", "(", "self", ",", "item", "=", "None", ",", "finalize", "=", "False", ",", "callback", "=", "None", ")", ":", "if", "item", ":", "if", "type", "(", "item", ")", "is", "list", ":", "check", "=", "list", "(", "set", "(", "[", "type"...
Takes a string, dictionary or list of items for adding to queue. To help troubleshoot it will output the updated buffer size, however when the content gets written it will output the file path of the new file. Generally this can be safely discarded. :param <dict,list> item: Item to add to the queue. If dict wi...
[ "Takes", "a", "string", "dictionary", "or", "list", "of", "items", "for", "adding", "to", "queue", ".", "To", "help", "troubleshoot", "it", "will", "output", "the", "updated", "buffer", "size", "however", "when", "the", "content", "gets", "written", "it", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L83-L104
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._lock
def _lock(self): ''' Locks, or returns False if already locked ''' if not self._is_locked(): with open(self._lck,'w') as fh: if self._devel: self.logger.debug("Locking") fh.write(str(os.getpid())) return True else: ...
python
def _lock(self): ''' Locks, or returns False if already locked ''' if not self._is_locked(): with open(self._lck,'w') as fh: if self._devel: self.logger.debug("Locking") fh.write(str(os.getpid())) return True else: ...
[ "def", "_lock", "(", "self", ")", ":", "if", "not", "self", ".", "_is_locked", "(", ")", ":", "with", "open", "(", "self", ".", "_lck", ",", "'w'", ")", "as", "fh", ":", "if", "self", ".", "_devel", ":", "self", ".", "logger", ".", "debug", "("...
Locks, or returns False if already locked
[ "Locks", "or", "returns", "False", "if", "already", "locked" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L167-L177
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._is_locked
def _is_locked(self): ''' Checks to see if we are already pulling items from the queue ''' if os.path.isfile(self._lck): try: import psutil except ImportError: return True #Lock file exists and no psutil #If psutil is im...
python
def _is_locked(self): ''' Checks to see if we are already pulling items from the queue ''' if os.path.isfile(self._lck): try: import psutil except ImportError: return True #Lock file exists and no psutil #If psutil is im...
[ "def", "_is_locked", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "_lck", ")", ":", "try", ":", "import", "psutil", "except", "ImportError", ":", "return", "True", "#Lock file exists and no psutil", "#If psutil is imported",...
Checks to see if we are already pulling items from the queue
[ "Checks", "to", "see", "if", "we", "are", "already", "pulling", "items", "from", "the", "queue" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L180-L194
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ._unlock
def _unlock(self): ''' Unlocks the index ''' if self._devel: self.logger.debug("Unlocking Index") if self._is_locked(): os.remove(self._lck) return True else: return True
python
def _unlock(self): ''' Unlocks the index ''' if self._devel: self.logger.debug("Unlocking Index") if self._is_locked(): os.remove(self._lck) return True else: return True
[ "def", "_unlock", "(", "self", ")", ":", "if", "self", ".", "_devel", ":", "self", ".", "logger", ".", "debug", "(", "\"Unlocking Index\"", ")", "if", "self", ".", "_is_locked", "(", ")", ":", "os", ".", "remove", "(", "self", ".", "_lck", ")", "re...
Unlocks the index
[ "Unlocks", "the", "index" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L197-L206
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_all_as_list
def get_all_as_list(self, dir='_todo_dir'): ''' Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, th...
python
def get_all_as_list(self, dir='_todo_dir'): ''' Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, th...
[ "def", "get_all_as_list", "(", "self", ",", "dir", "=", "'_todo_dir'", ")", ":", "dir", "=", "getattr", "(", "self", ",", "dir", ")", "list", "=", "[", "x", "for", "x", "in", "os", ".", "listdir", "(", "dir", ")", "if", "x", ".", "endswith", "(",...
Returns a list of the the full path to all items currently in the todo directory. The items will be listed in ascending order based on filesystem time. This will re-scan the directory on each execution. Do not use this to process items, this method should only be used for troubleshooting or something a...
[ "Returns", "a", "list", "of", "the", "the", "full", "path", "to", "all", "items", "currently", "in", "the", "todo", "directory", ".", "The", "items", "will", "be", "listed", "in", "ascending", "order", "based", "on", "filesystem", "time", ".", "This", "w...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L209-L220
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_todo_items
def get_todo_items(self, **kwargs): ''' Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the f...
python
def get_todo_items(self, **kwargs): ''' Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the f...
[ "def", "get_todo_items", "(", "self", ",", "*", "*", "kwargs", ")", ":", "def", "inner", "(", "self", ")", ":", "for", "item", "in", "self", ".", "get_all_as_list", "(", ")", ":", "yield", "item", "self", ".", "_unlock", "(", ")", "if", "not", "sel...
Returns an iterator that will provide each item in the todo queue. Note that to complete each item you have to run complete method with the output of this iterator. That will move the item to the done directory and prevent it from being retrieved in the future.
[ "Returns", "an", "iterator", "that", "will", "provide", "each", "item", "in", "the", "todo", "queue", ".", "Note", "that", "to", "complete", "each", "item", "you", "have", "to", "run", "complete", "method", "with", "the", "output", "of", "this", "iterator"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L223-L237
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.complete
def complete(self, filepath): ''' Marks the item as complete by moving it to the done directory and optionally gzipping it. ''' if not os.path.exists(filepath): raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath)) if self._devel: self.logger...
python
def complete(self, filepath): ''' Marks the item as complete by moving it to the done directory and optionally gzipping it. ''' if not os.path.exists(filepath): raise FileNotFoundError("Can't Complete {}, it doesn't exist".format(filepath)) if self._devel: self.logger...
[ "def", "complete", "(", "self", ",", "filepath", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filepath", ")", ":", "raise", "FileNotFoundError", "(", "\"Can't Complete {}, it doesn't exist\"", ".", "format", "(", "filepath", ")", ")", "if",...
Marks the item as complete by moving it to the done directory and optionally gzipping it.
[ "Marks", "the", "item", "as", "complete", "by", "moving", "it", "to", "the", "done", "directory", "and", "optionally", "gzipping", "it", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L240-L279
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.index
def index(self, solr, collection, threads=1, send_method='stream_file', **kwargs): ''' Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Exampl...
python
def index(self, solr, collection, threads=1, send_method='stream_file', **kwargs): ''' Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Exampl...
[ "def", "index", "(", "self", ",", "solr", ",", "collection", ",", "threads", "=", "1", ",", "send_method", "=", "'stream_file'", ",", "*", "*", "kwargs", ")", ":", "try", ":", "method", "=", "getattr", "(", "solr", ",", "send_method", ")", "except", ...
Will index the queue into a specified solr instance and collection. Specify multiple threads to make this faster, however keep in mind that if you specify multiple threads the items may not be in order. Example:: solr = SolrClient('http://localhost:8983/solr/') for doc in self.docs: ...
[ "Will", "index", "the", "queue", "into", "a", "specified", "solr", "instance", "and", "collection", ".", "Specify", "multiple", "threads", "to", "make", "this", "faster", "however", "keep", "in", "mind", "that", "if", "you", "specify", "multiple", "threads", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L295-L336
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_all_json_from_indexq
def get_all_json_from_indexq(self): ''' Gets all data from the todo files in indexq and returns one huge list of all data. ''' files = self.get_all_as_list() out = [] for efile in files: out.extend(self._open_file(efile)) return out
python
def get_all_json_from_indexq(self): ''' Gets all data from the todo files in indexq and returns one huge list of all data. ''' files = self.get_all_as_list() out = [] for efile in files: out.extend(self._open_file(efile)) return out
[ "def", "get_all_json_from_indexq", "(", "self", ")", ":", "files", "=", "self", ".", "get_all_as_list", "(", ")", "out", "=", "[", "]", "for", "efile", "in", "files", ":", "out", ".", "extend", "(", "self", ".", "_open_file", "(", "efile", ")", ")", ...
Gets all data from the todo files in indexq and returns one huge list of all data.
[ "Gets", "all", "data", "from", "the", "todo", "files", "in", "indexq", "and", "returns", "one", "huge", "list", "of", "all", "data", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L389-L397
train
moonlitesolutions/SolrClient
SolrClient/indexq.py
IndexQ.get_multi_q
def get_multi_q(self, sentinel='STOP'): ''' This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will...
python
def get_multi_q(self, sentinel='STOP'): ''' This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will...
[ "def", "get_multi_q", "(", "self", ",", "sentinel", "=", "'STOP'", ")", ":", "self", ".", "in_q", "=", "JoinableQueue", "(", ")", "self", ".", "indexer_process", "=", "Process", "(", "target", "=", "self", ".", "_indexer_process", ",", "args", "=", "(", ...
This helps indexq operate in multiprocessing environment without each process having to have it's own IndexQ. It also is a handy way to deal with thread / process safety. This method will create and return a JoinableQueue object. Additionally, it will kick off a back end process that will monitor the queue, de...
[ "This", "helps", "indexq", "operate", "in", "multiprocessing", "environment", "without", "each", "process", "having", "to", "have", "it", "s", "own", "IndexQ", ".", "It", "also", "is", "a", "handy", "way", "to", "deal", "with", "thread", "/", "process", "s...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L408-L424
train
moonlitesolutions/SolrClient
SolrClient/transport/transportbase.py
TransportBase._retry
def _retry(function): """ Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one. """ def inner(self, **kwargs): last_exception = None #for host in self.router.get_hosts(**kwargs): for host in self.ho...
python
def _retry(function): """ Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one. """ def inner(self, **kwargs): last_exception = None #for host in self.router.get_hosts(**kwargs): for host in self.ho...
[ "def", "_retry", "(", "function", ")", ":", "def", "inner", "(", "self", ",", "*", "*", "kwargs", ")", ":", "last_exception", "=", "None", "#for host in self.router.get_hosts(**kwargs):", "for", "host", "in", "self", ".", "host", ":", "try", ":", "return", ...
Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one.
[ "Internal", "mechanism", "to", "try", "to", "send", "data", "to", "multiple", "Solr", "Hosts", "if", "the", "query", "fails", "on", "the", "first", "one", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/transport/transportbase.py#L28-L51
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.commit
def commit(self, collection, openSearcher=False, softCommit=False, waitSearcher=True, commit=True, **kwargs): """ :param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit ...
python
def commit(self, collection, openSearcher=False, softCommit=False, waitSearcher=True, commit=True, **kwargs): """ :param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit ...
[ "def", "commit", "(", "self", ",", "collection", ",", "openSearcher", "=", "False", ",", "softCommit", "=", "False", ",", "waitSearcher", "=", "True", ",", "commit", "=", "True", ",", "*", "*", "kwargs", ")", ":", "comm", "=", "{", "'openSearcher'", ":...
:param str collection: The name of the collection for the request :param bool openSearcher: If new searcher is to be opened :param bool softCommit: SoftCommit :param bool waitServer: Blocks until the new searcher is opened :param bool commit: Commit Sends a commit to a Solr coll...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "bool", "openSearcher", ":", "If", "new", "searcher", "is", "to", "be", "opened", ":", "param", "bool", "softCommit", ":", "SoftCommit"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L39-L64
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.query_raw
def query_raw(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends...
python
def query_raw(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends...
[ "def", "query_raw", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/x-www-form-urlencoded'", "}", "data", "=", "query", "resp", ...
:param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictionary of Solr query parameters. Sends a query to Solr, returns a dict. `query` should be a dictionary of solr request handler argumen...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "request_handler", ":", "Request", "handler", "default", "is", "select", ":", "param", "dict", "query", ":", "Python", "dictionary...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L66-L90
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.query
def query(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a qu...
python
def query(self, collection, query, request_handler='select', **kwargs): """ :param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a qu...
[ "def", "query", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "[", "'facet.pivot'", "]", ":", "if", "field", "in", "query", ".", "keys", "(", ")", ":", ...
:param str collection: The name of the collection for the request :param str request_handler: Request handler, default is 'select' :param dict query: Python dictonary of Solr query parameters. Sends a query to Solr, returns a SolrResults Object. `query` should be a dictionary of solr request ha...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "request_handler", ":", "Request", "handler", "default", "is", "select", ":", "param", "dict", "query", ":", "Python", "dictonary"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L92-L129
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.index
def index(self, collection, docs, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replica...
python
def index(self, collection, docs, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replica...
[ "def", "index", "(", "self", ",", "collection", ",", "docs", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "json", ".", "dumps", "(", "docs", ")", "return", "self", ".", "index_json", "(", ...
:param str collection: The name of the collection for the request. :param docs list docs: List of dicts. ex: [{"title": "testing solr indexing", "id": "test1"}] :param min_rf int min_rf: Required number of replicas to write to' Sends supplied list of dicts to solr for indexing. :: ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "docs", "list", "docs", ":", "List", "of", "dicts", ".", "ex", ":", "[", "{", "title", ":", "testing", "solr", "indexing", "...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L131-L144
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.index_json
def index_json(self, collection, data, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Requir...
python
def index_json(self, collection, data, params=None, min_rf=None, **kwargs): """ :param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Requir...
[ "def", "index_json", "(", "self", ",", "collection", ",", "data", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "resp", ",", "con_inf", "=", ...
:param str collection: The name of the collection for the request. :param data str data: Valid Solr JSON as a string. ex: '[{"title": "testing solr indexing", "id": "test1"}]' :param min_rf int min_rf: Required number of replicas to write to' Sends supplied json to solr for indexing, supplied J...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "data", "str", "data", ":", "Valid", "Solr", "JSON", "as", "a", "string", ".", "ex", ":", "[", "{", "title", ":", "testing",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L146-L175
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.get
def get(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') "...
python
def get(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') "...
[ "def", "get", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection", ...
:param str collection: The name of the collection for the request :param str doc_id: ID of the document to be retrieved. Retrieve document from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "doc_id", ":", "ID", "of", "the", "document", "to", "be", "retrieved", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L177-L194
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.mget
def mget(self, collection, doc_ids, **kwargs): """ :param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') ...
python
def mget(self, collection, doc_ids, **kwargs): """ :param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme') ...
[ "def", "mget", "(", "self", ",", "collection", ",", "doc_ids", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection",...
:param str collection: The name of the collection for the request :param tuple doc_ids: ID of the document to be retrieved. Retrieve documents from Solr based on the ID. :: >>> solr.get('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "tuple", "doc_ids", ":", "ID", "of", "the", "document", "to", "be", "retrieved", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L196-L213
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.delete_doc_by_id
def delete_doc_by_id(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete...
python
def delete_doc_by_id(self, collection, doc_id, **kwargs): """ :param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete...
[ "def", "delete_doc_by_id", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "if", "' '", "in", "doc_id", ":", "doc_id", "=", "'\"{}\"'", ".", "format", "(", "doc_id", ")", "temp", "=", "{", "\"delete\"", ":", "{", "\"...
:param str collection: The name of the collection for the request :param str id: ID of the document to be deleted. Can specify '*' to delete everything. Deletes items from Solr based on the ID. :: >>> solr.delete_doc_by_id('SolrClient_unittest','changeme')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "id", ":", "ID", "of", "the", "document", "to", "be", "deleted", ".", "Can", "specify", "*", "to", "delete", "everything", "...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L215-L233
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.delete_doc_by_query
def delete_doc_by_query(self, collection, query, **kwargs): """ :param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('Solr...
python
def delete_doc_by_query(self, collection, query, **kwargs): """ :param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('Solr...
[ "def", "delete_doc_by_query", "(", "self", ",", "collection", ",", "query", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "{", "\"delete\"", ":", "{", "\"query\"", ":", "query", "}", "}", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", ...
:param str collection: The name of the collection for the request :param str query: Query selecting documents to be deleted. Deletes items from Solr based on a given query. :: >>> solr.delete_doc_by_query('SolrClient_unittest','*:*')
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "query", ":", "Query", "selecting", "documents", "to", "be", "deleted", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L235-L251
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.local_index
def local_index(self, collection, filename, **kwargs): """ :param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other...
python
def local_index(self, collection, filename, **kwargs): """ :param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other...
[ "def", "local_index", "(", "self", ",", "collection", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "self", ".", "logger", ".", "info", "(", "\"Indexing {} into Solr Collection...
:param str collection: The name of the collection for the request :param str filename: String file path of the file to index. Will index specified file into Solr. The `file` must be local to the server, this is faster than other indexing options. If the files are already on the servers I sugges...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "filename", ":", "String", "file", "path", "of", "the", "file", "to", "index", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L276-L298
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.paging_query
def paging_query(self, collection, query, rows=1000, start=0, max_start=200000): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int...
python
def paging_query(self, collection, query, rows=1000, start=0, max_start=200000): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int...
[ "def", "paging_query", "(", "self", ",", "collection", ",", "query", ",", "rows", "=", "1000", ",", "start", "=", "0", ",", "max_start", "=", "200000", ")", ":", "query", "=", "dict", "(", "query", ")", "while", "True", ":", "query", "[", "'start'", ...
:param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. :param int rows: Number of rows to return in each batch. Default is 1000. :param int start: What position to start with. Default is 0. :param int max_start: Once the start will ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "dict", "query", ":", "Dictionary", "of", "solr", "args", ".", ":", "param", "int", "rows", ":", "Number", "of", "rows", "to",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L301-L328
train
moonlitesolutions/SolrClient
SolrClient/solrclient.py
SolrClient.cursor_query
def cursor_query(self, collection, query): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ ...
python
def cursor_query(self, collection, query): """ :param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ ...
[ "def", "cursor_query", "(", "self", ",", "collection", ",", "query", ")", ":", "cursor", "=", "'*'", "if", "'sort'", "not", "in", "query", ":", "query", "[", "'sort'", "]", "=", "'id desc'", "while", "True", ":", "query", "[", "'cursorMark'", "]", "=",...
:param str collection: The name of the collection for the request. :param dict query: Dictionary of solr args. Will page through the result set in increments using cursorMark until it has all items. Sort is required for cursorMark \ queries, if you don't specify it, the default is 'id desc'. ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "dict", "query", ":", "Dictionary", "of", "solr", "args", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L330-L355
train
moonlitesolutions/SolrClient
SolrClient/routers/aware.py
AwareRouter.get_shard_map
def get_shard_map(self, force_refresh=False): """ You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map(). """ now = datetime.utcnow() if force_refresh is True or \ self.shard_map is ...
python
def get_shard_map(self, force_refresh=False): """ You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map(). """ now = datetime.utcnow() if force_refresh is True or \ self.shard_map is ...
[ "def", "get_shard_map", "(", "self", ",", "force_refresh", "=", "False", ")", ":", "now", "=", "datetime", ".", "utcnow", "(", ")", "if", "force_refresh", "is", "True", "or", "self", ".", "shard_map", "is", "None", "or", "(", "now", "-", "self", ".", ...
You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map().
[ "You", "can", "change", "this", "function", "to", "get", "the", "shard", "-", "map", "from", "somewhere", "/", "somehow", "place", "else", "in", "conjuction", "with", "save_shard_map", "()", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/aware.py#L122-L134
train
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.check_zk
def check_zk(self): ''' Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not...
python
def check_zk(self): ''' Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not...
[ "def", "check_zk", "(", "self", ")", ":", "import", "telnetlib", "temp", "=", "self", ".", "zk_hosts", ".", "split", "(", "'/'", ")", "zks", "=", "temp", "[", "0", "]", ".", "split", "(", "','", ")", "status", "=", "{", "}", "for", "zk", "in", ...
Will attempt to telnet to each zookeeper that is used by SolrClient and issue 'mntr' command. Response is parsed to check to see if the zookeeper node is a leader or a follower and returned as a dict. If the telnet collection fails or the proper response is not parsed, the zk node will be listed as '...
[ "Will", "attempt", "to", "telnet", "to", "each", "zookeeper", "that", "is", "used", "by", "SolrClient", "and", "issue", "mntr", "command", ".", "Response", "is", "parsed", "to", "check", "to", "see", "if", "the", "zookeeper", "node", "is", "a", "leader", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L43-L72
train
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.copy_config
def copy_config(self, original, new): ''' Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param n...
python
def copy_config(self, original, new): ''' Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param n...
[ "def", "copy_config", "(", "self", ",", "original", ",", "new", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "original", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collection doesn't exist in Zooke...
Copies collection configs into a new folder. Can be used to create new collections based on existing configs. Basically, copies all nodes under /configs/original to /configs/new. :param original str: ZK name of original config :param new str: New name of the ZK config.
[ "Copies", "collection", "configs", "into", "a", "new", "folder", ".", "Can", "be", "used", "to", "create", "new", "collections", "based", "on", "existing", "configs", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L98-L111
train
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.download_collection_configs
def download_collection_configs(self, collection, fs_path): ''' Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path. ''' if not self.kz.exists('/configs/{}'.for...
python
def download_collection_configs(self, collection, fs_path): ''' Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path. ''' if not self.kz.exists('/configs/{}'.for...
[ "def", "download_collection_configs", "(", "self", ",", "collection", ",", "fs_path", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "collection", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collectio...
Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path.
[ "Downloads", "ZK", "Directory", "to", "the", "FileSystem", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L114-L124
train
moonlitesolutions/SolrClient
SolrClient/zk.py
ZK.upload_collection_configs
def upload_collection_configs(self, collection, fs_path): ''' Uploads collection configurations from a specified directory to zookeeper. ''' coll_path = fs_path if not os.path.isdir(coll_path): raise ValueError("{} Doesn't Exist".format(coll_path)) s...
python
def upload_collection_configs(self, collection, fs_path): ''' Uploads collection configurations from a specified directory to zookeeper. ''' coll_path = fs_path if not os.path.isdir(coll_path): raise ValueError("{} Doesn't Exist".format(coll_path)) s...
[ "def", "upload_collection_configs", "(", "self", ",", "collection", ",", "fs_path", ")", ":", "coll_path", "=", "fs_path", "if", "not", "os", ".", "path", ".", "isdir", "(", "coll_path", ")", ":", "raise", "ValueError", "(", "\"{} Doesn't Exist\"", ".", "for...
Uploads collection configurations from a specified directory to zookeeper.
[ "Uploads", "collection", "configurations", "from", "a", "specified", "directory", "to", "zookeeper", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L144-L152
train
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.create_field
def create_field(self, collection, field_dict): ''' Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True ...
python
def create_field(self, collection, field_dict): ''' Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True ...
[ "def", "create_field", "(", "self", ",", "collection", ",", "field_dict", ")", ":", "if", "self", ".", "does_field_exist", "(", "collection", ",", "field_dict", "[", "'name'", "]", ")", ":", "raise", "ValueError", "(", "\"Field {} Already Exists in Solr Collection...
Creates a new field in managed schema, will raise ValueError if the field already exists. field_dict should look like this:: { "name":"sell-by", "type":"tdate", "stored":True } Reference: https://cwiki.apache.org/confluence/display/so...
[ "Creates", "a", "new", "field", "in", "managed", "schema", "will", "raise", "ValueError", "if", "the", "field", "already", "exists", ".", "field_dict", "should", "look", "like", "this", "::" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L35-L52
train
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.delete_field
def delete_field(self,collection,field_name): ''' Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' if not se...
python
def delete_field(self,collection,field_name): ''' Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' if not se...
[ "def", "delete_field", "(", "self", ",", "collection", ",", "field_name", ")", ":", "if", "not", "self", ".", "does_field_exist", "(", "collection", ",", "field_name", ")", ":", "raise", "ValueError", "(", "\"Field {} Doesn't Exists in Solr Collection {}\"", ".", ...
Deletes a field from the Solr Collection. Will raise ValueError if the field doesn't exist. :param string collection: Name of the collection for the action :param string field_name: String name of the field.
[ "Deletes", "a", "field", "from", "the", "Solr", "Collection", ".", "Will", "raise", "ValueError", "if", "the", "field", "doesn", "t", "exist", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L70-L82
train
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.does_field_exist
def does_field_exist(self,collection,field_name): ''' Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' schema = ...
python
def does_field_exist(self,collection,field_name): ''' Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field. ''' schema = ...
[ "def", "does_field_exist", "(", "self", ",", "collection", ",", "field_name", ")", ":", "schema", "=", "self", ".", "get_schema_fields", "(", "collection", ")", "logging", ".", "info", "(", "schema", ")", "return", "True", "if", "field_name", "in", "[", "f...
Checks if the field exists will return a boolean True (exists) or False(doesn't exist). :param string collection: Name of the collection for the action :param string field_name: String name of the field.
[ "Checks", "if", "the", "field", "exists", "will", "return", "a", "boolean", "True", "(", "exists", ")", "or", "False", "(", "doesn", "t", "exist", ")", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L85-L94
train
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.create_copy_field
def create_copy_field(self,collection,copy_dict): ''' Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictiona...
python
def create_copy_field(self,collection,copy_dict): ''' Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictiona...
[ "def", "create_copy_field", "(", "self", ",", "collection", ",", "copy_dict", ")", ":", "temp", "=", "{", "\"add-copy-field\"", ":", "dict", "(", "copy_dict", ")", "}", "res", ",", "con_info", "=", "self", ".", "solr", ".", "transport", ".", "send_request"...
Creates a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictionary of field info Reference: https://cwiki.apache.org/confluen...
[ "Creates", "a", "copy", "field", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L96-L111
train
moonlitesolutions/SolrClient
SolrClient/schema.py
Schema.delete_copy_field
def delete_copy_field(self, collection, copy_dict): ''' Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictio...
python
def delete_copy_field(self, collection, copy_dict): ''' Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictio...
[ "def", "delete_copy_field", "(", "self", ",", "collection", ",", "copy_dict", ")", ":", "#Fix this later to check for field before sending a delete", "if", "self", ".", "devel", ":", "self", ".", "logger", ".", "debug", "(", "\"Deleting {}\"", ".", "format", "(", ...
Deletes a copy field. copy_dict should look like :: {'source':'source_field_name','dest':'destination_field_name'} :param string collection: Name of the collection for the action :param dict copy_field: Dictionary of field info
[ "Deletes", "a", "copy", "field", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L113-L133
train
moonlitesolutions/SolrClient
SolrClient/routers/base.py
BaseRouter.shuffle_hosts
def shuffle_hosts(self): """ Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :retu...
python
def shuffle_hosts(self): """ Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :retu...
[ "def", "shuffle_hosts", "(", "self", ")", ":", "if", "len", "(", "self", ".", "hosts", ")", ">", "1", ":", "random", ".", "shuffle", "(", "self", ".", "hosts", ")", "return", "self", ".", "hosts" ]
Shuffle hosts so we don't always query the first one. Example: using in a webapp with X processes in Y servers, the hosts contacted will be more random. The user can also call this function to reshuffle every 'x' seconds or before every request. :return:
[ "Shuffle", "hosts", "so", "we", "don", "t", "always", "query", "the", "first", "one", ".", "Example", ":", "using", "in", "a", "webapp", "with", "X", "processes", "in", "Y", "servers", "the", "hosts", "contacted", "will", "be", "more", "random", ".", "...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/base.py#L26-L35
train
drobota/robotframework-xvfb
XvfbRobot/__init__.py
XvfbRobot.start_virtual_display
def start_virtual_display(self, width=1440, height=900, colordepth=24, **kwargs): """Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in p...
python
def start_virtual_display(self, width=1440, height=900, colordepth=24, **kwargs): """Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in p...
[ "def", "start_virtual_display", "(", "self", ",", "width", "=", "1440", ",", "height", "=", "900", ",", "colordepth", "=", "24", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_display", "is", "None", ":", "logger", ".", "info", "(", "\"Using...
Starts virtual display which will be destroyed after test execution will be end *Arguments:* - width: a width to be set in pixels - height: a height to be set in pixels - color_depth: a color depth to be used - kwargs: extra parameters *Example:* | Sta...
[ "Starts", "virtual", "display", "which", "will", "be", "destroyed", "after", "test", "execution", "will", "be", "end" ]
66cd6174b637ab71aada71067ce4eaaa3280eb17
https://github.com/drobota/robotframework-xvfb/blob/66cd6174b637ab71aada71067ce4eaaa3280eb17/XvfbRobot/__init__.py#L34-L58
train
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.api
def api(self, action, args=None): """ Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters ...
python
def api(self, action, args=None): """ Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters ...
[ "def", "api", "(", "self", ",", "action", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "{", "}", "args", "[", "'action'", "]", "=", "action", ".", "upper", "(", ")", "try", ":", "res", ",", "con_info", "=", ...
Sends a request to Solr Collections API. Documentation is here: https://cwiki.apache.org/confluence/display/solr/Collections+API :param string action: Name of the collection for the action :param dict args: Dictionary of specific parameters for action
[ "Sends", "a", "request", "to", "Solr", "Collections", "API", ".", "Documentation", "is", "here", ":", "https", ":", "//", "cwiki", ".", "apache", ".", "org", "/", "confluence", "/", "display", "/", "solr", "/", "Collections", "+", "API" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L20-L42
train
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.clusterstatus
def clusterstatus(self): """ Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica. """ res = self.cluster_status_raw() cluster = res['clu...
python
def clusterstatus(self): """ Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica. """ res = self.cluster_status_raw() cluster = res['clu...
[ "def", "clusterstatus", "(", "self", ")", ":", "res", "=", "self", ".", "cluster_status_raw", "(", ")", "cluster", "=", "res", "[", "'cluster'", "]", "[", "'collections'", "]", "out", "=", "{", "}", "try", ":", "for", "collection", "in", "cluster", ":"...
Returns a slightly slimmed down version of the clusterstatus api command. It also gets count of documents in each shard on each replica and returns it as doc_count key for each replica.
[ "Returns", "a", "slightly", "slimmed", "down", "version", "of", "the", "clusterstatus", "api", "command", ".", "It", "also", "gets", "count", "of", "documents", "in", "each", "shard", "on", "each", "replica", "and", "returns", "it", "as", "doc_count", "key",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L44-L71
train
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.create
def create(self, name, numShards, params=None): """ Create a new collection. """ if params is None: params = {} params.update( name=name, numShards=numShards ) return self.api('CREATE', params)
python
def create(self, name, numShards, params=None): """ Create a new collection. """ if params is None: params = {} params.update( name=name, numShards=numShards ) return self.api('CREATE', params)
[ "def", "create", "(", "self", ",", "name", ",", "numShards", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "params", ".", "update", "(", "name", "=", "name", ",", "numShards", "=", "numShards", ")...
Create a new collection.
[ "Create", "a", "new", "collection", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L97-L107
train
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections._get_collection_counts
def _get_collection_counts(self, core_data): """ Queries each core to get individual counts for each core for each shard. """ if core_data['base_url'] not in self.solr_clients: from SolrClient import SolrClient self.solr_clients['base_url'] = SolrClient(core_data[...
python
def _get_collection_counts(self, core_data): """ Queries each core to get individual counts for each core for each shard. """ if core_data['base_url'] not in self.solr_clients: from SolrClient import SolrClient self.solr_clients['base_url'] = SolrClient(core_data[...
[ "def", "_get_collection_counts", "(", "self", ",", "core_data", ")", ":", "if", "core_data", "[", "'base_url'", "]", "not", "in", "self", ".", "solr_clients", ":", "from", "SolrClient", "import", "SolrClient", "self", ".", "solr_clients", "[", "'base_url'", "]...
Queries each core to get individual counts for each core for each shard.
[ "Queries", "each", "core", "to", "get", "individual", "counts", "for", "each", "core", "for", "each", "shard", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L109-L125
train
moonlitesolutions/SolrClient
SolrClient/collections.py
Collections.check_status
def check_status(self, ignore=(), status=None): """ Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting. """ self.SH...
python
def check_status(self, ignore=(), status=None): """ Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting. """ self.SH...
[ "def", "check_status", "(", "self", ",", "ignore", "=", "(", ")", ",", "status", "=", "None", ")", ":", "self", ".", "SHARD_CHECKS", "=", "[", "{", "'check_msg'", ":", "'Bad Core Count Check'", ",", "'f'", ":", "self", ".", "_check_shard_count", "}", ","...
Checks status of each collection and shard to make sure that: a) Cluster state is active b) Number of docs matches across replicas for a given shard. Returns a dict of results for custom alerting.
[ "Checks", "status", "of", "each", "collection", "and", "shard", "to", "make", "sure", "that", ":", "a", ")", "Cluster", "state", "is", "active", "b", ")", "Number", "of", "docs", "matches", "across", "replicas", "for", "a", "given", "shard", ".", "Return...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L142-L172
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer.reindex
def reindex(self, fq= [], **kwargs): ''' Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results. ''' for items in self._gette...
python
def reindex(self, fq= [], **kwargs): ''' Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results. ''' for items in self._gette...
[ "def", "reindex", "(", "self", ",", "fq", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "for", "items", "in", "self", ".", "_getter", "(", "fq", "=", "fq", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_putter", "(", "items", ")", "if"...
Starts Reindexing Process. All parameter arguments will be passed down to the getter function. :param string fq: FilterQuery to pass to source Solr to retrieve items. This can be used to limit the results.
[ "Starts", "Reindexing", "Process", ".", "All", "parameter", "arguments", "will", "be", "passed", "down", "to", "the", "getter", "function", ".", ":", "param", "string", "fq", ":", "FilterQuery", "to", "pass", "to", "source", "Solr", "to", "retrieve", "items"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L87-L96
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._from_solr
def _from_solr(self, fq=[], report_frequency = 25): ''' Method for retrieving batch data from Solr. ''' cursor = '*' stime = datetime.now() query_count = 0 while True: #Get data with starting cursorMark query = self._get_query(curs...
python
def _from_solr(self, fq=[], report_frequency = 25): ''' Method for retrieving batch data from Solr. ''' cursor = '*' stime = datetime.now() query_count = 0 while True: #Get data with starting cursorMark query = self._get_query(curs...
[ "def", "_from_solr", "(", "self", ",", "fq", "=", "[", "]", ",", "report_frequency", "=", "25", ")", ":", "cursor", "=", "'*'", "stime", "=", "datetime", ".", "now", "(", ")", "query_count", "=", "0", "while", "True", ":", "#Get data with starting cursor...
Method for retrieving batch data from Solr.
[ "Method", "for", "retrieving", "batch", "data", "from", "Solr", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L99-L139
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._trim_fields
def _trim_fields(self, docs): ''' Removes ignore fields from the data that we got from Solr. ''' for doc in docs: for field in self._ignore_fields: if field in doc: del(doc[field]) return docs
python
def _trim_fields(self, docs): ''' Removes ignore fields from the data that we got from Solr. ''' for doc in docs: for field in self._ignore_fields: if field in doc: del(doc[field]) return docs
[ "def", "_trim_fields", "(", "self", ",", "docs", ")", ":", "for", "doc", "in", "docs", ":", "for", "field", "in", "self", ".", "_ignore_fields", ":", "if", "field", "in", "doc", ":", "del", "(", "doc", "[", "field", "]", ")", "return", "docs" ]
Removes ignore fields from the data that we got from Solr.
[ "Removes", "ignore", "fields", "from", "the", "data", "that", "we", "got", "from", "Solr", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L142-L150
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_query
def _get_query(self, cursor): ''' Query tempalte for source Solr, sorts by id by default. ''' query = {'q':'*:*', 'sort':'id desc', 'rows':self._rows, 'cursorMark':cursor} if self._date_field: query['sort'] = "{...
python
def _get_query(self, cursor): ''' Query tempalte for source Solr, sorts by id by default. ''' query = {'q':'*:*', 'sort':'id desc', 'rows':self._rows, 'cursorMark':cursor} if self._date_field: query['sort'] = "{...
[ "def", "_get_query", "(", "self", ",", "cursor", ")", ":", "query", "=", "{", "'q'", ":", "'*:*'", ",", "'sort'", ":", "'id desc'", ",", "'rows'", ":", "self", ".", "_rows", ",", "'cursorMark'", ":", "cursor", "}", "if", "self", ".", "_date_field", "...
Query tempalte for source Solr, sorts by id by default.
[ "Query", "tempalte", "for", "source", "Solr", "sorts", "by", "id", "by", "default", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L153-L165
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._to_solr
def _to_solr(self, data): ''' Sends data to a Solr instance. ''' return self._dest.index_json(self._dest_coll, json.dumps(data,sort_keys=True))
python
def _to_solr(self, data): ''' Sends data to a Solr instance. ''' return self._dest.index_json(self._dest_coll, json.dumps(data,sort_keys=True))
[ "def", "_to_solr", "(", "self", ",", "data", ")", ":", "return", "self", ".", "_dest", ".", "index_json", "(", "self", ".", "_dest_coll", ",", "json", ".", "dumps", "(", "data", ",", "sort_keys", "=", "True", ")", ")" ]
Sends data to a Solr instance.
[ "Sends", "data", "to", "a", "Solr", "instance", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L175-L179
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_date_range_query
def _get_date_range_query(self, start_date, end_date, timespan= 'DAY', date_field= None): ''' Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY ''' ...
python
def _get_date_range_query(self, start_date, end_date, timespan= 'DAY', date_field= None): ''' Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY ''' ...
[ "def", "_get_date_range_query", "(", "self", ",", "start_date", ",", "end_date", ",", "timespan", "=", "'DAY'", ",", "date_field", "=", "None", ")", ":", "if", "date_field", "is", "None", ":", "date_field", "=", "self", ".", "_date_field", "query", "=", "{...
Gets counts of items per specified date range. :param collection: Solr Collection to use. :param timespan: Solr Date Math compliant value for faceting ex HOUR, MONTH, DAY
[ "Gets", "counts", "of", "items", "per", "specified", "date", "range", ".", ":", "param", "collection", ":", "Solr", "Collection", "to", "use", ".", ":", "param", "timespan", ":", "Solr", "Date", "Math", "compliant", "value", "for", "faceting", "ex", "HOUR"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L182-L201
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_edge_date
def _get_edge_date(self, date_field, sort): ''' This method is used to get start and end dates for the collection. ''' return self._source.query(self._source_coll, { 'q':'*:*', 'rows':1, 'fq':'+{}:*'.format(date_field), ...
python
def _get_edge_date(self, date_field, sort): ''' This method is used to get start and end dates for the collection. ''' return self._source.query(self._source_coll, { 'q':'*:*', 'rows':1, 'fq':'+{}:*'.format(date_field), ...
[ "def", "_get_edge_date", "(", "self", ",", "date_field", ",", "sort", ")", ":", "return", "self", ".", "_source", ".", "query", "(", "self", ".", "_source_coll", ",", "{", "'q'", ":", "'*:*'", ",", "'rows'", ":", "1", ",", "'fq'", ":", "'+{}:*'", "."...
This method is used to get start and end dates for the collection.
[ "This", "method", "is", "used", "to", "get", "start", "and", "end", "dates", "for", "the", "collection", "." ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L204-L212
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer._get_date_facet_counts
def _get_date_facet_counts(self, timespan, date_field, start_date=None, end_date=None): ''' Returns Range Facet counts based on ''' if 'DAY' not in timespan: raise ValueError("At this time, only DAY date range increment is supported. Aborting..... ") #Need to ...
python
def _get_date_facet_counts(self, timespan, date_field, start_date=None, end_date=None): ''' Returns Range Facet counts based on ''' if 'DAY' not in timespan: raise ValueError("At this time, only DAY date range increment is supported. Aborting..... ") #Need to ...
[ "def", "_get_date_facet_counts", "(", "self", ",", "timespan", ",", "date_field", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ")", ":", "if", "'DAY'", "not", "in", "timespan", ":", "raise", "ValueError", "(", "\"At this time, only DAY date rang...
Returns Range Facet counts based on
[ "Returns", "Range", "Facet", "counts", "based", "on" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L215-L248
train
moonlitesolutions/SolrClient
SolrClient/helpers/reindexer.py
Reindexer.resume
def resume(self, start_date=None, end_date=None, timespan='DAY', check= False): ''' This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the ...
python
def resume(self, start_date=None, end_date=None, timespan='DAY', check= False): ''' This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the ...
[ "def", "resume", "(", "self", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "timespan", "=", "'DAY'", ",", "check", "=", "False", ")", ":", "if", "type", "(", "self", ".", "_source", ")", "is", "not", "SolrClient", "or", "type", ...
This method may help if the original run was interrupted for some reason. It will only work under the following conditions * You have a date field that you can facet on * Indexing was stopped for the duration of the copy The way this tries to resume re-indexing is by running a date range fa...
[ "This", "method", "may", "help", "if", "the", "original", "run", "was", "interrupted", "for", "some", "reason", ".", "It", "will", "only", "work", "under", "the", "following", "conditions", "*", "You", "have", "a", "date", "field", "that", "you", "can", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L251-L291
train
bitprophet/ssh
ssh/transport.py
Transport.start_client
def start_client(self, event=None): """ Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiati...
python
def start_client(self, event=None): """ Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiati...
[ "def", "start_client", "(", "self", ",", "event", "=", "None", ")", ":", "self", ".", "active", "=", "True", "if", "event", "is", "not", "None", ":", "# async, return immediately and let the app poll for completion", "self", ".", "completion_event", "=", "event", ...
Negotiate a new SSH2 session as a client. This is the first step after creating a new L{Transport}. A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiation is done (successful or not), the given C{Event} will ...
[ "Negotiate", "a", "new", "SSH2", "session", "as", "a", "client", ".", "This", "is", "the", "first", "step", "after", "creating", "a", "new", "L", "{", "Transport", "}", ".", "A", "separate", "thread", "is", "created", "for", "protocol", "negotiation", "....
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L417-L467
train
bitprophet/ssh
ssh/transport.py
Transport.start_server
def start_server(self, event=None, server=None): """ Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this...
python
def start_server(self, event=None, server=None): """ Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this...
[ "def", "start_server", "(", "self", ",", "event", "=", "None", ",", "server", "=", "None", ")", ":", "if", "server", "is", "None", ":", "server", "=", "ServerInterface", "(", ")", "self", ".", "server_mode", "=", "True", "self", ".", "server_object", "...
Negotiate a new SSH2 session as a server. This is the first step after creating a new L{Transport} and setting up your server host key(s). A separate thread is created for protocol negotiation. If an event is passed in, this method returns immediately. When negotiation is done (succe...
[ "Negotiate", "a", "new", "SSH2", "session", "as", "a", "server", ".", "This", "is", "the", "first", "step", "after", "creating", "a", "new", "L", "{", "Transport", "}", "and", "setting", "up", "your", "server", "host", "key", "(", "s", ")", ".", "A",...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L469-L531
train
bitprophet/ssh
ssh/transport.py
Transport.close
def close(self): """ Close this session, and any open channels that are tied to it. """ if not self.active: return self.active = False self.packetizer.close() self.join() for chan in self._channels.values(): chan._unlink()
python
def close(self): """ Close this session, and any open channels that are tied to it. """ if not self.active: return self.active = False self.packetizer.close() self.join() for chan in self._channels.values(): chan._unlink()
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "active", ":", "return", "self", ".", "active", "=", "False", "self", ".", "packetizer", ".", "close", "(", ")", "self", ".", "join", "(", ")", "for", "chan", "in", "self", ".", "_c...
Close this session, and any open channels that are tied to it.
[ "Close", "this", "session", "and", "any", "open", "channels", "that", "are", "tied", "to", "it", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L610-L620
train
bitprophet/ssh
ssh/transport.py
Transport.open_forwarded_tcpip_channel
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)): """ Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @para...
python
def open_forwarded_tcpip_channel(self, (src_addr, src_port), (dest_addr, dest_port)): """ Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @para...
[ "def", "open_forwarded_tcpip_channel", "(", "self", ",", "(", "src_addr", ",", "src_port", ")", ",", "(", "dest_addr", ",", "dest_port", ")", ")", ":", "return", "self", ".", "open_channel", "(", "'forwarded-tcpip'", ",", "(", "dest_addr", ",", "dest_port", ...
Request a new channel back to the client, of type C{"forwarded-tcpip"}. This is used after a client has requested port forwarding, for sending incoming connections back to the client. @param src_addr: originator's address @param src_port: originator's port @param dest_addr: loca...
[ "Request", "a", "new", "channel", "back", "to", "the", "client", "of", "type", "C", "{", "forwarded", "-", "tcpip", "}", ".", "This", "is", "used", "after", "a", "client", "has", "requested", "port", "forwarding", "for", "sending", "incoming", "connections...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L693-L704
train
bitprophet/ssh
ssh/transport.py
Transport.request_port_forward
def request_port_forward(self, address, port, handler=None): """ Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives....
python
def request_port_forward(self, address, port, handler=None): """ Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives....
[ "def", "request_port_forward", "(", "self", ",", "address", ",", "port", ",", "handler", "=", "None", ")", ":", "if", "not", "self", ".", "active", ":", "raise", "SSHException", "(", "'SSH session not active'", ")", "address", "=", "str", "(", "address", "...
Ask the server to forward TCP connections from a listening port on the server, across this SSH session. If a handler is given, that handler is called from a different thread whenever a forwarded connection arrives. The handler parameters are:: handler(channel, (origin_addr, origin...
[ "Ask", "the", "server", "to", "forward", "TCP", "connections", "from", "a", "listening", "port", "on", "the", "server", "across", "this", "SSH", "session", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L774-L817
train
bitprophet/ssh
ssh/transport.py
Transport.send_ignore
def send_ignore(self, bytes=None): """ Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: ...
python
def send_ignore(self, bytes=None): """ Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: ...
[ "def", "send_ignore", "(", "self", ",", "bytes", "=", "None", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_byte", "(", "chr", "(", "MSG_IGNORE", ")", ")", "if", "bytes", "is", "None", ":", "bytes", "=", "(", "ord", "(", "rng", ".", "...
Send a junk packet across the encrypted link. This is sometimes used to add "noise" to a connection to confuse would-be attackers. It can also be used as a keep-alive for long lived connections traversing firewalls. @param bytes: the number of random bytes to send in the payload of th...
[ "Send", "a", "junk", "packet", "across", "the", "encrypted", "link", ".", "This", "is", "sometimes", "used", "to", "add", "noise", "to", "a", "connection", "to", "confuse", "would", "-", "be", "attackers", ".", "It", "can", "also", "be", "used", "as", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L847-L863
train
bitprophet/ssh
ssh/transport.py
Transport.renegotiate_keys
def renegotiate_keys(self): """ Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating ne...
python
def renegotiate_keys(self): """ Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating ne...
[ "def", "renegotiate_keys", "(", "self", ")", ":", "self", ".", "completion_event", "=", "threading", ".", "Event", "(", ")", "self", ".", "_send_kex_init", "(", ")", "while", "True", ":", "self", ".", "completion_event", ".", "wait", "(", "0.1", ")", "if...
Force this session to switch to new keys. Normally this is done automatically after the session hits a certain number of packets or bytes sent or received, but this method gives you the option of forcing new keys whenever you want. Negotiating new keys causes a pause in traffic both wa...
[ "Force", "this", "session", "to", "switch", "to", "new", "keys", ".", "Normally", "this", "is", "done", "automatically", "after", "the", "session", "hits", "a", "certain", "number", "of", "packets", "or", "bytes", "sent", "or", "received", "but", "this", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L865-L888
train
bitprophet/ssh
ssh/transport.py
Transport.set_keepalive
def set_keepalive(self, interval): """ Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connecti...
python
def set_keepalive(self, interval): """ Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connecti...
[ "def", "set_keepalive", "(", "self", ",", "interval", ")", ":", "self", ".", "packetizer", ".", "set_keepalive", "(", "interval", ",", "lambda", "x", "=", "weakref", ".", "proxy", "(", "self", ")", ":", "x", ".", "global_request", "(", "'keepalive@lag.net'...
Turn on/off keepalive packets (default is off). If this is set, after C{interval} seconds without sending any data over the connection, a "keepalive" packet will be sent (and ignored by the remote host). This can be useful to keep connections alive over a NAT, for example. @param inte...
[ "Turn", "on", "/", "off", "keepalive", "packets", "(", "default", "is", "off", ")", ".", "If", "this", "is", "set", "after", "C", "{", "interval", "}", "seconds", "without", "sending", "any", "data", "over", "the", "connection", "a", "keepalive", "packet...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L890-L902
train
bitprophet/ssh
ssh/transport.py
Transport.connect
def connect(self, hostkey=None, username='', password=None, pkey=None): """ Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport....
python
def connect(self, hostkey=None, username='', password=None, pkey=None): """ Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport....
[ "def", "connect", "(", "self", ",", "hostkey", "=", "None", ",", "username", "=", "''", ",", "password", "=", "None", ",", "pkey", "=", "None", ")", ":", "if", "hostkey", "is", "not", "None", ":", "self", ".", "_preferred_keys", "=", "[", "hostkey", ...
Negotiate an SSH2 session, and optionally verify the server's host key and authenticate using a password or private key. This is a shortcut for L{start_client}, L{get_remote_server_key}, and L{Transport.auth_password} or L{Transport.auth_publickey}. Use those methods if you want more c...
[ "Negotiate", "an", "SSH2", "session", "and", "optionally", "verify", "the", "server", "s", "host", "key", "and", "authenticate", "using", "a", "password", "or", "private", "key", ".", "This", "is", "a", "shortcut", "for", "L", "{", "start_client", "}", "L"...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L969-L1026
train
bitprophet/ssh
ssh/transport.py
Transport.auth_none
def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised...
python
def auth_none(self, username): """ Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised...
[ "def", "auth_none", "(", "self", ",", "username", ")", ":", "if", "(", "not", "self", ".", "active", ")", "or", "(", "not", "self", ".", "initial_kex_done", ")", ":", "raise", "SSHException", "(", "'No existing session'", ")", "my_event", "=", "threading",...
Try to authenticate to the server using no authentication at all. This will almost always fail. It may be useful for determining the list of authentication types supported by the server, by catching the L{BadAuthenticationType} exception raised. @param username: the username to authent...
[ "Try", "to", "authenticate", "to", "the", "server", "using", "no", "authentication", "at", "all", ".", "This", "will", "almost", "always", "fail", ".", "It", "may", "be", "useful", "for", "determining", "the", "list", "of", "authentication", "types", "suppor...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1094-L1119
train
bitprophet/ssh
ssh/transport.py
Transport._send_user_message
def _send_user_message(self, data): """ send a message, but block if we're in key negotiation. this is used for user-initiated requests. """ start = time.time() while True: self.clear_to_send.wait(0.1) if not self.active: self._log...
python
def _send_user_message(self, data): """ send a message, but block if we're in key negotiation. this is used for user-initiated requests. """ start = time.time() while True: self.clear_to_send.wait(0.1) if not self.active: self._log...
[ "def", "_send_user_message", "(", "self", ",", "data", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "True", ":", "self", ".", "clear_to_send", ".", "wait", "(", "0.1", ")", "if", "not", "self", ".", "active", ":", "self", ".", "_...
send a message, but block if we're in key negotiation. this is used for user-initiated requests.
[ "send", "a", "message", "but", "block", "if", "we", "re", "in", "key", "negotiation", ".", "this", "is", "used", "for", "user", "-", "initiated", "requests", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1425-L1445
train
bitprophet/ssh
ssh/transport.py
Transport._set_K_H
def _set_K_H(self, k, h): "used by a kex object to set the K (root key) and H (exchange hash)" self.K = k self.H = h if self.session_id == None: self.session_id = h
python
def _set_K_H(self, k, h): "used by a kex object to set the K (root key) and H (exchange hash)" self.K = k self.H = h if self.session_id == None: self.session_id = h
[ "def", "_set_K_H", "(", "self", ",", "k", ",", "h", ")", ":", "self", ".", "K", "=", "k", "self", ".", "H", "=", "h", "if", "self", ".", "session_id", "==", "None", ":", "self", ".", "session_id", "=", "h" ]
used by a kex object to set the K (root key) and H (exchange hash)
[ "used", "by", "a", "kex", "object", "to", "set", "the", "K", "(", "root", "key", ")", "and", "H", "(", "exchange", "hash", ")" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1447-L1452
train
bitprophet/ssh
ssh/transport.py
Transport._compute_key
def _compute_key(self, id, nbytes): "id is 'A' - 'F' for the various keys used by ssh" m = Message() m.add_mpint(self.K) m.add_bytes(self.H) m.add_byte(id) m.add_bytes(self.session_id) out = sofar = SHA.new(str(m)).digest() while len(out) < nbytes: ...
python
def _compute_key(self, id, nbytes): "id is 'A' - 'F' for the various keys used by ssh" m = Message() m.add_mpint(self.K) m.add_bytes(self.H) m.add_byte(id) m.add_bytes(self.session_id) out = sofar = SHA.new(str(m)).digest() while len(out) < nbytes: ...
[ "def", "_compute_key", "(", "self", ",", "id", ",", "nbytes", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_mpint", "(", "self", ".", "K", ")", "m", ".", "add_bytes", "(", "self", ".", "H", ")", "m", ".", "add_byte", "(", "id", ")", ...
id is 'A' - 'F' for the various keys used by ssh
[ "id", "is", "A", "-", "F", "for", "the", "various", "keys", "used", "by", "ssh" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1466-L1482
train
bitprophet/ssh
ssh/transport.py
Transport._send_kex_init
def _send_kex_init(self): """ announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support. """ self.clear_to_send_lock.acquire() try: self.clear_to_send.clear() finally: self.clear_to_send_lock.r...
python
def _send_kex_init(self): """ announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support. """ self.clear_to_send_lock.acquire() try: self.clear_to_send.clear() finally: self.clear_to_send_lock.r...
[ "def", "_send_kex_init", "(", "self", ")", ":", "self", ".", "clear_to_send_lock", ".", "acquire", "(", ")", "try", ":", "self", ".", "clear_to_send", ".", "clear", "(", ")", "finally", ":", "self", ".", "clear_to_send_lock", ".", "release", "(", ")", "s...
announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support.
[ "announce", "to", "the", "other", "side", "that", "we", "d", "like", "to", "negotiate", "keys", "and", "what", "kind", "of", "key", "negotiation", "we", "support", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1698-L1737
train
bitprophet/ssh
ssh/primes.py
_generate_prime
def _generate_prime(bits, rng): "primtive attempt at prime generation" hbyte_mask = pow(2, bits % 8) - 1 while True: # loop catches the case where we increment n into a higher bit-range x = rng.read((bits+7) // 8) if hbyte_mask > 0: x = chr(ord(x[0]) & hbyte_mask) + x[1:]...
python
def _generate_prime(bits, rng): "primtive attempt at prime generation" hbyte_mask = pow(2, bits % 8) - 1 while True: # loop catches the case where we increment n into a higher bit-range x = rng.read((bits+7) // 8) if hbyte_mask > 0: x = chr(ord(x[0]) & hbyte_mask) + x[1:]...
[ "def", "_generate_prime", "(", "bits", ",", "rng", ")", ":", "hbyte_mask", "=", "pow", "(", "2", ",", "bits", "%", "8", ")", "-", "1", "while", "True", ":", "# loop catches the case where we increment n into a higher bit-range", "x", "=", "rng", ".", "read", ...
primtive attempt at prime generation
[ "primtive", "attempt", "at", "prime", "generation" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L29-L44
train
bitprophet/ssh
ssh/primes.py
_roll_random
def _roll_random(rng, n): "returns a random # from 0 to N-1" bits = util.bit_length(n-1) bytes = (bits + 7) // 8 hbyte_mask = pow(2, bits % 8) - 1 # so here's the plan: # we fetch as many random bits as we'd need to fit N-1, and if the # generated number is >= N, we try again. in the worst...
python
def _roll_random(rng, n): "returns a random # from 0 to N-1" bits = util.bit_length(n-1) bytes = (bits + 7) // 8 hbyte_mask = pow(2, bits % 8) - 1 # so here's the plan: # we fetch as many random bits as we'd need to fit N-1, and if the # generated number is >= N, we try again. in the worst...
[ "def", "_roll_random", "(", "rng", ",", "n", ")", ":", "bits", "=", "util", ".", "bit_length", "(", "n", "-", "1", ")", "bytes", "=", "(", "bits", "+", "7", ")", "//", "8", "hbyte_mask", "=", "pow", "(", "2", ",", "bits", "%", "8", ")", "-", ...
returns a random # from 0 to N-1
[ "returns", "a", "random", "#", "from", "0", "to", "N", "-", "1" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L46-L65
train
bitprophet/ssh
ssh/pkey.py
PKey._write_private_key_file
def _write_private_key_file(self, tag, filename, data, password=None): """ Write an SSH2-format private key file in a form that can be read by ssh or openssh. If no password is given, the key is written in a trivially-encoded format (base64) which is completely insecure. If a p...
python
def _write_private_key_file(self, tag, filename, data, password=None): """ Write an SSH2-format private key file in a form that can be read by ssh or openssh. If no password is given, the key is written in a trivially-encoded format (base64) which is completely insecure. If a p...
[ "def", "_write_private_key_file", "(", "self", ",", "tag", ",", "filename", ",", "data", ",", "password", "=", "None", ")", ":", "f", "=", "open", "(", "filename", ",", "'w'", ",", "0600", ")", "# grrr... the mode doesn't always take hold", "os", ".", "chmod...
Write an SSH2-format private key file in a form that can be read by ssh or openssh. If no password is given, the key is written in a trivially-encoded format (base64) which is completely insecure. If a password is given, DES-EDE3-CBC is used. @param tag: C{"RSA"} or C{"DSA"}, the tag ...
[ "Write", "an", "SSH2", "-", "format", "private", "key", "file", "in", "a", "form", "that", "can", "be", "read", "by", "ssh", "or", "openssh", ".", "If", "no", "password", "is", "given", "the", "key", "is", "written", "in", "a", "trivially", "-", "enc...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/pkey.py#L331-L353
train
bitprophet/ssh
ssh/buffered_pipe.py
BufferedPipe.set_event
def set_event(self, event): """ Set an event on this buffer. When data is ready to be read (or the buffer has been closed), the event will be set. When no data is ready, the event will be cleared. @param event: the event to set/clear @type event: Event ...
python
def set_event(self, event): """ Set an event on this buffer. When data is ready to be read (or the buffer has been closed), the event will be set. When no data is ready, the event will be cleared. @param event: the event to set/clear @type event: Event ...
[ "def", "set_event", "(", "self", ",", "event", ")", ":", "self", ".", "_event", "=", "event", "if", "len", "(", "self", ".", "_buffer", ")", ">", "0", ":", "event", ".", "set", "(", ")", "else", ":", "event", ".", "clear", "(", ")" ]
Set an event on this buffer. When data is ready to be read (or the buffer has been closed), the event will be set. When no data is ready, the event will be cleared. @param event: the event to set/clear @type event: Event
[ "Set", "an", "event", "on", "this", "buffer", ".", "When", "data", "is", "ready", "to", "be", "read", "(", "or", "the", "buffer", "has", "been", "closed", ")", "the", "event", "will", "be", "set", ".", "When", "no", "data", "is", "ready", "the", "e...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L51-L64
train
bitprophet/ssh
ssh/buffered_pipe.py
BufferedPipe.feed
def feed(self, data): """ Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done. @param data: the data to add @type data: str """ self._lock.acquire() try: if self._event ...
python
def feed(self, data): """ Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done. @param data: the data to add @type data: str """ self._lock.acquire() try: if self._event ...
[ "def", "feed", "(", "self", ",", "data", ")", ":", "self", ".", "_lock", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "_event", "is", "not", "None", ":", "self", ".", "_event", ".", "set", "(", ")", "self", ".", "_buffer", ".", "fro...
Feed new data into this pipe. This method is assumed to be called from a separate thread, so synchronization is done. @param data: the data to add @type data: str
[ "Feed", "new", "data", "into", "this", "pipe", ".", "This", "method", "is", "assumed", "to", "be", "called", "from", "a", "separate", "thread", "so", "synchronization", "is", "done", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L66-L81
train
bitprophet/ssh
ssh/sftp_handle.py
SFTPHandle.read
def read(self, offset, length): """ Read up to C{length} bytes from this file, starting at position C{offset}. The offset may be a python long, since SFTP allows it to be 64 bits. If the end of the file has been reached, this method may return an empty string to signify...
python
def read(self, offset, length): """ Read up to C{length} bytes from this file, starting at position C{offset}. The offset may be a python long, since SFTP allows it to be 64 bits. If the end of the file has been reached, this method may return an empty string to signify...
[ "def", "read", "(", "self", ",", "offset", ",", "length", ")", ":", "readfile", "=", "getattr", "(", "self", ",", "'readfile'", ",", "None", ")", "if", "readfile", "is", "None", ":", "return", "SFTP_OP_UNSUPPORTED", "try", ":", "if", "self", ".", "__te...
Read up to C{length} bytes from this file, starting at position C{offset}. The offset may be a python long, since SFTP allows it to be 64 bits. If the end of the file has been reached, this method may return an empty string to signify EOF, or it may also return L{SFTP_EOF}. Th...
[ "Read", "up", "to", "C", "{", "length", "}", "bytes", "from", "this", "file", "starting", "at", "position", "C", "{", "offset", "}", ".", "The", "offset", "may", "be", "a", "python", "long", "since", "SFTP", "allows", "it", "to", "be", "64", "bits", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L72-L107
train
bitprophet/ssh
ssh/sftp_handle.py
SFTPHandle.write
def write(self, offset, data): """ Write C{data} into this file at position C{offset}. Extending the file past its original end is expected. Unlike python's normal C{write()} methods, this method cannot do a partial write: it must write all of C{data} or else return an error. ...
python
def write(self, offset, data): """ Write C{data} into this file at position C{offset}. Extending the file past its original end is expected. Unlike python's normal C{write()} methods, this method cannot do a partial write: it must write all of C{data} or else return an error. ...
[ "def", "write", "(", "self", ",", "offset", ",", "data", ")", ":", "writefile", "=", "getattr", "(", "self", ",", "'writefile'", ",", "None", ")", "if", "writefile", "is", "None", ":", "return", "SFTP_OP_UNSUPPORTED", "try", ":", "# in append mode, don't car...
Write C{data} into this file at position C{offset}. Extending the file past its original end is expected. Unlike python's normal C{write()} methods, this method cannot do a partial write: it must write all of C{data} or else return an error. The default implementation checks for an at...
[ "Write", "C", "{", "data", "}", "into", "this", "file", "at", "position", "C", "{", "offset", "}", ".", "Extending", "the", "file", "past", "its", "original", "end", "is", "expected", ".", "Unlike", "python", "s", "normal", "C", "{", "write", "()", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L109-L147
train
bitprophet/ssh
ssh/sftp_si.py
SFTPServerInterface.canonicalize
def canonicalize(self, path): """ Return the canonical form of a path on the server. For example, if the server's home folder is C{/home/foo}, the path C{"../betty"} would be canonicalized to C{"/home/betty"}. Note the obvious security issues: if you're serving files only from ...
python
def canonicalize(self, path): """ Return the canonical form of a path on the server. For example, if the server's home folder is C{/home/foo}, the path C{"../betty"} would be canonicalized to C{"/home/betty"}. Note the obvious security issues: if you're serving files only from ...
[ "def", "canonicalize", "(", "self", ",", "path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "out", "=", "os", ".", "path", ".", "normpath", "(", "path", ")", "else", ":", "out", "=", "os", ".", "path", ".", "normpat...
Return the canonical form of a path on the server. For example, if the server's home folder is C{/home/foo}, the path C{"../betty"} would be canonicalized to C{"/home/betty"}. Note the obvious security issues: if you're serving files only from a specific folder, you probably don't want...
[ "Return", "the", "canonical", "form", "of", "a", "path", "on", "the", "server", ".", "For", "example", "if", "the", "server", "s", "home", "folder", "is", "C", "{", "/", "home", "/", "foo", "}", "the", "path", "C", "{", "..", "/", "betty", "}", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_si.py#L259-L280
train
bitprophet/ssh
ssh/agent.py
AgentClientProxy.connect
def connect(self): """ Method automatically called by the run() method of the AgentProxyThread """ if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'): conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: retry_on_signal(lambd...
python
def connect(self): """ Method automatically called by the run() method of the AgentProxyThread """ if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'): conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: retry_on_signal(lambd...
[ "def", "connect", "(", "self", ")", ":", "if", "(", "'SSH_AUTH_SOCK'", "in", "os", ".", "environ", ")", "and", "(", "sys", ".", "platform", "!=", "'win32'", ")", ":", "conn", "=", "socket", ".", "socket", "(", "socket", ".", "AF_UNIX", ",", "socket",...
Method automatically called by the run() method of the AgentProxyThread
[ "Method", "automatically", "called", "by", "the", "run", "()", "method", "of", "the", "AgentProxyThread" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/agent.py#L199-L219
train
bitprophet/ssh
ssh/client.py
SSHClient.save_host_keys
def save_host_keys(self, filename): """ Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved -- not any host keys loaded with L{load_system_host_keys}. @param filename: the filename to save to @type ...
python
def save_host_keys(self, filename): """ Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved -- not any host keys loaded with L{load_system_host_keys}. @param filename: the filename to save to @type ...
[ "def", "save_host_keys", "(", "self", ",", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "'w'", ")", "f", ".", "write", "(", "'# SSH host keys collected by ssh\\n'", ")", "for", "hostname", ",", "keys", "in", "self", ".", "_host_keys", ".",...
Save the host keys back to a file. Only the host keys loaded with L{load_host_keys} (plus any added directly) will be saved -- not any host keys loaded with L{load_system_host_keys}. @param filename: the filename to save to @type filename: str @raise IOError: if the file could...
[ "Save", "the", "host", "keys", "back", "to", "a", "file", ".", "Only", "the", "host", "keys", "loaded", "with", "L", "{", "load_host_keys", "}", "(", "plus", "any", "added", "directly", ")", "will", "be", "saved", "--", "not", "any", "host", "keys", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L179-L195
train
bitprophet/ssh
ssh/client.py
SSHClient.exec_command
def exec_command(self, command, bufsize=-1): """ Execute a command on the SSH server. A new L{Channel} is opened and the requested command is executed. The command's input and output streams are returned as python C{file}-like objects representing stdin, stdout, and stderr. ...
python
def exec_command(self, command, bufsize=-1): """ Execute a command on the SSH server. A new L{Channel} is opened and the requested command is executed. The command's input and output streams are returned as python C{file}-like objects representing stdin, stdout, and stderr. ...
[ "def", "exec_command", "(", "self", ",", "command", ",", "bufsize", "=", "-", "1", ")", ":", "chan", "=", "self", ".", "_transport", ".", "open_session", "(", ")", "chan", ".", "exec_command", "(", "command", ")", "stdin", "=", "chan", ".", "makefile",...
Execute a command on the SSH server. A new L{Channel} is opened and the requested command is executed. The command's input and output streams are returned as python C{file}-like objects representing stdin, stdout, and stderr. @param command: the command to execute @type comman...
[ "Execute", "a", "command", "on", "the", "SSH", "server", ".", "A", "new", "L", "{", "Channel", "}", "is", "opened", "and", "the", "requested", "command", "is", "executed", ".", "The", "command", "s", "input", "and", "output", "streams", "are", "returned"...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L348-L369
train
bitprophet/ssh
ssh/client.py
SSHClient._auth
def _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_keys): """ Try, in order: - The key passed in, if one was passed in. - Any key we can find through an SSH agent (if allowed). - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if all...
python
def _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_keys): """ Try, in order: - The key passed in, if one was passed in. - Any key we can find through an SSH agent (if allowed). - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if all...
[ "def", "_auth", "(", "self", ",", "username", ",", "password", ",", "pkey", ",", "key_filenames", ",", "allow_agent", ",", "look_for_keys", ")", ":", "saved_exception", "=", "None", "two_factor", "=", "False", "allowed_types", "=", "[", "]", "if", "pkey", ...
Try, in order: - The key passed in, if one was passed in. - Any key we can find through an SSH agent (if allowed). - Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if allowed). - Plain username/password auth, if a password was given. (The password might b...
[ "Try", "in", "order", ":" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L413-L516
train
bitprophet/ssh
ssh/message.py
Message.get_bytes
def get_bytes(self, n): """ Return the next C{n} bytes of the Message, without decomposing into an int, string, etc. Just the raw bytes are returned. @return: a string of the next C{n} bytes of the Message, or a string of C{n} zero bytes, if there aren't C{n} bytes remainin...
python
def get_bytes(self, n): """ Return the next C{n} bytes of the Message, without decomposing into an int, string, etc. Just the raw bytes are returned. @return: a string of the next C{n} bytes of the Message, or a string of C{n} zero bytes, if there aren't C{n} bytes remainin...
[ "def", "get_bytes", "(", "self", ",", "n", ")", ":", "b", "=", "self", ".", "packet", ".", "read", "(", "n", ")", "if", "len", "(", "b", ")", "<", "n", ":", "return", "b", "+", "'\\x00'", "*", "(", "n", "-", "len", "(", "b", ")", ")", "re...
Return the next C{n} bytes of the Message, without decomposing into an int, string, etc. Just the raw bytes are returned. @return: a string of the next C{n} bytes of the Message, or a string of C{n} zero bytes, if there aren't C{n} bytes remaining. @rtype: string
[ "Return", "the", "next", "C", "{", "n", "}", "bytes", "of", "the", "Message", "without", "decomposing", "into", "an", "int", "string", "etc", ".", "Just", "the", "raw", "bytes", "are", "returned", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L103-L115
train
bitprophet/ssh
ssh/message.py
Message.add_int
def add_int(self, n): """ Add an integer to the stream. @param n: integer to add @type n: int """ self.packet.write(struct.pack('>I', n)) return self
python
def add_int(self, n): """ Add an integer to the stream. @param n: integer to add @type n: int """ self.packet.write(struct.pack('>I', n)) return self
[ "def", "add_int", "(", "self", ",", "n", ")", ":", "self", ".", "packet", ".", "write", "(", "struct", ".", "pack", "(", "'>I'", ",", "n", ")", ")", "return", "self" ]
Add an integer to the stream. @param n: integer to add @type n: int
[ "Add", "an", "integer", "to", "the", "stream", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L219-L227
train
bitprophet/ssh
ssh/message.py
Message.add_string
def add_string(self, s): """ Add a string to the stream. @param s: string to add @type s: str """ self.add_int(len(s)) self.packet.write(s) return self
python
def add_string(self, s): """ Add a string to the stream. @param s: string to add @type s: str """ self.add_int(len(s)) self.packet.write(s) return self
[ "def", "add_string", "(", "self", ",", "s", ")", ":", "self", ".", "add_int", "(", "len", "(", "s", ")", ")", "self", ".", "packet", ".", "write", "(", "s", ")", "return", "self" ]
Add a string to the stream. @param s: string to add @type s: str
[ "Add", "a", "string", "to", "the", "stream", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L250-L259
train
bitprophet/ssh
ssh/channel.py
Channel.resize_pty
def resize_pty(self, width=80, height=24): """ Resize the pseudo-terminal. This can be used to change the width and height of the terminal emulation created in a previous L{get_pty} call. @param width: new width (in characters) of the terminal screen @type width: int @p...
python
def resize_pty(self, width=80, height=24): """ Resize the pseudo-terminal. This can be used to change the width and height of the terminal emulation created in a previous L{get_pty} call. @param width: new width (in characters) of the terminal screen @type width: int @p...
[ "def", "resize_pty", "(", "self", ",", "width", "=", "80", ",", "height", "=", "24", ")", ":", "if", "self", ".", "closed", "or", "self", ".", "eof_received", "or", "self", ".", "eof_sent", "or", "not", "self", ".", "active", ":", "raise", "SSHExcept...
Resize the pseudo-terminal. This can be used to change the width and height of the terminal emulation created in a previous L{get_pty} call. @param width: new width (in characters) of the terminal screen @type width: int @param height: new height (in characters) of the terminal screen ...
[ "Resize", "the", "pseudo", "-", "terminal", ".", "This", "can", "be", "used", "to", "change", "the", "width", "and", "height", "of", "the", "terminal", "emulation", "created", "in", "a", "previous", "L", "{", "get_pty", "}", "call", "." ]
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L242-L267
train
bitprophet/ssh
ssh/channel.py
Channel.recv_exit_status
def recv_exit_status(self): """ Return the exit status from the process on the server. This is mostly useful for retrieving the reults of an L{exec_command}. If the command hasn't finished yet, this method will wait until it does, or until the channel is closed. If no exit stat...
python
def recv_exit_status(self): """ Return the exit status from the process on the server. This is mostly useful for retrieving the reults of an L{exec_command}. If the command hasn't finished yet, this method will wait until it does, or until the channel is closed. If no exit stat...
[ "def", "recv_exit_status", "(", "self", ")", ":", "self", ".", "status_event", ".", "wait", "(", ")", "assert", "self", ".", "status_event", ".", "isSet", "(", ")", "return", "self", ".", "exit_status" ]
Return the exit status from the process on the server. This is mostly useful for retrieving the reults of an L{exec_command}. If the command hasn't finished yet, this method will wait until it does, or until the channel is closed. If no exit status is provided by the server, -1 is retu...
[ "Return", "the", "exit", "status", "from", "the", "process", "on", "the", "server", ".", "This", "is", "mostly", "useful", "for", "retrieving", "the", "reults", "of", "an", "L", "{", "exec_command", "}", ".", "If", "the", "command", "hasn", "t", "finishe...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L282-L297
train
bitprophet/ssh
ssh/channel.py
Channel.send_exit_status
def send_exit_status(self, status): """ Send the exit status of an executed command to the client. (This really only makes sense in server mode.) Many clients expect to get some sort of status code back from an executed command after it completes. @param status...
python
def send_exit_status(self, status): """ Send the exit status of an executed command to the client. (This really only makes sense in server mode.) Many clients expect to get some sort of status code back from an executed command after it completes. @param status...
[ "def", "send_exit_status", "(", "self", ",", "status", ")", ":", "# in many cases, the channel will not still be open here.", "# that's fine.", "m", "=", "Message", "(", ")", "m", ".", "add_byte", "(", "chr", "(", "MSG_CHANNEL_REQUEST", ")", ")", "m", ".", "add_in...
Send the exit status of an executed command to the client. (This really only makes sense in server mode.) Many clients expect to get some sort of status code back from an executed command after it completes. @param status: the exit code of the process @type status: int...
[ "Send", "the", "exit", "status", "of", "an", "executed", "command", "to", "the", "client", ".", "(", "This", "really", "only", "makes", "sense", "in", "server", "mode", ".", ")", "Many", "clients", "expect", "to", "get", "some", "sort", "of", "status", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L299-L319
train
bitprophet/ssh
ssh/channel.py
Channel.recv
def recv(self, nbytes): """ Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by C{nbytes}. If a string of length zero is returned, the channel stream has closed. ...
python
def recv(self, nbytes): """ Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by C{nbytes}. If a string of length zero is returned, the channel stream has closed. ...
[ "def", "recv", "(", "self", ",", "nbytes", ")", ":", "try", ":", "out", "=", "self", ".", "in_buffer", ".", "read", "(", "nbytes", ",", "self", ".", "timeout", ")", "except", "PipeTimeout", ",", "e", ":", "raise", "socket", ".", "timeout", "(", ")"...
Receive data from the channel. The return value is a string representing the data received. The maximum amount of data to be received at once is specified by C{nbytes}. If a string of length zero is returned, the channel stream has closed. @param nbytes: maximum number of bytes to re...
[ "Receive", "data", "from", "the", "channel", ".", "The", "return", "value", "is", "a", "string", "representing", "the", "data", "received", ".", "The", "maximum", "amount", "of", "data", "to", "be", "received", "at", "once", "is", "specified", "by", "C", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L593-L622
train
bitprophet/ssh
ssh/channel.py
Channel.sendall
def sendall(self, s): """ Send data to the channel, without allowing partial results. Unlike L{send}, this method continues to send data from the given string until either all data has been sent or an error occurs. Nothing is returned. @param s: data to send. @type s: ...
python
def sendall(self, s): """ Send data to the channel, without allowing partial results. Unlike L{send}, this method continues to send data from the given string until either all data has been sent or an error occurs. Nothing is returned. @param s: data to send. @type s: ...
[ "def", "sendall", "(", "self", ",", "s", ")", ":", "while", "s", ":", "if", "self", ".", "closed", ":", "# this doesn't seem useful, but it is the documented behavior of Socket", "raise", "socket", ".", "error", "(", "'Socket is closed'", ")", "sent", "=", "self",...
Send data to the channel, without allowing partial results. Unlike L{send}, this method continues to send data from the given string until either all data has been sent or an error occurs. Nothing is returned. @param s: data to send. @type s: str @raise socket.timeout: if sen...
[ "Send", "data", "to", "the", "channel", "without", "allowing", "partial", "results", ".", "Unlike", "L", "{", "send", "}", "this", "method", "continues", "to", "send", "data", "from", "the", "given", "string", "until", "either", "all", "data", "has", "been...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L767-L791
train
bitprophet/ssh
ssh/channel.py
Channel.sendall_stderr
def sendall_stderr(self, s): """ Send data to the channel's "stderr" stream, without allowing partial results. Unlike L{send_stderr}, this method continues to send data from the given string until all data has been sent or an error occurs. Nothing is returned. @...
python
def sendall_stderr(self, s): """ Send data to the channel's "stderr" stream, without allowing partial results. Unlike L{send_stderr}, this method continues to send data from the given string until all data has been sent or an error occurs. Nothing is returned. @...
[ "def", "sendall_stderr", "(", "self", ",", "s", ")", ":", "while", "s", ":", "if", "self", ".", "closed", ":", "raise", "socket", ".", "error", "(", "'Socket is closed'", ")", "sent", "=", "self", ".", "send_stderr", "(", "s", ")", "s", "=", "s", "...
Send data to the channel's "stderr" stream, without allowing partial results. Unlike L{send_stderr}, this method continues to send data from the given string until all data has been sent or an error occurs. Nothing is returned. @param s: data to send to the client as "stderr" o...
[ "Send", "data", "to", "the", "channel", "s", "stderr", "stream", "without", "allowing", "partial", "results", ".", "Unlike", "L", "{", "send_stderr", "}", "this", "method", "continues", "to", "send", "data", "from", "the", "given", "string", "until", "all", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L793-L815
train