repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
MediaFire/mediafire-python-open-sdk
mediafire/subsetio.py
SubsetIO.read
def read(self, limit=-1): """Read content. See file.read""" remaining = self.len - self.parent_fd.tell() + self.offset if limit > remaining or limit == -1: limit = remaining return self.parent_fd.read(limit)
python
def read(self, limit=-1): """Read content. See file.read""" remaining = self.len - self.parent_fd.tell() + self.offset if limit > remaining or limit == -1: limit = remaining return self.parent_fd.read(limit)
[ "def", "read", "(", "self", ",", "limit", "=", "-", "1", ")", ":", "remaining", "=", "self", ".", "len", "-", "self", ".", "parent_fd", ".", "tell", "(", ")", "+", "self", ".", "offset", "if", "limit", ">", "remaining", "or", "limit", "==", "-", ...
Read content. See file.read
[ "Read", "content", ".", "See", "file", ".", "read" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/subsetio.py#L48-L55
train
MediaFire/mediafire-python-open-sdk
mediafire/subsetio.py
SubsetIO.seek
def seek(self, offset, whence=os.SEEK_SET): """Seek to position in stream, see file.seek""" pos = None if whence == os.SEEK_SET: pos = self.offset + offset elif whence == os.SEEK_CUR: pos = self.tell() + offset elif whence == os.SEEK_END: pos ...
python
def seek(self, offset, whence=os.SEEK_SET): """Seek to position in stream, see file.seek""" pos = None if whence == os.SEEK_SET: pos = self.offset + offset elif whence == os.SEEK_CUR: pos = self.tell() + offset elif whence == os.SEEK_END: pos ...
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "os", ".", "SEEK_SET", ")", ":", "pos", "=", "None", "if", "whence", "==", "os", ".", "SEEK_SET", ":", "pos", "=", "self", ".", "offset", "+", "offset", "elif", "whence", "==", "os", ...
Seek to position in stream, see file.seek
[ "Seek", "to", "position", "in", "stream", "see", "file", ".", "seek" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/subsetio.py#L57-L73
train
MediaFire/mediafire-python-open-sdk
mediafire/subsetio.py
SubsetIO.close
def close(self): """Close file, see file.close""" try: self.parent_fd.fileno() except io.UnsupportedOperation: logger.debug("Not closing parent_fd - reusing existing") else: self.parent_fd.close()
python
def close(self): """Close file, see file.close""" try: self.parent_fd.fileno() except io.UnsupportedOperation: logger.debug("Not closing parent_fd - reusing existing") else: self.parent_fd.close()
[ "def", "close", "(", "self", ")", ":", "try", ":", "self", ".", "parent_fd", ".", "fileno", "(", ")", "except", "io", ".", "UnsupportedOperation", ":", "logger", ".", "debug", "(", "\"Not closing parent_fd - reusing existing\"", ")", "else", ":", "self", "."...
Close file, see file.close
[ "Close", "file", "see", "file", ".", "close" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/subsetio.py#L80-L87
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi._build_query
def _build_query(self, uri, params=None, action_token_type=None): """Prepare query string""" if params is None: params = QueryParams() params['response_format'] = 'json' session_token = None if action_token_type in self._action_tokens: # Favor action t...
python
def _build_query(self, uri, params=None, action_token_type=None): """Prepare query string""" if params is None: params = QueryParams() params['response_format'] = 'json' session_token = None if action_token_type in self._action_tokens: # Favor action t...
[ "def", "_build_query", "(", "self", ",", "uri", ",", "params", "=", "None", ",", "action_token_type", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "QueryParams", "(", ")", "params", "[", "'response_format'", "]", "=", "'json'"...
Prepare query string
[ "Prepare", "query", "string" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L97-L134
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.request
def request(self, action, params=None, action_token_type=None, upload_info=None, headers=None): """Perform request to MediaFire API action -- "category/name" of method to call params -- dict of parameters or query string action_token_type -- action token to use: None, "u...
python
def request(self, action, params=None, action_token_type=None, upload_info=None, headers=None): """Perform request to MediaFire API action -- "category/name" of method to call params -- dict of parameters or query string action_token_type -- action token to use: None, "u...
[ "def", "request", "(", "self", ",", "action", ",", "params", "=", "None", ",", "action_token_type", "=", "None", ",", "upload_info", "=", "None", ",", "headers", "=", "None", ")", ":", "uri", "=", "self", ".", "_build_uri", "(", "action", ")", "if", ...
Perform request to MediaFire API action -- "category/name" of method to call params -- dict of parameters or query string action_token_type -- action token to use: None, "upload", "image" upload_info -- in case of upload, dict of "fd" and "filename" headers -- additional headers...
[ "Perform", "request", "to", "MediaFire", "API" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L136-L197
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi._process_response
def _process_response(self, response): """Parse response""" forward_raw = False content_type = response.headers['Content-Type'] if content_type != 'application/json': logger.debug("headers: %s", response.headers) # API BUG: text/xml content-type with json payload...
python
def _process_response(self, response): """Parse response""" forward_raw = False content_type = response.headers['Content-Type'] if content_type != 'application/json': logger.debug("headers: %s", response.headers) # API BUG: text/xml content-type with json payload...
[ "def", "_process_response", "(", "self", ",", "response", ")", ":", "forward_raw", "=", "False", "content_type", "=", "response", ".", "headers", "[", "'Content-Type'", "]", "if", "content_type", "!=", "'application/json'", ":", "logger", ".", "debug", "(", "\...
Parse response
[ "Parse", "response" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L199-L238
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi._regenerate_secret_key
def _regenerate_secret_key(self): """Regenerate secret key http://www.mediafire.com/developers/core_api/1.3/getting_started/#call_signature """ # Don't regenerate the key if we have none if self._session and 'secret_key' in self._session: self._session['secret_key'] ...
python
def _regenerate_secret_key(self): """Regenerate secret key http://www.mediafire.com/developers/core_api/1.3/getting_started/#call_signature """ # Don't regenerate the key if we have none if self._session and 'secret_key' in self._session: self._session['secret_key'] ...
[ "def", "_regenerate_secret_key", "(", "self", ")", ":", "# Don't regenerate the key if we have none", "if", "self", ".", "_session", "and", "'secret_key'", "in", "self", ".", "_session", ":", "self", ".", "_session", "[", "'secret_key'", "]", "=", "(", "int", "(...
Regenerate secret key http://www.mediafire.com/developers/core_api/1.3/getting_started/#call_signature
[ "Regenerate", "secret", "key" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L240-L248
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.session
def session(self, value): """Set session token value -- dict returned by user/get_session_token""" # unset session token if value is None: self._session = None return if not isinstance(value, dict): raise ValueError("session info is required...
python
def session(self, value): """Set session token value -- dict returned by user/get_session_token""" # unset session token if value is None: self._session = None return if not isinstance(value, dict): raise ValueError("session info is required...
[ "def", "session", "(", "self", ",", "value", ")", ":", "# unset session token", "if", "value", "is", "None", ":", "self", ".", "_session", "=", "None", "return", "if", "not", "isinstance", "(", "value", ",", "dict", ")", ":", "raise", "ValueError", "(", ...
Set session token value -- dict returned by user/get_session_token
[ "Set", "session", "token" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L256-L281
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.set_action_token
def set_action_token(self, type_=None, action_token=None): """Set action tokens type_ -- either "upload" or "image" action_token -- string obtained from user/get_action_token, set None to remove the token """ if action_token is None: del self....
python
def set_action_token(self, type_=None, action_token=None): """Set action tokens type_ -- either "upload" or "image" action_token -- string obtained from user/get_action_token, set None to remove the token """ if action_token is None: del self....
[ "def", "set_action_token", "(", "self", ",", "type_", "=", "None", ",", "action_token", "=", "None", ")", ":", "if", "action_token", "is", "None", ":", "del", "self", ".", "_action_tokens", "[", "type_", "]", "else", ":", "self", ".", "_action_tokens", "...
Set action tokens type_ -- either "upload" or "image" action_token -- string obtained from user/get_action_token, set None to remove the token
[ "Set", "action", "tokens" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L288-L298
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.user_get_session_token
def user_get_session_token(self, app_id=None, email=None, password=None, ekey=None, fb_access_token=None, tw_oauth_token=None, tw_oauth_token_secret=None, api_key=None): """user/get_session_token http://www.med...
python
def user_get_session_token(self, app_id=None, email=None, password=None, ekey=None, fb_access_token=None, tw_oauth_token=None, tw_oauth_token_secret=None, api_key=None): """user/get_session_token http://www.med...
[ "def", "user_get_session_token", "(", "self", ",", "app_id", "=", "None", ",", "email", "=", "None", ",", "password", "=", "None", ",", "ekey", "=", "None", ",", "fb_access_token", "=", "None", ",", "tw_oauth_token", "=", "None", ",", "tw_oauth_token_secret"...
user/get_session_token http://www.mediafire.com/developers/core_api/1.3/user/#get_session_token
[ "user", "/", "get_session_token" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L318-L374
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.user_set_avatar
def user_set_avatar(self, action=None, quick_key=None, url=None): """user/set_avatar http://www.mediafire.com/developers/core_api/1.3/user/#set_avatar """ return self.request("user/set_avatar", QueryParams({ "action": action, "quick_key": quick_key, "...
python
def user_set_avatar(self, action=None, quick_key=None, url=None): """user/set_avatar http://www.mediafire.com/developers/core_api/1.3/user/#set_avatar """ return self.request("user/set_avatar", QueryParams({ "action": action, "quick_key": quick_key, "...
[ "def", "user_set_avatar", "(", "self", ",", "action", "=", "None", ",", "quick_key", "=", "None", ",", "url", "=", "None", ")", ":", "return", "self", ".", "request", "(", "\"user/set_avatar\"", ",", "QueryParams", "(", "{", "\"action\"", ":", "action", ...
user/set_avatar http://www.mediafire.com/developers/core_api/1.3/user/#set_avatar
[ "user", "/", "set_avatar" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L430-L439
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.user_update
def user_update(self, display_name=None, first_name=None, last_name=None, email=None, password=None, current_password=None, birth_date=None, gender=None, website=None, subdomain=None, location=None, newsletter=None, primary_usage=None, time...
python
def user_update(self, display_name=None, first_name=None, last_name=None, email=None, password=None, current_password=None, birth_date=None, gender=None, website=None, subdomain=None, location=None, newsletter=None, primary_usage=None, time...
[ "def", "user_update", "(", "self", ",", "display_name", "=", "None", ",", "first_name", "=", "None", ",", "last_name", "=", "None", ",", "email", "=", "None", ",", "password", "=", "None", ",", "current_password", "=", "None", ",", "birth_date", "=", "No...
user/update http://www.mediafire.com/developers/core_api/1.3/user/#update
[ "user", "/", "update" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L441-L466
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.folder_get_info
def folder_get_info(self, folder_key=None, device_id=None, details=None): """folder/get_info http://www.mediafire.com/developers/core_api/1.3/folder/#get_info """ return self.request('folder/get_info', QueryParams({ 'folder_key': folder_key, 'device_id': device_i...
python
def folder_get_info(self, folder_key=None, device_id=None, details=None): """folder/get_info http://www.mediafire.com/developers/core_api/1.3/folder/#get_info """ return self.request('folder/get_info', QueryParams({ 'folder_key': folder_key, 'device_id': device_i...
[ "def", "folder_get_info", "(", "self", ",", "folder_key", "=", "None", ",", "device_id", "=", "None", ",", "details", "=", "None", ")", ":", "return", "self", ".", "request", "(", "'folder/get_info'", ",", "QueryParams", "(", "{", "'folder_key'", ":", "fol...
folder/get_info http://www.mediafire.com/developers/core_api/1.3/folder/#get_info
[ "folder", "/", "get_info" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L468-L477
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.folder_get_content
def folder_get_content(self, folder_key=None, content_type=None, filter_=None, device_id=None, order_by=None, order_direction=None, chunk=None, details=None, chunk_size=None): """folder/get_content http://www.mediafire.com...
python
def folder_get_content(self, folder_key=None, content_type=None, filter_=None, device_id=None, order_by=None, order_direction=None, chunk=None, details=None, chunk_size=None): """folder/get_content http://www.mediafire.com...
[ "def", "folder_get_content", "(", "self", ",", "folder_key", "=", "None", ",", "content_type", "=", "None", ",", "filter_", "=", "None", ",", "device_id", "=", "None", ",", "order_by", "=", "None", ",", "order_direction", "=", "None", ",", "chunk", "=", ...
folder/get_content http://www.mediafire.com/developers/core_api/1.3/folder/#get_content
[ "folder", "/", "get_content" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L479-L497
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.folder_update
def folder_update(self, folder_key, foldername=None, description=None, privacy=None, privacy_recursive=None, mtime=None): """folder/update http://www.mediafire.com/developers/core_api/1.3/folder/#update """ return self.request('folder/update', QueryParams({ ...
python
def folder_update(self, folder_key, foldername=None, description=None, privacy=None, privacy_recursive=None, mtime=None): """folder/update http://www.mediafire.com/developers/core_api/1.3/folder/#update """ return self.request('folder/update', QueryParams({ ...
[ "def", "folder_update", "(", "self", ",", "folder_key", ",", "foldername", "=", "None", ",", "description", "=", "None", ",", "privacy", "=", "None", ",", "privacy_recursive", "=", "None", ",", "mtime", "=", "None", ")", ":", "return", "self", ".", "requ...
folder/update http://www.mediafire.com/developers/core_api/1.3/folder/#update
[ "folder", "/", "update" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L499-L512
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.folder_create
def folder_create(self, foldername=None, parent_key=None, action_on_duplicate=None, mtime=None): """folder/create http://www.mediafire.com/developers/core_api/1.3/folder/#create """ return self.request('folder/create', QueryParams({ 'foldername': folder...
python
def folder_create(self, foldername=None, parent_key=None, action_on_duplicate=None, mtime=None): """folder/create http://www.mediafire.com/developers/core_api/1.3/folder/#create """ return self.request('folder/create', QueryParams({ 'foldername': folder...
[ "def", "folder_create", "(", "self", ",", "foldername", "=", "None", ",", "parent_key", "=", "None", ",", "action_on_duplicate", "=", "None", ",", "mtime", "=", "None", ")", ":", "return", "self", ".", "request", "(", "'folder/create'", ",", "QueryParams", ...
folder/create http://www.mediafire.com/developers/core_api/1.3/folder/#create
[ "folder", "/", "create" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L514-L525
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.upload_check
def upload_check(self, filename=None, folder_key=None, filedrop_key=None, size=None, hash_=None, path=None, resumable=None): """upload/check http://www.mediafire.com/developers/core_api/1.3/upload/#check """ return self.request('upload/check', QueryParams({ ...
python
def upload_check(self, filename=None, folder_key=None, filedrop_key=None, size=None, hash_=None, path=None, resumable=None): """upload/check http://www.mediafire.com/developers/core_api/1.3/upload/#check """ return self.request('upload/check', QueryParams({ ...
[ "def", "upload_check", "(", "self", ",", "filename", "=", "None", ",", "folder_key", "=", "None", ",", "filedrop_key", "=", "None", ",", "size", "=", "None", ",", "hash_", "=", "None", ",", "path", "=", "None", ",", "resumable", "=", "None", ")", ":"...
upload/check http://www.mediafire.com/developers/core_api/1.3/upload/#check
[ "upload", "/", "check" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L555-L569
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.upload_simple
def upload_simple(self, fd, filename, folder_key=None, path=None, filedrop_key=None, action_on_duplicate=None, mtime=None, file_size=None, file_hash=None): """upload/simple http://www.mediafire.com/developers/core_api/1.3/upload/#simple """ ac...
python
def upload_simple(self, fd, filename, folder_key=None, path=None, filedrop_key=None, action_on_duplicate=None, mtime=None, file_size=None, file_hash=None): """upload/simple http://www.mediafire.com/developers/core_api/1.3/upload/#simple """ ac...
[ "def", "upload_simple", "(", "self", ",", "fd", ",", "filename", ",", "folder_key", "=", "None", ",", "path", "=", "None", ",", "filedrop_key", "=", "None", ",", "action_on_duplicate", "=", "None", ",", "mtime", "=", "None", ",", "file_size", "=", "None"...
upload/simple http://www.mediafire.com/developers/core_api/1.3/upload/#simple
[ "upload", "/", "simple" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L571-L599
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.upload_resumable
def upload_resumable(self, fd, filesize, filehash, unit_hash, unit_id, unit_size, quick_key=None, action_on_duplicate=None, mtime=None, version_control=None, folder_key=None, filedrop_key=None, path=None, previous_hash=None): """upload/r...
python
def upload_resumable(self, fd, filesize, filehash, unit_hash, unit_id, unit_size, quick_key=None, action_on_duplicate=None, mtime=None, version_control=None, folder_key=None, filedrop_key=None, path=None, previous_hash=None): """upload/r...
[ "def", "upload_resumable", "(", "self", ",", "fd", ",", "filesize", ",", "filehash", ",", "unit_hash", ",", "unit_id", ",", "unit_size", ",", "quick_key", "=", "None", ",", "action_on_duplicate", "=", "None", ",", "mtime", "=", "None", ",", "version_control"...
upload/resumable http://www.mediafire.com/developers/core_api/1.3/upload/#resumable
[ "upload", "/", "resumable" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L603-L638
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.upload_instant
def upload_instant(self, filename, size, hash_, quick_key=None, folder_key=None, filedrop_key=None, path=None, action_on_duplicate=None, mtime=None, version_control=None, previous_hash=None): """upload/instant http://www.mediafire.com...
python
def upload_instant(self, filename, size, hash_, quick_key=None, folder_key=None, filedrop_key=None, path=None, action_on_duplicate=None, mtime=None, version_control=None, previous_hash=None): """upload/instant http://www.mediafire.com...
[ "def", "upload_instant", "(", "self", ",", "filename", ",", "size", ",", "hash_", ",", "quick_key", "=", "None", ",", "folder_key", "=", "None", ",", "filedrop_key", "=", "None", ",", "path", "=", "None", ",", "action_on_duplicate", "=", "None", ",", "mt...
upload/instant http://www.mediafire.com/developers/core_api/1.3/upload/#instant
[ "upload", "/", "instant" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L641-L661
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.file_update
def file_update(self, quick_key, filename=None, description=None, mtime=None, privacy=None): """file/update http://www.mediafire.com/developers/core_api/1.3/file/#update """ return self.request('file/update', QueryParams({ 'quick_key': quick_key, ...
python
def file_update(self, quick_key, filename=None, description=None, mtime=None, privacy=None): """file/update http://www.mediafire.com/developers/core_api/1.3/file/#update """ return self.request('file/update', QueryParams({ 'quick_key': quick_key, ...
[ "def", "file_update", "(", "self", ",", "quick_key", ",", "filename", "=", "None", ",", "description", "=", "None", ",", "mtime", "=", "None", ",", "privacy", "=", "None", ")", ":", "return", "self", ".", "request", "(", "'file/update'", ",", "QueryParam...
file/update http://www.mediafire.com/developers/core_api/1.3/file/#update
[ "file", "/", "update" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L691-L703
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.file_update_file
def file_update_file(self, quick_key, file_extension=None, filename=None, description=None, mtime=None, privacy=None, timezone=None): """file/update_file http://www.mediafire.com/developers/core_api/1.3/file/#update_file """ return self....
python
def file_update_file(self, quick_key, file_extension=None, filename=None, description=None, mtime=None, privacy=None, timezone=None): """file/update_file http://www.mediafire.com/developers/core_api/1.3/file/#update_file """ return self....
[ "def", "file_update_file", "(", "self", ",", "quick_key", ",", "file_extension", "=", "None", ",", "filename", "=", "None", ",", "description", "=", "None", ",", "mtime", "=", "None", ",", "privacy", "=", "None", ",", "timezone", "=", "None", ")", ":", ...
file/update_file http://www.mediafire.com/developers/core_api/1.3/file/#update_file
[ "file", "/", "update_file" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L705-L720
train
MediaFire/mediafire-python-open-sdk
mediafire/api.py
MediaFireApi.file_zip
def file_zip(self, keys, confirm_download=None, meta_only=None): """file/zip http://www.mediafire.com/developers/core_api/1.3/file/#zip """ return self.request('file/zip', QueryParams({ 'keys': keys, 'confirm_download': confirm_download, 'meta_only': ...
python
def file_zip(self, keys, confirm_download=None, meta_only=None): """file/zip http://www.mediafire.com/developers/core_api/1.3/file/#zip """ return self.request('file/zip', QueryParams({ 'keys': keys, 'confirm_download': confirm_download, 'meta_only': ...
[ "def", "file_zip", "(", "self", ",", "keys", ",", "confirm_download", "=", "None", ",", "meta_only", "=", "None", ")", ":", "return", "self", ".", "request", "(", "'file/zip'", ",", "QueryParams", "(", "{", "'keys'", ":", "keys", ",", "'confirm_download'",...
file/zip http://www.mediafire.com/developers/core_api/1.3/file/#zip
[ "file", "/", "zip" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/api.py#L750-L759
train
dlecocq/nsq-py
nsq/connection.py
Connection._reset
def _reset(self): '''Reset all of our stateful variables''' self._socket = None # The pending messages we have to send, and the current buffer we're # sending self._pending = deque() self._out_buffer = '' # Our read buffer self._buffer = '' # The i...
python
def _reset(self): '''Reset all of our stateful variables''' self._socket = None # The pending messages we have to send, and the current buffer we're # sending self._pending = deque() self._out_buffer = '' # Our read buffer self._buffer = '' # The i...
[ "def", "_reset", "(", "self", ")", ":", "self", ".", "_socket", "=", "None", "# The pending messages we have to send, and the current buffer we're", "# sending", "self", ".", "_pending", "=", "deque", "(", ")", "self", ".", "_out_buffer", "=", "''", "# Our read buff...
Reset all of our stateful variables
[ "Reset", "all", "of", "our", "stateful", "variables" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L91-L104
train
dlecocq/nsq-py
nsq/connection.py
Connection.connect
def connect(self, force=False): '''Establish a connection''' # Don't re-establish existing connections if not force and self.alive(): return True self._reset() # Otherwise, try to connect with self._socket_lock: try: logger.info('...
python
def connect(self, force=False): '''Establish a connection''' # Don't re-establish existing connections if not force and self.alive(): return True self._reset() # Otherwise, try to connect with self._socket_lock: try: logger.info('...
[ "def", "connect", "(", "self", ",", "force", "=", "False", ")", ":", "# Don't re-establish existing connections", "if", "not", "force", "and", "self", ".", "alive", "(", ")", ":", "return", "True", "self", ".", "_reset", "(", ")", "# Otherwise, try to connect"...
Establish a connection
[ "Establish", "a", "connection" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L106-L151
train
dlecocq/nsq-py
nsq/connection.py
Connection.close
def close(self): '''Close our connection''' # Flush any unsent message try: while self.pending(): self.flush() except socket.error: pass with self._socket_lock: try: if self._socket: self._soc...
python
def close(self): '''Close our connection''' # Flush any unsent message try: while self.pending(): self.flush() except socket.error: pass with self._socket_lock: try: if self._socket: self._soc...
[ "def", "close", "(", "self", ")", ":", "# Flush any unsent message", "try", ":", "while", "self", ".", "pending", "(", ")", ":", "self", ".", "flush", "(", ")", "except", "socket", ".", "error", ":", "pass", "with", "self", ".", "_socket_lock", ":", "t...
Close our connection
[ "Close", "our", "connection" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L153-L166
train
dlecocq/nsq-py
nsq/connection.py
Connection.socket
def socket(self, blocking=True): '''Blockingly yield the socket''' # If the socket is available, then yield it. Otherwise, yield nothing if self._socket_lock.acquire(blocking): try: yield self._socket finally: self._socket_lock.release()
python
def socket(self, blocking=True): '''Blockingly yield the socket''' # If the socket is available, then yield it. Otherwise, yield nothing if self._socket_lock.acquire(blocking): try: yield self._socket finally: self._socket_lock.release()
[ "def", "socket", "(", "self", ",", "blocking", "=", "True", ")", ":", "# If the socket is available, then yield it. Otherwise, yield nothing", "if", "self", ".", "_socket_lock", ".", "acquire", "(", "blocking", ")", ":", "try", ":", "yield", "self", ".", "_socket"...
Blockingly yield the socket
[ "Blockingly", "yield", "the", "socket" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L168-L175
train
dlecocq/nsq-py
nsq/connection.py
Connection.identified
def identified(self, res): '''Handle a response to our 'identify' command. Returns response''' # If they support it, they should give us a JSON blob which we should # inspect. try: res.data = json.loads(res.data) self._identify_response = res.data logg...
python
def identified(self, res): '''Handle a response to our 'identify' command. Returns response''' # If they support it, they should give us a JSON blob which we should # inspect. try: res.data = json.loads(res.data) self._identify_response = res.data logg...
[ "def", "identified", "(", "self", ",", "res", ")", ":", "# If they support it, they should give us a JSON blob which we should", "# inspect.", "try", ":", "res", ".", "data", "=", "json", ".", "loads", "(", "res", ".", "data", ")", "self", ".", "_identify_response...
Handle a response to our 'identify' command. Returns response
[ "Handle", "a", "response", "to", "our", "identify", "command", ".", "Returns", "response" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L177-L211
train
dlecocq/nsq-py
nsq/connection.py
Connection.setblocking
def setblocking(self, blocking): '''Set whether or not this message is blocking''' for sock in self.socket(): sock.setblocking(blocking) self._blocking = blocking
python
def setblocking(self, blocking): '''Set whether or not this message is blocking''' for sock in self.socket(): sock.setblocking(blocking) self._blocking = blocking
[ "def", "setblocking", "(", "self", ",", "blocking", ")", ":", "for", "sock", "in", "self", ".", "socket", "(", ")", ":", "sock", ".", "setblocking", "(", "blocking", ")", "self", ".", "_blocking", "=", "blocking" ]
Set whether or not this message is blocking
[ "Set", "whether", "or", "not", "this", "message", "is", "blocking" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L217-L221
train
dlecocq/nsq-py
nsq/connection.py
Connection.flush
def flush(self): '''Flush some of the waiting messages, returns count written''' # When profiling, we found that while there was some efficiency to be # gained elsewhere, the big performance hit is sending lots of small # messages at a time. In particular, consumers send many 'FIN' messa...
python
def flush(self): '''Flush some of the waiting messages, returns count written''' # When profiling, we found that while there was some efficiency to be # gained elsewhere, the big performance hit is sending lots of small # messages at a time. In particular, consumers send many 'FIN' messa...
[ "def", "flush", "(", "self", ")", ":", "# When profiling, we found that while there was some efficiency to be", "# gained elsewhere, the big performance hit is sending lots of small", "# messages at a time. In particular, consumers send many 'FIN' messages", "# which are very small indeed and the ...
Flush some of the waiting messages, returns count written
[ "Flush", "some", "of", "the", "waiting", "messages", "returns", "count", "written" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L234-L266
train
dlecocq/nsq-py
nsq/connection.py
Connection.send
def send(self, command, message=None): '''Send a command over the socket with length endcoded''' if message: joined = command + constants.NL + util.pack(message) else: joined = command + constants.NL if self._blocking: for sock in self.socket(): ...
python
def send(self, command, message=None): '''Send a command over the socket with length endcoded''' if message: joined = command + constants.NL + util.pack(message) else: joined = command + constants.NL if self._blocking: for sock in self.socket(): ...
[ "def", "send", "(", "self", ",", "command", ",", "message", "=", "None", ")", ":", "if", "message", ":", "joined", "=", "command", "+", "constants", ".", "NL", "+", "util", ".", "pack", "(", "message", ")", "else", ":", "joined", "=", "command", "+...
Send a command over the socket with length endcoded
[ "Send", "a", "command", "over", "the", "socket", "with", "length", "endcoded" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L268-L278
train
dlecocq/nsq-py
nsq/connection.py
Connection.identify
def identify(self, data): '''Send an identification message''' return self.send(constants.IDENTIFY, json.dumps(data))
python
def identify(self, data): '''Send an identification message''' return self.send(constants.IDENTIFY, json.dumps(data))
[ "def", "identify", "(", "self", ",", "data", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "IDENTIFY", ",", "json", ".", "dumps", "(", "data", ")", ")" ]
Send an identification message
[ "Send", "an", "identification", "message" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L280-L282
train
dlecocq/nsq-py
nsq/connection.py
Connection.sub
def sub(self, topic, channel): '''Subscribe to a topic/channel''' return self.send(' '.join((constants.SUB, topic, channel)))
python
def sub(self, topic, channel): '''Subscribe to a topic/channel''' return self.send(' '.join((constants.SUB, topic, channel)))
[ "def", "sub", "(", "self", ",", "topic", ",", "channel", ")", ":", "return", "self", ".", "send", "(", "' '", ".", "join", "(", "(", "constants", ".", "SUB", ",", "topic", ",", "channel", ")", ")", ")" ]
Subscribe to a topic/channel
[ "Subscribe", "to", "a", "topic", "/", "channel" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L288-L290
train
dlecocq/nsq-py
nsq/connection.py
Connection.pub
def pub(self, topic, message): '''Publish to a topic''' return self.send(' '.join((constants.PUB, topic)), message)
python
def pub(self, topic, message): '''Publish to a topic''' return self.send(' '.join((constants.PUB, topic)), message)
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "return", "self", ".", "send", "(", "' '", ".", "join", "(", "(", "constants", ".", "PUB", ",", "topic", ")", ")", ",", "message", ")" ]
Publish to a topic
[ "Publish", "to", "a", "topic" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L292-L294
train
dlecocq/nsq-py
nsq/connection.py
Connection.mpub
def mpub(self, topic, *messages): '''Publish multiple messages to a topic''' return self.send(constants.MPUB + ' ' + topic, messages)
python
def mpub(self, topic, *messages): '''Publish multiple messages to a topic''' return self.send(constants.MPUB + ' ' + topic, messages)
[ "def", "mpub", "(", "self", ",", "topic", ",", "*", "messages", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "MPUB", "+", "' '", "+", "topic", ",", "messages", ")" ]
Publish multiple messages to a topic
[ "Publish", "multiple", "messages", "to", "a", "topic" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L296-L298
train
dlecocq/nsq-py
nsq/connection.py
Connection.rdy
def rdy(self, count): '''Indicate that you're ready to receive''' self.ready = count self.last_ready_sent = count return self.send(constants.RDY + ' ' + str(count))
python
def rdy(self, count): '''Indicate that you're ready to receive''' self.ready = count self.last_ready_sent = count return self.send(constants.RDY + ' ' + str(count))
[ "def", "rdy", "(", "self", ",", "count", ")", ":", "self", ".", "ready", "=", "count", "self", ".", "last_ready_sent", "=", "count", "return", "self", ".", "send", "(", "constants", ".", "RDY", "+", "' '", "+", "str", "(", "count", ")", ")" ]
Indicate that you're ready to receive
[ "Indicate", "that", "you", "re", "ready", "to", "receive" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L300-L304
train
dlecocq/nsq-py
nsq/connection.py
Connection.req
def req(self, message_id, timeout): '''Re-queue a message''' return self.send(constants.REQ + ' ' + message_id + ' ' + str(timeout))
python
def req(self, message_id, timeout): '''Re-queue a message''' return self.send(constants.REQ + ' ' + message_id + ' ' + str(timeout))
[ "def", "req", "(", "self", ",", "message_id", ",", "timeout", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "REQ", "+", "' '", "+", "message_id", "+", "' '", "+", "str", "(", "timeout", ")", ")" ]
Re-queue a message
[ "Re", "-", "queue", "a", "message" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L310-L312
train
dlecocq/nsq-py
nsq/connection.py
Connection._read
def _read(self, limit=1000): '''Return all the responses read''' # It's important to know that it may return no responses or multiple # responses. It depends on how the buffering works out. First, read from # the socket for sock in self.socket(): if sock is None: ...
python
def _read(self, limit=1000): '''Return all the responses read''' # It's important to know that it may return no responses or multiple # responses. It depends on how the buffering works out. First, read from # the socket for sock in self.socket(): if sock is None: ...
[ "def", "_read", "(", "self", ",", "limit", "=", "1000", ")", ":", "# It's important to know that it may return no responses or multiple", "# responses. It depends on how the buffering works out. First, read from", "# the socket", "for", "sock", "in", "self", ".", "socket", "(",...
Return all the responses read
[ "Return", "all", "the", "responses", "read" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L330-L371
train
dlecocq/nsq-py
nsq/connection.py
Connection.read
def read(self): '''Responses from an established socket''' responses = self._read() # Determine the number of messages in here and decrement our ready # count appropriately self.ready -= sum( map(int, (r.frame_type == Message.FRAME_TYPE for r in responses))) r...
python
def read(self): '''Responses from an established socket''' responses = self._read() # Determine the number of messages in here and decrement our ready # count appropriately self.ready -= sum( map(int, (r.frame_type == Message.FRAME_TYPE for r in responses))) r...
[ "def", "read", "(", "self", ")", ":", "responses", "=", "self", ".", "_read", "(", ")", "# Determine the number of messages in here and decrement our ready", "# count appropriately", "self", ".", "ready", "-=", "sum", "(", "map", "(", "int", ",", "(", "r", ".", ...
Responses from an established socket
[ "Responses", "from", "an", "established", "socket" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L373-L380
train
dlecocq/nsq-py
nsq/client.py
Client.discover
def discover(self, topic): '''Run the discovery mechanism''' logger.info('Discovering on topic %s', topic) producers = [] for lookupd in self._lookupd: logger.info('Discovering on %s', lookupd) try: # Find all the current producers on this instance...
python
def discover(self, topic): '''Run the discovery mechanism''' logger.info('Discovering on topic %s', topic) producers = [] for lookupd in self._lookupd: logger.info('Discovering on %s', lookupd) try: # Find all the current producers on this instance...
[ "def", "discover", "(", "self", ",", "topic", ")", ":", "logger", ".", "info", "(", "'Discovering on topic %s'", ",", "topic", ")", "producers", "=", "[", "]", "for", "lookupd", "in", "self", ".", "_lookupd", ":", "logger", ".", "info", "(", "'Discoverin...
Run the discovery mechanism
[ "Run", "the", "discovery", "mechanism" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L59-L89
train
dlecocq/nsq-py
nsq/client.py
Client.check_connections
def check_connections(self): '''Connect to all the appropriate instances''' logger.info('Checking connections') if self._lookupd: self.discover(self._topic) # Make sure we're connected to all the prescribed hosts for hostspec in self._nsqd_tcp_addresses: ...
python
def check_connections(self): '''Connect to all the appropriate instances''' logger.info('Checking connections') if self._lookupd: self.discover(self._topic) # Make sure we're connected to all the prescribed hosts for hostspec in self._nsqd_tcp_addresses: ...
[ "def", "check_connections", "(", "self", ")", ":", "logger", ".", "info", "(", "'Checking connections'", ")", "if", "self", ".", "_lookupd", ":", "self", ".", "discover", "(", "self", ".", "_topic", ")", "# Make sure we're connected to all the prescribed hosts", "...
Connect to all the appropriate instances
[ "Connect", "to", "all", "the", "appropriate", "instances" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L91-L125
train
dlecocq/nsq-py
nsq/client.py
Client.connection_checker
def connection_checker(self): '''Run periodic reconnection checks''' thread = ConnectionChecker(self) logger.info('Starting connection-checker thread') thread.start() try: yield thread finally: logger.info('Stopping connection-checker') ...
python
def connection_checker(self): '''Run periodic reconnection checks''' thread = ConnectionChecker(self) logger.info('Starting connection-checker thread') thread.start() try: yield thread finally: logger.info('Stopping connection-checker') ...
[ "def", "connection_checker", "(", "self", ")", ":", "thread", "=", "ConnectionChecker", "(", "self", ")", "logger", ".", "info", "(", "'Starting connection-checker thread'", ")", "thread", ".", "start", "(", ")", "try", ":", "yield", "thread", "finally", ":", ...
Run periodic reconnection checks
[ "Run", "periodic", "reconnection", "checks" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L128-L139
train
dlecocq/nsq-py
nsq/client.py
Client.connect
def connect(self, host, port): '''Connect to the provided host, port''' conn = connection.Connection(host, port, reconnection_backoff=self._reconnection_backoff, auth_secret=self._auth_secret, timeout=self._connect_timeout, **self._identify_options) ...
python
def connect(self, host, port): '''Connect to the provided host, port''' conn = connection.Connection(host, port, reconnection_backoff=self._reconnection_backoff, auth_secret=self._auth_secret, timeout=self._connect_timeout, **self._identify_options) ...
[ "def", "connect", "(", "self", ",", "host", ",", "port", ")", ":", "conn", "=", "connection", ".", "Connection", "(", "host", ",", "port", ",", "reconnection_backoff", "=", "self", ".", "_reconnection_backoff", ",", "auth_secret", "=", "self", ".", "_auth_...
Connect to the provided host, port
[ "Connect", "to", "the", "provided", "host", "port" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L141-L151
train
dlecocq/nsq-py
nsq/client.py
Client.add
def add(self, connection): '''Add a connection''' key = (connection.host, connection.port) with self._lock: if key not in self._connections: self._connections[key] = connection self.added(connection) return connection else: ...
python
def add(self, connection): '''Add a connection''' key = (connection.host, connection.port) with self._lock: if key not in self._connections: self._connections[key] = connection self.added(connection) return connection else: ...
[ "def", "add", "(", "self", ",", "connection", ")", ":", "key", "=", "(", "connection", ".", "host", ",", "connection", ".", "port", ")", "with", "self", ".", "_lock", ":", "if", "key", "not", "in", "self", ".", "_connections", ":", "self", ".", "_c...
Add a connection
[ "Add", "a", "connection" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L164-L173
train
dlecocq/nsq-py
nsq/client.py
Client.remove
def remove(self, connection): '''Remove a connection''' key = (connection.host, connection.port) with self._lock: found = self._connections.pop(key, None) try: self.close_connection(found) except Exception as exc: logger.warn('Failed to close %...
python
def remove(self, connection): '''Remove a connection''' key = (connection.host, connection.port) with self._lock: found = self._connections.pop(key, None) try: self.close_connection(found) except Exception as exc: logger.warn('Failed to close %...
[ "def", "remove", "(", "self", ",", "connection", ")", ":", "key", "=", "(", "connection", ".", "host", ",", "connection", ".", "port", ")", "with", "self", ".", "_lock", ":", "found", "=", "self", ".", "_connections", ".", "pop", "(", "key", ",", "...
Remove a connection
[ "Remove", "a", "connection" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L175-L184
train
dlecocq/nsq-py
nsq/client.py
Client.read
def read(self): '''Read from any of the connections that need it''' # We'll check all living connections connections = [c for c in self.connections() if c.alive()] if not connections: # If there are no connections, obviously we return no messages, but # we should...
python
def read(self): '''Read from any of the connections that need it''' # We'll check all living connections connections = [c for c in self.connections() if c.alive()] if not connections: # If there are no connections, obviously we return no messages, but # we should...
[ "def", "read", "(", "self", ")", ":", "# We'll check all living connections", "connections", "=", "[", "c", "for", "c", "in", "self", ".", "connections", "(", ")", "if", "c", ".", "alive", "(", ")", "]", "if", "not", "connections", ":", "# If there are no ...
Read from any of the connections that need it
[ "Read", "from", "any", "of", "the", "connections", "that", "need", "it" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L194-L270
train
dlecocq/nsq-py
nsq/client.py
Client.random_connection
def random_connection(self): '''Pick a random living connection''' # While at the moment there's no need for this to be a context manager # per se, I would like to use that interface since I anticipate # adding some wrapping around it at some point. yield random.choice( ...
python
def random_connection(self): '''Pick a random living connection''' # While at the moment there's no need for this to be a context manager # per se, I would like to use that interface since I anticipate # adding some wrapping around it at some point. yield random.choice( ...
[ "def", "random_connection", "(", "self", ")", ":", "# While at the moment there's no need for this to be a context manager", "# per se, I would like to use that interface since I anticipate", "# adding some wrapping around it at some point.", "yield", "random", ".", "choice", "(", "[", ...
Pick a random living connection
[ "Pick", "a", "random", "living", "connection" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L273-L279
train
dlecocq/nsq-py
nsq/client.py
Client.wait_response
def wait_response(self): '''Wait for a response''' responses = self.read() while not responses: responses = self.read() return responses
python
def wait_response(self): '''Wait for a response''' responses = self.read() while not responses: responses = self.read() return responses
[ "def", "wait_response", "(", "self", ")", ":", "responses", "=", "self", ".", "read", "(", ")", "while", "not", "responses", ":", "responses", "=", "self", ".", "read", "(", ")", "return", "responses" ]
Wait for a response
[ "Wait", "for", "a", "response" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L281-L286
train
dlecocq/nsq-py
nsq/client.py
Client.pub
def pub(self, topic, message): '''Publish the provided message to the provided topic''' with self.random_connection() as client: client.pub(topic, message) return self.wait_response()
python
def pub(self, topic, message): '''Publish the provided message to the provided topic''' with self.random_connection() as client: client.pub(topic, message) return self.wait_response()
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "with", "self", ".", "random_connection", "(", ")", "as", "client", ":", "client", ".", "pub", "(", "topic", ",", "message", ")", "return", "self", ".", "wait_response", "(", ")" ]
Publish the provided message to the provided topic
[ "Publish", "the", "provided", "message", "to", "the", "provided", "topic" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L293-L297
train
dlecocq/nsq-py
nsq/client.py
Client.mpub
def mpub(self, topic, *messages): '''Publish messages to a topic''' with self.random_connection() as client: client.mpub(topic, *messages) return self.wait_response()
python
def mpub(self, topic, *messages): '''Publish messages to a topic''' with self.random_connection() as client: client.mpub(topic, *messages) return self.wait_response()
[ "def", "mpub", "(", "self", ",", "topic", ",", "*", "messages", ")", ":", "with", "self", ".", "random_connection", "(", ")", "as", "client", ":", "client", ".", "mpub", "(", "topic", ",", "*", "messages", ")", "return", "self", ".", "wait_response", ...
Publish messages to a topic
[ "Publish", "messages", "to", "a", "topic" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L299-L303
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.create_socket
def create_socket(self): """Create a socket for the daemon, depending on the directory location. Args: config_dir (str): The absolute path to the config directory used by the daemon. Returns: socket.socket: The daemon socket. Clients connect to this socket. """...
python
def create_socket(self): """Create a socket for the daemon, depending on the directory location. Args: config_dir (str): The absolute path to the config directory used by the daemon. Returns: socket.socket: The daemon socket. Clients connect to this socket. """...
[ "def", "create_socket", "(", "self", ")", ":", "socket_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.sock'", ")", "# Create Socket and exit with 1, if socket can't be created", "try", ":", "if", "os", ".", "path", ".", ...
Create a socket for the daemon, depending on the directory location. Args: config_dir (str): The absolute path to the config directory used by the daemon. Returns: socket.socket: The daemon socket. Clients connect to this socket.
[ "Create", "a", "socket", "for", "the", "daemon", "depending", "on", "the", "directory", "location", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L82-L109
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.initialize_directories
def initialize_directories(self, root_dir): """Create all directories needed for logs and configs.""" if not root_dir: root_dir = os.path.expanduser('~') # Create config directory, if it doesn't exist self.config_dir = os.path.join(root_dir, '.config/pueue') if not o...
python
def initialize_directories(self, root_dir): """Create all directories needed for logs and configs.""" if not root_dir: root_dir = os.path.expanduser('~') # Create config directory, if it doesn't exist self.config_dir = os.path.join(root_dir, '.config/pueue') if not o...
[ "def", "initialize_directories", "(", "self", ",", "root_dir", ")", ":", "if", "not", "root_dir", ":", "root_dir", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "# Create config directory, if it doesn't exist", "self", ".", "config_dir", "=", "os",...
Create all directories needed for logs and configs.
[ "Create", "all", "directories", "needed", "for", "logs", "and", "configs", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L111-L119
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.respond_client
def respond_client(self, answer, socket): """Send an answer to the client.""" response = pickle.dumps(answer, -1) socket.sendall(response) self.read_list.remove(socket) socket.close()
python
def respond_client(self, answer, socket): """Send an answer to the client.""" response = pickle.dumps(answer, -1) socket.sendall(response) self.read_list.remove(socket) socket.close()
[ "def", "respond_client", "(", "self", ",", "answer", ",", "socket", ")", ":", "response", "=", "pickle", ".", "dumps", "(", "answer", ",", "-", "1", ")", "socket", ".", "sendall", "(", "response", ")", "self", ".", "read_list", ".", "remove", "(", "s...
Send an answer to the client.
[ "Send", "an", "answer", "to", "the", "client", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L121-L126
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.read_config
def read_config(self): """Read a previous configuration file or create a new with default values.""" config_file = os.path.join(self.config_dir, 'pueue.ini') self.config = configparser.ConfigParser() # Try to get configuration file and return it # If this doesn't work, a new defa...
python
def read_config(self): """Read a previous configuration file or create a new with default values.""" config_file = os.path.join(self.config_dir, 'pueue.ini') self.config = configparser.ConfigParser() # Try to get configuration file and return it # If this doesn't work, a new defa...
[ "def", "read_config", "(", "self", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.ini'", ")", "self", ".", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "# Try to get configuration f...
Read a previous configuration file or create a new with default values.
[ "Read", "a", "previous", "configuration", "file", "or", "create", "a", "new", "with", "default", "values", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L128-L150
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.write_config
def write_config(self): """Write the current configuration to the config file.""" config_file = os.path.join(self.config_dir, 'pueue.ini') with open(config_file, 'w') as file_descriptor: self.config.write(file_descriptor)
python
def write_config(self): """Write the current configuration to the config file.""" config_file = os.path.join(self.config_dir, 'pueue.ini') with open(config_file, 'w') as file_descriptor: self.config.write(file_descriptor)
[ "def", "write_config", "(", "self", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.ini'", ")", "with", "open", "(", "config_file", ",", "'w'", ")", "as", "file_descriptor", ":", "self", ".", "...
Write the current configuration to the config file.
[ "Write", "the", "current", "configuration", "to", "the", "config", "file", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L152-L156
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.main
def main(self): """The main function containing the loop for communication and process management. This function is the heart of the daemon. It is responsible for: - Client communication - Executing commands from clients - Update the status of processes by polling the Pr...
python
def main(self): """The main function containing the loop for communication and process management. This function is the heart of the daemon. It is responsible for: - Client communication - Executing commands from clients - Update the status of processes by polling the Pr...
[ "def", "main", "(", "self", ")", ":", "try", ":", "while", "self", ".", "running", ":", "# Trigger the processing of finished processes by the ProcessHandler.", "# If there are finished processes we write the log to keep it up to date.", "if", "self", ".", "process_handler", "....
The main function containing the loop for communication and process management. This function is the heart of the daemon. It is responsible for: - Client communication - Executing commands from clients - Update the status of processes by polling the ProcessHandler. - Log...
[ "The", "main", "function", "containing", "the", "loop", "for", "communication", "and", "process", "management", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L158-L273
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.stop_daemon
def stop_daemon(self, payload=None): """Kill current processes and initiate daemon shutdown. The daemon will shut down after a last check on all killed processes. """ kill_signal = signals['9'] self.process_handler.kill_all(kill_signal, True) self.running = False ...
python
def stop_daemon(self, payload=None): """Kill current processes and initiate daemon shutdown. The daemon will shut down after a last check on all killed processes. """ kill_signal = signals['9'] self.process_handler.kill_all(kill_signal, True) self.running = False ...
[ "def", "stop_daemon", "(", "self", ",", "payload", "=", "None", ")", ":", "kill_signal", "=", "signals", "[", "'9'", "]", "self", ".", "process_handler", ".", "kill_all", "(", "kill_signal", ",", "True", ")", "self", ".", "running", "=", "False", "return...
Kill current processes and initiate daemon shutdown. The daemon will shut down after a last check on all killed processes.
[ "Kill", "current", "processes", "and", "initiate", "daemon", "shutdown", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L275-L285
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.set_config
def set_config(self, payload): """Update the current config depending on the payload and save it.""" self.config['default'][payload['option']] = str(payload['value']) if payload['option'] == 'maxProcesses': self.process_handler.set_max(payload['value']) if payload['option'] ...
python
def set_config(self, payload): """Update the current config depending on the payload and save it.""" self.config['default'][payload['option']] = str(payload['value']) if payload['option'] == 'maxProcesses': self.process_handler.set_max(payload['value']) if payload['option'] ...
[ "def", "set_config", "(", "self", ",", "payload", ")", ":", "self", ".", "config", "[", "'default'", "]", "[", "payload", "[", "'option'", "]", "]", "=", "str", "(", "payload", "[", "'value'", "]", ")", "if", "payload", "[", "'option'", "]", "==", ...
Update the current config depending on the payload and save it.
[ "Update", "the", "current", "config", "depending", "on", "the", "payload", "and", "save", "it", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L287-L306
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.pipe_to_process
def pipe_to_process(self, payload): """Send something to stdin of a specific process.""" message = payload['input'] key = payload['key'] if not self.process_handler.is_running(key): return {'message': 'No running process for this key', 'status': 'error'} ...
python
def pipe_to_process(self, payload): """Send something to stdin of a specific process.""" message = payload['input'] key = payload['key'] if not self.process_handler.is_running(key): return {'message': 'No running process for this key', 'status': 'error'} ...
[ "def", "pipe_to_process", "(", "self", ",", "payload", ")", ":", "message", "=", "payload", "[", "'input'", "]", "key", "=", "payload", "[", "'key'", "]", "if", "not", "self", ".", "process_handler", ".", "is_running", "(", "key", ")", ":", "return", "...
Send something to stdin of a specific process.
[ "Send", "something", "to", "stdin", "of", "a", "specific", "process", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L308-L317
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.send_status
def send_status(self, payload): """Send the daemon status and the current queue for displaying.""" answer = {} data = [] # Get daemon status if self.paused: answer['status'] = 'paused' else: answer['status'] = 'running' # Add current queue...
python
def send_status(self, payload): """Send the daemon status and the current queue for displaying.""" answer = {} data = [] # Get daemon status if self.paused: answer['status'] = 'paused' else: answer['status'] = 'running' # Add current queue...
[ "def", "send_status", "(", "self", ",", "payload", ")", ":", "answer", "=", "{", "}", "data", "=", "[", "]", "# Get daemon status", "if", "self", ".", "paused", ":", "answer", "[", "'status'", "]", "=", "'paused'", "else", ":", "answer", "[", "'status'...
Send the daemon status and the current queue for displaying.
[ "Send", "the", "daemon", "status", "and", "the", "current", "queue", "for", "displaying", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L319-L344
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.reset_everything
def reset_everything(self, payload): """Kill all processes, delete the queue and clean everything up.""" kill_signal = signals['9'] self.process_handler.kill_all(kill_signal, True) self.process_handler.wait_for_finish() self.reset = True answer = {'message': 'Resetting c...
python
def reset_everything(self, payload): """Kill all processes, delete the queue and clean everything up.""" kill_signal = signals['9'] self.process_handler.kill_all(kill_signal, True) self.process_handler.wait_for_finish() self.reset = True answer = {'message': 'Resetting c...
[ "def", "reset_everything", "(", "self", ",", "payload", ")", ":", "kill_signal", "=", "signals", "[", "'9'", "]", "self", ".", "process_handler", ".", "kill_all", "(", "kill_signal", ",", "True", ")", "self", ".", "process_handler", ".", "wait_for_finish", "...
Kill all processes, delete the queue and clean everything up.
[ "Kill", "all", "processes", "delete", "the", "queue", "and", "clean", "everything", "up", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L346-L354
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.clear
def clear(self, payload): """Clear queue from any `done` or `failed` entries. The log will be rotated once. Otherwise we would loose all logs from thoes finished processes. """ self.logger.rotate(self.queue) self.queue.clear() self.logger.write(self.queue) ...
python
def clear(self, payload): """Clear queue from any `done` or `failed` entries. The log will be rotated once. Otherwise we would loose all logs from thoes finished processes. """ self.logger.rotate(self.queue) self.queue.clear() self.logger.write(self.queue) ...
[ "def", "clear", "(", "self", ",", "payload", ")", ":", "self", ".", "logger", ".", "rotate", "(", "self", ".", "queue", ")", "self", ".", "queue", ".", "clear", "(", ")", "self", ".", "logger", ".", "write", "(", "self", ".", "queue", ")", "answe...
Clear queue from any `done` or `failed` entries. The log will be rotated once. Otherwise we would loose all logs from thoes finished processes.
[ "Clear", "queue", "from", "any", "done", "or", "failed", "entries", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L356-L367
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.start
def start(self, payload): """Start the daemon and all processes or only specific processes.""" # Start specific processes, if `keys` is given in the payload if payload.get('keys'): succeeded = [] failed = [] for key in payload.get('keys'): succ...
python
def start(self, payload): """Start the daemon and all processes or only specific processes.""" # Start specific processes, if `keys` is given in the payload if payload.get('keys'): succeeded = [] failed = [] for key in payload.get('keys'): succ...
[ "def", "start", "(", "self", ",", "payload", ")", ":", "# Start specific processes, if `keys` is given in the payload", "if", "payload", ".", "get", "(", "'keys'", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", ...
Start the daemon and all processes or only specific processes.
[ "Start", "the", "daemon", "and", "all", "processes", "or", "only", "specific", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L369-L402
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.pause
def pause(self, payload): """Start the daemon and all processes or only specific processes.""" # Pause specific processes, if `keys` is given in the payload if payload.get('keys'): succeeded = [] failed = [] for key in payload.get('keys'): succ...
python
def pause(self, payload): """Start the daemon and all processes or only specific processes.""" # Pause specific processes, if `keys` is given in the payload if payload.get('keys'): succeeded = [] failed = [] for key in payload.get('keys'): succ...
[ "def", "pause", "(", "self", ",", "payload", ")", ":", "# Pause specific processes, if `keys` is given in the payload", "if", "payload", ".", "get", "(", "'keys'", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", ...
Start the daemon and all processes or only specific processes.
[ "Start", "the", "daemon", "and", "all", "processes", "or", "only", "specific", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L404-L443
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.edit_command
def edit_command(self, payload): """Edit the command of a specific entry.""" key = payload['key'] command = payload['command'] if self.queue[key]: if self.queue[key]['status'] in ['queued', 'stashed']: self.queue[key]['command'] = command answe...
python
def edit_command(self, payload): """Edit the command of a specific entry.""" key = payload['key'] command = payload['command'] if self.queue[key]: if self.queue[key]['status'] in ['queued', 'stashed']: self.queue[key]['command'] = command answe...
[ "def", "edit_command", "(", "self", ",", "payload", ")", ":", "key", "=", "payload", "[", "'key'", "]", "command", "=", "payload", "[", "'command'", "]", "if", "self", ".", "queue", "[", "key", "]", ":", "if", "self", ".", "queue", "[", "key", "]",...
Edit the command of a specific entry.
[ "Edit", "the", "command", "of", "a", "specific", "entry", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L445-L460
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.stash
def stash(self, payload): """Stash the specified processes.""" succeeded = [] failed = [] for key in payload['keys']: if self.queue.get(key) is not None: if self.queue[key]['status'] == 'queued': self.queue[key]['status'] = 'stashed' ...
python
def stash(self, payload): """Stash the specified processes.""" succeeded = [] failed = [] for key in payload['keys']: if self.queue.get(key) is not None: if self.queue[key]['status'] == 'queued': self.queue[key]['status'] = 'stashed' ...
[ "def", "stash", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "if", "self", ".", "queue", ".", "get", "(", "key", ")", "is", "not", "None", ":...
Stash the specified processes.
[ "Stash", "the", "specified", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L462-L486
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.kill_process
def kill_process(self, payload): """Pause the daemon and kill all processes or kill a specific process.""" # Kill specific processes, if `keys` is given in the payload kill_signal = signals[payload['signal'].lower()] kill_shell = payload.get('all', False) if payload.get('keys'): ...
python
def kill_process(self, payload): """Pause the daemon and kill all processes or kill a specific process.""" # Kill specific processes, if `keys` is given in the payload kill_signal = signals[payload['signal'].lower()] kill_shell = payload.get('all', False) if payload.get('keys'): ...
[ "def", "kill_process", "(", "self", ",", "payload", ")", ":", "# Kill specific processes, if `keys` is given in the payload", "kill_signal", "=", "signals", "[", "payload", "[", "'signal'", "]", ".", "lower", "(", ")", "]", "kill_shell", "=", "payload", ".", "get"...
Pause the daemon and kill all processes or kill a specific process.
[ "Pause", "the", "daemon", "and", "kill", "all", "processes", "or", "kill", "a", "specific", "process", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L514-L548
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.remove
def remove(self, payload): """Remove specified entries from the queue.""" succeeded = [] failed = [] for key in payload['keys']: running = self.process_handler.is_running(key) if not running: removed = self.queue.remove(key) if remo...
python
def remove(self, payload): """Remove specified entries from the queue.""" succeeded = [] failed = [] for key in payload['keys']: running = self.process_handler.is_running(key) if not running: removed = self.queue.remove(key) if remo...
[ "def", "remove", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "running", "=", "self", ".", "process_handler", ".", "is_running", "(", "key", ")", ...
Remove specified entries from the queue.
[ "Remove", "specified", "entries", "from", "the", "queue", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L555-L580
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.switch
def switch(self, payload): """Switch the two specified entry positions in the queue.""" first = payload['first'] second = payload['second'] running = self.process_handler.is_running(first) or self.process_handler.is_running(second) if running: answer = { ...
python
def switch(self, payload): """Switch the two specified entry positions in the queue.""" first = payload['first'] second = payload['second'] running = self.process_handler.is_running(first) or self.process_handler.is_running(second) if running: answer = { ...
[ "def", "switch", "(", "self", ",", "payload", ")", ":", "first", "=", "payload", "[", "'first'", "]", "second", "=", "payload", "[", "'second'", "]", "running", "=", "self", ".", "process_handler", ".", "is_running", "(", "first", ")", "or", "self", "....
Switch the two specified entry positions in the queue.
[ "Switch", "the", "two", "specified", "entry", "positions", "in", "the", "queue", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L582-L604
train
Nukesor/pueue
pueue/daemon/daemon.py
Daemon.restart
def restart(self, payload): """Restart the specified entries.""" succeeded = [] failed = [] for key in payload['keys']: restarted = self.queue.restart(key) if restarted: succeeded.append(str(key)) else: failed.append(str...
python
def restart(self, payload): """Restart the specified entries.""" succeeded = [] failed = [] for key in payload['keys']: restarted = self.queue.restart(key) if restarted: succeeded.append(str(key)) else: failed.append(str...
[ "def", "restart", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "restarted", "=", "self", ".", "queue", ".", "restart", "(", "key", ")", "if", "...
Restart the specified entries.
[ "Restart", "the", "specified", "entries", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L606-L626
train
dlecocq/nsq-py
nsq/sockets/base.py
SocketWrapper.sendall
def sendall(self, data, flags=0): '''Same as socket.sendall''' count = len(data) while count: sent = self.send(data, flags) # This could probably be a buffer object data = data[sent:] count -= sent
python
def sendall(self, data, flags=0): '''Same as socket.sendall''' count = len(data) while count: sent = self.send(data, flags) # This could probably be a buffer object data = data[sent:] count -= sent
[ "def", "sendall", "(", "self", ",", "data", ",", "flags", "=", "0", ")", ":", "count", "=", "len", "(", "data", ")", "while", "count", ":", "sent", "=", "self", ".", "send", "(", "data", ",", "flags", ")", "# This could probably be a buffer object", "d...
Same as socket.sendall
[ "Same", "as", "socket", ".", "sendall" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/sockets/base.py#L31-L38
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_ls
def do_ls(client, args): """List directory""" for item in client.get_folder_contents_iter(args.uri): # privacy flag if item['privacy'] == 'public': item['pf'] = '@' else: item['pf'] = '-' if isinstance(item, Folder): # type flag i...
python
def do_ls(client, args): """List directory""" for item in client.get_folder_contents_iter(args.uri): # privacy flag if item['privacy'] == 'public': item['pf'] = '@' else: item['pf'] = '-' if isinstance(item, Folder): # type flag i...
[ "def", "do_ls", "(", "client", ",", "args", ")", ":", "for", "item", "in", "client", ".", "get_folder_contents_iter", "(", "args", ".", "uri", ")", ":", "# privacy flag", "if", "item", "[", "'privacy'", "]", "==", "'public'", ":", "item", "[", "'pf'", ...
List directory
[ "List", "directory" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L28-L50
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_file_upload
def do_file_upload(client, args): """Upload files""" # Sanity check if len(args.paths) > 1: # destination must be a directory try: resource = client.get_resource_by_uri(args.dest_uri) except ResourceNotFoundError: resource = None if resource and not ...
python
def do_file_upload(client, args): """Upload files""" # Sanity check if len(args.paths) > 1: # destination must be a directory try: resource = client.get_resource_by_uri(args.dest_uri) except ResourceNotFoundError: resource = None if resource and not ...
[ "def", "do_file_upload", "(", "client", ",", "args", ")", ":", "# Sanity check", "if", "len", "(", "args", ".", "paths", ")", ">", "1", ":", "# destination must be a directory", "try", ":", "resource", "=", "client", ".", "get_resource_by_uri", "(", "args", ...
Upload files
[ "Upload", "files" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L53-L76
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_file_download
def do_file_download(client, args): """Download file""" # Sanity check if not os.path.isdir(args.dest_path) and not args.dest_path.endswith('/'): print("file-download: " "target '{}' is not a directory".format(args.dest_path)) if not os.path.exists(args.dest_path): ...
python
def do_file_download(client, args): """Download file""" # Sanity check if not os.path.isdir(args.dest_path) and not args.dest_path.endswith('/'): print("file-download: " "target '{}' is not a directory".format(args.dest_path)) if not os.path.exists(args.dest_path): ...
[ "def", "do_file_download", "(", "client", ",", "args", ")", ":", "# Sanity check", "if", "not", "os", ".", "path", ".", "isdir", "(", "args", ".", "dest_path", ")", "and", "not", "args", ".", "dest_path", ".", "endswith", "(", "'/'", ")", ":", "print",...
Download file
[ "Download", "file" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L79-L95
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_file_show
def do_file_show(client, args): """Output file contents to stdout""" for src_uri in args.uris: client.download_file(src_uri, sys.stdout.buffer) return True
python
def do_file_show(client, args): """Output file contents to stdout""" for src_uri in args.uris: client.download_file(src_uri, sys.stdout.buffer) return True
[ "def", "do_file_show", "(", "client", ",", "args", ")", ":", "for", "src_uri", "in", "args", ".", "uris", ":", "client", ".", "download_file", "(", "src_uri", ",", "sys", ".", "stdout", ".", "buffer", ")", "return", "True" ]
Output file contents to stdout
[ "Output", "file", "contents", "to", "stdout" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L98-L103
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_folder_create
def do_folder_create(client, args): """Create directory""" for folder_uri in args.uris: client.create_folder(folder_uri, recursive=True) return True
python
def do_folder_create(client, args): """Create directory""" for folder_uri in args.uris: client.create_folder(folder_uri, recursive=True) return True
[ "def", "do_folder_create", "(", "client", ",", "args", ")", ":", "for", "folder_uri", "in", "args", ".", "uris", ":", "client", ".", "create_folder", "(", "folder_uri", ",", "recursive", "=", "True", ")", "return", "True" ]
Create directory
[ "Create", "directory" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L106-L110
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_resource_delete
def do_resource_delete(client, args): """Remove resource""" for resource_uri in args.uris: client.delete_resource(resource_uri, purge=args.purge) print("Deleted {}".format(resource_uri)) return True
python
def do_resource_delete(client, args): """Remove resource""" for resource_uri in args.uris: client.delete_resource(resource_uri, purge=args.purge) print("Deleted {}".format(resource_uri)) return True
[ "def", "do_resource_delete", "(", "client", ",", "args", ")", ":", "for", "resource_uri", "in", "args", ".", "uris", ":", "client", ".", "delete_resource", "(", "resource_uri", ",", "purge", "=", "args", ".", "purge", ")", "print", "(", "\"Deleted {}\"", "...
Remove resource
[ "Remove", "resource" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L113-L118
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_file_update_metadata
def do_file_update_metadata(client, args): """Update file metadata""" client.update_file_metadata(args.uri, filename=args.filename, description=args.description, mtime=args.mtime, privacy=args.privacy) return True
python
def do_file_update_metadata(client, args): """Update file metadata""" client.update_file_metadata(args.uri, filename=args.filename, description=args.description, mtime=args.mtime, privacy=args.privacy) return True
[ "def", "do_file_update_metadata", "(", "client", ",", "args", ")", ":", "client", ".", "update_file_metadata", "(", "args", ".", "uri", ",", "filename", "=", "args", ".", "filename", ",", "description", "=", "args", ".", "description", ",", "mtime", "=", "...
Update file metadata
[ "Update", "file", "metadata" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L121-L126
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
do_folder_update_metadata
def do_folder_update_metadata(client, args): """Update file metadata""" client.update_folder_metadata(args.uri, foldername=args.foldername, description=args.description, mtime=args.mtime, privacy=args.privacy, ...
python
def do_folder_update_metadata(client, args): """Update file metadata""" client.update_folder_metadata(args.uri, foldername=args.foldername, description=args.description, mtime=args.mtime, privacy=args.privacy, ...
[ "def", "do_folder_update_metadata", "(", "client", ",", "args", ")", ":", "client", ".", "update_folder_metadata", "(", "args", ".", "uri", ",", "foldername", "=", "args", ".", "foldername", ",", "description", "=", "args", ".", "description", ",", "mtime", ...
Update file metadata
[ "Update", "file", "metadata" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L129-L135
train
MediaFire/mediafire-python-open-sdk
examples/mediafire-cli.py
main
def main(): # pylint: disable=too-many-statements """Main entry point""" parser = argparse.ArgumentParser(prog='mediafire-cli', description=__doc__) parser.add_argument('--debug', dest='debug', action='store_true', default=False, help='Enable de...
python
def main(): # pylint: disable=too-many-statements """Main entry point""" parser = argparse.ArgumentParser(prog='mediafire-cli', description=__doc__) parser.add_argument('--debug', dest='debug', action='store_true', default=False, help='Enable de...
[ "def", "main", "(", ")", ":", "# pylint: disable=too-many-statements", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'mediafire-cli'", ",", "description", "=", "__doc__", ")", "parser", ".", "add_argument", "(", "'--debug'", ",", "dest", "...
Main entry point
[ "Main", "entry", "point" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L145-L273
train
dlecocq/nsq-py
nsq/http/nsqd.py
Client.pub
def pub(self, topic, message): '''Publish a message to a topic''' return self.post('pub', params={'topic': topic}, data=message)
python
def pub(self, topic, message): '''Publish a message to a topic''' return self.post('pub', params={'topic': topic}, data=message)
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "return", "self", ".", "post", "(", "'pub'", ",", "params", "=", "{", "'topic'", ":", "topic", "}", ",", "data", "=", "message", ")" ]
Publish a message to a topic
[ "Publish", "a", "message", "to", "a", "topic" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L19-L21
train
dlecocq/nsq-py
nsq/http/nsqd.py
Client.mpub
def mpub(self, topic, messages, binary=True): '''Send multiple messages to a topic. Optionally pack the messages''' if binary: # Pack and ship the data return self.post('mpub', data=pack(messages)[4:], params={'topic': topic, 'binary': True}) elif any('\n'...
python
def mpub(self, topic, messages, binary=True): '''Send multiple messages to a topic. Optionally pack the messages''' if binary: # Pack and ship the data return self.post('mpub', data=pack(messages)[4:], params={'topic': topic, 'binary': True}) elif any('\n'...
[ "def", "mpub", "(", "self", ",", "topic", ",", "messages", ",", "binary", "=", "True", ")", ":", "if", "binary", ":", "# Pack and ship the data", "return", "self", ".", "post", "(", "'mpub'", ",", "data", "=", "pack", "(", "messages", ")", "[", "4", ...
Send multiple messages to a topic. Optionally pack the messages
[ "Send", "multiple", "messages", "to", "a", "topic", ".", "Optionally", "pack", "the", "messages" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L24-L37
train
dlecocq/nsq-py
nsq/http/nsqd.py
Client.clean_stats
def clean_stats(self): '''Stats with topics and channels keyed on topic and channel names''' stats = self.stats() if 'topics' in stats: # pragma: no branch topics = stats['topics'] topics = dict((t.pop('topic_name'), t) for t in topics) for topic, data in top...
python
def clean_stats(self): '''Stats with topics and channels keyed on topic and channel names''' stats = self.stats() if 'topics' in stats: # pragma: no branch topics = stats['topics'] topics = dict((t.pop('topic_name'), t) for t in topics) for topic, data in top...
[ "def", "clean_stats", "(", "self", ")", ":", "stats", "=", "self", ".", "stats", "(", ")", "if", "'topics'", "in", "stats", ":", "# pragma: no branch", "topics", "=", "stats", "[", "'topics'", "]", "topics", "=", "dict", "(", "(", "t", ".", "pop", "(...
Stats with topics and channels keyed on topic and channel names
[ "Stats", "with", "topics", "and", "channels", "keyed", "on", "topic", "and", "channel", "names" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L99-L112
train
Nukesor/pueue
pueue/client/manipulation.py
execute_add
def execute_add(args, root_dir=None): """Add a new command to the daemon queue. Args: args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al'] root_dir (string): The path to the root directory the daemon is running in. """ # We accept a list of s...
python
def execute_add(args, root_dir=None): """Add a new command to the daemon queue. Args: args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al'] root_dir (string): The path to the root directory the daemon is running in. """ # We accept a list of s...
[ "def", "execute_add", "(", "args", ",", "root_dir", "=", "None", ")", ":", "# We accept a list of strings.", "# This is done to create a better commandline experience with argparse.", "command", "=", "' '", ".", "join", "(", "args", "[", "'command'", "]", ")", "# Send n...
Add a new command to the daemon queue. Args: args['command'] (list(str)): The actual programm call. Something like ['ls', '-a'] or ['ls -al'] root_dir (string): The path to the root directory the daemon is running in.
[ "Add", "a", "new", "command", "to", "the", "daemon", "queue", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L9-L26
train
Nukesor/pueue
pueue/client/manipulation.py
execute_edit
def execute_edit(args, root_dir=None): """Edit a existing queue command in the daemon. Args: args['key'] int: The key of the queue entry to be edited root_dir (string): The path to the root directory the daemon is running in. """ # Get editor EDITOR = os.environ.get('EDITOR', 'vim')...
python
def execute_edit(args, root_dir=None): """Edit a existing queue command in the daemon. Args: args['key'] int: The key of the queue entry to be edited root_dir (string): The path to the root directory the daemon is running in. """ # Get editor EDITOR = os.environ.get('EDITOR', 'vim')...
[ "def", "execute_edit", "(", "args", ",", "root_dir", "=", "None", ")", ":", "# Get editor", "EDITOR", "=", "os", ".", "environ", ".", "get", "(", "'EDITOR'", ",", "'vim'", ")", "# Get command from server", "key", "=", "args", "[", "'key'", "]", "status", ...
Edit a existing queue command in the daemon. Args: args['key'] int: The key of the queue entry to be edited root_dir (string): The path to the root directory the daemon is running in.
[ "Edit", "a", "existing", "queue", "command", "in", "the", "daemon", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L29-L66
train
Nukesor/pueue
pueue/client/factories.py
command_factory
def command_factory(command): """A factory which returns functions for direct daemon communication. This factory will create a function which sends a payload to the daemon and returns the unpickled object which is returned by the daemon. Args: command (string): The type of payload this should ...
python
def command_factory(command): """A factory which returns functions for direct daemon communication. This factory will create a function which sends a payload to the daemon and returns the unpickled object which is returned by the daemon. Args: command (string): The type of payload this should ...
[ "def", "command_factory", "(", "command", ")", ":", "def", "communicate", "(", "body", "=", "{", "}", ",", "root_dir", "=", "None", ")", ":", "\"\"\"Communicate with the daemon.\n\n This function sends a payload to the daemon and returns the unpickled\n object sen...
A factory which returns functions for direct daemon communication. This factory will create a function which sends a payload to the daemon and returns the unpickled object which is returned by the daemon. Args: command (string): The type of payload this should be. This determines as wh...
[ "A", "factory", "which", "returns", "functions", "for", "direct", "daemon", "communication", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/factories.py#L6-L44
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.get_descriptor
def get_descriptor(self, number): """Create file descriptors for process output.""" # Create stdout file and get file descriptor stdout_path = os.path.join(self.config_dir, 'pueue_process_{}.stdout'.format(number)) if os.path.exists(stdout_path): ...
python
def get_descriptor(self, number): """Create file descriptors for process output.""" # Create stdout file and get file descriptor stdout_path = os.path.join(self.config_dir, 'pueue_process_{}.stdout'.format(number)) if os.path.exists(stdout_path): ...
[ "def", "get_descriptor", "(", "self", ",", "number", ")", ":", "# Create stdout file and get file descriptor", "stdout_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue_process_{}.stdout'", ".", "format", "(", "number", ")", ...
Create file descriptors for process output.
[ "Create", "file", "descriptors", "for", "process", "output", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L58-L79
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.clean_descriptor
def clean_descriptor(self, number): """Close file descriptor and remove underlying files.""" self.descriptors[number]['stdout'].close() self.descriptors[number]['stderr'].close() if os.path.exists(self.descriptors[number]['stdout_path']): os.remove(self.descriptors[number]['...
python
def clean_descriptor(self, number): """Close file descriptor and remove underlying files.""" self.descriptors[number]['stdout'].close() self.descriptors[number]['stderr'].close() if os.path.exists(self.descriptors[number]['stdout_path']): os.remove(self.descriptors[number]['...
[ "def", "clean_descriptor", "(", "self", ",", "number", ")", ":", "self", ".", "descriptors", "[", "number", "]", "[", "'stdout'", "]", ".", "close", "(", ")", "self", ".", "descriptors", "[", "number", "]", "[", "'stderr'", "]", ".", "close", "(", ")...
Close file descriptor and remove underlying files.
[ "Close", "file", "descriptor", "and", "remove", "underlying", "files", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L81-L90
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.check_finished
def check_finished(self): """Poll all processes and handle any finished processes.""" changed = False for key in list(self.processes.keys()): # Poll process and check if it finshed process = self.processes[key] process.poll() if process.returncode ...
python
def check_finished(self): """Poll all processes and handle any finished processes.""" changed = False for key in list(self.processes.keys()): # Poll process and check if it finshed process = self.processes[key] process.poll() if process.returncode ...
[ "def", "check_finished", "(", "self", ")", ":", "changed", "=", "False", "for", "key", "in", "list", "(", "self", ".", "processes", ".", "keys", "(", ")", ")", ":", "# Poll process and check if it finshed", "process", "=", "self", ".", "processes", "[", "k...
Poll all processes and handle any finished processes.
[ "Poll", "all", "processes", "and", "handle", "any", "finished", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L92-L146
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.check_for_new
def check_for_new(self): """Check if we can start a new process.""" free_slots = self.max_processes - len(self.processes) for item in range(free_slots): key = self.queue.next() if key is not None: self.spawn_new(key)
python
def check_for_new(self): """Check if we can start a new process.""" free_slots = self.max_processes - len(self.processes) for item in range(free_slots): key = self.queue.next() if key is not None: self.spawn_new(key)
[ "def", "check_for_new", "(", "self", ")", ":", "free_slots", "=", "self", ".", "max_processes", "-", "len", "(", "self", ".", "processes", ")", "for", "item", "in", "range", "(", "free_slots", ")", ":", "key", "=", "self", ".", "queue", ".", "next", ...
Check if we can start a new process.
[ "Check", "if", "we", "can", "start", "a", "new", "process", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L148-L154
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.spawn_new
def spawn_new(self, key): """Spawn a new task and save it to the queue.""" # Check if path exists if not os.path.exists(self.queue[key]['path']): self.queue[key]['status'] = 'failed' error_msg = "The directory for this command doesn't exist anymore: {}".format(self.queue[...
python
def spawn_new(self, key): """Spawn a new task and save it to the queue.""" # Check if path exists if not os.path.exists(self.queue[key]['path']): self.queue[key]['status'] = 'failed' error_msg = "The directory for this command doesn't exist anymore: {}".format(self.queue[...
[ "def", "spawn_new", "(", "self", ",", "key", ")", ":", "# Check if path exists", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "queue", "[", "key", "]", "[", "'path'", "]", ")", ":", "self", ".", "queue", "[", "key", "]", "[", ...
Spawn a new task and save it to the queue.
[ "Spawn", "a", "new", "task", "and", "save", "it", "to", "the", "queue", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L156-L201
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.kill_all
def kill_all(self, kill_signal, kill_shell=False): """Kill all running processes.""" for key in self.processes.keys(): self.kill_process(key, kill_signal, kill_shell)
python
def kill_all(self, kill_signal, kill_shell=False): """Kill all running processes.""" for key in self.processes.keys(): self.kill_process(key, kill_signal, kill_shell)
[ "def", "kill_all", "(", "self", ",", "kill_signal", ",", "kill_shell", "=", "False", ")", ":", "for", "key", "in", "self", ".", "processes", ".", "keys", "(", ")", ":", "self", ".", "kill_process", "(", "key", ",", "kill_signal", ",", "kill_shell", ")"...
Kill all running processes.
[ "Kill", "all", "running", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L221-L224
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.start_process
def start_process(self, key): """Start a specific processes.""" if key in self.processes and key in self.paused: os.killpg(os.getpgid(self.processes[key].pid), signal.SIGCONT) self.queue[key]['status'] = 'running' self.paused.remove(key) return True ...
python
def start_process(self, key): """Start a specific processes.""" if key in self.processes and key in self.paused: os.killpg(os.getpgid(self.processes[key].pid), signal.SIGCONT) self.queue[key]['status'] = 'running' self.paused.remove(key) return True ...
[ "def", "start_process", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "processes", "and", "key", "in", "self", ".", "paused", ":", "os", ".", "killpg", "(", "os", ".", "getpgid", "(", "self", ".", "processes", "[", "key", "]", ...
Start a specific processes.
[ "Start", "a", "specific", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L226-L238
train
Nukesor/pueue
pueue/daemon/process_handler.py
ProcessHandler.pause_process
def pause_process(self, key): """Pause a specific processes.""" if key in self.processes and key not in self.paused: os.killpg(os.getpgid(self.processes[key].pid), signal.SIGSTOP) self.queue[key]['status'] = 'paused' self.paused.append(key) return True ...
python
def pause_process(self, key): """Pause a specific processes.""" if key in self.processes and key not in self.paused: os.killpg(os.getpgid(self.processes[key].pid), signal.SIGSTOP) self.queue[key]['status'] = 'paused' self.paused.append(key) return True ...
[ "def", "pause_process", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "processes", "and", "key", "not", "in", "self", ".", "paused", ":", "os", ".", "killpg", "(", "os", ".", "getpgid", "(", "self", ".", "processes", "[", "key"...
Pause a specific processes.
[ "Pause", "a", "specific", "processes", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L240-L247
train
Nukesor/pueue
pueue/__init__.py
daemon_factory
def daemon_factory(path): """Create a closure which creates a running daemon. We need to create a closure that contains the correct path the daemon should be started with. This is needed as the `Daemonize` library requires a callable function for daemonization and doesn't accept any arguments. This...
python
def daemon_factory(path): """Create a closure which creates a running daemon. We need to create a closure that contains the correct path the daemon should be started with. This is needed as the `Daemonize` library requires a callable function for daemonization and doesn't accept any arguments. This...
[ "def", "daemon_factory", "(", "path", ")", ":", "def", "start_daemon", "(", ")", ":", "root_dir", "=", "path", "config_dir", "=", "os", ".", "path", ".", "join", "(", "root_dir", ",", "'.config/pueue'", ")", "try", ":", "daemon", "=", "Daemon", "(", "r...
Create a closure which creates a running daemon. We need to create a closure that contains the correct path the daemon should be started with. This is needed as the `Daemonize` library requires a callable function for daemonization and doesn't accept any arguments. This function cleans up sockets and o...
[ "Create", "a", "closure", "which", "creates", "a", "running", "daemon", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L13-L37
train
Nukesor/pueue
pueue/__init__.py
main
def main(): """Execute entry function.""" args = parser.parse_args() args_dict = vars(args) root_dir = args_dict['root'] if 'root' in args else None # If a root directory is specified, get the absolute path and # check if it exists. Abort if it doesn't exist! if root_dir: root_dir =...
python
def main(): """Execute entry function.""" args = parser.parse_args() args_dict = vars(args) root_dir = args_dict['root'] if 'root' in args else None # If a root directory is specified, get the absolute path and # check if it exists. Abort if it doesn't exist! if root_dir: root_dir =...
[ "def", "main", "(", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "args_dict", "=", "vars", "(", "args", ")", "root_dir", "=", "args_dict", "[", "'root'", "]", "if", "'root'", "in", "args", "else", "None", "# If a root directory is specifie...
Execute entry function.
[ "Execute", "entry", "function", "." ]
f1d276360454d4dd2738658a13df1e20caa4b926
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L40-L73
train
corpusops/pdbclone
lib/pdb_clone/pdbhandler.py
register
def register(host=DFLT_ADDRESS[0], port=DFLT_ADDRESS[1], signum=signal.SIGUSR1): """Register a pdb handler for signal 'signum'. The handler sets pdb to listen on the ('host', 'port') internet address and to start a remote debugging session on accepting a socket connection. """ _pdbhand...
python
def register(host=DFLT_ADDRESS[0], port=DFLT_ADDRESS[1], signum=signal.SIGUSR1): """Register a pdb handler for signal 'signum'. The handler sets pdb to listen on the ('host', 'port') internet address and to start a remote debugging session on accepting a socket connection. """ _pdbhand...
[ "def", "register", "(", "host", "=", "DFLT_ADDRESS", "[", "0", "]", ",", "port", "=", "DFLT_ADDRESS", "[", "1", "]", ",", "signum", "=", "signal", ".", "SIGUSR1", ")", ":", "_pdbhandler", ".", "_register", "(", "host", ",", "port", ",", "signum", ")"...
Register a pdb handler for signal 'signum'. The handler sets pdb to listen on the ('host', 'port') internet address and to start a remote debugging session on accepting a socket connection.
[ "Register", "a", "pdb", "handler", "for", "signal", "signum", "." ]
f781537c243a4874b246d43dbdef8c4279f0094d
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L19-L26
train
corpusops/pdbclone
lib/pdb_clone/pdbhandler.py
get_handler
def get_handler(): """Return the handler as a named tuple. The named tuple attributes are 'host', 'port', 'signum'. Return None when no handler has been registered. """ host, port, signum = _pdbhandler._registered() if signum: return Handler(host if host else DFLT_ADDRESS[0].encode(), ...
python
def get_handler(): """Return the handler as a named tuple. The named tuple attributes are 'host', 'port', 'signum'. Return None when no handler has been registered. """ host, port, signum = _pdbhandler._registered() if signum: return Handler(host if host else DFLT_ADDRESS[0].encode(), ...
[ "def", "get_handler", "(", ")", ":", "host", ",", "port", ",", "signum", "=", "_pdbhandler", ".", "_registered", "(", ")", "if", "signum", ":", "return", "Handler", "(", "host", "if", "host", "else", "DFLT_ADDRESS", "[", "0", "]", ".", "encode", "(", ...
Return the handler as a named tuple. The named tuple attributes are 'host', 'port', 'signum'. Return None when no handler has been registered.
[ "Return", "the", "handler", "as", "a", "named", "tuple", "." ]
f781537c243a4874b246d43dbdef8c4279f0094d
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L35-L44
train
dlecocq/nsq-py
nsq/checker.py
StoppableThread.wait
def wait(self, timeout): '''Wait for the provided time to elapse''' logger.debug('Waiting for %fs', timeout) return self._event.wait(timeout)
python
def wait(self, timeout): '''Wait for the provided time to elapse''' logger.debug('Waiting for %fs', timeout) return self._event.wait(timeout)
[ "def", "wait", "(", "self", ",", "timeout", ")", ":", "logger", ".", "debug", "(", "'Waiting for %fs'", ",", "timeout", ")", "return", "self", ".", "_event", ".", "wait", "(", "timeout", ")" ]
Wait for the provided time to elapse
[ "Wait", "for", "the", "provided", "time", "to", "elapse" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L14-L17
train
dlecocq/nsq-py
nsq/checker.py
PeriodicThread.delay
def delay(self): '''How long to wait before the next check''' if self._last_checked: return self._interval - (time.time() - self._last_checked) return self._interval
python
def delay(self): '''How long to wait before the next check''' if self._last_checked: return self._interval - (time.time() - self._last_checked) return self._interval
[ "def", "delay", "(", "self", ")", ":", "if", "self", ".", "_last_checked", ":", "return", "self", ".", "_interval", "-", "(", "time", ".", "time", "(", ")", "-", "self", ".", "_last_checked", ")", "return", "self", ".", "_interval" ]
How long to wait before the next check
[ "How", "long", "to", "wait", "before", "the", "next", "check" ]
3ecacf6ab7719d38031179277113d875554a0c16
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L34-L38
train