text stringlengths 81 112k |
|---|
Switch inbound data cipher.
def set_inbound_cipher(
self, block_engine, block_size, mac_engine, mac_size, mac_key
):
"""
Switch inbound data cipher.
"""
self.__block_engine_in = block_engine
self.__block_size_in = block_size
self.__mac_engine_in = mac_engine
... |
Turn on/off the callback keepalive. If ``interval`` seconds pass with
no data read from or written to the socket, the callback will be
executed and the timer will be reset.
def set_keepalive(self, interval, callback):
"""
Turn on/off the callback keepalive. If ``interval`` seconds pas... |
Tells `Packetizer` that the handshake process started.
Starts a book keeping timer that can signal a timeout in the
handshake process.
:param float timeout: amount of seconds to wait before timing out
def start_handshake(self, timeout):
"""
Tells `Packetizer` that the handshake... |
Checks if the handshake has timed out.
If `start_handshake` wasn't called before the call to this function,
the return value will always be `False`. If the handshake completed
before a timeout was reached, the return value will be `False`
:return: handshake time out status, as a `bool`... |
Tells `Packetizer` that the handshake has completed.
def complete_handshake(self):
"""
Tells `Packetizer` that the handshake has completed.
"""
if self.__timer:
self.__timer.cancel()
self.__timer_expired = False
self.__handshake_complete = True |
When a client closes a file, this method is called on the handle.
Normally you would use this method to close the underlying OS level
file object(s).
The default implementation checks for attributes on ``self`` named
``readfile`` and/or ``writefile``, and if either or both are present,
... |
Used by the SFTP server code to retrieve a cached directory
listing.
def _get_next_files(self):
"""
Used by the SFTP server code to retrieve a cached directory
listing.
"""
fnlist = self.__files[:16]
self.__files = self.__files[16:]
return fnlist |
Given a password, passphrase, or other human-source key, scramble it
through a secure hash into some keyworthy bytes. This specific algorithm
is used for encrypting/decrypting private key files.
:param function hash_alg: A function which creates a new hash object, such
as ``hashlib.sha256``.
:... |
send paramiko logs to a logfile,
if they're not already going somewhere
def log_to_file(filename, level=DEBUG):
"""send paramiko logs to a logfile,
if they're not already going somewhere"""
logger = logging.getLogger("paramiko")
if len(logger.handlers) > 0:
return
logger.setLevel(level)... |
Write the content received from the SSH client to the standard
input of the forked command.
:param str content: string to be sent to the forked command
def send(self, content):
"""
Write the content received from the SSH client to the standard
input of the forked command.
... |
Read from the standard output of the forked program.
:param int size: how many chars should be read
:return: the string of bytes read, which may be shorter than requested
def recv(self, size):
"""
Read from the standard output of the forked program.
:param int size: how many ... |
Call FormatMessage with a system error number to retrieve
the descriptive error message.
def format_system_message(errno):
"""
Call FormatMessage with a system error number to retrieve
the descriptive error message.
"""
# first some flags used by FormatMessageW
ALLOCATE_BUFFER = 0x100
F... |
Given a token, get the token information for it.
def GetTokenInformation(token, information_class):
"""
Given a token, get the token information for it.
"""
data_size = ctypes.wintypes.DWORD()
ctypes.windll.advapi32.GetTokenInformation(
token, information_class.num, 0, 0, ctypes.byref(data_... |
Return a TOKEN_USER for the owner of this process.
def get_current_user():
"""
Return a TOKEN_USER for the owner of this process.
"""
process = OpenProcessToken(
ctypes.windll.kernel32.GetCurrentProcess(), TokenAccess.TOKEN_QUERY
)
return GetTokenInformation(process, TOKEN_USER) |
Generate a new private DSS key. This factory function can be used to
generate a new host key or authentication key.
:param int bits: number of bits the generated key should be.
:param progress_func: Unused
:return: new `.DSSKey` private key
def generate(bits=1024, progress_func=None):... |
Load host keys from a system (read-only) file. Host keys read with
this method will not be saved back by `save_host_keys`.
This method can be called multiple times. Each new set of host keys
will be merged with the existing set (new replacing old if there are
conflicts).
If `... |
Load host keys from a local host-key file. Host keys read with this
method will be checked after keys loaded via `load_system_host_keys`,
but will be saved back by `save_host_keys` (so they can be modified).
The missing host key policy `.AutoAddPolicy` adds keys to this set and
saves th... |
Set policy to use when connecting to servers without a known host key.
Specifically:
* A **policy** is a "policy class" (or instance thereof), namely some
subclass of `.MissingHostKeyPolicy` such as `.RejectPolicy` (the
default), `.AutoAddPolicy`, `.WarningPolicy`, or a user-create... |
Yield pairs of address families and addresses to try for connecting.
:param str hostname: the server to connect to
:param int port: the server port to connect to
:returns: Yields an iterable of ``(family, address)`` tuples
def _families_and_addresses(self, hostname, port):
"""
... |
Connect to an SSH server and authenticate to it. The server's host key
is checked against the system host keys (see `load_system_host_keys`)
and any local host keys (`load_host_keys`). If the server's hostname
is not found in either set of host keys, the missing host key policy
is used... |
Close this SSHClient and its underlying `.Transport`.
.. warning::
Failure to do this may, in some situations, cause your Python
interpreter to hang at shutdown (often due to race conditions).
It's good practice to `close` your client objects anytime you're
done ... |
Execute a command on the SSH server. A new `.Channel` is opened and
the requested command is executed. The command's input and output
streams are returned as Python ``file``-like objects representing
stdin, stdout, and stderr.
:param str command: the command to execute
:param ... |
Start an interactive shell session on the SSH server. A new `.Channel`
is opened and connected to a pseudo-terminal using the requested
terminal type and size.
:param str term:
the terminal type to emulate (for example, ``"vt100"``)
:param int width: the width (in character... |
Attempt to derive a `.PKey` from given string path ``filename``:
- If ``filename`` appears to be a cert, the matching private key is
loaded.
- Otherwise, the filename is assumed to be a private key, and the
matching public cert will be loaded if it exists.
def _key_from_filepath(se... |
Try, in order:
- The key(s) passed in, if one was passed in.
- Any key we can find through an SSH agent (if allowed).
- Any "id_rsa", "id_dsa" or "id_ecdsa" key discoverable in ~/.ssh/
(if allowed).
- Plain username/password auth, if a password was given.
... |
Sets the language of this KernelPushRequest.
The language that the kernel is written in # noqa: E501
:param language: The language of this KernelPushRequest. # noqa: E501
:type: str
def language(self, language):
"""Sets the language of this KernelPushRequest.
The language t... |
Sets the kernel_type of this KernelPushRequest.
The type of kernel. Cannot be changed once the kernel has been created # noqa: E501
:param kernel_type: The kernel_type of this KernelPushRequest. # noqa: E501
:type: str
def kernel_type(self, kernel_type):
"""Sets the kernel_type of t... |
Download competition leaderboard # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competition_download_leaderboard(id, async_req=True)
>>> result = thread.get()
:param async_... |
VIew competition leaderboard # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competition_view_leaderboard(id, async_req=True)
>>> result = thread.get()
:param async_req bool... |
Download competition data file # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_data_download_file(id, file_name, async_req=True)
>>> result = thread.get()
:para... |
List competition data files # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_data_list_files(id, async_req=True)
>>> result = thread.get()
:param async_req bool
... |
List competitions # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_list(async_req=True)
>>> result = thread.get()
:param async_req bool
:param str group:... |
List competition submissions # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_submissions_list(id, async_req=True)
>>> result = thread.get()
:param async_req boo... |
Submit to competition # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_submissions_submit(blob_file_tokens, submission_description, id, async_req=True)
>>> result = threa... |
Upload competition submission file # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_submissions_upload(file, guid, content_length, last_modified_date_utc, async_req=True)
... |
Generate competition submission URL # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.competitions_submissions_url(id, content_length, last_modified_date_utc, async_req=True)
>>> resul... |
Create a new dataset # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_create_new(dataset_new_request, async_req=True)
>>> result = thread.get()
:param async_req bool... |
Create a new dataset version # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_create_version(owner_slug, dataset_slug, dataset_new_version_request, async_req=True)
>>> result... |
Create a new dataset version by id # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_create_version_by_id(id, dataset_new_version_request, async_req=True)
>>> result = thread.... |
Download dataset file # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_download(owner_slug, dataset_slug, async_req=True)
>>> result = thread.get()
:param async_req ... |
Download dataset file # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_download_file(owner_slug, dataset_slug, file_name, async_req=True)
>>> result = thread.get()
:... |
List datasets # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_list(async_req=True)
>>> result = thread.get()
:param async_req bool
:param str group: Display... |
List dataset files # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_list_files(owner_slug, dataset_slug, async_req=True)
>>> result = thread.get()
:param async_req b... |
Get dataset creation status # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_status(owner_slug, dataset_slug, async_req=True)
>>> result = thread.get()
:param async_... |
Get URL and token to start uploading a data file # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_upload_file(file_name, content_length, last_modified_date_utc, async_req=True)
... |
Show details about a dataset # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.datasets_view(owner_slug, dataset_slug, async_req=True)
>>> result = thread.get()
:param async_r... |
Download the latest output from a kernel # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_output(user_name, kernel_slug, async_req=True)
>>> result = thread.get()
:par... |
Pull the latest code from a kernel # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_pull(user_name, kernel_slug, async_req=True)
>>> result = thread.get()
:param async... |
Push a new kernel version. Can be used to create a new kernel and update an existing one. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_push(kernel_push_request, async_req=True)
... |
Get the status of the latest kernel version # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernel_status(user_name, kernel_slug, async_req=True)
>>> result = thread.get()
:... |
List kernels # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.kernels_list(async_req=True)
>>> result = thread.get()
:param async_req bool
:param int page: Page numbe... |
authenticate the user with the Kaggle API. This method will generate
a configuration, first checking the environment for credential
variables, and falling back to looking for the .kaggle/kaggle.json
configuration file.
def authenticate(self):
"""authenticate the user with the K... |
read_config_environment is the second effort to get a username
and key to authenticate to the Kaggle API. The environment keys
are equivalent to the kaggle.json file, but with "KAGGLE_" prefix
to define a unique namespace.
Parameters
==========
config_d... |
the final step of the authenticate steps, where we load the values
from config_data into the Configuration object.
Parameters
==========
config_data: a dictionary with configuration values (keys) to read
into self.config_values
def _load_config(self,... |
read_config_file is the first effort to get a username
and key to authenticate to the Kaggle API. Since we can get the
username and password from the environment, it's not required.
Parameters
==========
config_data: the Configuration object to save a username and... |
read in the configuration file, a json file defined at self.config
def _read_config_file(self):
"""read in the configuration file, a json file defined at self.config"""
try:
with open(self.config, 'r') as f:
config_data = json.load(f)
except FileNotFoundError:
... |
write config data to file.
Parameters
==========
config_data: the Configuration object to save a username and
password, if defined
indent: number of tab indentations to use when writing json
def _write_config_file(self, config_data, indent=2):
... |
a client helper function to set a configuration value, meaning
reading in the configuration file (if it exists), saving a new
config value, and then writing back
Parameters
==========
name: the name of the value to set (key in dictionary)
value: the val... |
unset a configuration value
Parameters
==========
name: the name of the value to unset (remove key in dictionary)
quiet: disable verbose output if True (default is False)
def unset_config_value(self, name, quiet=False):
"""unset a configuration value
Par... |
Get the download path for a file. If not defined, return default
from config.
Parameters
==========
subdirs: a single (or list of) subfolders under the basepath
def get_default_download_dir(self, *subdirs):
""" Get the download path for a file. If not defined, r... |
print a single configuration value, based on a prefix and separator
Parameters
==========
name: the key of the config valur in self.config_values to print
prefix: the prefix to print
separator: the separator to use (default is : )
def print_config_value(self, nam... |
a wrapper to print_config_value to print all configuration values
Parameters
==========
prefix: the character prefix to put before the printed config value
defaults to "- "
def print_config_values(self, prefix='- '):
"""a wrapper to print_config_value to pri... |
make call to list competitions, format the response, and return
a list of Competition instances
Parameters
==========
page: the page to return (default is 1)
search: a search term to use (default is empty string)
sort_by: how to sort the result, ... |
a wrapper for competitions_list for the client.
Parameters
==========
group: group to filter result to
category: category to filter result to
sort_by: how to sort the result, see valid_sort_by for options
page: the page to return (default is 1)
... |
submit a competition!
Parameters
==========
file_name: the competition metadata file
message: the submission description
competition: the competition name
quiet: suppress verbose output (default is False)
def competition_submit(self, file_name, m... |
submit a competition using the client. Arguments are same as for
competition_submit, except for extra arguments provided here.
Parameters
==========
competition_opt: an alternative competition option provided by cli
def competition_submit_cli(self,
... |
get the list of Submission for a particular competition
Parameters
==========
competition: the name of the competition
def competition_submissions(self, competition):
""" get the list of Submission for a particular competition
Parameters
==========
... |
wrapper to competition_submission, will return either json or csv
to the user. Additional parameters are listed below, see
competition_submissions for rest.
Parameters
==========
competition: the name of the competition. If None, look to config
co... |
list files for competition
Parameters
==========
competition: the name of the competition
def competition_list_files(self, competition):
""" list files for competition
Parameters
==========
competition: the name of the competition
... |
List files for a competition, if it exists
Parameters
==========
competition: the name of the competition. If None, look to config
competition_opt: an alternative competition option provided by cli
csv_display: if True, print comma separated values
... |
download a competition file to a designated location, or use
a default location
Paramters
=========
competition: the name of the competition
file_name: the configuration file name
path: a path to download the file to
force: force the d... |
a wrapper to competition_download_file to download all competition
files.
Parameters
=========
competition: the name of the competition
path: a path to download the file to
force: force the download if the file already exists (default False)
... |
a wrapper to competition_download_files, but first will parse input
from API client. Additional parameters are listed here, see
competition_download for remaining.
Parameters
=========
competition: the name of the competition
competition_opt: an a... |
Download competition leaderboards
Parameters
=========
competition: the name of the competition
path: a path to download the file to
quiet: suppress verbose output (default is True)
def competition_leaderboard_download(self, competition, path, quiet=True):
... |
view a leaderboard based on a competition name
Parameters
==========
competition: the competition name to view leadboard for
def competition_leaderboard_view(self, competition):
""" view a leaderboard based on a competition name
Parameters
=========... |
a wrapper for competition_leaderbord_view that will print the
results as a table or comma separated values
Parameters
==========
competition: the competition name to view leadboard for
competition_opt: an alternative competition option provided by cli
... |
return a list of datasets!
Parameters
==========
sort_by: how to sort the result, see valid_sort_bys for options
size: the size of the dataset, see valid_sizes for string options
file_type: the format, see valid_file_types for string options
licen... |
a wrapper to datasets_list for the client. Additional parameters
are described here, see dataset_list for others.
Parameters
==========
sort_by: how to sort the result, see valid_sort_bys for options
size: the size of the dataset, see valid_sizes for string o... |
view metadata for a dataset.
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
def dataset_view(self, dataset):
""" view metadata for a dataset.
Parameters
==========
... |
list files for a dataset
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
def dataset_list_files(self, dataset):
""" list files for a dataset
Parameters
==========
... |
a wrapper to dataset_list_files for the client
(list files for a dataset)
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
dataset_opt: an alternative option to providing a dat... |
call to get the status of a dataset from the API
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
def dataset_status(self, dataset):
""" call to get the status of a dataset from the API
... |
wrapper for client for dataset_status, with additional
dataset_opt to get the status of a dataset from the API
Parameters
==========
dataset_opt: an alternative to dataset
def dataset_status_cli(self, dataset, dataset_opt=None):
""" wrapper for client for datase... |
download a single file for a dataset
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
file_name: the dataset configuration file
path: if defined, download to this location
... |
download all files for a dataset
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
path: the path to download the dataset to
force: force the download if the file already exists... |
client wrapper for dataset_download_files and download dataset file,
either for a specific file (when file_name is provided),
or all files for a dataset (plural)
Parameters
==========
dataset: the string identified of the dataset
should b... |
upload a dataset file
Parameters
==========
path: the complete path to upload
quiet: suppress verbose output (default is False)
def dataset_upload_file(self, path, quiet):
""" upload a dataset file
Parameters
==========
path:... |
create a version of a dataset
Parameters
==========
folder: the folder with the dataset configuration / data files
version_notes: notes to add for the version
quiet: suppress verbose output (default is False)
convert_to_csv: on upload, if data sho... |
client wrapper for creating a version of a dataset
Parameters
==========
folder: the folder with the dataset configuration / data files
version_notes: notes to add for the version
quiet: suppress verbose output (default is False)
convert_to_csv: o... |
initialize a folder with a a dataset configuration (metadata) file
Parameters
==========
folder: the folder to initialize the metadata file in
def dataset_initialize(self, folder):
""" initialize a folder with a a dataset configuration (metadata) file
Parameter... |
create a new dataset, meaning the same as creating a version but
with extra metadata like license and user/owner.
Parameters
==========
folder: the folder to initialize the metadata file in
public: should the dataset be public?
quiet: suppress ver... |
client wrapper for creating a new dataset
Parameters
==========
folder: the folder to initialize the metadata file in
public: should the dataset be public?
quiet: suppress verbose output (default is False)
convert_to_csv: if True, convert data to ... |
download a file to an output file based on a chunk size
Parameters
==========
response: the response to download
outfile: the output file to download to
quiet: suppress verbose output (default is True)
chunk_size: the size of the chunk to stream
... |
list kernels based on a set of search criteria
Parameters
==========
page: the page of results to return (default is 1)
page_size: results per page (default is 20)
dataset: if defined, filter to this dataset (default None)
competition: if defined,... |
client wrapper for kernels_list, see this function for arguments.
Additional arguments are provided here.
Parameters
==========
csv_display: if True, print comma separated values instead of table
def kernels_list_cli(self,
mine=False,
... |
create a new kernel in a specified folder from template, including
json metadata that grabs values from the configuration.
Parameters
==========
folder: the path of the folder
def kernels_initialize(self, folder):
""" create a new kernel in a specified folder fr... |
client wrapper for kernels_initialize, takes same arguments but
sets default folder to be None. If None, defaults to present
working directory.
Parameters
==========
folder: the path of the folder (None defaults to ${PWD})
def kernels_initialize_cli(self, fo... |
read the metadata file and kernel files from a notebook, validate
both, and use Kernel API to push to Kaggle if all is valid.
Parameters
==========
folder: the path of the folder
def kernels_push(self, folder):
""" read the metadata file and kernel files from a ... |
client wrapper for kernels_push, with same arguments.
def kernels_push_cli(self, folder):
""" client wrapper for kernels_push, with same arguments.
"""
folder = folder or os.getcwd()
result = self.kernels_push(folder)
if result is None:
print('Kernel push error: see... |
pull a kernel, including a metadata file (if metadata is True)
and associated files to a specified path.
Parameters
==========
kernel: the kernel to pull
path: the path to pull files to on the filesystem
metadata: if True, also pull metadata
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.