Search is not available for this dataset
text stringlengths 75 104k |
|---|
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
self.__mac_size_in = ... |
def set_keepalive(self, interval, callback):
"""
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.
"""
self.__keepalive_interval = interval
... |
def start_handshake(self, timeout):
"""
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
"""
if not self.__time... |
def handshake_timed_out(self):
"""
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`
... |
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 |
def close(self):
"""
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``... |
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 |
def generate_key_bytes(hash_alg, salt, key, nbytes):
"""
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 cre... |
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)
f = open(filename, "a")
handler = logging.StreamHandler(f)
frm =... |
def send(self, content):
"""
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
"""
try:
self.process.stdin.write(content)
except IOError as e:
... |
def recv(self, size):
"""
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
"""
try:
buffer = b""
start = time.time()
... |
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
FROM_SYSTEM = 0x1000
# Let FormatMessageW allocate the buffer (we'll free it below)
# ... |
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_size)
)
data = ctypes.create_string_buffer... |
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) |
def generate(bits=1024, progress_func=None):
"""
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 `.... |
def load_system_host_keys(self, filename=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 s... |
def load_host_keys(self, filename):
"""
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 `.A... |
def set_missing_host_key_policy(self, policy):
"""
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
... |
def _families_and_addresses(self, hostname, port):
"""
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 connect(
self,
hostname,
port=SSH_PORT,
username=None,
password=None,
pkey=None,
key_filename=None,
timeout=None,
allow_agent=True,
look_for_keys=True,
compress=False,
sock=None,
gss_auth=False,
gss_kex=F... |
def close(self):
"""
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 obj... |
def exec_command(
self,
command,
bufsize=-1,
timeout=None,
get_pty=False,
environment=None,
):
"""
Execute a command on the SSH server. A new `.Channel` is opened and
the requested command is executed. The command's input and output
s... |
def invoke_shell(
self,
term="vt100",
width=80,
height=24,
width_pixels=0,
height_pixels=0,
environment=None,
):
"""
Start an interactive shell session on the SSH server. A new `.Channel`
is opened and connected to a pseudo-terminal us... |
def _key_from_filepath(self, filename, klass, password):
"""
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
... |
def _auth(
self,
username,
password,
pkey,
key_filenames,
allow_agent,
look_for_keys,
gss_auth,
gss_kex,
gss_deleg_creds,
gss_host,
passphrase,
):
"""
Try, in order:
- The key(s) passed in, i... |
def language(self, language):
"""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
"""
if language is None:
raise ValueError... |
def kernel_type(self, kernel_type):
"""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
"""
if ker... |
def competition_download_leaderboard(self, id, **kwargs): # noqa: E501
"""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_leade... |
def competition_view_leaderboard(self, id, **kwargs): # noqa: E501
"""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, a... |
def competitions_data_download_file(self, id, file_name, **kwargs): # noqa: E501
"""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_... |
def competitions_data_list_files(self, id, **kwargs): # noqa: E501
"""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, as... |
def competitions_list(self, **kwargs): # noqa: E501
"""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 = threa... |
def competitions_submissions_list(self, id, **kwargs): # noqa: E501
"""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,... |
def competitions_submissions_submit(self, blob_file_tokens, submission_description, id, **kwargs): # noqa: E501
"""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 = ... |
def competitions_submissions_upload(self, file, guid, content_length, last_modified_date_utc, **kwargs): # noqa: E501
"""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
... |
def competitions_submissions_url(self, id, content_length, last_modified_date_utc, **kwargs): # noqa: E501
"""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
>>> ... |
def datasets_create_new(self, dataset_new_request, **kwargs): # noqa: E501
"""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_re... |
def datasets_create_version(self, owner_slug, dataset_slug, dataset_new_version_request, **kwargs): # noqa: E501
"""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
>>> t... |
def datasets_create_version_by_id(self, id, dataset_new_version_request, **kwargs): # noqa: E501
"""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 = ap... |
def datasets_download(self, owner_slug, dataset_slug, **kwargs): # noqa: E501
"""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, ... |
def datasets_download_file(self, owner_slug, dataset_slug, file_name, **kwargs): # noqa: E501
"""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_downl... |
def datasets_list(self, **kwargs): # noqa: E501
"""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()
... |
def datasets_list_files(self, owner_slug, dataset_slug, **kwargs): # noqa: E501
"""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,... |
def datasets_status(self, owner_slug, dataset_slug, **kwargs): # noqa: E501
"""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... |
def datasets_upload_file(self, file_name, content_length, last_modified_date_utc, **kwargs): # noqa: E501
"""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
... |
def datasets_view(self, owner_slug, dataset_slug, **kwargs): # noqa: E501
"""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, d... |
def kernel_output(self, user_name, kernel_slug, **kwargs): # noqa: E501
"""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(use... |
def kernel_pull(self, user_name, kernel_slug, **kwargs): # noqa: E501
"""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, ke... |
def kernel_push(self, kernel_push_request, **kwargs): # noqa: E501
"""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=Tr... |
def kernel_status(self, user_name, kernel_slug, **kwargs): # noqa: E501
"""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(... |
def kernels_list(self, **kwargs): # noqa: E501
"""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()
... |
def authenticate(self):
"""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.
"""
config_data ... |
def read_config_environment(self, config_data=None, quiet=False):
"""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 uniqu... |
def _load_config(self, config_data):
"""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
... |
def read_config_file(self, config_data=None, quiet=False):
"""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
==========
... |
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:
config_data = {}
return config_data |
def _write_config_file(self, config_data, indent=2):
"""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 j... |
def set_config_value(self, name, value, quiet=False):
"""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 ... |
def unset_config_value(self, name, quiet=False):
"""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)
"""
config_data = self._rea... |
def get_default_download_dir(self, *subdirs):
""" 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
"""
# Look up value for key "path" i... |
def print_config_value(self, name, prefix='- ', separator=': '):
"""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
separ... |
def print_config_values(self, prefix='- '):
"""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 "- "
"""
print('Configuratio... |
def competitions_list(self,
group=None,
category=None,
sort_by=None,
page=1,
search=None):
""" make call to list competitions, format the response, and return
a list of C... |
def competitions_list_cli(self,
group=None,
category=None,
sort_by=None,
page=1,
search=None,
csv_display=False):
""" a wrapper for ... |
def competition_submit(self, file_name, message, competition, quiet=False):
""" submit a competition!
Parameters
==========
file_name: the competition metadata file
message: the submission description
competition: the competition name
quie... |
def competition_submit_cli(self,
file_name,
message,
competition,
competition_opt=None,
quiet=False):
""" submit a competition using the client. Arguments ar... |
def competition_submissions(self, competition):
""" get the list of Submission for a particular competition
Parameters
==========
competition: the name of the competition
"""
submissions_result = self.process_response(
self.competitions_submission... |
def competition_submissions_cli(self,
competition=None,
competition_opt=None,
csv_display=False,
quiet=False):
""" wrapper to competition_submission, will return either... |
def competition_list_files(self, competition):
""" list files for competition
Parameters
==========
competition: the name of the competition
"""
competition_list_files_result = self.process_response(
self.competitions_data_list_files_with_http_inf... |
def competition_list_files_cli(self,
competition,
competition_opt=None,
csv_display=False,
quiet=False):
""" List files for a competition, if it exists
Paramet... |
def competition_download_file(self,
competition,
file_name,
path=None,
force=False,
quiet=False):
""" download a competition file to a designa... |
def competition_download_files(self,
competition,
path=None,
force=False,
quiet=True):
""" a wrapper to competition_download_file to download all competition
fi... |
def competition_download_cli(self,
competition,
competition_opt=None,
file_name=None,
path=None,
force=False,
quiet=False)... |
def competition_leaderboard_download(self, competition, path, quiet=True):
""" Download competition leaderboards
Parameters
=========
competition: the name of the competition
path: a path to download the file to
quiet: suppress verbose output (default... |
def competition_leaderboard_view(self, competition):
""" view a leaderboard based on a competition name
Parameters
==========
competition: the competition name to view leadboard for
"""
result = self.process_response(
self.competition_view_leaderb... |
def competition_leaderboard_cli(self,
competition,
competition_opt=None,
path=None,
view=False,
download=False,
... |
def dataset_list(self,
sort_by=None,
size=None,
file_type=None,
license_name=None,
tag_ids=None,
search=None,
user=None,
mine=False,
... |
def dataset_list_cli(self,
sort_by=None,
size=None,
file_type=None,
license_name=None,
tag_ids=None,
search=None,
user=None,
... |
def dataset_view(self, dataset):
""" view metadata for a dataset.
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
"""
if '/' in dataset:
self.validate_dataset_stri... |
def dataset_list_files(self, dataset):
""" list files for a dataset
Parameters
==========
dataset: the string identified of the dataset
should be in format [owner]/[dataset-name]
"""
if dataset is None:
raise ValueError('A dat... |
def dataset_list_files_cli(self,
dataset,
dataset_opt=None,
csv_display=False):
""" a wrapper to dataset_list_files for the client
(list files for a dataset)
Parameters
==========
... |
def dataset_status(self, dataset):
""" 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]
"""
if dataset is None:
rai... |
def dataset_status_cli(self, dataset, dataset_opt=None):
""" 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
"""
dataset = ... |
def dataset_download_file(self,
dataset,
file_name,
path=None,
force=False,
quiet=True):
""" download a single file for a dataset
Parameters
... |
def dataset_download_files(self,
dataset,
path=None,
force=False,
quiet=True,
unzip=False):
""" download all files for a dataset
Parameters
... |
def dataset_download_cli(self,
dataset,
dataset_opt=None,
file_name=None,
path=None,
unzip=False,
force=False,
quiet=... |
def dataset_upload_file(self, path, quiet):
""" upload a dataset file
Parameters
==========
path: the complete path to upload
quiet: suppress verbose output (default is False)
"""
file_name = os.path.basename(path)
content_length = os.path... |
def dataset_create_version(self,
folder,
version_notes,
quiet=False,
convert_to_csv=True,
delete_old_versions=False,
dir_mode='skip'):... |
def dataset_create_version_cli(self,
folder,
version_notes,
quiet=False,
convert_to_csv=True,
delete_old_versions=False,
... |
def dataset_initialize(self, folder):
""" initialize a folder with a a dataset configuration (metadata) file
Parameters
==========
folder: the folder to initialize the metadata file in
"""
if not os.path.isdir(folder):
raise ValueError('Invalid fo... |
def dataset_create_new(self,
folder,
public=False,
quiet=False,
convert_to_csv=True,
dir_mode='skip'):
""" create a new dataset, meaning the same as creating a version but
... |
def dataset_create_new_cli(self,
folder=None,
public=False,
quiet=False,
convert_to_csv=True,
dir_mode='skip'):
""" client wrapper for creating a new dataset... |
def download_file(self, response, outfile, quiet=True, chunk_size=1048576):
""" 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 ve... |
def kernels_list(self,
page=1,
page_size=20,
dataset=None,
competition=None,
parent_kernel=None,
search=None,
mine=False,
user=None,
... |
def kernels_list_cli(self,
mine=False,
page=1,
page_size=20,
search=None,
csv_display=False,
parent=None,
competition=None,
... |
def kernels_initialize(self, folder):
""" 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
"""
if not os.path.isdir(fold... |
def kernels_initialize_cli(self, folder=None):
""" 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 (No... |
def kernels_push(self, folder):
""" 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
"""
if not os.path.isdir(folder)... |
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 previous output')
elif not result.error:
... |
def kernels_pull(self, kernel, path, metadata=False, quiet=True):
""" 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 file... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.