partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
IndexQ.get_all_json_from_indexq
Gets all data from the todo files in indexq and returns one huge list of all data.
SolrClient/indexq.py
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): ''' 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
[ "Gets", "all", "data", "from", "the", "todo", "files", "in", "indexq", "and", "returns", "one", "huge", "list", "of", "all", "data", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L389-L397
[ "def", "get_all_json_from_indexq", "(", "self", ")", ":", "files", "=", "self", ".", "get_all_as_list", "(", ")", "out", "=", "[", "]", "for", "efile", "in", "files", ":", "out", ".", "extend", "(", "self", ".", "_open_file", "(", "efile", ")", ")", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
IndexQ.get_multi_q
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...
SolrClient/indexq.py
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'): ''' 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...
[ "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...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/indexq.py#L408-L424
[ "def", "get_multi_q", "(", "self", ",", "sentinel", "=", "'STOP'", ")", ":", "self", ".", "in_q", "=", "JoinableQueue", "(", ")", "self", ".", "indexer_process", "=", "Process", "(", "target", "=", "self", ".", "_indexer_process", ",", "args", "=", "(", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
TransportBase._retry
Internal mechanism to try to send data to multiple Solr Hosts if the query fails on the first one.
SolrClient/transport/transportbase.py
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): """ 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...
[ "Internal", "mechanism", "to", "try", "to", "send", "data", "to", "multiple", "Solr", "Hosts", "if", "the", "query", "fails", "on", "the", "first", "one", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/transport/transportbase.py#L28-L51
[ "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", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.commit
: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...
SolrClient/solrclient.py
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): """ :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", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "bool", "openSearcher", ":", "If", "new", "searcher", "is", "to", "be", "opened", ":", "param", "bool", "softCommit", ":", "SoftCommit"...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L39-L64
[ "def", "commit", "(", "self", ",", "collection", ",", "openSearcher", "=", "False", ",", "softCommit", "=", "False", ",", "waitSearcher", "=", "True", ",", "commit", "=", "True", ",", "*", "*", "kwargs", ")", ":", "comm", "=", "{", "'openSearcher'", ":...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.query_raw
: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...
SolrClient/solrclient.py
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): """ :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...
[ ":", "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...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L66-L90
[ "def", "query_raw", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "headers", "=", "{", "'content-type'", ":", "'application/x-www-form-urlencoded'", "}", "data", "=", "query", "resp", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.query
: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...
SolrClient/solrclient.py
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): """ :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...
[ ":", "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"...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L92-L129
[ "def", "query", "(", "self", ",", "collection", ",", "query", ",", "request_handler", "=", "'select'", ",", "*", "*", "kwargs", ")", ":", "for", "field", "in", "[", "'facet.pivot'", "]", ":", "if", "field", "in", "query", ".", "keys", "(", ")", ":", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.index
: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. :: ...
SolrClient/solrclient.py
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): """ :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...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "docs", "list", "docs", ":", "List", "of", "dicts", ".", "ex", ":", "[", "{", "title", ":", "testing", "solr", "indexing", "...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L131-L144
[ "def", "index", "(", "self", ",", "collection", ",", "docs", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "json", ".", "dumps", "(", "docs", ")", "return", "self", ".", "index_json", "(", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.index_json
: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...
SolrClient/solrclient.py
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): """ :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...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "data", "str", "data", ":", "Valid", "Solr", "JSON", "as", "a", "string", ".", "ex", ":", "[", "{", "title", ":", "testing",...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L146-L175
[ "def", "index_json", "(", "self", ",", "collection", ",", "data", ",", "params", "=", "None", ",", "min_rf", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "resp", ",", "con_inf", "=", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.get
: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')
SolrClient/solrclient.py
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): """ :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", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L177-L194
[ "def", "get", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.mget
: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')
SolrClient/solrclient.py
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): """ :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", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L196-L213
[ "def", "mget", "(", "self", ",", "collection", ",", "doc_ids", ",", "*", "*", "kwargs", ")", ":", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", "send_request", "(", "method", "=", "'GET'", ",", "endpoint", "=", "'get'", ",", "collection",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.delete_doc_by_id
: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')
SolrClient/solrclient.py
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): """ :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...
[ ":", "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", "...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L215-L233
[ "def", "delete_doc_by_id", "(", "self", ",", "collection", ",", "doc_id", ",", "*", "*", "kwargs", ")", ":", "if", "' '", "in", "doc_id", ":", "doc_id", "=", "'\"{}\"'", ".", "format", "(", "doc_id", ")", "temp", "=", "{", "\"delete\"", ":", "{", "\"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.delete_doc_by_query
: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','*:*')
SolrClient/solrclient.py
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): """ :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...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "query", ":", "Query", "selecting", "documents", "to", "be", "deleted", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L235-L251
[ "def", "delete_doc_by_query", "(", "self", ",", "collection", ",", "query", ",", "*", "*", "kwargs", ")", ":", "temp", "=", "{", "\"delete\"", ":", "{", "\"query\"", ":", "query", "}", "}", "resp", ",", "con_inf", "=", "self", ".", "transport", ".", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.local_index
: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...
SolrClient/solrclient.py
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): """ :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...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ":", "param", "str", "filename", ":", "String", "file", "path", "of", "the", "file", "to", "index", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L276-L298
[ "def", "local_index", "(", "self", ",", "collection", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "filename", ")", "self", ".", "logger", ".", "info", "(", "\"Indexing {} into Solr Collection...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.paging_query
: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 ...
SolrClient/solrclient.py
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): """ :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...
[ ":", "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",...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L301-L328
[ "def", "paging_query", "(", "self", ",", "collection", ",", "query", ",", "rows", "=", "1000", ",", "start", "=", "0", ",", "max_start", "=", "200000", ")", ":", "query", "=", "dict", "(", "query", ")", "while", "True", ":", "query", "[", "'start'", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
SolrClient.cursor_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 \ queries, if you don't specify it, the default is 'id desc'. ...
SolrClient/solrclient.py
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): """ :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 \ ...
[ ":", "param", "str", "collection", ":", "The", "name", "of", "the", "collection", "for", "the", "request", ".", ":", "param", "dict", "query", ":", "Dictionary", "of", "solr", "args", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrclient.py#L330-L355
[ "def", "cursor_query", "(", "self", ",", "collection", ",", "query", ")", ":", "cursor", "=", "'*'", "if", "'sort'", "not", "in", "query", ":", "query", "[", "'sort'", "]", "=", "'id desc'", "while", "True", ":", "query", "[", "'cursorMark'", "]", "=",...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
AwareRouter.get_shard_map
You can change this function to get the shard-map from somewhere/somehow place else in conjuction with save_shard_map().
SolrClient/routers/aware.py
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): """ 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 ...
[ "You", "can", "change", "this", "function", "to", "get", "the", "shard", "-", "map", "from", "somewhere", "/", "somehow", "place", "else", "in", "conjuction", "with", "save_shard_map", "()", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/aware.py#L122-L134
[ "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", ".", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
ZK.check_zk
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 '...
SolrClient/zk.py
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): ''' 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...
[ "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", ...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L43-L72
[ "def", "check_zk", "(", "self", ")", ":", "import", "telnetlib", "temp", "=", "self", ".", "zk_hosts", ".", "split", "(", "'/'", ")", "zks", "=", "temp", "[", "0", "]", ".", "split", "(", "','", ")", "status", "=", "{", "}", "for", "zk", "in", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
ZK.copy_config
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.
SolrClient/zk.py
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): ''' 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...
[ "Copies", "collection", "configs", "into", "a", "new", "folder", ".", "Can", "be", "used", "to", "create", "new", "collections", "based", "on", "existing", "configs", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L98-L111
[ "def", "copy_config", "(", "self", ",", "original", ",", "new", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "original", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collection doesn't exist in Zooke...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
ZK.download_collection_configs
Downloads ZK Directory to the FileSystem. :param collection str: Name of the collection (zk config name) :param fs_path str: Destination filesystem path.
SolrClient/zk.py
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): ''' 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...
[ "Downloads", "ZK", "Directory", "to", "the", "FileSystem", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L114-L124
[ "def", "download_collection_configs", "(", "self", ",", "collection", ",", "fs_path", ")", ":", "if", "not", "self", ".", "kz", ".", "exists", "(", "'/configs/{}'", ".", "format", "(", "collection", ")", ")", ":", "raise", "ZookeeperError", "(", "\"Collectio...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
ZK.upload_collection_configs
Uploads collection configurations from a specified directory to zookeeper.
SolrClient/zk.py
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): ''' 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...
[ "Uploads", "collection", "configurations", "from", "a", "specified", "directory", "to", "zookeeper", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/zk.py#L144-L152
[ "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...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Schema.create_field
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...
SolrClient/schema.py
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): ''' 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 ...
[ "Creates", "a", "new", "field", "in", "managed", "schema", "will", "raise", "ValueError", "if", "the", "field", "already", "exists", ".", "field_dict", "should", "look", "like", "this", "::" ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L35-L52
[ "def", "create_field", "(", "self", ",", "collection", ",", "field_dict", ")", ":", "if", "self", ".", "does_field_exist", "(", "collection", ",", "field_dict", "[", "'name'", "]", ")", ":", "raise", "ValueError", "(", "\"Field {} Already Exists in Solr Collection...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Schema.delete_field
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.
SolrClient/schema.py
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): ''' 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...
[ "Deletes", "a", "field", "from", "the", "Solr", "Collection", ".", "Will", "raise", "ValueError", "if", "the", "field", "doesn", "t", "exist", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L70-L82
[ "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 {}\"", ".", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Schema.does_field_exist
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.
SolrClient/schema.py
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): ''' 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 = ...
[ "Checks", "if", "the", "field", "exists", "will", "return", "a", "boolean", "True", "(", "exists", ")", "or", "False", "(", "doesn", "t", "exist", ")", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L85-L94
[ "def", "does_field_exist", "(", "self", ",", "collection", ",", "field_name", ")", ":", "schema", "=", "self", ".", "get_schema_fields", "(", "collection", ")", "logging", ".", "info", "(", "schema", ")", "return", "True", "if", "field_name", "in", "[", "f...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Schema.create_copy_field
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...
SolrClient/schema.py
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): ''' 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...
[ "Creates", "a", "copy", "field", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L96-L111
[ "def", "create_copy_field", "(", "self", ",", "collection", ",", "copy_dict", ")", ":", "temp", "=", "{", "\"add-copy-field\"", ":", "dict", "(", "copy_dict", ")", "}", "res", ",", "con_info", "=", "self", ".", "solr", ".", "transport", ".", "send_request"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Schema.delete_copy_field
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
SolrClient/schema.py
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): ''' 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...
[ "Deletes", "a", "copy", "field", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/schema.py#L113-L133
[ "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", "(", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
BaseRouter.shuffle_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:
SolrClient/routers/base.py
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): """ 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...
[ "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", ".", "...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/routers/base.py#L26-L35
[ "def", "shuffle_hosts", "(", "self", ")", ":", "if", "len", "(", "self", ".", "hosts", ")", ">", "1", ":", "random", ".", "shuffle", "(", "self", ".", "hosts", ")", "return", "self", ".", "hosts" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
XvfbRobot.start_virtual_display
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...
XvfbRobot/__init__.py
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): """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...
[ "Starts", "virtual", "display", "which", "will", "be", "destroyed", "after", "test", "execution", "will", "be", "end" ]
drobota/robotframework-xvfb
python
https://github.com/drobota/robotframework-xvfb/blob/66cd6174b637ab71aada71067ce4eaaa3280eb17/XvfbRobot/__init__.py#L34-L58
[ "def", "start_virtual_display", "(", "self", ",", "width", "=", "1440", ",", "height", "=", "900", ",", "colordepth", "=", "24", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_display", "is", "None", ":", "logger", ".", "info", "(", "\"Using...
66cd6174b637ab71aada71067ce4eaaa3280eb17
train
Collections.api
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
SolrClient/collections.py
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): """ 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 ...
[ "Sends", "a", "request", "to", "Solr", "Collections", "API", ".", "Documentation", "is", "here", ":", "https", ":", "//", "cwiki", ".", "apache", ".", "org", "/", "confluence", "/", "display", "/", "solr", "/", "Collections", "+", "API" ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L20-L42
[ "def", "api", "(", "self", ",", "action", ",", "args", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "{", "}", "args", "[", "'action'", "]", "=", "action", ".", "upper", "(", ")", "try", ":", "res", ",", "con_info", "=", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Collections.clusterstatus
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.
SolrClient/collections.py
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): """ 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...
[ "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",...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L44-L71
[ "def", "clusterstatus", "(", "self", ")", ":", "res", "=", "self", ".", "cluster_status_raw", "(", ")", "cluster", "=", "res", "[", "'cluster'", "]", "[", "'collections'", "]", "out", "=", "{", "}", "try", ":", "for", "collection", "in", "cluster", ":"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Collections.create
Create a new collection.
SolrClient/collections.py
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): """ Create a new collection. """ if params is None: params = {} params.update( name=name, numShards=numShards ) return self.api('CREATE', params)
[ "Create", "a", "new", "collection", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L97-L107
[ "def", "create", "(", "self", ",", "name", ",", "numShards", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "params", ".", "update", "(", "name", "=", "name", ",", "numShards", "=", "numShards", ")...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Collections._get_collection_counts
Queries each core to get individual counts for each core for each shard.
SolrClient/collections.py
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): """ 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[...
[ "Queries", "each", "core", "to", "get", "individual", "counts", "for", "each", "core", "for", "each", "shard", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L109-L125
[ "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'", "]...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Collections.check_status
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.
SolrClient/collections.py
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): """ 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...
[ "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...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/collections.py#L142-L172
[ "def", "check_status", "(", "self", ",", "ignore", "=", "(", ")", ",", "status", "=", "None", ")", ":", "self", ".", "SHARD_CHECKS", "=", "[", "{", "'check_msg'", ":", "'Bad Core Count Check'", ",", "'f'", ":", "self", ".", "_check_shard_count", "}", ","...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer.reindex
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.
SolrClient/helpers/reindexer.py
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): ''' 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...
[ "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"...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L87-L96
[ "def", "reindex", "(", "self", ",", "fq", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "for", "items", "in", "self", ".", "_getter", "(", "fq", "=", "fq", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_putter", "(", "items", ")", "if"...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._from_solr
Method for retrieving batch data from Solr.
SolrClient/helpers/reindexer.py
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): ''' 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...
[ "Method", "for", "retrieving", "batch", "data", "from", "Solr", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L99-L139
[ "def", "_from_solr", "(", "self", ",", "fq", "=", "[", "]", ",", "report_frequency", "=", "25", ")", ":", "cursor", "=", "'*'", "stime", "=", "datetime", ".", "now", "(", ")", "query_count", "=", "0", "while", "True", ":", "#Get data with starting cursor...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._trim_fields
Removes ignore fields from the data that we got from Solr.
SolrClient/helpers/reindexer.py
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): ''' 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
[ "Removes", "ignore", "fields", "from", "the", "data", "that", "we", "got", "from", "Solr", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L142-L150
[ "def", "_trim_fields", "(", "self", ",", "docs", ")", ":", "for", "doc", "in", "docs", ":", "for", "field", "in", "self", ".", "_ignore_fields", ":", "if", "field", "in", "doc", ":", "del", "(", "doc", "[", "field", "]", ")", "return", "docs" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._get_query
Query tempalte for source Solr, sorts by id by default.
SolrClient/helpers/reindexer.py
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 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'] = "{...
[ "Query", "tempalte", "for", "source", "Solr", "sorts", "by", "id", "by", "default", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L153-L165
[ "def", "_get_query", "(", "self", ",", "cursor", ")", ":", "query", "=", "{", "'q'", ":", "'*:*'", ",", "'sort'", ":", "'id desc'", ",", "'rows'", ":", "self", ".", "_rows", ",", "'cursorMark'", ":", "cursor", "}", "if", "self", ".", "_date_field", "...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._to_solr
Sends data to a Solr instance.
SolrClient/helpers/reindexer.py
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): ''' Sends data to a Solr instance. ''' return self._dest.index_json(self._dest_coll, json.dumps(data,sort_keys=True))
[ "Sends", "data", "to", "a", "Solr", "instance", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L175-L179
[ "def", "_to_solr", "(", "self", ",", "data", ")", ":", "return", "self", ".", "_dest", ".", "index_json", "(", "self", ".", "_dest_coll", ",", "json", ".", "dumps", "(", "data", ",", "sort_keys", "=", "True", ")", ")" ]
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._get_date_range_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
SolrClient/helpers/reindexer.py
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): ''' 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"...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L182-L201
[ "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", "=", "{...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._get_edge_date
This method is used to get start and end dates for the collection.
SolrClient/helpers/reindexer.py
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): ''' 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), ...
[ "This", "method", "is", "used", "to", "get", "start", "and", "end", "dates", "for", "the", "collection", "." ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L204-L212
[ "def", "_get_edge_date", "(", "self", ",", "date_field", ",", "sort", ")", ":", "return", "self", ".", "_source", ".", "query", "(", "self", ".", "_source_coll", ",", "{", "'q'", ":", "'*:*'", ",", "'rows'", ":", "1", ",", "'fq'", ":", "'+{}:*'", "."...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer._get_date_facet_counts
Returns Range Facet counts based on
SolrClient/helpers/reindexer.py
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): ''' 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 ...
[ "Returns", "Range", "Facet", "counts", "based", "on" ]
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L215-L248
[ "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...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Reindexer.resume
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...
SolrClient/helpers/reindexer.py
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): ''' 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 ...
[ "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", ...
moonlitesolutions/SolrClient
python
https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L251-L291
[ "def", "resume", "(", "self", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "timespan", "=", "'DAY'", ",", "check", "=", "False", ")", ":", "if", "type", "(", "self", ".", "_source", ")", "is", "not", "SolrClient", "or", "type", ...
19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b
train
Transport.start_client
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 ...
ssh/transport.py
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): """ 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...
[ "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", "....
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L417-L467
[ "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", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.start_server
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...
ssh/transport.py
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): """ 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...
[ "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",...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L469-L531
[ "def", "start_server", "(", "self", ",", "event", "=", "None", ",", "server", "=", "None", ")", ":", "if", "server", "is", "None", ":", "server", "=", "ServerInterface", "(", ")", "self", ".", "server_mode", "=", "True", "self", ".", "server_object", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.close
Close this session, and any open channels that are tied to it.
ssh/transport.py
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): """ 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()
[ "Close", "this", "session", "and", "any", "open", "channels", "that", "are", "tied", "to", "it", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L610-L620
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "active", ":", "return", "self", ".", "active", "=", "False", "self", ".", "packetizer", ".", "close", "(", ")", "self", ".", "join", "(", ")", "for", "chan", "in", "self", ".", "_c...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.open_forwarded_tcpip_channel
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...
ssh/transport.py
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)): """ 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...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L693-L704
[ "def", "open_forwarded_tcpip_channel", "(", "self", ",", "(", "src_addr", ",", "src_port", ")", ",", "(", "dest_addr", ",", "dest_port", ")", ")", ":", "return", "self", ".", "open_channel", "(", "'forwarded-tcpip'", ",", "(", "dest_addr", ",", "dest_port", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.request_port_forward
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...
ssh/transport.py
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): """ 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....
[ "Ask", "the", "server", "to", "forward", "TCP", "connections", "from", "a", "listening", "port", "on", "the", "server", "across", "this", "SSH", "session", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L774-L817
[ "def", "request_port_forward", "(", "self", ",", "address", ",", "port", ",", "handler", "=", "None", ")", ":", "if", "not", "self", ".", "active", ":", "raise", "SSHException", "(", "'SSH session not active'", ")", "address", "=", "str", "(", "address", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.send_ignore
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...
ssh/transport.py
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): """ 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: ...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L847-L863
[ "def", "send_ignore", "(", "self", ",", "bytes", "=", "None", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_byte", "(", "chr", "(", "MSG_IGNORE", ")", ")", "if", "bytes", "is", "None", ":", "bytes", "=", "(", "ord", "(", "rng", ".", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.renegotiate_keys
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...
ssh/transport.py
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): """ 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...
[ "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", "...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L865-L888
[ "def", "renegotiate_keys", "(", "self", ")", ":", "self", ".", "completion_event", "=", "threading", ".", "Event", "(", ")", "self", ".", "_send_kex_init", "(", ")", "while", "True", ":", "self", ".", "completion_event", ".", "wait", "(", "0.1", ")", "if...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.set_keepalive
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...
ssh/transport.py
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): """ 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...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L890-L902
[ "def", "set_keepalive", "(", "self", ",", "interval", ")", ":", "self", ".", "packetizer", ".", "set_keepalive", "(", "interval", ",", "lambda", "x", "=", "weakref", ".", "proxy", "(", "self", ")", ":", "x", ".", "global_request", "(", "'keepalive@lag.net'...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.connect
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...
ssh/transport.py
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): """ 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....
[ "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"...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L969-L1026
[ "def", "connect", "(", "self", ",", "hostkey", "=", "None", ",", "username", "=", "''", ",", "password", "=", "None", ",", "pkey", "=", "None", ")", ":", "if", "hostkey", "is", "not", "None", ":", "self", ".", "_preferred_keys", "=", "[", "hostkey", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport.auth_none
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...
ssh/transport.py
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): """ 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...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1094-L1119
[ "def", "auth_none", "(", "self", ",", "username", ")", ":", "if", "(", "not", "self", ".", "active", ")", "or", "(", "not", "self", ".", "initial_kex_done", ")", ":", "raise", "SSHException", "(", "'No existing session'", ")", "my_event", "=", "threading",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport._send_user_message
send a message, but block if we're in key negotiation. this is used for user-initiated requests.
ssh/transport.py
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): """ 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...
[ "send", "a", "message", "but", "block", "if", "we", "re", "in", "key", "negotiation", ".", "this", "is", "used", "for", "user", "-", "initiated", "requests", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1425-L1445
[ "def", "_send_user_message", "(", "self", ",", "data", ")", ":", "start", "=", "time", ".", "time", "(", ")", "while", "True", ":", "self", ".", "clear_to_send", ".", "wait", "(", "0.1", ")", "if", "not", "self", ".", "active", ":", "self", ".", "_...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport._set_K_H
used by a kex object to set the K (root key) and H (exchange hash)
ssh/transport.py
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): "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
[ "used", "by", "a", "kex", "object", "to", "set", "the", "K", "(", "root", "key", ")", "and", "H", "(", "exchange", "hash", ")" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1447-L1452
[ "def", "_set_K_H", "(", "self", ",", "k", ",", "h", ")", ":", "self", ".", "K", "=", "k", "self", ".", "H", "=", "h", "if", "self", ".", "session_id", "==", "None", ":", "self", ".", "session_id", "=", "h" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport._compute_key
id is 'A' - 'F' for the various keys used by ssh
ssh/transport.py
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): "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: ...
[ "id", "is", "A", "-", "F", "for", "the", "various", "keys", "used", "by", "ssh" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1466-L1482
[ "def", "_compute_key", "(", "self", ",", "id", ",", "nbytes", ")", ":", "m", "=", "Message", "(", ")", "m", ".", "add_mpint", "(", "self", ".", "K", ")", "m", ".", "add_bytes", "(", "self", ".", "H", ")", "m", ".", "add_byte", "(", "id", ")", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Transport._send_kex_init
announce to the other side that we'd like to negotiate keys, and what kind of key negotiation we support.
ssh/transport.py
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): """ 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...
[ "announce", "to", "the", "other", "side", "that", "we", "d", "like", "to", "negotiate", "keys", "and", "what", "kind", "of", "key", "negotiation", "we", "support", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1698-L1737
[ "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...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
_generate_prime
primtive attempt at prime generation
ssh/primes.py
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): "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:]...
[ "primtive", "attempt", "at", "prime", "generation" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L29-L44
[ "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", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
_roll_random
returns a random # from 0 to N-1
ssh/primes.py
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): "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...
[ "returns", "a", "random", "#", "from", "0", "to", "N", "-", "1" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L46-L65
[ "def", "_roll_random", "(", "rng", ",", "n", ")", ":", "bits", "=", "util", ".", "bit_length", "(", "n", "-", "1", ")", "bytes", "=", "(", "bits", "+", "7", ")", "//", "8", "hbyte_mask", "=", "pow", "(", "2", ",", "bits", "%", "8", ")", "-", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
PKey._write_private_key_file
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 ...
ssh/pkey.py
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): """ 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...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/pkey.py#L331-L353
[ "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...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
BufferedPipe.set_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
ssh/buffered_pipe.py
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): """ 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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L51-L64
[ "def", "set_event", "(", "self", ",", "event", ")", ":", "self", ".", "_event", "=", "event", "if", "len", "(", "self", ".", "_buffer", ")", ">", "0", ":", "event", ".", "set", "(", ")", "else", ":", "event", ".", "clear", "(", ")" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
BufferedPipe.feed
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
ssh/buffered_pipe.py
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): """ 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 ...
[ "Feed", "new", "data", "into", "this", "pipe", ".", "This", "method", "is", "assumed", "to", "be", "called", "from", "a", "separate", "thread", "so", "synchronization", "is", "done", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L66-L81
[ "def", "feed", "(", "self", ",", "data", ")", ":", "self", ".", "_lock", ".", "acquire", "(", ")", "try", ":", "if", "self", ".", "_event", "is", "not", "None", ":", "self", ".", "_event", ".", "set", "(", ")", "self", ".", "_buffer", ".", "fro...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPHandle.read
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...
ssh/sftp_handle.py
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): """ 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...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L72-L107
[ "def", "read", "(", "self", ",", "offset", ",", "length", ")", ":", "readfile", "=", "getattr", "(", "self", ",", "'readfile'", ",", "None", ")", "if", "readfile", "is", "None", ":", "return", "SFTP_OP_UNSUPPORTED", "try", ":", "if", "self", ".", "__te...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPHandle.write
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...
ssh/sftp_handle.py
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): """ 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. ...
[ "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", "()", "...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L109-L147
[ "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...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPServerInterface.canonicalize
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...
ssh/sftp_si.py
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): """ 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 ...
[ "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", "}", "...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_si.py#L259-L280
[ "def", "canonicalize", "(", "self", ",", "path", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "out", "=", "os", ".", "path", ".", "normpath", "(", "path", ")", "else", ":", "out", "=", "os", ".", "path", ".", "normpat...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
AgentClientProxy.connect
Method automatically called by the run() method of the AgentProxyThread
ssh/agent.py
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): """ 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...
[ "Method", "automatically", "called", "by", "the", "run", "()", "method", "of", "the", "AgentProxyThread" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/agent.py#L199-L219
[ "def", "connect", "(", "self", ")", ":", "if", "(", "'SSH_AUTH_SOCK'", "in", "os", ".", "environ", ")", "and", "(", "sys", ".", "platform", "!=", "'win32'", ")", ":", "conn", "=", "socket", ".", "socket", "(", "socket", ".", "AF_UNIX", ",", "socket",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SSHClient.save_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...
ssh/client.py
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): """ 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 ...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L179-L195
[ "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", ".",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SSHClient.exec_command
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...
ssh/client.py
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): """ 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. ...
[ "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"...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L348-L369
[ "def", "exec_command", "(", "self", ",", "command", ",", "bufsize", "=", "-", "1", ")", ":", "chan", "=", "self", ".", "_transport", ".", "open_session", "(", ")", "chan", ".", "exec_command", "(", "command", ")", "stdin", "=", "chan", ".", "makefile",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SSHClient._auth
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...
ssh/client.py
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): """ 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...
[ "Try", "in", "order", ":" ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L413-L516
[ "def", "_auth", "(", "self", ",", "username", ",", "password", ",", "pkey", ",", "key_filenames", ",", "allow_agent", ",", "look_for_keys", ")", ":", "saved_exception", "=", "None", "two_factor", "=", "False", "allowed_types", "=", "[", "]", "if", "pkey", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Message.get_bytes
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
ssh/message.py
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): """ 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...
[ "Return", "the", "next", "C", "{", "n", "}", "bytes", "of", "the", "Message", "without", "decomposing", "into", "an", "int", "string", "etc", ".", "Just", "the", "raw", "bytes", "are", "returned", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L103-L115
[ "def", "get_bytes", "(", "self", ",", "n", ")", ":", "b", "=", "self", ".", "packet", ".", "read", "(", "n", ")", "if", "len", "(", "b", ")", "<", "n", ":", "return", "b", "+", "'\\x00'", "*", "(", "n", "-", "len", "(", "b", ")", ")", "re...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Message.add_int
Add an integer to the stream. @param n: integer to add @type n: int
ssh/message.py
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): """ Add an integer to the stream. @param n: integer to add @type n: int """ self.packet.write(struct.pack('>I', n)) return self
[ "Add", "an", "integer", "to", "the", "stream", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L219-L227
[ "def", "add_int", "(", "self", ",", "n", ")", ":", "self", ".", "packet", ".", "write", "(", "struct", ".", "pack", "(", "'>I'", ",", "n", ")", ")", "return", "self" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Message.add_string
Add a string to the stream. @param s: string to add @type s: str
ssh/message.py
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): """ 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
[ "Add", "a", "string", "to", "the", "stream", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L250-L259
[ "def", "add_string", "(", "self", ",", "s", ")", ":", "self", ".", "add_int", "(", "len", "(", "s", ")", ")", "self", ".", "packet", ".", "write", "(", "s", ")", "return", "self" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.resize_pty
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 ...
ssh/channel.py
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): """ 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...
[ "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", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L242-L267
[ "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...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.recv_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...
ssh/channel.py
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): """ 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...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L282-L297
[ "def", "recv_exit_status", "(", "self", ")", ":", "self", ".", "status_event", ".", "wait", "(", ")", "assert", "self", ".", "status_event", ".", "isSet", "(", ")", "return", "self", ".", "exit_status" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.send_exit_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: the exit code of the process @type status: int...
ssh/channel.py
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): """ 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...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L299-L319
[ "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...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.recv
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...
ssh/channel.py
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): """ 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. ...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L593-L622
[ "def", "recv", "(", "self", ",", "nbytes", ")", ":", "try", ":", "out", "=", "self", ".", "in_buffer", ".", "read", "(", "nbytes", ",", "self", ".", "timeout", ")", "except", "PipeTimeout", ",", "e", ":", "raise", "socket", ".", "timeout", "(", ")"...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.sendall
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...
ssh/channel.py
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): """ 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: ...
[ "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...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L767-L791
[ "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",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
Channel.sendall_stderr
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...
ssh/channel.py
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): """ 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. @...
[ "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", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L793-L815
[ "def", "sendall_stderr", "(", "self", ",", "s", ")", ":", "while", "s", ":", "if", "self", ".", "closed", ":", "raise", "socket", ".", "error", "(", "'Socket is closed'", ")", "sent", "=", "self", ".", "send_stderr", "(", "s", ")", "s", "=", "s", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
agent_auth
Attempt to authenticate to the given transport using any of the private keys available from an SSH agent.
demos/demo.py
def agent_auth(transport, username): """ Attempt to authenticate to the given transport using any of the private keys available from an SSH agent. """ agent = ssh.Agent() agent_keys = agent.get_keys() if len(agent_keys) == 0: return for key in agent_keys: pr...
def agent_auth(transport, username): """ Attempt to authenticate to the given transport using any of the private keys available from an SSH agent. """ agent = ssh.Agent() agent_keys = agent.get_keys() if len(agent_keys) == 0: return for key in agent_keys: pr...
[ "Attempt", "to", "authenticate", "to", "the", "given", "transport", "using", "any", "of", "the", "private", "keys", "available", "from", "an", "SSH", "agent", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/demos/demo.py#L37-L55
[ "def", "agent_auth", "(", "transport", ",", "username", ")", ":", "agent", "=", "ssh", ".", "Agent", "(", ")", "agent_keys", "=", "agent", ".", "get_keys", "(", ")", "if", "len", "(", "agent_keys", ")", "==", "0", ":", "return", "for", "key", "in", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPFile._read_prefetch
read data out of the prefetch buffer, if possible. if the data isn't in the buffer, return None. otherwise, behaves like a normal read.
ssh/sftp_file.py
def _read_prefetch(self, size): """ read data out of the prefetch buffer, if possible. if the data isn't in the buffer, return None. otherwise, behaves like a normal read. """ # while not closed, and haven't fetched past the current position, and haven't reached EOF... ...
def _read_prefetch(self, size): """ read data out of the prefetch buffer, if possible. if the data isn't in the buffer, return None. otherwise, behaves like a normal read. """ # while not closed, and haven't fetched past the current position, and haven't reached EOF... ...
[ "read", "data", "out", "of", "the", "prefetch", "buffer", "if", "possible", ".", "if", "the", "data", "isn", "t", "in", "the", "buffer", "return", "None", ".", "otherwise", "behaves", "like", "a", "normal", "read", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L120-L147
[ "def", "_read_prefetch", "(", "self", ",", "size", ")", ":", "# while not closed, and haven't fetched past the current position, and haven't reached EOF...", "while", "True", ":", "offset", "=", "self", ".", "_data_in_prefetch_buffers", "(", "self", ".", "_realpos", ")", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPFile.chmod
Change the mode (permissions) of this file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param mode: new permissions @type mode: int
ssh/sftp_file.py
def chmod(self, mode): """ Change the mode (permissions) of this file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param mode: new permissions @type mode: int """ self.sftp._log(DEBUG, 'chmod(%s, %r)' % (...
def chmod(self, mode): """ Change the mode (permissions) of this file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param mode: new permissions @type mode: int """ self.sftp._log(DEBUG, 'chmod(%s, %r)' % (...
[ "Change", "the", "mode", "(", "permissions", ")", "of", "this", "file", ".", "The", "permissions", "are", "unix", "-", "style", "and", "identical", "to", "those", "used", "by", "python", "s", "C", "{", "os", ".", "chmod", "}", "function", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L230-L242
[ "def", "chmod", "(", "self", ",", "mode", ")", ":", "self", ".", "sftp", ".", "_log", "(", "DEBUG", ",", "'chmod(%s, %r)'", "%", "(", "hexlify", "(", "self", ".", "handle", ")", ",", "mode", ")", ")", "attr", "=", "SFTPAttributes", "(", ")", "attr"...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPFile.chown
Change the owner (C{uid}) and group (C{gid}) of this file. As with python's C{os.chown} function, you must pass both arguments, so if you only want to change one, use L{stat} first to retrieve the current owner and group. @param uid: new owner's uid @type uid: int @para...
ssh/sftp_file.py
def chown(self, uid, gid): """ Change the owner (C{uid}) and group (C{gid}) of this file. As with python's C{os.chown} function, you must pass both arguments, so if you only want to change one, use L{stat} first to retrieve the current owner and group. @param uid: new o...
def chown(self, uid, gid): """ Change the owner (C{uid}) and group (C{gid}) of this file. As with python's C{os.chown} function, you must pass both arguments, so if you only want to change one, use L{stat} first to retrieve the current owner and group. @param uid: new o...
[ "Change", "the", "owner", "(", "C", "{", "uid", "}", ")", "and", "group", "(", "C", "{", "gid", "}", ")", "of", "this", "file", ".", "As", "with", "python", "s", "C", "{", "os", ".", "chown", "}", "function", "you", "must", "pass", "both", "arg...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L244-L259
[ "def", "chown", "(", "self", ",", "uid", ",", "gid", ")", ":", "self", ".", "sftp", ".", "_log", "(", "DEBUG", ",", "'chown(%s, %r, %r)'", "%", "(", "hexlify", "(", "self", ".", "handle", ")", ",", "uid", ",", "gid", ")", ")", "attr", "=", "SFTPA...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPFile.utime
Set the access and modified times of this file. If C{times} is C{None}, then the file's access and modified times are set to the current time. Otherwise, C{times} must be a 2-tuple of numbers, of the form C{(atime, mtime)}, which is used to set the access and modified times, respective...
ssh/sftp_file.py
def utime(self, times): """ Set the access and modified times of this file. If C{times} is C{None}, then the file's access and modified times are set to the current time. Otherwise, C{times} must be a 2-tuple of numbers, of the form C{(atime, mtime)}, which is used to set the a...
def utime(self, times): """ Set the access and modified times of this file. If C{times} is C{None}, then the file's access and modified times are set to the current time. Otherwise, C{times} must be a 2-tuple of numbers, of the form C{(atime, mtime)}, which is used to set the a...
[ "Set", "the", "access", "and", "modified", "times", "of", "this", "file", ".", "If", "C", "{", "times", "}", "is", "C", "{", "None", "}", "then", "the", "file", "s", "access", "and", "modified", "times", "are", "set", "to", "the", "current", "time", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L261-L279
[ "def", "utime", "(", "self", ",", "times", ")", ":", "if", "times", "is", "None", ":", "times", "=", "(", "time", ".", "time", "(", ")", ",", "time", ".", "time", "(", ")", ")", "self", ".", "sftp", ".", "_log", "(", "DEBUG", ",", "'utime(%s, %...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
BufferedFile.flush
Write out any data in the write buffer. This may do nothing if write buffering is not turned on.
ssh/file.py
def flush(self): """ Write out any data in the write buffer. This may do nothing if write buffering is not turned on. """ self._write_all(self._wbuffer.getvalue()) self._wbuffer = StringIO() return
def flush(self): """ Write out any data in the write buffer. This may do nothing if write buffering is not turned on. """ self._write_all(self._wbuffer.getvalue()) self._wbuffer = StringIO() return
[ "Write", "out", "any", "data", "in", "the", "write", "buffer", ".", "This", "may", "do", "nothing", "if", "write", "buffering", "is", "not", "turned", "on", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L86-L93
[ "def", "flush", "(", "self", ")", ":", "self", ".", "_write_all", "(", "self", ".", "_wbuffer", ".", "getvalue", "(", ")", ")", "self", ".", "_wbuffer", "=", "StringIO", "(", ")", "return" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
BufferedFile.readline
Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is present and non-negative, it is a maximum byte count (including the trailing newline) and an incomplete line may ...
ssh/file.py
def readline(self, size=None): """ Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is present and non-negative, it is a maximum byte count (including the tr...
def readline(self, size=None): """ Read one entire line from the file. A trailing newline character is kept in the string (but may be absent when a file ends with an incomplete line). If the size argument is present and non-negative, it is a maximum byte count (including the tr...
[ "Read", "one", "entire", "line", "from", "the", "file", ".", "A", "trailing", "newline", "character", "is", "kept", "in", "the", "string", "(", "but", "may", "be", "absent", "when", "a", "file", "ends", "with", "an", "incomplete", "line", ")", ".", "If...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L165-L242
[ "def", "readline", "(", "self", ",", "size", "=", "None", ")", ":", "# it's almost silly how complex this function is.", "if", "self", ".", "_closed", ":", "raise", "IOError", "(", "'File is closed'", ")", "if", "not", "(", "self", ".", "_flags", "&", "self", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
BufferedFile._set_mode
Subclasses call this method to initialize the BufferedFile.
ssh/file.py
def _set_mode(self, mode='r', bufsize=-1): """ Subclasses call this method to initialize the BufferedFile. """ # set bufsize in any event, because it's used for readline(). self._bufsize = self._DEFAULT_BUFSIZE if bufsize < 0: # do no buffering by default, bec...
def _set_mode(self, mode='r', bufsize=-1): """ Subclasses call this method to initialize the BufferedFile. """ # set bufsize in any event, because it's used for readline(). self._bufsize = self._DEFAULT_BUFSIZE if bufsize < 0: # do no buffering by default, bec...
[ "Subclasses", "call", "this", "method", "to", "initialize", "the", "BufferedFile", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L391-L429
[ "def", "_set_mode", "(", "self", ",", "mode", "=", "'r'", ",", "bufsize", "=", "-", "1", ")", ":", "# set bufsize in any event, because it's used for readline().", "self", ".", "_bufsize", "=", "self", ".", "_DEFAULT_BUFSIZE", "if", "bufsize", "<", "0", ":", "...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.from_transport
Create an SFTP client channel from an open L{Transport}. @param t: an open L{Transport} which is already authenticated @type t: L{Transport} @return: a new L{SFTPClient} object, referring to an sftp session (channel) across the transport @rtype: L{SFTPClient}
ssh/sftp_client.py
def from_transport(cls, t): """ Create an SFTP client channel from an open L{Transport}. @param t: an open L{Transport} which is already authenticated @type t: L{Transport} @return: a new L{SFTPClient} object, referring to an sftp session (channel) across the transpo...
def from_transport(cls, t): """ Create an SFTP client channel from an open L{Transport}. @param t: an open L{Transport} which is already authenticated @type t: L{Transport} @return: a new L{SFTPClient} object, referring to an sftp session (channel) across the transpo...
[ "Create", "an", "SFTP", "client", "channel", "from", "an", "open", "L", "{", "Transport", "}", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L92-L106
[ "def", "from_transport", "(", "cls", ",", "t", ")", ":", "chan", "=", "t", ".", "open_session", "(", ")", "if", "chan", "is", "None", ":", "return", "None", "chan", ".", "invoke_subsystem", "(", "'sftp'", ")", "return", "cls", "(", "chan", ")" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.listdir_attr
Return a list containing L{SFTPAttributes} objects corresponding to files in the given C{path}. The list is in arbitrary order. It does not include the special entries C{'.'} and C{'..'} even if they are present in the folder. The returned L{SFTPAttributes} objects will each have an a...
ssh/sftp_client.py
def listdir_attr(self, path='.'): """ Return a list containing L{SFTPAttributes} objects corresponding to files in the given C{path}. The list is in arbitrary order. It does not include the special entries C{'.'} and C{'..'} even if they are present in the folder. The ...
def listdir_attr(self, path='.'): """ Return a list containing L{SFTPAttributes} objects corresponding to files in the given C{path}. The list is in arbitrary order. It does not include the special entries C{'.'} and C{'..'} even if they are present in the folder. The ...
[ "Return", "a", "list", "containing", "L", "{", "SFTPAttributes", "}", "objects", "corresponding", "to", "files", "in", "the", "given", "C", "{", "path", "}", ".", "The", "list", "is", "in", "arbitrary", "order", ".", "It", "does", "not", "include", "the"...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L152-L194
[ "def", "listdir_attr", "(", "self", ",", "path", "=", "'.'", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'listdir(%r)'", "%", "path", ")", "t", ",", "msg", "=", "self", ".", "_reques...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.remove
Remove the file at the given path. This only works on files; for removing folders (directories), use L{rmdir}. @param path: path (absolute or relative) of the file to remove @type path: str @raise IOError: if the path refers to a folder (directory)
ssh/sftp_client.py
def remove(self, path): """ Remove the file at the given path. This only works on files; for removing folders (directories), use L{rmdir}. @param path: path (absolute or relative) of the file to remove @type path: str @raise IOError: if the path refers to a folder (dir...
def remove(self, path): """ Remove the file at the given path. This only works on files; for removing folders (directories), use L{rmdir}. @param path: path (absolute or relative) of the file to remove @type path: str @raise IOError: if the path refers to a folder (dir...
[ "Remove", "the", "file", "at", "the", "given", "path", ".", "This", "only", "works", "on", "files", ";", "for", "removing", "folders", "(", "directories", ")", "use", "L", "{", "rmdir", "}", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L255-L267
[ "def", "remove", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'remove(%r)'", "%", "path", ")", "self", ".", "_request", "(", "CMD_REMOVE", ",", "path", ")" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.rmdir
Remove the folder named C{path}. @param path: name of the folder to remove @type path: str
ssh/sftp_client.py
def rmdir(self, path): """ Remove the folder named C{path}. @param path: name of the folder to remove @type path: str """ path = self._adjust_cwd(path) self._log(DEBUG, 'rmdir(%r)' % path) self._request(CMD_RMDIR, path)
def rmdir(self, path): """ Remove the folder named C{path}. @param path: name of the folder to remove @type path: str """ path = self._adjust_cwd(path) self._log(DEBUG, 'rmdir(%r)' % path) self._request(CMD_RMDIR, path)
[ "Remove", "the", "folder", "named", "C", "{", "path", "}", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L305-L314
[ "def", "rmdir", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'rmdir(%r)'", "%", "path", ")", "self", ".", "_request", "(", "CMD_RMDIR", ",", "path", ")" ]
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.stat
Retrieve information about a file on the remote system. The return value is an object whose attributes correspond to the attributes of python's C{stat} structure as returned by C{os.stat}, except that it contains fewer fields. An SFTP server may return as much or as little info as it w...
ssh/sftp_client.py
def stat(self, path): """ Retrieve information about a file on the remote system. The return value is an object whose attributes correspond to the attributes of python's C{stat} structure as returned by C{os.stat}, except that it contains fewer fields. An SFTP server may return...
def stat(self, path): """ Retrieve information about a file on the remote system. The return value is an object whose attributes correspond to the attributes of python's C{stat} structure as returned by C{os.stat}, except that it contains fewer fields. An SFTP server may return...
[ "Retrieve", "information", "about", "a", "file", "on", "the", "remote", "system", ".", "The", "return", "value", "is", "an", "object", "whose", "attributes", "correspond", "to", "the", "attributes", "of", "python", "s", "C", "{", "stat", "}", "structure", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L316-L340
[ "def", "stat", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'stat(%r)'", "%", "path", ")", "t", ",", "msg", "=", "self", ".", "_request", "(", "CMD_STAT", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.lstat
Retrieve information about a file on the remote system, without following symbolic links (shortcuts). This otherwise behaves exactly the same as L{stat}. @param path: the filename to stat @type path: str @return: an object containing attributes about the given file @rty...
ssh/sftp_client.py
def lstat(self, path): """ Retrieve information about a file on the remote system, without following symbolic links (shortcuts). This otherwise behaves exactly the same as L{stat}. @param path: the filename to stat @type path: str @return: an object containing a...
def lstat(self, path): """ Retrieve information about a file on the remote system, without following symbolic links (shortcuts). This otherwise behaves exactly the same as L{stat}. @param path: the filename to stat @type path: str @return: an object containing a...
[ "Retrieve", "information", "about", "a", "file", "on", "the", "remote", "system", "without", "following", "symbolic", "links", "(", "shortcuts", ")", ".", "This", "otherwise", "behaves", "exactly", "the", "same", "as", "L", "{", "stat", "}", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L342-L358
[ "def", "lstat", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'lstat(%r)'", "%", "path", ")", "t", ",", "msg", "=", "self", ".", "_request", "(", "CMD_LSTAT",...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.symlink
Create a symbolic link (shortcut) of the C{source} path at C{destination}. @param source: path of the original file @type source: str @param dest: path of the newly created symlink @type dest: str
ssh/sftp_client.py
def symlink(self, source, dest): """ Create a symbolic link (shortcut) of the C{source} path at C{destination}. @param source: path of the original file @type source: str @param dest: path of the newly created symlink @type dest: str """ dest = se...
def symlink(self, source, dest): """ Create a symbolic link (shortcut) of the C{source} path at C{destination}. @param source: path of the original file @type source: str @param dest: path of the newly created symlink @type dest: str """ dest = se...
[ "Create", "a", "symbolic", "link", "(", "shortcut", ")", "of", "the", "C", "{", "source", "}", "path", "at", "C", "{", "destination", "}", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L360-L374
[ "def", "symlink", "(", "self", ",", "source", ",", "dest", ")", ":", "dest", "=", "self", ".", "_adjust_cwd", "(", "dest", ")", "self", ".", "_log", "(", "DEBUG", ",", "'symlink(%r, %r)'", "%", "(", "source", ",", "dest", ")", ")", "if", "type", "(...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.chmod
Change the mode (permissions) of a file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param path: path of the file to change the permissions of @type path: str @param mode: new permissions @type mode: int
ssh/sftp_client.py
def chmod(self, path, mode): """ Change the mode (permissions) of a file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param path: path of the file to change the permissions of @type path: str @param mode: new per...
def chmod(self, path, mode): """ Change the mode (permissions) of a file. The permissions are unix-style and identical to those used by python's C{os.chmod} function. @param path: path of the file to change the permissions of @type path: str @param mode: new per...
[ "Change", "the", "mode", "(", "permissions", ")", "of", "a", "file", ".", "The", "permissions", "are", "unix", "-", "style", "and", "identical", "to", "those", "used", "by", "python", "s", "C", "{", "os", ".", "chmod", "}", "function", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L376-L391
[ "def", "chmod", "(", "self", ",", "path", ",", "mode", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'chmod(%r, %r)'", "%", "(", "path", ",", "mode", ")", ")", "attr", "=", "SFTPAttrib...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.readlink
Return the target of a symbolic link (shortcut). You can use L{symlink} to create these. The result may be either an absolute or relative pathname. @param path: path of the symbolic link file @type path: str @return: target path @rtype: str
ssh/sftp_client.py
def readlink(self, path): """ Return the target of a symbolic link (shortcut). You can use L{symlink} to create these. The result may be either an absolute or relative pathname. @param path: path of the symbolic link file @type path: str @return: target path ...
def readlink(self, path): """ Return the target of a symbolic link (shortcut). You can use L{symlink} to create these. The result may be either an absolute or relative pathname. @param path: path of the symbolic link file @type path: str @return: target path ...
[ "Return", "the", "target", "of", "a", "symbolic", "link", "(", "shortcut", ")", ".", "You", "can", "use", "L", "{", "symlink", "}", "to", "create", "these", ".", "The", "result", "may", "be", "either", "an", "absolute", "or", "relative", "pathname", "....
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L453-L474
[ "def", "readlink", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'readlink(%r)'", "%", "path", ")", "t", ",", "msg", "=", "self", ".", "_request", "(", "CMD_R...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.normalize
Return the normalized path (on the server) of a given path. This can be used to quickly resolve symbolic links or determine what the server is considering to be the "current folder" (by passing C{'.'} as C{path}). @param path: path to be normalized @type path: str @retu...
ssh/sftp_client.py
def normalize(self, path): """ Return the normalized path (on the server) of a given path. This can be used to quickly resolve symbolic links or determine what the server is considering to be the "current folder" (by passing C{'.'} as C{path}). @param path: path to be n...
def normalize(self, path): """ Return the normalized path (on the server) of a given path. This can be used to quickly resolve symbolic links or determine what the server is considering to be the "current folder" (by passing C{'.'} as C{path}). @param path: path to be n...
[ "Return", "the", "normalized", "path", "(", "on", "the", "server", ")", "of", "a", "given", "path", ".", "This", "can", "be", "used", "to", "quickly", "resolve", "symbolic", "links", "or", "determine", "what", "the", "server", "is", "considering", "to", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L476-L498
[ "def", "normalize", "(", "self", ",", "path", ")", ":", "path", "=", "self", ".", "_adjust_cwd", "(", "path", ")", "self", ".", "_log", "(", "DEBUG", ",", "'normalize(%r)'", "%", "path", ")", "t", ",", "msg", "=", "self", ".", "_request", "(", "CMD...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient.get
Copy a remote file (C{remotepath}) from the SFTP server to the local host as C{localpath}. Any exception raised by operations will be passed through. This method is primarily provided as a convenience. @param remotepath: the remote file to copy @type remotepath: str @param loc...
ssh/sftp_client.py
def get(self, remotepath, localpath, callback=None): """ Copy a remote file (C{remotepath}) from the SFTP server to the local host as C{localpath}. Any exception raised by operations will be passed through. This method is primarily provided as a convenience. @param remotepath:...
def get(self, remotepath, localpath, callback=None): """ Copy a remote file (C{remotepath}) from the SFTP server to the local host as C{localpath}. Any exception raised by operations will be passed through. This method is primarily provided as a convenience. @param remotepath:...
[ "Copy", "a", "remote", "file", "(", "C", "{", "remotepath", "}", ")", "from", "the", "SFTP", "server", "to", "the", "local", "host", "as", "C", "{", "localpath", "}", ".", "Any", "exception", "raised", "by", "operations", "will", "be", "passed", "throu...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L589-L627
[ "def", "get", "(", "self", ",", "remotepath", ",", "localpath", ",", "callback", "=", "None", ")", ":", "fr", "=", "self", ".", "file", "(", "remotepath", ",", "'rb'", ")", "file_size", "=", "self", ".", "stat", "(", "remotepath", ")", ".", "st_size"...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
SFTPClient._adjust_cwd
Return an adjusted path if we're emulating a "current working directory" for the server.
ssh/sftp_client.py
def _adjust_cwd(self, path): """ Return an adjusted path if we're emulating a "current working directory" for the server. """ if type(path) is unicode: path = path.encode('utf-8') if self._cwd is None: return path if (len(path) > 0) and (pa...
def _adjust_cwd(self, path): """ Return an adjusted path if we're emulating a "current working directory" for the server. """ if type(path) is unicode: path = path.encode('utf-8') if self._cwd is None: return path if (len(path) > 0) and (pa...
[ "Return", "an", "adjusted", "path", "if", "we", "re", "emulating", "a", "current", "working", "directory", "for", "the", "server", "." ]
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L714-L728
[ "def", "_adjust_cwd", "(", "self", ",", "path", ")", ":", "if", "type", "(", "path", ")", "is", "unicode", ":", "path", "=", "path", ".", "encode", "(", "'utf-8'", ")", "if", "self", ".", "_cwd", "is", "None", ":", "return", "path", "if", "(", "l...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
ResourceManager.register
Register a resource to be closed with an object is collected. When the given C{obj} is garbage-collected by the python interpreter, the C{resource} will be closed by having its C{close()} method called. Any exceptions are ignored. @param obj: the object to track ...
ssh/resource.py
def register(self, obj, resource): """ Register a resource to be closed with an object is collected. When the given C{obj} is garbage-collected by the python interpreter, the C{resource} will be closed by having its C{close()} method called. Any exceptions are ignored. ...
def register(self, obj, resource): """ Register a resource to be closed with an object is collected. When the given C{obj} is garbage-collected by the python interpreter, the C{resource} will be closed by having its C{close()} method called. Any exceptions are ignored. ...
[ "Register", "a", "resource", "to", "be", "closed", "with", "an", "object", "is", "collected", ".", "When", "the", "given", "C", "{", "obj", "}", "is", "garbage", "-", "collected", "by", "the", "python", "interpreter", "the", "C", "{", "resource", "}", ...
bitprophet/ssh
python
https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/resource.py#L46-L68
[ "def", "register", "(", "self", ",", "obj", ",", "resource", ")", ":", "def", "callback", "(", "ref", ")", ":", "try", ":", "resource", ".", "close", "(", ")", "except", ":", "pass", "del", "self", ".", "_table", "[", "id", "(", "resource", ")", ...
e8bdad4c82a50158a749233dca58c29e47c60b76
train
FlashArray._request
Perform HTTP request for REST API.
purestorage/purestorage.py
def _request(self, method, path, data=None, reestablish_session=True): """Perform HTTP request for REST API.""" if path.startswith("http"): url = path # For cases where URL of different form is needed. else: url = self._format_path(path) headers = {"Content-Type...
def _request(self, method, path, data=None, reestablish_session=True): """Perform HTTP request for REST API.""" if path.startswith("http"): url = path # For cases where URL of different form is needed. else: url = self._format_path(path) headers = {"Content-Type...
[ "Perform", "HTTP", "request", "for", "REST", "API", "." ]
PureStorage-OpenConnect/rest-client
python
https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L149-L196
[ "def", "_request", "(", "self", ",", "method", ",", "path", ",", "data", "=", "None", ",", "reestablish_session", "=", "True", ")", ":", "if", "path", ".", "startswith", "(", "\"http\"", ")", ":", "url", "=", "path", "# For cases where URL of different form ...
097d5f2bc6facf607d7e4a92567b09fb8cf5cb34
train
FlashArray._check_rest_version
Validate a REST API version is supported by the library and target array.
purestorage/purestorage.py
def _check_rest_version(self, version): """Validate a REST API version is supported by the library and target array.""" version = str(version) if version not in self.supported_rest_versions: msg = "Library is incompatible with REST API version {0}" raise ValueError(msg.f...
def _check_rest_version(self, version): """Validate a REST API version is supported by the library and target array.""" version = str(version) if version not in self.supported_rest_versions: msg = "Library is incompatible with REST API version {0}" raise ValueError(msg.f...
[ "Validate", "a", "REST", "API", "version", "is", "supported", "by", "the", "library", "and", "target", "array", "." ]
PureStorage-OpenConnect/rest-client
python
https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L202-L215
[ "def", "_check_rest_version", "(", "self", ",", "version", ")", ":", "version", "=", "str", "(", "version", ")", "if", "version", "not", "in", "self", ".", "supported_rest_versions", ":", "msg", "=", "\"Library is incompatible with REST API version {0}\"", "raise", ...
097d5f2bc6facf607d7e4a92567b09fb8cf5cb34
train
FlashArray._choose_rest_version
Return the newest REST API version supported by target array.
purestorage/purestorage.py
def _choose_rest_version(self): """Return the newest REST API version supported by target array.""" versions = self._list_available_rest_versions() versions = [LooseVersion(x) for x in versions if x in self.supported_rest_versions] if versions: return max(versions) el...
def _choose_rest_version(self): """Return the newest REST API version supported by target array.""" versions = self._list_available_rest_versions() versions = [LooseVersion(x) for x in versions if x in self.supported_rest_versions] if versions: return max(versions) el...
[ "Return", "the", "newest", "REST", "API", "version", "supported", "by", "target", "array", "." ]
PureStorage-OpenConnect/rest-client
python
https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L217-L226
[ "def", "_choose_rest_version", "(", "self", ")", ":", "versions", "=", "self", ".", "_list_available_rest_versions", "(", ")", "versions", "=", "[", "LooseVersion", "(", "x", ")", "for", "x", "in", "versions", "if", "x", "in", "self", ".", "supported_rest_ve...
097d5f2bc6facf607d7e4a92567b09fb8cf5cb34