sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def do_down(self, arg):
"""d(own) [count]
Move the current frame count (default one) levels down in the
stack trace (to a newer frame).
"""
if self.curindex + 1 == len(self.stack):
self.error('Newest frame')
return
try:
count = int(arg ... | d(own) [count]
Move the current frame count (default one) levels down in the
stack trace (to a newer frame). | entailment |
def do_until(self, arg):
"""unt(il) [lineno]
Without argument, continue execution until the line with a
number greater than the current one is reached. With a line
number, continue execution until a line with a number greater
or equal to that is reached. In both cases, also sto... | unt(il) [lineno]
Without argument, continue execution until the line with a
number greater than the current one is reached. With a line
number, continue execution until a line with a number greater
or equal to that is reached. In both cases, also stop when
the current frame ret... | entailment |
def do_run(self, arg):
"""run [args...]
Restart the debugged python program. If a string is supplied
it is splitted with "shlex", and the result is used as the new
sys.argv. History, breakpoints, actions and debugger options
are preserved. "restart" is an alias for "run".
... | run [args...]
Restart the debugged python program. If a string is supplied
it is splitted with "shlex", and the result is used as the new
sys.argv. History, breakpoints, actions and debugger options
are preserved. "restart" is an alias for "run". | entailment |
def do_jump(self, arg):
"""j(ump) lineno
Set the next line that will be executed. Only available in
the bottom-most frame. This lets you jump back and execute
code again, or jump forward to skip code that you don't want
to run.
It should be noted that not all jumps are... | j(ump) lineno
Set the next line that will be executed. Only available in
the bottom-most frame. This lets you jump back and execute
code again, or jump forward to skip code that you don't want
to run.
It should be noted that not all jumps are allowed -- for
instance it... | entailment |
def do_debug(self, arg):
"""debug code
Enter a recursive debugger that steps through the code
argument (which is an arbitrary expression or statement to be
executed in the current environment).
"""
self.settrace(False)
globals = self.curframe.f_globals
loc... | debug code
Enter a recursive debugger that steps through the code
argument (which is an arbitrary expression or statement to be
executed in the current environment). | entailment |
def do_quit(self, arg):
"""q(uit)\nexit
Quit from the debugger. The program being executed is aborted.
"""
if isinstance(self.stdin, RemoteSocket) and not self.is_debug_instance:
return self.do_detach(arg)
self._user_requested_quit = True
self.set_quit()
... | q(uit)\nexit
Quit from the debugger. The program being executed is aborted. | entailment |
def do_args(self, arg):
"""a(rgs)
Print the argument list of the current function.
"""
co = self.curframe.f_code
dict = self.get_locals(self.curframe)
n = co.co_argcount
if co.co_flags & 4: n = n+1
if co.co_flags & 8: n = n+1
for i in range(n):
... | a(rgs)
Print the argument list of the current function. | entailment |
def do_retval(self, arg):
"""retval
Print the return value for the last return of a function.
"""
locals = self.get_locals(self.curframe)
if '__return__' in locals:
self.message(bdb.safe_repr(locals['__return__']))
else:
self.error('Not yet returne... | retval
Print the return value for the last return of a function. | entailment |
def do_p(self, arg):
"""p expression
Print the value of the expression.
"""
try:
self.message(bdb.safe_repr(self._getval(arg)))
except Exception:
pass | p expression
Print the value of the expression. | entailment |
def do_pp(self, arg):
"""pp expression
Pretty-print the value of the expression.
"""
obj = self._getval(arg)
try:
repr(obj)
except Exception:
self.message(bdb.safe_repr(obj))
else:
self.message(pprint.pformat(obj)) | pp expression
Pretty-print the value of the expression. | entailment |
def do_list(self, arg):
"""l(ist) [first [,last] | .]
List source code for the current file. Without arguments,
list 11 lines around the current line or continue the previous
listing. With . as argument, list 11 lines around the current
line. With one argument, list 11 lines ... | l(ist) [first [,last] | .]
List source code for the current file. Without arguments,
list 11 lines around the current line or continue the previous
listing. With . as argument, list 11 lines around the current
line. With one argument, list 11 lines starting at that line.
With... | entailment |
def do_longlist(self, arg):
"""longlist | ll
List the whole source code for the current function or frame.
"""
filename = self.curframe.f_code.co_filename
breaklist = self.get_file_breaks(filename)
try:
lines, lineno = getsourcelines(self.curframe,
... | longlist | ll
List the whole source code for the current function or frame. | entailment |
def do_source(self, arg):
"""source expression
Try to get source code for the given object and display it.
"""
try:
obj = self._getval(arg)
except Exception:
return
try:
lines, lineno = getsourcelines(obj, self.get_locals(self.curframe)... | source expression
Try to get source code for the given object and display it. | entailment |
def _print_lines(self, lines, start, breaks=(), frame=None):
"""Print a range of lines."""
if frame:
current_lineno = frame.f_lineno
exc_lineno = self.tb_lineno.get(frame, -1)
else:
current_lineno = exc_lineno = -1
for lineno, line in enumerate(lines, ... | Print a range of lines. | entailment |
def do_whatis(self, arg):
"""whatis arg
Print the type of the argument.
"""
try:
value = self._getval(arg)
except Exception:
# _getval() already printed the error
return
code = None
# Is it a function?
try:
c... | whatis arg
Print the type of the argument. | entailment |
def do_display(self, arg):
"""display [expression]
Display the value of the expression if it changed, each time execution
stops in the current frame.
Without expression, list all display expressions for the current frame.
"""
if not arg:
self.message('Curren... | display [expression]
Display the value of the expression if it changed, each time execution
stops in the current frame.
Without expression, list all display expressions for the current frame. | entailment |
def do_undisplay(self, arg):
"""undisplay [expression]
Do not display the expression any more in the current frame.
Without expression, clear all display expressions for the current frame.
"""
if arg:
try:
del self.displaying.get(self.curframe, {})[a... | undisplay [expression]
Do not display the expression any more in the current frame.
Without expression, clear all display expressions for the current frame. | entailment |
def do_interact(self, arg):
"""interact
Start an interative interpreter whose global namespace
contains all the (global and local) names found in the current scope.
"""
def readfunc(prompt):
self.stdout.write(prompt)
self.stdout.flush()
line =... | interact
Start an interative interpreter whose global namespace
contains all the (global and local) names found in the current scope. | entailment |
def do_alias(self, arg):
"""alias [name [command [parameter parameter ...] ]]
Create an alias called 'name' that executes 'command'. The
command must *not* be enclosed in quotes. Replaceable
parameters can be indicated by %1, %2, and so on, while %* is
replaced by all the param... | alias [name [command [parameter parameter ...] ]]
Create an alias called 'name' that executes 'command'. The
command must *not* be enclosed in quotes. Replaceable
parameters can be indicated by %1, %2, and so on, while %* is
replaced by all the parameters. If no command is given, the
... | entailment |
def do_unalias(self, arg):
"""unalias name
Delete the specified alias.
"""
args = arg.split()
if len(args) == 0: return
if args[0] in self.aliases:
del self.aliases[args[0]] | unalias name
Delete the specified alias. | entailment |
def do_thread(self, arg):
"""th(read) [threadnumber]
Without argument, display a summary of all active threads.
The summary prints for each thread:
1. the thread number assigned by pdb
2. the thread name
3. the python thread identifier
4. the current s... | th(read) [threadnumber]
Without argument, display a summary of all active threads.
The summary prints for each thread:
1. the thread number assigned by pdb
2. the thread name
3. the python thread identifier
4. the current stack frame summary for that thread
... | entailment |
def do_help(self, arg):
"""h(elp)
Without argument, print the list of available commands.
With a command name as argument, print help about that command.
"help pdb" shows the full pdb documentation.
"help exec" gives help on the ! command.
"""
if not arg:
... | h(elp)
Without argument, print the list of available commands.
With a command name as argument, print help about that command.
"help pdb" shows the full pdb documentation.
"help exec" gives help on the ! command. | entailment |
def read(self, limit=-1):
"""Read content. See file.read"""
remaining = self.len - self.parent_fd.tell() + self.offset
if limit > remaining or limit == -1:
limit = remaining
return self.parent_fd.read(limit) | Read content. See file.read | entailment |
def seek(self, offset, whence=os.SEEK_SET):
"""Seek to position in stream, see file.seek"""
pos = None
if whence == os.SEEK_SET:
pos = self.offset + offset
elif whence == os.SEEK_CUR:
pos = self.tell() + offset
elif whence == os.SEEK_END:
pos ... | Seek to position in stream, see file.seek | entailment |
def close(self):
"""Close file, see file.close"""
try:
self.parent_fd.fileno()
except io.UnsupportedOperation:
logger.debug("Not closing parent_fd - reusing existing")
else:
self.parent_fd.close() | Close file, see file.close | entailment |
def _build_query(self, uri, params=None, action_token_type=None):
"""Prepare query string"""
if params is None:
params = QueryParams()
params['response_format'] = 'json'
session_token = None
if action_token_type in self._action_tokens:
# Favor action t... | Prepare query string | entailment |
def request(self, action, params=None, action_token_type=None,
upload_info=None, headers=None):
"""Perform request to MediaFire API
action -- "category/name" of method to call
params -- dict of parameters or query string
action_token_type -- action token to use: None, "u... | Perform request to MediaFire API
action -- "category/name" of method to call
params -- dict of parameters or query string
action_token_type -- action token to use: None, "upload", "image"
upload_info -- in case of upload, dict of "fd" and "filename"
headers -- additional headers... | entailment |
def _process_response(self, response):
"""Parse response"""
forward_raw = False
content_type = response.headers['Content-Type']
if content_type != 'application/json':
logger.debug("headers: %s", response.headers)
# API BUG: text/xml content-type with json payload... | Parse response | entailment |
def _regenerate_secret_key(self):
"""Regenerate secret key
http://www.mediafire.com/developers/core_api/1.3/getting_started/#call_signature
"""
# Don't regenerate the key if we have none
if self._session and 'secret_key' in self._session:
self._session['secret_key'] ... | Regenerate secret key
http://www.mediafire.com/developers/core_api/1.3/getting_started/#call_signature | entailment |
def session(self, value):
"""Set session token
value -- dict returned by user/get_session_token"""
# unset session token
if value is None:
self._session = None
return
if not isinstance(value, dict):
raise ValueError("session info is required... | Set session token
value -- dict returned by user/get_session_token | entailment |
def set_action_token(self, type_=None, action_token=None):
"""Set action tokens
type_ -- either "upload" or "image"
action_token -- string obtained from user/get_action_token,
set None to remove the token
"""
if action_token is None:
del self.... | Set action tokens
type_ -- either "upload" or "image"
action_token -- string obtained from user/get_action_token,
set None to remove the token | entailment |
def user_get_session_token(self, app_id=None, email=None, password=None,
ekey=None, fb_access_token=None,
tw_oauth_token=None,
tw_oauth_token_secret=None, api_key=None):
"""user/get_session_token
http://www.med... | user/get_session_token
http://www.mediafire.com/developers/core_api/1.3/user/#get_session_token | entailment |
def user_set_avatar(self, action=None, quick_key=None, url=None):
"""user/set_avatar
http://www.mediafire.com/developers/core_api/1.3/user/#set_avatar
"""
return self.request("user/set_avatar", QueryParams({
"action": action,
"quick_key": quick_key,
"... | user/set_avatar
http://www.mediafire.com/developers/core_api/1.3/user/#set_avatar | entailment |
def user_update(self, display_name=None, first_name=None, last_name=None,
email=None, password=None, current_password=None,
birth_date=None, gender=None, website=None, subdomain=None,
location=None, newsletter=None, primary_usage=None,
time... | user/update
http://www.mediafire.com/developers/core_api/1.3/user/#update | entailment |
def folder_get_info(self, folder_key=None, device_id=None, details=None):
"""folder/get_info
http://www.mediafire.com/developers/core_api/1.3/folder/#get_info
"""
return self.request('folder/get_info', QueryParams({
'folder_key': folder_key,
'device_id': device_i... | folder/get_info
http://www.mediafire.com/developers/core_api/1.3/folder/#get_info | entailment |
def folder_get_content(self, folder_key=None, content_type=None,
filter_=None, device_id=None, order_by=None,
order_direction=None, chunk=None, details=None,
chunk_size=None):
"""folder/get_content
http://www.mediafire.com... | folder/get_content
http://www.mediafire.com/developers/core_api/1.3/folder/#get_content | entailment |
def folder_update(self, folder_key, foldername=None, description=None,
privacy=None, privacy_recursive=None, mtime=None):
"""folder/update
http://www.mediafire.com/developers/core_api/1.3/folder/#update
"""
return self.request('folder/update', QueryParams({
... | folder/update
http://www.mediafire.com/developers/core_api/1.3/folder/#update | entailment |
def folder_create(self, foldername=None, parent_key=None,
action_on_duplicate=None, mtime=None):
"""folder/create
http://www.mediafire.com/developers/core_api/1.3/folder/#create
"""
return self.request('folder/create', QueryParams({
'foldername': folder... | folder/create
http://www.mediafire.com/developers/core_api/1.3/folder/#create | entailment |
def upload_check(self, filename=None, folder_key=None, filedrop_key=None,
size=None, hash_=None, path=None, resumable=None):
"""upload/check
http://www.mediafire.com/developers/core_api/1.3/upload/#check
"""
return self.request('upload/check', QueryParams({
... | upload/check
http://www.mediafire.com/developers/core_api/1.3/upload/#check | entailment |
def upload_simple(self, fd, filename, folder_key=None, path=None,
filedrop_key=None, action_on_duplicate=None,
mtime=None, file_size=None, file_hash=None):
"""upload/simple
http://www.mediafire.com/developers/core_api/1.3/upload/#simple
"""
ac... | upload/simple
http://www.mediafire.com/developers/core_api/1.3/upload/#simple | entailment |
def upload_resumable(self, fd, filesize, filehash, unit_hash, unit_id,
unit_size, quick_key=None, action_on_duplicate=None,
mtime=None, version_control=None, folder_key=None,
filedrop_key=None, path=None, previous_hash=None):
"""upload/r... | upload/resumable
http://www.mediafire.com/developers/core_api/1.3/upload/#resumable | entailment |
def upload_instant(self, filename, size, hash_, quick_key=None,
folder_key=None, filedrop_key=None, path=None,
action_on_duplicate=None, mtime=None,
version_control=None, previous_hash=None):
"""upload/instant
http://www.mediafire.com... | upload/instant
http://www.mediafire.com/developers/core_api/1.3/upload/#instant | entailment |
def file_update(self, quick_key, filename=None, description=None,
mtime=None, privacy=None):
"""file/update
http://www.mediafire.com/developers/core_api/1.3/file/#update
"""
return self.request('file/update', QueryParams({
'quick_key': quick_key,
... | file/update
http://www.mediafire.com/developers/core_api/1.3/file/#update | entailment |
def file_update_file(self, quick_key, file_extension=None, filename=None,
description=None, mtime=None, privacy=None,
timezone=None):
"""file/update_file
http://www.mediafire.com/developers/core_api/1.3/file/#update_file
"""
return self.... | file/update_file
http://www.mediafire.com/developers/core_api/1.3/file/#update_file | entailment |
def file_zip(self, keys, confirm_download=None, meta_only=None):
"""file/zip
http://www.mediafire.com/developers/core_api/1.3/file/#zip
"""
return self.request('file/zip', QueryParams({
'keys': keys,
'confirm_download': confirm_download,
'meta_only': ... | file/zip
http://www.mediafire.com/developers/core_api/1.3/file/#zip | entailment |
def _reset(self):
'''Reset all of our stateful variables'''
self._socket = None
# The pending messages we have to send, and the current buffer we're
# sending
self._pending = deque()
self._out_buffer = ''
# Our read buffer
self._buffer = ''
# The i... | Reset all of our stateful variables | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
def identify(self, data):
'''Send an identification message'''
return self.send(constants.IDENTIFY, json.dumps(data)) | Send an identification message | entailment |
def sub(self, topic, channel):
'''Subscribe to a topic/channel'''
return self.send(' '.join((constants.SUB, topic, channel))) | Subscribe to a topic/channel | entailment |
def pub(self, topic, message):
'''Publish to a topic'''
return self.send(' '.join((constants.PUB, topic)), message) | Publish to a topic | entailment |
def mpub(self, topic, *messages):
'''Publish multiple messages to a topic'''
return self.send(constants.MPUB + ' ' + topic, messages) | Publish multiple messages to a topic | entailment |
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 | entailment |
def req(self, message_id, timeout):
'''Re-queue a message'''
return self.send(constants.REQ + ' ' + message_id + ' ' + str(timeout)) | Re-queue a message | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
def wait_response(self):
'''Wait for a response'''
responses = self.read()
while not responses:
responses = self.read()
return responses | Wait for a response | entailment |
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 | entailment |
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 | entailment |
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.
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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.
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... | entailment |
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.
The daemon will shut down after a last check on all killed processes. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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.
The log will be rotated once. Otherwise we would loose all logs from
thoes finished processes. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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. | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
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 | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.