sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def clear_message_streams(self):
""" Resets streams and sockets of incoming messages.
You can use this method to reuse the same connections for several
consecutive test cases.
"""
for client in self._clients:
client.empty()
for server in self._servers:
... | Resets streams and sockets of incoming messages.
You can use this method to reuse the same connections for several
consecutive test cases. | entailment |
def new_protocol(self, protocol_name):
"""Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template.
"""
if self._protocol_in_progress:
raise Exception('Can not start a new ... | Start defining a new protocol template.
All messages sent and received from a connection that uses a protocol
have to conform to this protocol template. | entailment |
def end_protocol(self):
"""End protocol definition."""
protocol = self._get_message_template()
self._protocols[protocol.name] = protocol
self._protocol_in_progress = False | End protocol definition. | entailment |
def start_udp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6.
Examples:
| Start U... | Starts a new UDP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6.
Examples:
| Start UDP server | 10.10.10.2 | 53 |
| Start UDP server | 10.10.10.2 | 53 | Server1 |
| Start U... | entailment |
def start_tcp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6. Notice that you have to
use ... | Starts a new TCP server to given `ip` and `port`.
Server can be given a `name`, default `timeout` and a `protocol`.
`family` can be either ipv4 (default) or ipv6. Notice that you have to
use `Accept Connection` keyword for server to receive connections.
Examples:
| Start TCP se... | entailment |
def start_sctp_server(self, ip, port, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new STCP server to given `ip` and `port`.
`family` can be either ipv4 (default) or ipv6.
pysctp (https://github.com/philpraxis/pysctp) need to be installed your system.
Server can ... | Starts a new STCP server to given `ip` and `port`.
`family` can be either ipv4 (default) or ipv6.
pysctp (https://github.com/philpraxis/pysctp) need to be installed your system.
Server can be given a `name`, default `timeout` and a `protocol`.
Notice that you have to use `Accept Connec... | entailment |
def start_udp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new UDP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ... | Starts a new UDP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start UD... | entailment |
def start_tcp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new TCP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or i... | Starts a new TCP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start TCP... | entailment |
def start_sctp_client(self, ip=None, port=None, name=None, timeout=None, protocol=None, family='ipv4'):
"""Starts a new SCTP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) o... | Starts a new SCTP client.
Client can be optionally given `ip` and `port` to bind to, as well as
`name`, default `timeout` and a `protocol`. `family` can be either
ipv4 (default) or ipv6.
You should use `Connect` keyword to connect client to a host.
Examples:
| Start T... | entailment |
def accept_connection(self, name=None, alias=None, timeout=0):
"""Accepts a connection to server identified by `name` or the latest
server if `name` is empty.
If given an `alias`, the connection is named and can be later referenced
with that name.
If `timeout` is > 0, the conne... | Accepts a connection to server identified by `name` or the latest
server if `name` is empty.
If given an `alias`, the connection is named and can be later referenced
with that name.
If `timeout` is > 0, the connection times out after the time specified.
`timeout` defaults to 0 ... | entailment |
def connect(self, host, port, name=None):
"""Connects a client to given `host` and `port`. If client `name` is not
given then connects the latest client.
Examples:
| Connect | 127.0.0.1 | 8080 |
| Connect | 127.0.0.1 | 8080 | Client1 |
"""
client = self._clients.... | Connects a client to given `host` and `port`. If client `name` is not
given then connects the latest client.
Examples:
| Connect | 127.0.0.1 | 8080 |
| Connect | 127.0.0.1 | 8080 | Client1 | | entailment |
def client_sends_binary(self, message, name=None, label=None):
"""Send raw binary `message`.
If client `name` is not given, uses the latest client. Optional message
`label` is shown on logs.
Examples:
| Client sends binary | Hello! |
| Client sends binary | ${some binar... | Send raw binary `message`.
If client `name` is not given, uses the latest client. Optional message
`label` is shown on logs.
Examples:
| Client sends binary | Hello! |
| Client sends binary | ${some binary} | Client1 | label=DebugMessage | | entailment |
def server_sends_binary(self, message, name=None, connection=None, label=None):
"""Send raw binary `message`.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| Server sends binary | Hello! |
| Server sends bina... | Send raw binary `message`.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| Server sends binary | Hello! |
| Server sends binary | ${some binary} | Server1 | label=DebugMessage |
| Server sends binary | ${some... | entailment |
def client_receives_binary(self, name=None, timeout=None, label=None):
"""Receive raw binary message.
If client `name` is not given, uses the latest client. Optional message
`label` is shown on logs.
Examples:
| ${binary} = | Client receives binary |
| ${binary} = | Cli... | Receive raw binary message.
If client `name` is not given, uses the latest client. Optional message
`label` is shown on logs.
Examples:
| ${binary} = | Client receives binary |
| ${binary} = | Client receives binary | Client1 | timeout=5 | | entailment |
def server_receives_binary(self, name=None, timeout=None, connection=None, label=None):
"""Receive raw binary message.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} = | Server receives binary |
| ... | Receive raw binary message.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} = | Server receives binary |
| ${binary} = | Server receives binary | Server1 | connection=my_connection | timeout=5 | | entailment |
def server_receives_binary_from(self, name=None, timeout=None, connection=None, label=None):
"""Receive raw binary message. Returns message, ip, and port.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} | $... | Receive raw binary message. Returns message, ip, and port.
If server `name` is not given, uses the latest server. Optional message
`label` is shown on logs.
Examples:
| ${binary} | ${ip} | ${port} = | Server receives binary from |
| ${binary} | ${ip} | ${port} = | Server receiv... | entailment |
def new_message(self, message_name, protocol=None, *parameters):
"""Define a new message template with `message_name`.
`protocol` has to be defined earlier with `Start Protocol Description`.
Optional parameters are default values for message header separated with
colon.
Example... | Define a new message template with `message_name`.
`protocol` has to be defined earlier with `Start Protocol Description`.
Optional parameters are default values for message header separated with
colon.
Examples:
| New message | MyMessage | MyProtocol | header_field:value | | entailment |
def save_template(self, name, unlocked=False):
"""Save a message template for later use with `Load template`.
If saved template is marked as unlocked, then changes can be made to it
afterwards. By default tempaltes are locked.
Examples:
| Save Template | MyMessage |
| S... | Save a message template for later use with `Load template`.
If saved template is marked as unlocked, then changes can be made to it
afterwards. By default tempaltes are locked.
Examples:
| Save Template | MyMessage |
| Save Template | MyOtherMessage | unlocked=True | | entailment |
def load_template(self, name, *parameters):
"""Load a message template saved with `Save template`.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Template | MyMessage | header_field:value |
"""
template, fields, h... | Load a message template saved with `Save template`.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Template | MyMessage | header_field:value | | entailment |
def load_copy_of_template(self, name, *parameters):
"""Load a copy of message template saved with `Save template` when originally saved values need to be preserved
from test to test.
Optional parameters are default values for message header separated with
colon.
Examples:
... | Load a copy of message template saved with `Save template` when originally saved values need to be preserved
from test to test.
Optional parameters are default values for message header separated with
colon.
Examples:
| Load Copy Of Template | MyMessage | header_field:value | | entailment |
def get_message(self, *parameters):
"""Get encoded message.
* Send Message -keywords are convenience methods, that will call this to
get the message object and then send it. Optional parameters are message
field values separated with colon.
Examples:
| ${msg} = | Get me... | Get encoded message.
* Send Message -keywords are convenience methods, that will call this to
get the message object and then send it. Optional parameters are message
field values separated with colon.
Examples:
| ${msg} = | Get message |
| ${msg} = | Get message | fiel... | entailment |
def client_receives_message(self, *parameters):
"""Receive a message with template defined using `New Message` and
validate field values.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is... | Receive a message with template defined using `New Message` and
validate field values.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) example: `name=Client 1`
- `timeo... | entailment |
def client_receives_without_validation(self, *parameters):
"""Receive a message with template defined using `New Message`.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) examp... | Receive a message with template defined using `New Message`.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) example: `name=Client 1`
- `timeout` for receiving message. example... | entailment |
def server_receives_message(self, *parameters):
"""Receive a message with template defined using `New Message` and
validate field values.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is... | Receive a message with template defined using `New Message` and
validate field values.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) example: `name=Client 1`
- `conne... | entailment |
def server_receives_without_validation(self, *parameters):
"""Receive a message with template defined using `New Message`.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) examp... | Receive a message with template defined using `New Message`.
Message template has to be defined with `New Message` before calling
this.
Optional parameters:
- `name` the client name (default is the latest used) example: `name=Client 1`
- `connection` alias. example: `connection... | entailment |
def validate_message(self, msg, *parameters):
"""Validates given message using template defined with `New Message` and
field values given as optional arguments.
Examples:
| Validate message | ${msg} |
| Validate message | ${msg} | status:0 |
"""
_, message_fields... | Validates given message using template defined with `New Message` and
field values given as optional arguments.
Examples:
| Validate message | ${msg} |
| Validate message | ${msg} | status:0 | | entailment |
def uint(self, length, name, value=None, align=None):
"""Add an unsigned integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Examples:
| uint | 2 | foo |
| uint | 2 | foo | 42 |
|... | Add an unsigned integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Examples:
| uint | 2 | foo |
| uint | 2 | foo | 42 |
| uint | 2 | fourByteFoo | 42 | align=4 | | entailment |
def int(self, length, name, value=None, align=None):
"""Add an signed integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Signed integer uses twos-complement with bits numbered in big-endian.
Exa... | Add an signed integer to template.
`length` is given in bytes and `value` is optional. `align` can be used
to align the field to longer byte length.
Signed integer uses twos-complement with bits numbered in big-endian.
Examples:
| int | 2 | foo |
| int | 2 | foo | 42 |
... | entailment |
def chars(self, length, name, value=None, terminator=None):
"""Add a char array to template.
`length` is given in bytes and can refer to earlier numeric fields in
template. Special value '*' in length means that length is encoded to
length of value and decoded as all available bytes.
... | Add a char array to template.
`length` is given in bytes and can refer to earlier numeric fields in
template. Special value '*' in length means that length is encoded to
length of value and decoded as all available bytes.
`value` is optional.
`value` could be either a "String" ... | entailment |
def new_struct(self, type, name, *parameters):
"""Defines a new struct to template.
You must call `End Struct` to end struct definition. `type` is the name
for generic type and `name` is the field name in containing structure.
Possible parameters are values for struct fields separated w... | Defines a new struct to template.
You must call `End Struct` to end struct definition. `type` is the name
for generic type and `name` is the field name in containing structure.
Possible parameters are values for struct fields separated with colon
and optional struct length defined with ... | entailment |
def _new_list(self, size, name):
"""Defines a new list to template of `size` and with `name`.
List type must be given after this keyword by defining one field. Then
the list definition has to be closed using `End List`.
Special value '*' in size means that list will decode values as lo... | Defines a new list to template of `size` and with `name`.
List type must be given after this keyword by defining one field. Then
the list definition has to be closed using `End List`.
Special value '*' in size means that list will decode values as long as
data is available. This free l... | entailment |
def new_binary_container(self, name):
"""Defines a new binary container to template.
Binary container can only contain binary fields defined with `Bin`
keyword.
Examples:
| New binary container | flags |
| bin | 2 | foo |
| bin | 6 | bar |
| End binary c... | Defines a new binary container to template.
Binary container can only contain binary fields defined with `Bin`
keyword.
Examples:
| New binary container | flags |
| bin | 2 | foo |
| bin | 6 | bar |
| End binary container | | entailment |
def end_binary_container(self):
"""End binary container. See `New Binary Container`.
"""
binary_container = self._message_stack.pop()
binary_container.verify()
self._add_field(binary_container) | End binary container. See `New Binary Container`. | entailment |
def bin(self, size, name, value=None):
"""Add new binary field to template.
This keyword has to be called within a binary container. See `New Binary
Container`.
"""
self._add_field(Binary(size, name, value)) | Add new binary field to template.
This keyword has to be called within a binary container. See `New Binary
Container`. | entailment |
def new_union(self, type, name):
"""Defines a new union to template of `type` and `name`.
Fields inside the union are alternatives and the length of the union is
the length of its longest field.
Example:
| New union | IntOrAddress | foo |
| Chars | 16 | ipAddress |
... | Defines a new union to template of `type` and `name`.
Fields inside the union are alternatives and the length of the union is
the length of its longest field.
Example:
| New union | IntOrAddress | foo |
| Chars | 16 | ipAddress |
| u32 | int |
| End union | | entailment |
def start_bag(self, name):
"""Bags are sets of optional elements with an optional count.
The optional elements are given each as a `Case` with the accepted count
as first argument. The received elements are matched from the list of
cases in order. If the the received value does not vali... | Bags are sets of optional elements with an optional count.
The optional elements are given each as a `Case` with the accepted count
as first argument. The received elements are matched from the list of
cases in order. If the the received value does not validate against the
case (for exa... | entailment |
def value(self, name, value):
"""Defines a default `value` for a template field identified by `name`.
Default values for header fields can be set with header:field syntax.
Examples:
| Value | foo | 42 |
| Value | struct.sub_field | 0xcafe |
| Value | header:version | 0x... | Defines a default `value` for a template field identified by `name`.
Default values for header fields can be set with header:field syntax.
Examples:
| Value | foo | 42 |
| Value | struct.sub_field | 0xcafe |
| Value | header:version | 0x02 | | entailment |
def conditional(self, condition, name):
"""Defines a 'condition' when conditional element of 'name' exists if `condition` is true.
`condition` can contain multiple conditions combined together using Logical Expressions(&&,||).
Example:
| Conditional | mycondition == 1 | foo |
|... | Defines a 'condition' when conditional element of 'name' exists if `condition` is true.
`condition` can contain multiple conditions combined together using Logical Expressions(&&,||).
Example:
| Conditional | mycondition == 1 | foo |
| u8 | myelement | 42 |
| End conditional ... | entailment |
def get_client_unread_messages_count(self, client_name=None):
"""Gets count of unread messages from client
"""
client = self._clients.get_with_name(client_name)[0]
return client.get_messages_count_in_buffer() | Gets count of unread messages from client | entailment |
def get_server_unread_messages_count(self, server_name=None):
"""Gets count of unread messages from server
"""
server = self._servers.get(server_name)
return server.get_messages_count_in_buffer() | Gets count of unread messages from server | entailment |
def to_twos_comp(val, bits):
"""compute the 2's compliment of int value val"""
if not val.startswith('-'):
return to_int(val)
value = _invert(to_bin_str_from_int_string(bits, bin(to_int(val[1:]))))
return int(value, 2) + 1 | compute the 2's compliment of int value val | entailment |
def u8(self, name, value=None, align=None):
"""Add an unsigned 1 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(1, name, value, align) | Add an unsigned 1 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u16(self, name, value=None, align=None):
"""Add an unsigned 2 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(2, name, value, align) | Add an unsigned 2 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u24(self, name, value=None, align=None):
"""Add an unsigned 3 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(3, name, value, align) | Add an unsigned 3 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u32(self, name, value=None, align=None):
"""Add an unsigned 4 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(4, name, value, align) | Add an unsigned 4 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u40(self, name, value=None, align=None):
"""Add an unsigned 5 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(5, name, value, align) | Add an unsigned 5 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u64(self, name, value=None, align=None):
"""Add an unsigned 8 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(8, name, value, align) | Add an unsigned 8 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def u128(self, name, value=None, align=None):
"""Add an unsigned 16 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length."""
self.uint(16, name, value, align) | Add an unsigned 16 byte integer field to template.
This is an convenience method that simply calls `Uint` keyword with predefined length. | entailment |
def i8(self, name, value=None, align=None):
"""Add an 1 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(1, name, value, align) | Add an 1 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length. | entailment |
def i32(self, name, value=None, align=None):
"""Add an 32 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length."""
self.int(4, name, value, align) | Add an 32 byte integer field to template.
This is an convenience method that simply calls `Int` keyword with predefined length. | entailment |
def array(self, size, type, name, *parameters):
"""Define a new array of given `size` and containing fields of type `type`.
`name` if the name of this array element. The `type` is the name of keyword that is executed as the contents of
the array and optional extra parameters are passed as argum... | Define a new array of given `size` and containing fields of type `type`.
`name` if the name of this array element. The `type` is the name of keyword that is executed as the contents of
the array and optional extra parameters are passed as arguments to this keyword.
Examples:
| Array | ... | entailment |
def container(self, name, length, type, *parameters):
"""Define a container with given length.
This is a convenience method creating a `Struct` with `length` containing fields defined in `type`.
"""
self.new_struct('Container', name, 'length=%s' % length)
BuiltIn().run_keyword(t... | Define a container with given length.
This is a convenience method creating a `Struct` with `length` containing fields defined in `type`. | entailment |
def case(self, size, kw, *parameters):
"""An element inside a bag started with `Start Bag`.
The first argument is size which can be absolute value like `1`, a range
like `0-3`, or just `*` to accept any number of elements.
Examples:
| Start bag | intBag |
| case | 0-1 |... | An element inside a bag started with `Start Bag`.
The first argument is size which can be absolute value like `1`, a range
like `0-3`, or just `*` to accept any number of elements.
Examples:
| Start bag | intBag |
| case | 0-1 | u8 | foo | 42 |
| case | 0-2 | u8 | bar |... | entailment |
def embed_seqdiag_sequence(self):
"""Create a message sequence diagram png file to output folder and embed the image to log file.
You need to have seqdiag installed to create the sequence diagram. See http://blockdiag.com/en/seqdiag/
"""
test_name = BuiltIn().replace_variables('${TEST N... | Create a message sequence diagram png file to output folder and embed the image to log file.
You need to have seqdiag installed to create the sequence diagram. See http://blockdiag.com/en/seqdiag/ | entailment |
def local_error(self, originalValue, calculatedValue):
"""Calculates the error between the two given values.
:param list originalValue: List containing the values of the original data.
:param list calculatedValue: List containing the values of the calculated TimeSeries that
co... | Calculates the error between the two given values.
:param list originalValue: List containing the values of the original data.
:param list calculatedValue: List containing the values of the calculated TimeSeries that
corresponds to originalValue.
:return: Returns the error... | entailment |
def tostring(self, inject):
"""
Convert an element to a single string and allow the passed inject method to place content before any
element.
"""
injected_parts = ''
for part in self.parts:
injected = part.tostring(inject)
tei_tag = next(
... | Convert an element to a single string and allow the passed inject method to place content before any
element. | entailment |
def _create_parser(self):
"""
Create a parser hooking up the command methods below to be run when chosen.
:return: CommandParser parser with commands attached.
"""
parser = CommandParser(get_internal_version_str())
parser.register_list_command(self._setup_run_command(List... | Create a parser hooking up the command methods below to be run when chosen.
:return: CommandParser parser with commands attached. | entailment |
def _check_pypi_version(self):
"""
When the version is out of date or we have trouble retrieving it print a error to stderr and pause.
"""
try:
check_version()
except VersionException as err:
print(str(err), file=sys.stderr)
time.sleep(TWO_SECO... | When the version is out of date or we have trouble retrieving it print a error to stderr and pause. | entailment |
def _run_command(self, command_constructor, args):
"""
Run command_constructor and call run(args) on the resulting object
:param command_constructor: class of an object that implements run(args)
:param args: object arguments for specific command created by CommandParser
"""
... | Run command_constructor and call run(args) on the resulting object
:param command_constructor: class of an object that implements run(args)
:param args: object arguments for specific command created by CommandParser | entailment |
def make_user_list(self, emails, usernames):
"""
Given a list of emails and usernames fetch DukeDS user info.
Parameters that are None will be skipped.
:param emails: [str]: list of emails (can be null)
:param usernames: [str]: list of usernames(netid)
:return: [RemoteUs... | Given a list of emails and usernames fetch DukeDS user info.
Parameters that are None will be skipped.
:param emails: [str]: list of emails (can be null)
:param usernames: [str]: list of usernames(netid)
:return: [RemoteUser]: details about any users referenced the two parameters | entailment |
def run(self, args):
"""
Upload contents of folders to a project with project_name on remote store.
If follow_symlinks we will traverse symlinked directories.
If content is already on remote site it will not be sent.
:param args: Namespace arguments parsed from the command line.
... | Upload contents of folders to a project with project_name on remote store.
If follow_symlinks we will traverse symlinked directories.
If content is already on remote site it will not be sent.
:param args: Namespace arguments parsed from the command line. | entailment |
def run(self, args):
"""
Download a project based on passed in args.
:param args: Namespace arguments parsed from the command line.
"""
project_name_or_id = self.create_project_name_or_id_from_args(args)
folder = args.folder # path to a folder to download d... | Download a project based on passed in args.
:param args: Namespace arguments parsed from the command line. | entailment |
def run(self, args):
"""
Give the user with user_full_name the auth_role permissions on the remote project with project_name.
:param args Namespace arguments parsed from the command line
"""
email = args.email # email of person to give permissions, will be None i... | Give the user with user_full_name the auth_role permissions on the remote project with project_name.
:param args Namespace arguments parsed from the command line | entailment |
def run(self, args):
"""
Remove permissions from the user with user_full_name or email on the remote project with project_name.
:param args Namespace arguments parsed from the command line
"""
email = args.email # email of person to remove permissions from (None if... | Remove permissions from the user with user_full_name or email on the remote project with project_name.
:param args Namespace arguments parsed from the command line | entailment |
def run(self, args):
"""
Gives user permission based on auth_role arg and sends email to that user.
:param args Namespace arguments parsed from the command line
"""
email = args.email # email of person to send email to
username = args.username ... | Gives user permission based on auth_role arg and sends email to that user.
:param args Namespace arguments parsed from the command line | entailment |
def run(self, args):
"""
Begins process that will transfer the project to another user.
Send delivery message to D4S2 service specifying a project and a user.
When user accepts delivery they receive access and we lose admin privileges.
:param args Namespace arguments parsed from ... | Begins process that will transfer the project to another user.
Send delivery message to D4S2 service specifying a project and a user.
When user accepts delivery they receive access and we lose admin privileges.
:param args Namespace arguments parsed from the command line | entailment |
def get_new_project_name(self, project_name):
"""
Return a unique project name for the copy.
:param project_name: str: name of project we will copy
:return: str
"""
timestamp_str = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M')
return "{} {}".format(project... | Return a unique project name for the copy.
:param project_name: str: name of project we will copy
:return: str | entailment |
def run(self, args):
"""
Lists project names.
:param args Namespace arguments parsed from the command line
"""
long_format = args.long_format
# project_name and auth_role args are mutually exclusive
if args.project_name or args.project_id:
project = se... | Lists project names.
:param args Namespace arguments parsed from the command line | entailment |
def print_project_list_details(self, filter_auth_role, long_format):
"""
Prints project names to stdout for all projects or just those with the specified auth_role
:param filter_auth_role: str: optional auth_role to filter project list
"""
if filter_auth_role:
project... | Prints project names to stdout for all projects or just those with the specified auth_role
:param filter_auth_role: str: optional auth_role to filter project list | entailment |
def run(self, args):
"""
Deletes a single project specified by project_name in args.
:param args Namespace arguments parsed from the command line
"""
project = self.fetch_project(args, must_exist=True, include_children=False)
if not args.force:
delete_prompt =... | Deletes a single project specified by project_name in args.
:param args Namespace arguments parsed from the command line | entailment |
def run(self, args):
"""
Prints out non deprecated project-type auth roles.
:param args Namespace arguments parsed from the command line
"""
auth_roles = self.remote_store.get_active_auth_roles(RemoteAuthRole.PROJECT_CONTEXT)
if auth_roles:
for auth_role in au... | Prints out non deprecated project-type auth roles.
:param args Namespace arguments parsed from the command line | entailment |
def get_ca_certs(environ=os.environ):
"""
Retrieve a list of CAs at either the DEFAULT_CERTS_PATH or the env
override, TXAWS_CERTS_PATH.
In order to find .pem files, this function checks first for presence of the
TXAWS_CERTS_PATH environment variable that should point to a directory
containing ... | Retrieve a list of CAs at either the DEFAULT_CERTS_PATH or the env
override, TXAWS_CERTS_PATH.
In order to find .pem files, this function checks first for presence of the
TXAWS_CERTS_PATH environment variable that should point to a directory
containing cert files. In the absense of this variable, the m... | entailment |
def _calculate(self, startingPercentage, endPercentage, startDate, endDate):
"""This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`.
Both parameters will be correct at this time.
:param float startingPercentage: Defines the start of the interval. Th... | This is the error calculation function that gets called by :py:meth:`BaseErrorMeasure.get_error`.
Both parameters will be correct at this time.
:param float startingPercentage: Defines the start of the interval. This has to be a value in [0.0, 100.0].
It represents the value, where the err... | entailment |
def iso8601time(time_tuple):
"""Format time_tuple as a ISO8601 time string.
:param time_tuple: Either None, to use the current time, or a tuple tuple.
"""
if time_tuple:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time_tuple)
else:
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmti... | Format time_tuple as a ISO8601 time string.
:param time_tuple: Either None, to use the current time, or a tuple tuple. | entailment |
def parse(url, defaultPort=True):
"""
Split the given URL into the scheme, host, port, and path.
@type url: C{str}
@param url: An URL to parse.
@type defaultPort: C{bool}
@param defaultPort: Whether to return the default port associated with the
scheme in the given url, when the url do... | Split the given URL into the scheme, host, port, and path.
@type url: C{str}
@param url: An URL to parse.
@type defaultPort: C{bool}
@param defaultPort: Whether to return the default port associated with the
scheme in the given url, when the url doesn't specify one.
@return: A four-tuple ... | entailment |
def tostring(self, inject):
"""Get the entire text content as str"""
return inject(self, '\n'.join(document.tostring(inject) for document in self.documents)) | Get the entire text content as str | entailment |
def retry_when_service_down(func):
"""
Decorator that will retry a function while it fails with status code 503
Assumes the first argument to the fuction will be an object with a set_status_message method.
:param func: function: will be called until it doesn't fail with DataServiceError status 503
:... | Decorator that will retry a function while it fails with status code 503
Assumes the first argument to the fuction will be an object with a set_status_message method.
:param func: function: will be called until it doesn't fail with DataServiceError status 503
:return: value returned by func | entailment |
def retry_until_resource_is_consistent(func, monitor):
"""
Runs func, if func raises DSResourceNotConsistentError will retry func indefinitely.
Notifies monitor if we have to wait(only happens if DukeDS API raises DSResourceNotConsistentError.
:param func: func(): function to run
:param monitor: obj... | Runs func, if func raises DSResourceNotConsistentError will retry func indefinitely.
Notifies monitor if we have to wait(only happens if DukeDS API raises DSResourceNotConsistentError.
:param func: func(): function to run
:param monitor: object: has start_waiting() and done_waiting() methods when waiting fo... | entailment |
def get_auth(self):
"""
Gets an active token refreshing it if necessary.
:return: str valid active authentication token.
"""
if self.legacy_auth():
return self._auth
if not self.auth_expired():
return self._auth
self.claim_new_token()
... | Gets an active token refreshing it if necessary.
:return: str valid active authentication token. | entailment |
def claim_new_token(self):
"""
Update internal state to have a new token using a no authorization data service.
"""
# Intentionally doing this manually so we don't have a chicken and egg problem with DataServiceApi.
headers = {
'Content-Type': ContentType.json,
... | Update internal state to have a new token using a no authorization data service. | entailment |
def auth_expired(self):
"""
Compare the expiration value of our current token including a CLOCK_SKEW.
:return: true if the token has expired
"""
if self._auth and self._expires:
now_with_skew = time.time() + AUTH_TOKEN_CLOCK_SKEW_MAX
return now_with_skew >... | Compare the expiration value of our current token including a CLOCK_SKEW.
:return: true if the token has expired | entailment |
def _url_parts(self, url_suffix, data, content_type):
"""
Format the url data based on config_type.
:param url_suffix: str URL path we are sending a GET/POST/PUT to
:param data: object data we are sending
:param content_type: str from ContentType that determines how we format the... | Format the url data based on config_type.
:param url_suffix: str URL path we are sending a GET/POST/PUT to
:param data: object data we are sending
:param content_type: str from ContentType that determines how we format the data
:return: complete url, formatted data, and headers for sendi... | entailment |
def _post(self, url_suffix, data, content_type=ContentType.json):
"""
Send POST request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a POST to
:param data: object data we are sendin... | Send POST request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a POST to
:param data: object data we are sending
:param content_type: str from ContentType that determines how we format the ... | entailment |
def _put(self, url_suffix, data, content_type=ContentType.json):
"""
Send PUT request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a PUT to
:param data: object data we are sending
... | Send PUT request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a PUT to
:param data: object data we are sending
:param content_type: str from ContentType that determines how we format the da... | entailment |
def _get_single_item(self, url_suffix, data, content_type=ContentType.json):
"""
Send GET request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a GET to
:param url_data: object data ... | Send GET request to API at url_suffix with post_data.
Raises error if x-total-pages is contained in the response.
:param url_suffix: str URL path we are sending a GET to
:param url_data: object data we are sending
:param content_type: str from ContentType that determines how we format th... | entailment |
def _get_single_page(self, url_suffix, data, page_num):
"""
Send GET request to API at url_suffix with post_data adding page and per_page parameters to
retrieve a single page. Page size is determined by config.page_size.
:param url_suffix: str URL path we are sending a GET to
:pa... | Send GET request to API at url_suffix with post_data adding page and per_page parameters to
retrieve a single page. Page size is determined by config.page_size.
:param url_suffix: str URL path we are sending a GET to
:param data: object data we are sending
:param page_num: int: page numb... | entailment |
def _get_collection(self, url_suffix, data):
"""
Performs GET for all pages based on x-total-pages in first response headers.
Merges the json() 'results' arrays.
If x-total-pages is missing or 1 just returns the response without fetching multiple pages.
:param url_suffix: str URL... | Performs GET for all pages based on x-total-pages in first response headers.
Merges the json() 'results' arrays.
If x-total-pages is missing or 1 just returns the response without fetching multiple pages.
:param url_suffix: str URL path we are sending a GET to
:param data: object data we... | entailment |
def _check_err(resp, url_suffix, data, allow_pagination):
"""
Raise DataServiceError if the response wasn't successful.
:param resp: requests.Response back from the request
:param url_suffix: str url to include in an error message
:param data: data payload we sent
:param ... | Raise DataServiceError if the response wasn't successful.
:param resp: requests.Response back from the request
:param url_suffix: str url to include in an error message
:param data: data payload we sent
:param allow_pagination: when False and response headers contains 'x-total-pages' rai... | entailment |
def create_project(self, project_name, desc):
"""
Send POST to /projects creating a new project with the specified name and desc.
Raises DataServiceError on error.
:param project_name: str name of the project
:param desc: str description of the project
:return: requests.R... | Send POST to /projects creating a new project with the specified name and desc.
Raises DataServiceError on error.
:param project_name: str name of the project
:param desc: str description of the project
:return: requests.Response containing the successful result | entailment |
def create_folder(self, folder_name, parent_kind_str, parent_uuid):
"""
Send POST to /folders to create a new folder with specified name and parent.
:param folder_name: str name of the new folder
:param parent_kind_str: str type of parent folder has(dds-folder,dds-project)
:param... | Send POST to /folders to create a new folder with specified name and parent.
:param folder_name: str name of the new folder
:param parent_kind_str: str type of parent folder has(dds-folder,dds-project)
:param parent_uuid: str uuid of the parent object
:return: requests.Response containin... | entailment |
def get_project_children(self, project_id, name_contains, exclude_response_fields=None):
"""
Send GET to /projects/{project_id}/children filtering by a name.
:param project_id: str uuid of the project
:param name_contains: str name to filter folders by (if not None this method works recu... | Send GET to /projects/{project_id}/children filtering by a name.
:param project_id: str uuid of the project
:param name_contains: str name to filter folders by (if not None this method works recursively)
:param exclude_response_fields: [str]: list of fields to exclude in the response items
... | entailment |
def _get_children(self, parent_name, parent_id, name_contains, exclude_response_fields=None):
"""
Send GET message to /<parent_name>/<parent_id>/children to fetch info about children(files and folders)
:param parent_name: str 'projects' or 'folders'
:param parent_id: str uuid of project ... | Send GET message to /<parent_name>/<parent_id>/children to fetch info about children(files and folders)
:param parent_name: str 'projects' or 'folders'
:param parent_id: str uuid of project or folder
:param name_contains: name filtering (if not None this method works recursively)
:param ... | entailment |
def create_upload(self, project_id, filename, content_type, size,
hash_value, hash_alg, storage_provider_id=None, chunked=True):
"""
Post to /projects/{project_id}/uploads to create a uuid for uploading chunks.
NOTE: The optional hash_value and hash_alg parameters are being... | Post to /projects/{project_id}/uploads to create a uuid for uploading chunks.
NOTE: The optional hash_value and hash_alg parameters are being removed from the DukeDS API.
:param project_id: str uuid of the project we are uploading data for.
:param filename: str name of the file we want to upload... | entailment |
def create_upload_url(self, upload_id, number, size, hash_value, hash_alg):
"""
Given an upload created by create_upload retrieve a url where we can upload a chunk.
:param upload_id: uuid of the upload
:param number: int incrementing number of the upload (1-based index)
:param si... | Given an upload created by create_upload retrieve a url where we can upload a chunk.
:param upload_id: uuid of the upload
:param number: int incrementing number of the upload (1-based index)
:param size: int size of the chunk in bytes
:param hash_value: str hash value of chunk
:p... | entailment |
def complete_upload(self, upload_id, hash_value, hash_alg):
"""
Mark the upload we created in create_upload complete.
:param upload_id: str uuid of the upload to complete.
:param hash_value: str hash value of chunk
:param hash_alg: str algorithm used to create hash
:retur... | Mark the upload we created in create_upload complete.
:param upload_id: str uuid of the upload to complete.
:param hash_value: str hash value of chunk
:param hash_alg: str algorithm used to create hash
:return: requests.Response containing the successful result | entailment |
def create_file(self, parent_kind, parent_id, upload_id):
"""
Create a new file after completing an upload.
:param parent_kind: str kind of parent(dds-folder,dds-project)
:param parent_id: str uuid of parent
:param upload_id: str uuid of complete upload
:return: requests.... | Create a new file after completing an upload.
:param parent_kind: str kind of parent(dds-folder,dds-project)
:param parent_id: str uuid of parent
:param upload_id: str uuid of complete upload
:return: requests.Response containing the successful result | entailment |
def update_file(self, file_id, upload_id):
"""
Send PUT request to /files/{file_id} to update the file contents to upload_id and sets a label.
:param file_id: str uuid of file
:param upload_id: str uuid of the upload where all the file chunks where uploaded
:param label: str shor... | Send PUT request to /files/{file_id} to update the file contents to upload_id and sets a label.
:param file_id: str uuid of file
:param upload_id: str uuid of the upload where all the file chunks where uploaded
:param label: str short display label for the file
:return: requests.Response... | entailment |
def send_external(self, http_verb, host, url, http_headers, chunk):
"""
Used with create_upload_url to send a chunk the the possibly external object store.
:param http_verb: str PUT or POST
:param host: str host we are sending the chunk to
:param url: str url to use when sending
... | Used with create_upload_url to send a chunk the the possibly external object store.
:param http_verb: str PUT or POST
:param host: str host we are sending the chunk to
:param url: str url to use when sending
:param http_headers: object headers to send with the request
:param chun... | entailment |
def receive_external(self, http_verb, host, url, http_headers):
"""
Retrieve a streaming request for a file.
:param http_verb: str GET is only supported right now
:param host: str host we are requesting the file from
:param url: str url to ask the host for
:param http_hea... | Retrieve a streaming request for a file.
:param http_verb: str GET is only supported right now
:param host: str host we are requesting the file from
:param url: str url to ask the host for
:param http_headers: object headers to send with the request
:return: requests.Response con... | entailment |
def get_users(self, full_name=None, email=None, username=None):
"""
Send GET request to /users for users with optional full_name, email, and/or username filtering.
:param full_name: str name of the user we are searching for
:param email: str: optional email to filter by
:param us... | Send GET request to /users for users with optional full_name, email, and/or username filtering.
:param full_name: str name of the user we are searching for
:param email: str: optional email to filter by
:param username: str: optional username to filter by
:return: requests.Response conta... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.