partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Connection.connect
Establish a connection
nsq/connection.py
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): '''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('...
[ "Establish", "a", "connection" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L106-L151
[ "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"...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.close
Close our connection
nsq/connection.py
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): '''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...
[ "Close", "our", "connection" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L153-L166
[ "def", "close", "(", "self", ")", ":", "# Flush any unsent message", "try", ":", "while", "self", ".", "pending", "(", ")", ":", "self", ".", "flush", "(", ")", "except", "socket", ".", "error", ":", "pass", "with", "self", ".", "_socket_lock", ":", "t...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.socket
Blockingly yield the socket
nsq/connection.py
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): '''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()
[ "Blockingly", "yield", "the", "socket" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L168-L175
[ "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"...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.identified
Handle a response to our 'identify' command. Returns response
nsq/connection.py
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): '''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...
[ "Handle", "a", "response", "to", "our", "identify", "command", ".", "Returns", "response" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L177-L211
[ "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...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.setblocking
Set whether or not this message is blocking
nsq/connection.py
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): '''Set whether or not this message is blocking''' for sock in self.socket(): sock.setblocking(blocking) self._blocking = blocking
[ "Set", "whether", "or", "not", "this", "message", "is", "blocking" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L217-L221
[ "def", "setblocking", "(", "self", ",", "blocking", ")", ":", "for", "sock", "in", "self", ".", "socket", "(", ")", ":", "sock", ".", "setblocking", "(", "blocking", ")", "self", ".", "_blocking", "=", "blocking" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.flush
Flush some of the waiting messages, returns count written
nsq/connection.py
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): '''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...
[ "Flush", "some", "of", "the", "waiting", "messages", "returns", "count", "written" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L234-L266
[ "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 ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.send
Send a command over the socket with length endcoded
nsq/connection.py
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): '''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(): ...
[ "Send", "a", "command", "over", "the", "socket", "with", "length", "endcoded" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L268-L278
[ "def", "send", "(", "self", ",", "command", ",", "message", "=", "None", ")", ":", "if", "message", ":", "joined", "=", "command", "+", "constants", ".", "NL", "+", "util", ".", "pack", "(", "message", ")", "else", ":", "joined", "=", "command", "+...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.identify
Send an identification message
nsq/connection.py
def identify(self, data): '''Send an identification message''' return self.send(constants.IDENTIFY, json.dumps(data))
def identify(self, data): '''Send an identification message''' return self.send(constants.IDENTIFY, json.dumps(data))
[ "Send", "an", "identification", "message" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L280-L282
[ "def", "identify", "(", "self", ",", "data", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "IDENTIFY", ",", "json", ".", "dumps", "(", "data", ")", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.sub
Subscribe to a topic/channel
nsq/connection.py
def sub(self, topic, channel): '''Subscribe to a topic/channel''' return self.send(' '.join((constants.SUB, topic, channel)))
def sub(self, topic, channel): '''Subscribe to a topic/channel''' return self.send(' '.join((constants.SUB, topic, channel)))
[ "Subscribe", "to", "a", "topic", "/", "channel" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L288-L290
[ "def", "sub", "(", "self", ",", "topic", ",", "channel", ")", ":", "return", "self", ".", "send", "(", "' '", ".", "join", "(", "(", "constants", ".", "SUB", ",", "topic", ",", "channel", ")", ")", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.pub
Publish to a topic
nsq/connection.py
def pub(self, topic, message): '''Publish to a topic''' return self.send(' '.join((constants.PUB, topic)), message)
def pub(self, topic, message): '''Publish to a topic''' return self.send(' '.join((constants.PUB, topic)), message)
[ "Publish", "to", "a", "topic" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L292-L294
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "return", "self", ".", "send", "(", "' '", ".", "join", "(", "(", "constants", ".", "PUB", ",", "topic", ")", ")", ",", "message", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.mpub
Publish multiple messages to a topic
nsq/connection.py
def mpub(self, topic, *messages): '''Publish multiple messages to a topic''' return self.send(constants.MPUB + ' ' + topic, messages)
def mpub(self, topic, *messages): '''Publish multiple messages to a topic''' return self.send(constants.MPUB + ' ' + topic, messages)
[ "Publish", "multiple", "messages", "to", "a", "topic" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L296-L298
[ "def", "mpub", "(", "self", ",", "topic", ",", "*", "messages", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "MPUB", "+", "' '", "+", "topic", ",", "messages", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.rdy
Indicate that you're ready to receive
nsq/connection.py
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): '''Indicate that you're ready to receive''' self.ready = count self.last_ready_sent = count return self.send(constants.RDY + ' ' + str(count))
[ "Indicate", "that", "you", "re", "ready", "to", "receive" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L300-L304
[ "def", "rdy", "(", "self", ",", "count", ")", ":", "self", ".", "ready", "=", "count", "self", ".", "last_ready_sent", "=", "count", "return", "self", ".", "send", "(", "constants", ".", "RDY", "+", "' '", "+", "str", "(", "count", ")", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.req
Re-queue a message
nsq/connection.py
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): '''Re-queue a message''' return self.send(constants.REQ + ' ' + message_id + ' ' + str(timeout))
[ "Re", "-", "queue", "a", "message" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L310-L312
[ "def", "req", "(", "self", ",", "message_id", ",", "timeout", ")", ":", "return", "self", ".", "send", "(", "constants", ".", "REQ", "+", "' '", "+", "message_id", "+", "' '", "+", "str", "(", "timeout", ")", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection._read
Return all the responses read
nsq/connection.py
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): '''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: ...
[ "Return", "all", "the", "responses", "read" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L330-L371
[ "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", "(",...
3ecacf6ab7719d38031179277113d875554a0c16
train
Connection.read
Responses from an established socket
nsq/connection.py
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 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...
[ "Responses", "from", "an", "established", "socket" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/connection.py#L373-L380
[ "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", ".", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.discover
Run the discovery mechanism
nsq/client.py
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): '''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...
[ "Run", "the", "discovery", "mechanism" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L59-L89
[ "def", "discover", "(", "self", ",", "topic", ")", ":", "logger", ".", "info", "(", "'Discovering on topic %s'", ",", "topic", ")", "producers", "=", "[", "]", "for", "lookupd", "in", "self", ".", "_lookupd", ":", "logger", ".", "info", "(", "'Discoverin...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.check_connections
Connect to all the appropriate instances
nsq/client.py
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): '''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: ...
[ "Connect", "to", "all", "the", "appropriate", "instances" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L91-L125
[ "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", "...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.connection_checker
Run periodic reconnection checks
nsq/client.py
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): '''Run periodic reconnection checks''' thread = ConnectionChecker(self) logger.info('Starting connection-checker thread') thread.start() try: yield thread finally: logger.info('Stopping connection-checker') ...
[ "Run", "periodic", "reconnection", "checks" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L128-L139
[ "def", "connection_checker", "(", "self", ")", ":", "thread", "=", "ConnectionChecker", "(", "self", ")", "logger", ".", "info", "(", "'Starting connection-checker thread'", ")", "thread", ".", "start", "(", ")", "try", ":", "yield", "thread", "finally", ":", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.connect
Connect to the provided host, port
nsq/client.py
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): '''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) ...
[ "Connect", "to", "the", "provided", "host", "port" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L141-L151
[ "def", "connect", "(", "self", ",", "host", ",", "port", ")", ":", "conn", "=", "connection", ".", "Connection", "(", "host", ",", "port", ",", "reconnection_backoff", "=", "self", ".", "_reconnection_backoff", ",", "auth_secret", "=", "self", ".", "_auth_...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.add
Add a connection
nsq/client.py
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): '''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: ...
[ "Add", "a", "connection" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L164-L173
[ "def", "add", "(", "self", ",", "connection", ")", ":", "key", "=", "(", "connection", ".", "host", ",", "connection", ".", "port", ")", "with", "self", ".", "_lock", ":", "if", "key", "not", "in", "self", ".", "_connections", ":", "self", ".", "_c...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.remove
Remove a connection
nsq/client.py
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): '''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 %...
[ "Remove", "a", "connection" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L175-L184
[ "def", "remove", "(", "self", ",", "connection", ")", ":", "key", "=", "(", "connection", ".", "host", ",", "connection", ".", "port", ")", "with", "self", ".", "_lock", ":", "found", "=", "self", ".", "_connections", ".", "pop", "(", "key", ",", "...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.read
Read from any of the connections that need it
nsq/client.py
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): '''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...
[ "Read", "from", "any", "of", "the", "connections", "that", "need", "it" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L194-L270
[ "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 ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.random_connection
Pick a random living connection
nsq/client.py
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): '''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( ...
[ "Pick", "a", "random", "living", "connection" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L273-L279
[ "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", "(", "[", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.wait_response
Wait for a response
nsq/client.py
def wait_response(self): '''Wait for a response''' responses = self.read() while not responses: responses = self.read() return responses
def wait_response(self): '''Wait for a response''' responses = self.read() while not responses: responses = self.read() return responses
[ "Wait", "for", "a", "response" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L281-L286
[ "def", "wait_response", "(", "self", ")", ":", "responses", "=", "self", ".", "read", "(", ")", "while", "not", "responses", ":", "responses", "=", "self", ".", "read", "(", ")", "return", "responses" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.pub
Publish the provided message to the provided topic
nsq/client.py
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): '''Publish the provided message to the provided topic''' with self.random_connection() as client: client.pub(topic, message) return self.wait_response()
[ "Publish", "the", "provided", "message", "to", "the", "provided", "topic" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L293-L297
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "with", "self", ".", "random_connection", "(", ")", "as", "client", ":", "client", ".", "pub", "(", "topic", ",", "message", ")", "return", "self", ".", "wait_response", "(", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.mpub
Publish messages to a topic
nsq/client.py
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): '''Publish messages to a topic''' with self.random_connection() as client: client.mpub(topic, *messages) return self.wait_response()
[ "Publish", "messages", "to", "a", "topic" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L299-L303
[ "def", "mpub", "(", "self", ",", "topic", ",", "*", "messages", ")", ":", "with", "self", ".", "random_connection", "(", ")", "as", "client", ":", "client", ".", "mpub", "(", "topic", ",", "*", "messages", ")", "return", "self", ".", "wait_response", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Daemon.create_socket
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.
pueue/daemon/daemon.py
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): """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", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L82-L109
[ "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", ".", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.initialize_directories
Create all directories needed for logs and configs.
pueue/daemon/daemon.py
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): """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...
[ "Create", "all", "directories", "needed", "for", "logs", "and", "configs", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L111-L119
[ "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",...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.respond_client
Send an answer to the client.
pueue/daemon/daemon.py
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): """Send an answer to the client.""" response = pickle.dumps(answer, -1) socket.sendall(response) self.read_list.remove(socket) socket.close()
[ "Send", "an", "answer", "to", "the", "client", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L121-L126
[ "def", "respond_client", "(", "self", ",", "answer", ",", "socket", ")", ":", "response", "=", "pickle", ".", "dumps", "(", "answer", ",", "-", "1", ")", "socket", ".", "sendall", "(", "response", ")", "self", ".", "read_list", ".", "remove", "(", "s...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.read_config
Read a previous configuration file or create a new with default values.
pueue/daemon/daemon.py
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): """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...
[ "Read", "a", "previous", "configuration", "file", "or", "create", "a", "new", "with", "default", "values", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L128-L150
[ "def", "read_config", "(", "self", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.ini'", ")", "self", ".", "config", "=", "configparser", ".", "ConfigParser", "(", ")", "# Try to get configuration f...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.write_config
Write the current configuration to the config file.
pueue/daemon/daemon.py
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): """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)
[ "Write", "the", "current", "configuration", "to", "the", "config", "file", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L152-L156
[ "def", "write_config", "(", "self", ")", ":", "config_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "config_dir", ",", "'pueue.ini'", ")", "with", "open", "(", "config_file", ",", "'w'", ")", "as", "file_descriptor", ":", "self", ".", "...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.main
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...
pueue/daemon/daemon.py
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): """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...
[ "The", "main", "function", "containing", "the", "loop", "for", "communication", "and", "process", "management", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L158-L273
[ "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", "....
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.stop_daemon
Kill current processes and initiate daemon shutdown. The daemon will shut down after a last check on all killed processes.
pueue/daemon/daemon.py
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 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 ...
[ "Kill", "current", "processes", "and", "initiate", "daemon", "shutdown", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L275-L285
[ "def", "stop_daemon", "(", "self", ",", "payload", "=", "None", ")", ":", "kill_signal", "=", "signals", "[", "'9'", "]", "self", ".", "process_handler", ".", "kill_all", "(", "kill_signal", ",", "True", ")", "self", ".", "running", "=", "False", "return...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.set_config
Update the current config depending on the payload and save it.
pueue/daemon/daemon.py
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): """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'] ...
[ "Update", "the", "current", "config", "depending", "on", "the", "payload", "and", "save", "it", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L287-L306
[ "def", "set_config", "(", "self", ",", "payload", ")", ":", "self", ".", "config", "[", "'default'", "]", "[", "payload", "[", "'option'", "]", "]", "=", "str", "(", "payload", "[", "'value'", "]", ")", "if", "payload", "[", "'option'", "]", "==", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.pipe_to_process
Send something to stdin of a specific process.
pueue/daemon/daemon.py
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): """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'} ...
[ "Send", "something", "to", "stdin", "of", "a", "specific", "process", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L308-L317
[ "def", "pipe_to_process", "(", "self", ",", "payload", ")", ":", "message", "=", "payload", "[", "'input'", "]", "key", "=", "payload", "[", "'key'", "]", "if", "not", "self", ".", "process_handler", ".", "is_running", "(", "key", ")", ":", "return", "...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.send_status
Send the daemon status and the current queue for displaying.
pueue/daemon/daemon.py
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): """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...
[ "Send", "the", "daemon", "status", "and", "the", "current", "queue", "for", "displaying", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L319-L344
[ "def", "send_status", "(", "self", ",", "payload", ")", ":", "answer", "=", "{", "}", "data", "=", "[", "]", "# Get daemon status", "if", "self", ".", "paused", ":", "answer", "[", "'status'", "]", "=", "'paused'", "else", ":", "answer", "[", "'status'...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.reset_everything
Kill all processes, delete the queue and clean everything up.
pueue/daemon/daemon.py
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 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...
[ "Kill", "all", "processes", "delete", "the", "queue", "and", "clean", "everything", "up", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L346-L354
[ "def", "reset_everything", "(", "self", ",", "payload", ")", ":", "kill_signal", "=", "signals", "[", "'9'", "]", "self", ".", "process_handler", ".", "kill_all", "(", "kill_signal", ",", "True", ")", "self", ".", "process_handler", ".", "wait_for_finish", "...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.clear
Clear queue from any `done` or `failed` entries. The log will be rotated once. Otherwise we would loose all logs from thoes finished processes.
pueue/daemon/daemon.py
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): """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) ...
[ "Clear", "queue", "from", "any", "done", "or", "failed", "entries", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L356-L367
[ "def", "clear", "(", "self", ",", "payload", ")", ":", "self", ".", "logger", ".", "rotate", "(", "self", ".", "queue", ")", "self", ".", "queue", ".", "clear", "(", ")", "self", ".", "logger", ".", "write", "(", "self", ".", "queue", ")", "answe...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.start
Start the daemon and all processes or only specific processes.
pueue/daemon/daemon.py
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 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...
[ "Start", "the", "daemon", "and", "all", "processes", "or", "only", "specific", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L369-L402
[ "def", "start", "(", "self", ",", "payload", ")", ":", "# Start specific processes, if `keys` is given in the payload", "if", "payload", ".", "get", "(", "'keys'", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.pause
Start the daemon and all processes or only specific processes.
pueue/daemon/daemon.py
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): """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...
[ "Start", "the", "daemon", "and", "all", "processes", "or", "only", "specific", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L404-L443
[ "def", "pause", "(", "self", ",", "payload", ")", ":", "# Pause specific processes, if `keys` is given in the payload", "if", "payload", ".", "get", "(", "'keys'", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.edit_command
Edit the command of a specific entry.
pueue/daemon/daemon.py
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): """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...
[ "Edit", "the", "command", "of", "a", "specific", "entry", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L445-L460
[ "def", "edit_command", "(", "self", ",", "payload", ")", ":", "key", "=", "payload", "[", "'key'", "]", "command", "=", "payload", "[", "'command'", "]", "if", "self", ".", "queue", "[", "key", "]", ":", "if", "self", ".", "queue", "[", "key", "]",...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.stash
Stash the specified processes.
pueue/daemon/daemon.py
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): """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' ...
[ "Stash", "the", "specified", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L462-L486
[ "def", "stash", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "if", "self", ".", "queue", ".", "get", "(", "key", ")", "is", "not", "None", ":...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.kill_process
Pause the daemon and kill all processes or kill a specific process.
pueue/daemon/daemon.py
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): """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'): ...
[ "Pause", "the", "daemon", "and", "kill", "all", "processes", "or", "kill", "a", "specific", "process", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L514-L548
[ "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"...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.remove
Remove specified entries from the queue.
pueue/daemon/daemon.py
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): """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...
[ "Remove", "specified", "entries", "from", "the", "queue", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L555-L580
[ "def", "remove", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "running", "=", "self", ".", "process_handler", ".", "is_running", "(", "key", ")", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.switch
Switch the two specified entry positions in the queue.
pueue/daemon/daemon.py
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): """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 = { ...
[ "Switch", "the", "two", "specified", "entry", "positions", "in", "the", "queue", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L582-L604
[ "def", "switch", "(", "self", ",", "payload", ")", ":", "first", "=", "payload", "[", "'first'", "]", "second", "=", "payload", "[", "'second'", "]", "running", "=", "self", ".", "process_handler", ".", "is_running", "(", "first", ")", "or", "self", "....
f1d276360454d4dd2738658a13df1e20caa4b926
train
Daemon.restart
Restart the specified entries.
pueue/daemon/daemon.py
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): """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...
[ "Restart", "the", "specified", "entries", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/daemon.py#L606-L626
[ "def", "restart", "(", "self", ",", "payload", ")", ":", "succeeded", "=", "[", "]", "failed", "=", "[", "]", "for", "key", "in", "payload", "[", "'keys'", "]", ":", "restarted", "=", "self", ".", "queue", ".", "restart", "(", "key", ")", "if", "...
f1d276360454d4dd2738658a13df1e20caa4b926
train
SocketWrapper.sendall
Same as socket.sendall
nsq/sockets/base.py
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): '''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
[ "Same", "as", "socket", ".", "sendall" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/sockets/base.py#L31-L38
[ "def", "sendall", "(", "self", ",", "data", ",", "flags", "=", "0", ")", ":", "count", "=", "len", "(", "data", ")", "while", "count", ":", "sent", "=", "self", ".", "send", "(", "data", ",", "flags", ")", "# This could probably be a buffer object", "d...
3ecacf6ab7719d38031179277113d875554a0c16
train
do_ls
List directory
examples/mediafire-cli.py
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): """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...
[ "List", "directory" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L28-L50
[ "def", "do_ls", "(", "client", ",", "args", ")", ":", "for", "item", "in", "client", ".", "get_folder_contents_iter", "(", "args", ".", "uri", ")", ":", "# privacy flag", "if", "item", "[", "'privacy'", "]", "==", "'public'", ":", "item", "[", "'pf'", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_file_upload
Upload files
examples/mediafire-cli.py
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): """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 ...
[ "Upload", "files" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L53-L76
[ "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", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_file_download
Download file
examples/mediafire-cli.py
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): """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): ...
[ "Download", "file" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L79-L95
[ "def", "do_file_download", "(", "client", ",", "args", ")", ":", "# Sanity check", "if", "not", "os", ".", "path", ".", "isdir", "(", "args", ".", "dest_path", ")", "and", "not", "args", ".", "dest_path", ".", "endswith", "(", "'/'", ")", ":", "print",...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_file_show
Output file contents to stdout
examples/mediafire-cli.py
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): """Output file contents to stdout""" for src_uri in args.uris: client.download_file(src_uri, sys.stdout.buffer) return True
[ "Output", "file", "contents", "to", "stdout" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L98-L103
[ "def", "do_file_show", "(", "client", ",", "args", ")", ":", "for", "src_uri", "in", "args", ".", "uris", ":", "client", ".", "download_file", "(", "src_uri", ",", "sys", ".", "stdout", ".", "buffer", ")", "return", "True" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_folder_create
Create directory
examples/mediafire-cli.py
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): """Create directory""" for folder_uri in args.uris: client.create_folder(folder_uri, recursive=True) return True
[ "Create", "directory" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L106-L110
[ "def", "do_folder_create", "(", "client", ",", "args", ")", ":", "for", "folder_uri", "in", "args", ".", "uris", ":", "client", ".", "create_folder", "(", "folder_uri", ",", "recursive", "=", "True", ")", "return", "True" ]
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_resource_delete
Remove resource
examples/mediafire-cli.py
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): """Remove resource""" for resource_uri in args.uris: client.delete_resource(resource_uri, purge=args.purge) print("Deleted {}".format(resource_uri)) return True
[ "Remove", "resource" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L113-L118
[ "def", "do_resource_delete", "(", "client", ",", "args", ")", ":", "for", "resource_uri", "in", "args", ".", "uris", ":", "client", ".", "delete_resource", "(", "resource_uri", ",", "purge", "=", "args", ".", "purge", ")", "print", "(", "\"Deleted {}\"", "...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_file_update_metadata
Update file metadata
examples/mediafire-cli.py
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): """Update file metadata""" client.update_file_metadata(args.uri, filename=args.filename, description=args.description, mtime=args.mtime, privacy=args.privacy) return True
[ "Update", "file", "metadata" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L121-L126
[ "def", "do_file_update_metadata", "(", "client", ",", "args", ")", ":", "client", ".", "update_file_metadata", "(", "args", ".", "uri", ",", "filename", "=", "args", ".", "filename", ",", "description", "=", "args", ".", "description", ",", "mtime", "=", "...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
do_folder_update_metadata
Update file metadata
examples/mediafire-cli.py
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): """Update file metadata""" client.update_folder_metadata(args.uri, foldername=args.foldername, description=args.description, mtime=args.mtime, privacy=args.privacy, ...
[ "Update", "file", "metadata" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L129-L135
[ "def", "do_folder_update_metadata", "(", "client", ",", "args", ")", ":", "client", ".", "update_folder_metadata", "(", "args", ".", "uri", ",", "foldername", "=", "args", ".", "foldername", ",", "description", "=", "args", ".", "description", ",", "mtime", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
main
Main entry point
examples/mediafire-cli.py
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 """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...
[ "Main", "entry", "point" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/examples/mediafire-cli.py#L145-L273
[ "def", "main", "(", ")", ":", "# pylint: disable=too-many-statements", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'mediafire-cli'", ",", "description", "=", "__doc__", ")", "parser", ".", "add_argument", "(", "'--debug'", ",", "dest", "...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
Client.pub
Publish a message to a topic
nsq/http/nsqd.py
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): '''Publish a message to a topic''' return self.post('pub', params={'topic': topic}, data=message)
[ "Publish", "a", "message", "to", "a", "topic" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L19-L21
[ "def", "pub", "(", "self", ",", "topic", ",", "message", ")", ":", "return", "self", ".", "post", "(", "'pub'", ",", "params", "=", "{", "'topic'", ":", "topic", "}", ",", "data", "=", "message", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.mpub
Send multiple messages to a topic. Optionally pack the messages
nsq/http/nsqd.py
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): '''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'...
[ "Send", "multiple", "messages", "to", "a", "topic", ".", "Optionally", "pack", "the", "messages" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L24-L37
[ "def", "mpub", "(", "self", ",", "topic", ",", "messages", ",", "binary", "=", "True", ")", ":", "if", "binary", ":", "# Pack and ship the data", "return", "self", ".", "post", "(", "'mpub'", ",", "data", "=", "pack", "(", "messages", ")", "[", "4", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Client.clean_stats
Stats with topics and channels keyed on topic and channel names
nsq/http/nsqd.py
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 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...
[ "Stats", "with", "topics", "and", "channels", "keyed", "on", "topic", "and", "channel", "names" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/http/nsqd.py#L99-L112
[ "def", "clean_stats", "(", "self", ")", ":", "stats", "=", "self", ".", "stats", "(", ")", "if", "'topics'", "in", "stats", ":", "# pragma: no branch", "topics", "=", "stats", "[", "'topics'", "]", "topics", "=", "dict", "(", "(", "t", ".", "pop", "(...
3ecacf6ab7719d38031179277113d875554a0c16
train
execute_add
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.
pueue/client/manipulation.py
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): """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...
[ "Add", "a", "new", "command", "to", "the", "daemon", "queue", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L9-L26
[ "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...
f1d276360454d4dd2738658a13df1e20caa4b926
train
execute_edit
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.
pueue/client/manipulation.py
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): """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')...
[ "Edit", "a", "existing", "queue", "command", "in", "the", "daemon", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/manipulation.py#L29-L66
[ "def", "execute_edit", "(", "args", ",", "root_dir", "=", "None", ")", ":", "# Get editor", "EDITOR", "=", "os", ".", "environ", ".", "get", "(", "'EDITOR'", ",", "'vim'", ")", "# Get command from server", "key", "=", "args", "[", "'key'", "]", "status", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
command_factory
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...
pueue/client/factories.py
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): """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 ...
[ "A", "factory", "which", "returns", "functions", "for", "direct", "daemon", "communication", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/client/factories.py#L6-L44
[ "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...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.get_descriptor
Create file descriptors for process output.
pueue/daemon/process_handler.py
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 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): ...
[ "Create", "file", "descriptors", "for", "process", "output", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L58-L79
[ "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", ")", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.clean_descriptor
Close file descriptor and remove underlying files.
pueue/daemon/process_handler.py
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): """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]['...
[ "Close", "file", "descriptor", "and", "remove", "underlying", "files", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L81-L90
[ "def", "clean_descriptor", "(", "self", ",", "number", ")", ":", "self", ".", "descriptors", "[", "number", "]", "[", "'stdout'", "]", ".", "close", "(", ")", "self", ".", "descriptors", "[", "number", "]", "[", "'stderr'", "]", ".", "close", "(", ")...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.check_finished
Poll all processes and handle any finished processes.
pueue/daemon/process_handler.py
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): """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 ...
[ "Poll", "all", "processes", "and", "handle", "any", "finished", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L92-L146
[ "def", "check_finished", "(", "self", ")", ":", "changed", "=", "False", "for", "key", "in", "list", "(", "self", ".", "processes", ".", "keys", "(", ")", ")", ":", "# Poll process and check if it finshed", "process", "=", "self", ".", "processes", "[", "k...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.check_for_new
Check if we can start a new process.
pueue/daemon/process_handler.py
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): """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)
[ "Check", "if", "we", "can", "start", "a", "new", "process", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L148-L154
[ "def", "check_for_new", "(", "self", ")", ":", "free_slots", "=", "self", ".", "max_processes", "-", "len", "(", "self", ".", "processes", ")", "for", "item", "in", "range", "(", "free_slots", ")", ":", "key", "=", "self", ".", "queue", ".", "next", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.spawn_new
Spawn a new task and save it to the queue.
pueue/daemon/process_handler.py
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): """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[...
[ "Spawn", "a", "new", "task", "and", "save", "it", "to", "the", "queue", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L156-L201
[ "def", "spawn_new", "(", "self", ",", "key", ")", ":", "# Check if path exists", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "queue", "[", "key", "]", "[", "'path'", "]", ")", ":", "self", ".", "queue", "[", "key", "]", "[", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.kill_all
Kill all running processes.
pueue/daemon/process_handler.py
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): """Kill all running processes.""" for key in self.processes.keys(): self.kill_process(key, kill_signal, kill_shell)
[ "Kill", "all", "running", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L221-L224
[ "def", "kill_all", "(", "self", ",", "kill_signal", ",", "kill_shell", "=", "False", ")", ":", "for", "key", "in", "self", ".", "processes", ".", "keys", "(", ")", ":", "self", ".", "kill_process", "(", "key", ",", "kill_signal", ",", "kill_shell", ")"...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.start_process
Start a specific processes.
pueue/daemon/process_handler.py
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): """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 ...
[ "Start", "a", "specific", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L226-L238
[ "def", "start_process", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "processes", "and", "key", "in", "self", ".", "paused", ":", "os", ".", "killpg", "(", "os", ".", "getpgid", "(", "self", ".", "processes", "[", "key", "]", ...
f1d276360454d4dd2738658a13df1e20caa4b926
train
ProcessHandler.pause_process
Pause a specific processes.
pueue/daemon/process_handler.py
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): """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 ...
[ "Pause", "a", "specific", "processes", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/daemon/process_handler.py#L240-L247
[ "def", "pause_process", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "processes", "and", "key", "not", "in", "self", ".", "paused", ":", "os", ".", "killpg", "(", "os", ".", "getpgid", "(", "self", ".", "processes", "[", "key"...
f1d276360454d4dd2738658a13df1e20caa4b926
train
daemon_factory
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...
pueue/__init__.py
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): """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...
[ "Create", "a", "closure", "which", "creates", "a", "running", "daemon", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L13-L37
[ "def", "daemon_factory", "(", "path", ")", ":", "def", "start_daemon", "(", ")", ":", "root_dir", "=", "path", "config_dir", "=", "os", ".", "path", ".", "join", "(", "root_dir", ",", "'.config/pueue'", ")", "try", ":", "daemon", "=", "Daemon", "(", "r...
f1d276360454d4dd2738658a13df1e20caa4b926
train
main
Execute entry function.
pueue/__init__.py
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(): """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 =...
[ "Execute", "entry", "function", "." ]
Nukesor/pueue
python
https://github.com/Nukesor/pueue/blob/f1d276360454d4dd2738658a13df1e20caa4b926/pueue/__init__.py#L40-L73
[ "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...
f1d276360454d4dd2738658a13df1e20caa4b926
train
register
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.
lib/pdb_clone/pdbhandler.py
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): """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...
[ "Register", "a", "pdb", "handler", "for", "signal", "signum", "." ]
corpusops/pdbclone
python
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L19-L26
[ "def", "register", "(", "host", "=", "DFLT_ADDRESS", "[", "0", "]", ",", "port", "=", "DFLT_ADDRESS", "[", "1", "]", ",", "signum", "=", "signal", ".", "SIGUSR1", ")", ":", "_pdbhandler", ".", "_register", "(", "host", ",", "port", ",", "signum", ")"...
f781537c243a4874b246d43dbdef8c4279f0094d
train
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.
lib/pdb_clone/pdbhandler.py
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(): """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(), ...
[ "Return", "the", "handler", "as", "a", "named", "tuple", "." ]
corpusops/pdbclone
python
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/pdbhandler.py#L35-L44
[ "def", "get_handler", "(", ")", ":", "host", ",", "port", ",", "signum", "=", "_pdbhandler", ".", "_registered", "(", ")", "if", "signum", ":", "return", "Handler", "(", "host", "if", "host", "else", "DFLT_ADDRESS", "[", "0", "]", ".", "encode", "(", ...
f781537c243a4874b246d43dbdef8c4279f0094d
train
StoppableThread.wait
Wait for the provided time to elapse
nsq/checker.py
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): '''Wait for the provided time to elapse''' logger.debug('Waiting for %fs', timeout) return self._event.wait(timeout)
[ "Wait", "for", "the", "provided", "time", "to", "elapse" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L14-L17
[ "def", "wait", "(", "self", ",", "timeout", ")", ":", "logger", ".", "debug", "(", "'Waiting for %fs'", ",", "timeout", ")", "return", "self", ".", "_event", ".", "wait", "(", "timeout", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
PeriodicThread.delay
How long to wait before the next check
nsq/checker.py
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): '''How long to wait before the next check''' if self._last_checked: return self._interval - (time.time() - self._last_checked) return self._interval
[ "How", "long", "to", "wait", "before", "the", "next", "check" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L34-L38
[ "def", "delay", "(", "self", ")", ":", "if", "self", ".", "_last_checked", ":", "return", "self", ".", "_interval", "-", "(", "time", ".", "time", "(", ")", "-", "self", ".", "_last_checked", ")", "return", "self", ".", "_interval" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
PeriodicThread.callback
Run the callback
nsq/checker.py
def callback(self): '''Run the callback''' self._callback(*self._args, **self._kwargs) self._last_checked = time.time()
def callback(self): '''Run the callback''' self._callback(*self._args, **self._kwargs) self._last_checked = time.time()
[ "Run", "the", "callback" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L40-L43
[ "def", "callback", "(", "self", ")", ":", "self", ".", "_callback", "(", "*", "self", ".", "_args", ",", "*", "*", "self", ".", "_kwargs", ")", "self", ".", "_last_checked", "=", "time", ".", "time", "(", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
PeriodicThread.run
Run the callback periodically
nsq/checker.py
def run(self): '''Run the callback periodically''' while not self.wait(self.delay()): try: logger.info('Invoking callback %s', self.callback) self.callback() except StandardError: logger.exception('Callback failed')
def run(self): '''Run the callback periodically''' while not self.wait(self.delay()): try: logger.info('Invoking callback %s', self.callback) self.callback() except StandardError: logger.exception('Callback failed')
[ "Run", "the", "callback", "periodically" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/checker.py#L45-L52
[ "def", "run", "(", "self", ")", ":", "while", "not", "self", ".", "wait", "(", "self", ".", "delay", "(", ")", ")", ":", "try", ":", "logger", ".", "info", "(", "'Invoking callback %s'", ",", "self", ".", "callback", ")", "self", ".", "callback", "...
3ecacf6ab7719d38031179277113d875554a0c16
train
MediaFireClient.login
Login to MediaFire account. Keyword arguments: email -- account email password -- account password app_id -- application ID api_key -- API Key (optional)
mediafire/client.py
def login(self, email=None, password=None, app_id=None, api_key=None): """Login to MediaFire account. Keyword arguments: email -- account email password -- account password app_id -- application ID api_key -- API Key (optional) """ session_token = self.ap...
def login(self, email=None, password=None, app_id=None, api_key=None): """Login to MediaFire account. Keyword arguments: email -- account email password -- account password app_id -- application ID api_key -- API Key (optional) """ session_token = self.ap...
[ "Login", "to", "MediaFire", "account", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L80-L93
[ "def", "login", "(", "self", ",", "email", "=", "None", ",", "password", "=", "None", ",", "app_id", "=", "None", ",", "api_key", "=", "None", ")", ":", "session_token", "=", "self", ".", "api", ".", "user_get_session_token", "(", "app_id", "=", "app_i...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.get_resource_by_uri
Return resource described by MediaFire URI. uri -- MediaFire URI Examples: Folder (using folderkey): mf:r5g3p2z0sqs3j mf:r5g3p2z0sqs3j/folder/file.ext File (using quickkey): mf:xkr43dadqa3o2p2 Path: mf:///Documents/f...
mediafire/client.py
def get_resource_by_uri(self, uri): """Return resource described by MediaFire URI. uri -- MediaFire URI Examples: Folder (using folderkey): mf:r5g3p2z0sqs3j mf:r5g3p2z0sqs3j/folder/file.ext File (using quickkey): mf:xkr43dadqa3o2p2 ...
def get_resource_by_uri(self, uri): """Return resource described by MediaFire URI. uri -- MediaFire URI Examples: Folder (using folderkey): mf:r5g3p2z0sqs3j mf:r5g3p2z0sqs3j/folder/file.ext File (using quickkey): mf:xkr43dadqa3o2p2 ...
[ "Return", "resource", "described", "by", "MediaFire", "URI", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L95-L130
[ "def", "get_resource_by_uri", "(", "self", ",", "uri", ")", ":", "location", "=", "self", ".", "_parse_uri", "(", "uri", ")", "if", "location", ".", "startswith", "(", "\"/\"", ")", ":", "# Use path lookup only, root=myfiles", "result", "=", "self", ".", "ge...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.get_resource_by_key
Return resource by quick_key/folder_key. key -- quick_key or folder_key
mediafire/client.py
def get_resource_by_key(self, resource_key): """Return resource by quick_key/folder_key. key -- quick_key or folder_key """ # search for quick_key by default lookup_order = ["quick_key", "folder_key"] if len(resource_key) == FOLDER_KEY_LENGTH: lookup_order ...
def get_resource_by_key(self, resource_key): """Return resource by quick_key/folder_key. key -- quick_key or folder_key """ # search for quick_key by default lookup_order = ["quick_key", "folder_key"] if len(resource_key) == FOLDER_KEY_LENGTH: lookup_order ...
[ "Return", "resource", "by", "quick_key", "/", "folder_key", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L132-L164
[ "def", "get_resource_by_key", "(", "self", ",", "resource_key", ")", ":", "# search for quick_key by default", "lookup_order", "=", "[", "\"quick_key\"", ",", "\"folder_key\"", "]", "if", "len", "(", "resource_key", ")", "==", "FOLDER_KEY_LENGTH", ":", "lookup_order",...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.get_resource_by_path
Return resource by remote path. path -- remote path Keyword arguments: folder_key -- what to use as the root folder (None for root)
mediafire/client.py
def get_resource_by_path(self, path, folder_key=None): """Return resource by remote path. path -- remote path Keyword arguments: folder_key -- what to use as the root folder (None for root) """ logger.debug("resolving %s", path) # remove empty path components ...
def get_resource_by_path(self, path, folder_key=None): """Return resource by remote path. path -- remote path Keyword arguments: folder_key -- what to use as the root folder (None for root) """ logger.debug("resolving %s", path) # remove empty path components ...
[ "Return", "resource", "by", "remote", "path", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L166-L225
[ "def", "get_resource_by_path", "(", "self", ",", "path", ",", "folder_key", "=", "None", ")", ":", "logger", ".", "debug", "(", "\"resolving %s\"", ",", "path", ")", "# remove empty path components", "path", "=", "posixpath", ".", "normpath", "(", "path", ")",...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient._folder_get_content_iter
Iterator for api.folder_get_content
mediafire/client.py
def _folder_get_content_iter(self, folder_key=None): """Iterator for api.folder_get_content""" lookup_params = [ {'content_type': 'folders', 'node': 'folders'}, {'content_type': 'files', 'node': 'files'} ] for param in lookup_params: more_chunks = Tr...
def _folder_get_content_iter(self, folder_key=None): """Iterator for api.folder_get_content""" lookup_params = [ {'content_type': 'folders', 'node': 'folders'}, {'content_type': 'files', 'node': 'files'} ] for param in lookup_params: more_chunks = Tr...
[ "Iterator", "for", "api", ".", "folder_get_content" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L227-L253
[ "def", "_folder_get_content_iter", "(", "self", ",", "folder_key", "=", "None", ")", ":", "lookup_params", "=", "[", "{", "'content_type'", ":", "'folders'", ",", "'node'", ":", "'folders'", "}", ",", "{", "'content_type'", ":", "'files'", ",", "'node'", ":"...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.get_folder_contents_iter
Return iterator for directory contents. uri -- mediafire URI Example: for item in get_folder_contents_iter('mf:///Documents'): print(item)
mediafire/client.py
def get_folder_contents_iter(self, uri): """Return iterator for directory contents. uri -- mediafire URI Example: for item in get_folder_contents_iter('mf:///Documents'): print(item) """ resource = self.get_resource_by_uri(uri) if not isins...
def get_folder_contents_iter(self, uri): """Return iterator for directory contents. uri -- mediafire URI Example: for item in get_folder_contents_iter('mf:///Documents'): print(item) """ resource = self.get_resource_by_uri(uri) if not isins...
[ "Return", "iterator", "for", "directory", "contents", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L255-L280
[ "def", "get_folder_contents_iter", "(", "self", ",", "uri", ")", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "uri", ")", "if", "not", "isinstance", "(", "resource", ",", "Folder", ")", ":", "raise", "NotAFolderError", "(", "uri", ")", "f...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.create_folder
Create folder. uri -- MediaFire URI Keyword arguments: recursive -- set to True to create intermediate folders.
mediafire/client.py
def create_folder(self, uri, recursive=False): """Create folder. uri -- MediaFire URI Keyword arguments: recursive -- set to True to create intermediate folders. """ logger.info("Creating %s", uri) # check that folder exists already try: res...
def create_folder(self, uri, recursive=False): """Create folder. uri -- MediaFire URI Keyword arguments: recursive -- set to True to create intermediate folders. """ logger.info("Creating %s", uri) # check that folder exists already try: res...
[ "Create", "folder", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L282-L327
[ "def", "create_folder", "(", "self", ",", "uri", ",", "recursive", "=", "False", ")", ":", "logger", ".", "info", "(", "\"Creating %s\"", ",", "uri", ")", "# check that folder exists already", "try", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.delete_folder
Delete folder. uri -- MediaFire folder URI Keyword arguments: purge -- delete the folder without sending it to Trash
mediafire/client.py
def delete_folder(self, uri, purge=False): """Delete folder. uri -- MediaFire folder URI Keyword arguments: purge -- delete the folder without sending it to Trash """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: ...
def delete_folder(self, uri, purge=False): """Delete folder. uri -- MediaFire folder URI Keyword arguments: purge -- delete the folder without sending it to Trash """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: ...
[ "Delete", "folder", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L329-L364
[ "def", "delete_folder", "(", "self", ",", "uri", ",", "purge", "=", "False", ")", ":", "try", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "uri", ")", "except", "ResourceNotFoundError", ":", "# Nothing to remove", "return", "None", "if", "n...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.delete_file
Delete file. uri -- MediaFire file URI Keyword arguments: purge -- delete the file without sending it to Trash.
mediafire/client.py
def delete_file(self, uri, purge=False): """Delete file. uri -- MediaFire file URI Keyword arguments: purge -- delete the file without sending it to Trash. """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: # ...
def delete_file(self, uri, purge=False): """Delete file. uri -- MediaFire file URI Keyword arguments: purge -- delete the file without sending it to Trash. """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: # ...
[ "Delete", "file", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L366-L388
[ "def", "delete_file", "(", "self", ",", "uri", ",", "purge", "=", "False", ")", ":", "try", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "uri", ")", "except", "ResourceNotFoundError", ":", "# Nothing to remove", "return", "None", "if", "not...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.delete_resource
Delete file or folder uri -- mediafire URI Keyword arguments: purge -- delete the resource without sending it to Trash.
mediafire/client.py
def delete_resource(self, uri, purge=False): """Delete file or folder uri -- mediafire URI Keyword arguments: purge -- delete the resource without sending it to Trash. """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: ...
def delete_resource(self, uri, purge=False): """Delete file or folder uri -- mediafire URI Keyword arguments: purge -- delete the resource without sending it to Trash. """ try: resource = self.get_resource_by_uri(uri) except ResourceNotFoundError: ...
[ "Delete", "file", "or", "folder" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L390-L411
[ "def", "delete_resource", "(", "self", ",", "uri", ",", "purge", "=", "False", ")", ":", "try", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "uri", ")", "except", "ResourceNotFoundError", ":", "# Nothing to remove", "return", "None", "if", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient._prepare_upload_info
Prepare Upload object, resolve paths
mediafire/client.py
def _prepare_upload_info(self, source, dest_uri): """Prepare Upload object, resolve paths""" try: dest_resource = self.get_resource_by_uri(dest_uri) except ResourceNotFoundError: dest_resource = None is_fh = hasattr(source, 'read') folder_key = None ...
def _prepare_upload_info(self, source, dest_uri): """Prepare Upload object, resolve paths""" try: dest_resource = self.get_resource_by_uri(dest_uri) except ResourceNotFoundError: dest_resource = None is_fh = hasattr(source, 'read') folder_key = None ...
[ "Prepare", "Upload", "object", "resolve", "paths" ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L428-L472
[ "def", "_prepare_upload_info", "(", "self", ",", "source", ",", "dest_uri", ")", ":", "try", ":", "dest_resource", "=", "self", ".", "get_resource_by_uri", "(", "dest_uri", ")", "except", "ResourceNotFoundError", ":", "dest_resource", "=", "None", "is_fh", "=", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.upload_file
Upload file to MediaFire. source -- path to the file or a file-like object (e.g. io.BytesIO) dest_uri -- MediaFire Resource URI
mediafire/client.py
def upload_file(self, source, dest_uri): """Upload file to MediaFire. source -- path to the file or a file-like object (e.g. io.BytesIO) dest_uri -- MediaFire Resource URI """ folder_key, name = self._prepare_upload_info(source, dest_uri) is_fh = hasattr(source, 'read'...
def upload_file(self, source, dest_uri): """Upload file to MediaFire. source -- path to the file or a file-like object (e.g. io.BytesIO) dest_uri -- MediaFire Resource URI """ folder_key, name = self._prepare_upload_info(source, dest_uri) is_fh = hasattr(source, 'read'...
[ "Upload", "file", "to", "MediaFire", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L474-L500
[ "def", "upload_file", "(", "self", ",", "source", ",", "dest_uri", ")", ":", "folder_key", ",", "name", "=", "self", ".", "_prepare_upload_info", "(", "source", ",", "dest_uri", ")", "is_fh", "=", "hasattr", "(", "source", ",", "'read'", ")", "fd", "=", ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.download_file
Download file from MediaFire. src_uri -- MediaFire file URI to download target -- download path or file-like object in write mode
mediafire/client.py
def download_file(self, src_uri, target): """Download file from MediaFire. src_uri -- MediaFire file URI to download target -- download path or file-like object in write mode """ resource = self.get_resource_by_uri(src_uri) if not isinstance(resource, File): ...
def download_file(self, src_uri, target): """Download file from MediaFire. src_uri -- MediaFire file URI to download target -- download path or file-like object in write mode """ resource = self.get_resource_by_uri(src_uri) if not isinstance(resource, File): ...
[ "Download", "file", "from", "MediaFire", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L502-L555
[ "def", "download_file", "(", "self", ",", "src_uri", ",", "target", ")", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "src_uri", ")", "if", "not", "isinstance", "(", "resource", ",", "File", ")", ":", "raise", "MediaFireError", "(", "\"On...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.update_file_metadata
Update file metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change the metadata on the server side: filename -- rename file description -- set file description string mtime -- set file modification time privacy -- set file pr...
mediafire/client.py
def update_file_metadata(self, uri, filename=None, description=None, mtime=None, privacy=None): """Update file metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change the metadata on the server side: filename -- r...
def update_file_metadata(self, uri, filename=None, description=None, mtime=None, privacy=None): """Update file metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change the metadata on the server side: filename -- r...
[ "Update", "file", "metadata", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L558-L582
[ "def", "update_file_metadata", "(", "self", ",", "uri", ",", "filename", "=", "None", ",", "description", "=", "None", ",", "mtime", "=", "None", ",", "privacy", "=", "None", ")", ":", "resource", "=", "self", ".", "get_resource_by_uri", "(", "uri", ")",...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient.update_folder_metadata
Update folder metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change the metadata on the server side: filename -- rename file description -- set file description string mtime -- set file modification time privacy -- set file ...
mediafire/client.py
def update_folder_metadata(self, uri, foldername=None, description=None, mtime=None, privacy=None, privacy_recursive=None): """Update folder metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change ...
def update_folder_metadata(self, uri, foldername=None, description=None, mtime=None, privacy=None, privacy_recursive=None): """Update folder metadata. uri -- MediaFire file URI Supplying the following keyword arguments would change ...
[ "Update", "folder", "metadata", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L586-L615
[ "def", "update_folder_metadata", "(", "self", ",", "uri", ",", "foldername", "=", "None", ",", "description", "=", "None", ",", "mtime", "=", "None", ",", "privacy", "=", "None", ",", "privacy_recursive", "=", "None", ")", ":", "resource", "=", "self", "...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
MediaFireClient._parse_uri
Parse and validate MediaFire URI.
mediafire/client.py
def _parse_uri(uri): """Parse and validate MediaFire URI.""" tokens = urlparse(uri) if tokens.netloc != '': logger.error("Invalid URI: %s", uri) raise ValueError("MediaFire URI format error: " "host should be empty - mf:///path") if...
def _parse_uri(uri): """Parse and validate MediaFire URI.""" tokens = urlparse(uri) if tokens.netloc != '': logger.error("Invalid URI: %s", uri) raise ValueError("MediaFire URI format error: " "host should be empty - mf:///path") if...
[ "Parse", "and", "validate", "MediaFire", "URI", "." ]
MediaFire/mediafire-python-open-sdk
python
https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L619-L633
[ "def", "_parse_uri", "(", "uri", ")", ":", "tokens", "=", "urlparse", "(", "uri", ")", "if", "tokens", ".", "netloc", "!=", "''", ":", "logger", ".", "error", "(", "\"Invalid URI: %s\"", ",", "uri", ")", "raise", "ValueError", "(", "\"MediaFire URI format ...
8f1f23db1b16f16e026f5c6777aec32d00baa05f
train
Nsqlookupd.merged
The clean stats from all the hosts reporting to this host.
nsq/stats.py
def merged(self): '''The clean stats from all the hosts reporting to this host.''' stats = {} for topic in self.client.topics()['topics']: for producer in self.client.lookup(topic)['producers']: hostname = producer['broadcast_address'] port = producer[...
def merged(self): '''The clean stats from all the hosts reporting to this host.''' stats = {} for topic in self.client.topics()['topics']: for producer in self.client.lookup(topic)['producers']: hostname = producer['broadcast_address'] port = producer[...
[ "The", "clean", "stats", "from", "all", "the", "hosts", "reporting", "to", "this", "host", "." ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L11-L21
[ "def", "merged", "(", "self", ")", ":", "stats", "=", "{", "}", "for", "topic", "in", "self", ".", "client", ".", "topics", "(", ")", "[", "'topics'", "]", ":", "for", "producer", "in", "self", ".", "client", ".", "lookup", "(", "topic", ")", "["...
3ecacf6ab7719d38031179277113d875554a0c16
train
Nsqlookupd.raw
All the raw, unaggregated stats (with duplicates).
nsq/stats.py
def raw(self): '''All the raw, unaggregated stats (with duplicates).''' topic_keys = ( 'message_count', 'depth', 'backend_depth', 'paused' ) channel_keys = ( 'in_flight_count', 'timeout_count', 'paused',...
def raw(self): '''All the raw, unaggregated stats (with duplicates).''' topic_keys = ( 'message_count', 'depth', 'backend_depth', 'paused' ) channel_keys = ( 'in_flight_count', 'timeout_count', 'paused',...
[ "All", "the", "raw", "unaggregated", "stats", "(", "with", "duplicates", ")", "." ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L24-L91
[ "def", "raw", "(", "self", ")", ":", "topic_keys", "=", "(", "'message_count'", ",", "'depth'", ",", "'backend_depth'", ",", "'paused'", ")", "channel_keys", "=", "(", "'in_flight_count'", ",", "'timeout_count'", ",", "'paused'", ",", "'deferred_count'", ",", ...
3ecacf6ab7719d38031179277113d875554a0c16
train
Nsqlookupd.stats
Stats that have been aggregated appropriately.
nsq/stats.py
def stats(self): '''Stats that have been aggregated appropriately.''' data = Counter() for name, value, aggregated in self.raw: if aggregated: data['%s.max' % name] = max(data['%s.max' % name], value) data['%s.total' % name] += value else: ...
def stats(self): '''Stats that have been aggregated appropriately.''' data = Counter() for name, value, aggregated in self.raw: if aggregated: data['%s.max' % name] = max(data['%s.max' % name], value) data['%s.total' % name] += value else: ...
[ "Stats", "that", "have", "been", "aggregated", "appropriately", "." ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/stats.py#L94-L104
[ "def", "stats", "(", "self", ")", ":", "data", "=", "Counter", "(", ")", "for", "name", ",", "value", ",", "aggregated", "in", "self", ".", "raw", ":", "if", "aggregated", ":", "data", "[", "'%s.max'", "%", "name", "]", "=", "max", "(", "data", "...
3ecacf6ab7719d38031179277113d875554a0c16
train
get_curline
Return the current python source line.
lib/pdb_clone/bootstrappdb_gdb.py
def get_curline(): """Return the current python source line.""" if Frame: frame = Frame.get_selected_python_frame() if frame: line = '' f = frame.get_pyop() if f and not f.is_optimized_out(): cwd = os.path.join(os.getcwd(), '') ...
def get_curline(): """Return the current python source line.""" if Frame: frame = Frame.get_selected_python_frame() if frame: line = '' f = frame.get_pyop() if f and not f.is_optimized_out(): cwd = os.path.join(os.getcwd(), '') ...
[ "Return", "the", "current", "python", "source", "line", "." ]
corpusops/pdbclone
python
https://github.com/corpusops/pdbclone/blob/f781537c243a4874b246d43dbdef8c4279f0094d/lib/pdb_clone/bootstrappdb_gdb.py#L80-L103
[ "def", "get_curline", "(", ")", ":", "if", "Frame", ":", "frame", "=", "Frame", ".", "get_selected_python_frame", "(", ")", "if", "frame", ":", "line", "=", "''", "f", "=", "frame", ".", "get_pyop", "(", ")", "if", "f", "and", "not", "f", ".", "is_...
f781537c243a4874b246d43dbdef8c4279f0094d
train
Reader.reconnected
Subscribe connection and manipulate its RDY state
nsq/reader.py
def reconnected(self, conn): '''Subscribe connection and manipulate its RDY state''' conn.sub(self._topic, self._channel) conn.rdy(1)
def reconnected(self, conn): '''Subscribe connection and manipulate its RDY state''' conn.sub(self._topic, self._channel) conn.rdy(1)
[ "Subscribe", "connection", "and", "manipulate", "its", "RDY", "state" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L16-L19
[ "def", "reconnected", "(", "self", ",", "conn", ")", ":", "conn", ".", "sub", "(", "self", ".", "_topic", ",", "self", ".", "_channel", ")", "conn", ".", "rdy", "(", "1", ")" ]
3ecacf6ab7719d38031179277113d875554a0c16
train
Reader.distribute_ready
Distribute the ready state across all of the connections
nsq/reader.py
def distribute_ready(self): '''Distribute the ready state across all of the connections''' connections = [c for c in self.connections() if c.alive()] if len(connections) > self._max_in_flight: raise NotImplementedError( 'Max in flight must be greater than number of co...
def distribute_ready(self): '''Distribute the ready state across all of the connections''' connections = [c for c in self.connections() if c.alive()] if len(connections) > self._max_in_flight: raise NotImplementedError( 'Max in flight must be greater than number of co...
[ "Distribute", "the", "ready", "state", "across", "all", "of", "the", "connections" ]
dlecocq/nsq-py
python
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/reader.py#L26-L42
[ "def", "distribute_ready", "(", "self", ")", ":", "connections", "=", "[", "c", "for", "c", "in", "self", ".", "connections", "(", ")", "if", "c", ".", "alive", "(", ")", "]", "if", "len", "(", "connections", ")", ">", "self", ".", "_max_in_flight", ...
3ecacf6ab7719d38031179277113d875554a0c16