Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def auth_interactive_dumb(self, username, handler=None, submethods=""): if not handler: def handler(title, instructions, prompt_list): answers = [] if title: print(title.strip()) ...
[ "\n Autenticate to the server interactively but dumber.\n Just print the prompt and / or instructions to stdout and send back\n the response. This is good for situations where partial auth is\n achieved by key and then the user has to enter a 2fac token.\n " ]
Please provide a description of the function:def auth_gssapi_with_mic(self, username, gss_host, gss_deleg_creds): if (not self.active) or (not self.initial_kex_done): # we should never try to authenticate unless we're on a secure link raise SSHException("No existing session") ...
[ "\n Authenticate to the Server using GSS-API / SSPI.\n\n :param str username: The username to authenticate as\n :param str gss_host: The target host\n :param bool gss_deleg_creds: Delegate credentials or not\n :return: list of auth types permissible for the next stage of\n ...
Please provide a description of the function:def set_log_channel(self, name): self.log_name = name self.logger = util.get_logger(name) self.packetizer.set_log(self.logger)
[ "\n Set the channel for this transport's logging. The default is\n ``\"paramiko.transport\"`` but it can be set to anything you want. (See\n the `.logging` module for more info.) SSH Channels will log to a\n sub-channel of the one specified.\n\n :param str name: new channel name...
Please provide a description of the function:def _next_channel(self): chanid = self._channel_counter while self._channels.get(chanid) is not None: self._channel_counter = (self._channel_counter + 1) & 0xffffff chanid = self._channel_counter self._channel_counter ...
[ "you are holding the lock" ]
Please provide a description of the function:def _compute_key(self, id, nbytes): m = Message() m.add_mpint(self.K) m.add_bytes(self.H) m.add_byte(b(id)) m.add_bytes(self.session_id) # Fallback to SHA1 for kex engines that fail to specify a hex # algorithm...
[ "id is 'A' - 'F' for the various keys used by ssh" ]
Please provide a description of the function:def _ensure_authed(self, ptype, message): if ( not self.server_mode or ptype <= HIGHEST_USERAUTH_MESSAGE_ID or self.is_authenticated() ): return None # WELP. We must be dealing with someone tryi...
[ "\n Checks message type against current auth state.\n\n If server mode, and auth has not succeeded, and the message is of a\n post-auth type (channel open or global request) an appropriate error\n response Message is crafted and returned to caller for sending.\n\n Otherwise (clien...
Please provide a description of the function:def _activate_outbound(self): m = Message() m.add_byte(cMSG_NEWKEYS) self._send_message(m) block_size = self._cipher_info[self.local_cipher]["block-size"] if self.server_mode: IV_out = self._compute_key("B", block_...
[ "switch on newly negotiated encryption parameters for\n outbound traffic" ]
Please provide a description of the function:def flush(self): self._write_all(self._wbuffer.getvalue()) self._wbuffer = BytesIO() return
[ "\n Write out any data in the write buffer. This may do nothing if write\n buffering is not turned on.\n " ]
Please provide a description of the function:def readinto(self, buff): data = self.read(len(buff)) buff[: len(data)] = data return len(data)
[ "\n Read up to ``len(buff)`` bytes into ``bytearray`` *buff* and return the\n number of bytes read.\n\n :returns:\n The number of bytes read.\n " ]
Please provide a description of the function:def readlines(self, sizehint=None): lines = [] byte_count = 0 while True: line = self.readline() if len(line) == 0: break lines.append(line) byte_count += len(line) i...
[ "\n Read all remaining lines using `readline` and return them as a list.\n If the optional ``sizehint`` argument is present, instead of reading up\n to EOF, whole lines totalling approximately sizehint bytes (possibly\n after rounding up to an internal buffer size) are read.\n\n :...
Please provide a description of the function:def write(self, data): if isinstance(data, text_type): # Accept text and encode as utf-8 for compatibility only. data = data.encode("utf-8") if self._closed: raise IOError("File is closed") if not (self._fl...
[ "\n Write data to the file. If write buffering is on (``bufsize`` was\n specified and non-zero), some or all of the data may not actually be\n written yet. (Use `flush` or `close` to force buffered data to be\n written out.)\n\n :param data: ``str``/``bytes`` data to write\n ...
Please provide a description of the function:def add(self, hostname, keytype, key): for e in self._entries: if (hostname in e.hostnames) and (e.key.get_name() == keytype): e.key = key return self._entries.append(HostKeyEntry([hostname], key))
[ "\n Add a host key entry to the table. Any existing entry for a\n ``(hostname, keytype)`` pair will be replaced.\n\n :param str hostname: the hostname (or IP) to add\n :param str keytype: key type (``\"ssh-rsa\"`` or ``\"ssh-dss\"``)\n :param .PKey key: the key to add\n " ...
Please provide a description of the function:def load(self, filename): with open(filename, "r") as f: for lineno, line in enumerate(f, 1): line = line.strip() if (len(line) == 0) or (line[0] == "#"): continue try: ...
[ "\n Read a file of known SSH host keys, in the format used by OpenSSH.\n This type of file unfortunately doesn't exist on Windows, but on\n posix, it will usually be stored in\n ``os.path.expanduser(\"~/.ssh/known_hosts\")``.\n\n If this method is called multiple times, the host k...
Please provide a description of the function:def lookup(self, hostname): class SubDict(MutableMapping): def __init__(self, hostname, entries, hostkeys): self._hostname = hostname self._entries = entries self._hostkeys = hostkeys ...
[ "\n Find a hostkey entry for a given hostname or IP. If no entry is found,\n ``None`` is returned. Otherwise a dictionary of keytype to key is\n returned. The keytype will be either ``\"ssh-rsa\"`` or ``\"ssh-dss\"``.\n\n :param str hostname: the hostname (or IP) to lookup\n :r...
Please provide a description of the function:def _hostname_matches(self, hostname, entry): for h in entry.hostnames: if ( h == hostname or h.startswith("|1|") and not hostname.startswith("|1|") and constant_time_bytes_eq(self.h...
[ "\n Tests whether ``hostname`` string matches given SubDict ``entry``.\n\n :returns bool:\n " ]
Please provide a description of the function:def from_line(cls, line, lineno=None): log = get_logger("paramiko.hostkeys") fields = line.split(" ") if len(fields) < 3: # Bad number of fields msg = "Not enough fields found in known_hosts in line {} ({!r})" ...
[ "\n Parses the given line of text to find the names for the host,\n the type of key, and the key data. The line is expected to be in the\n format used by the OpenSSH known_hosts file.\n\n Lines are expected to not have leading or trailing whitespace.\n We don't bother to check for...
Please provide a description of the function:def _query_pageant(msg): hwnd = _get_pageant_window_object() if not hwnd: # Raise a failure to connect exception, pageant isn't running anymore! return None # create a name for the mmap map_name = "PageantRequest%08x" % thread.get_ident(...
[ "\n Communication with the Pageant process is done through a shared\n memory-mapped file.\n " ]
Please provide a description of the function:def get_remainder(self): position = self.packet.tell() remainder = self.packet.read() self.packet.seek(position) return remainder
[ "\n Return the bytes (as a `str`) of this message that haven't already been\n parsed and returned.\n " ]
Please provide a description of the function:def get_so_far(self): position = self.packet.tell() self.rewind() return self.packet.read(position)
[ "\n Returns the `str` bytes of this message that have been parsed and\n returned. The string passed into a message's constructor can be\n regenerated by concatenating ``get_so_far`` and `get_remainder`.\n " ]
Please provide a description of the function:def get_bytes(self, n): b = self.packet.read(n) max_pad_size = 1 << 20 # Limit padding to 1 MB if len(b) < n < max_pad_size: return b + zero_byte * (n - len(b)) return b
[ "\n Return the next ``n`` bytes of the message (as a `str`), without\n decomposing into an int, decoded string, etc. Just the raw bytes are\n returned. Returns a string of ``n`` zero bytes if there weren't ``n``\n bytes remaining in the message.\n " ]
Please provide a description of the function:def add_boolean(self, b): if b: self.packet.write(one_byte) else: self.packet.write(zero_byte) return self
[ "\n Add a boolean value to the stream.\n\n :param bool b: boolean value to add\n " ]
Please provide a description of the function:def add_adaptive_int(self, n): if n >= Message.big_int: self.packet.write(max_byte) self.add_string(util.deflate_long(n)) else: self.packet.write(struct.pack(">I", n)) return self
[ "\n Add an integer to the stream.\n\n :param int n: integer to add\n " ]
Please provide a description of the function:def add_int64(self, n): self.packet.write(struct.pack(">Q", n)) return self
[ "\n Add a 64-bit int to the stream.\n\n :param long n: long int to add\n " ]
Please provide a description of the function:def _roll_random(n): bits = util.bit_length(n - 1) byte_count = (bits + 7) // 8 hbyte_mask = pow(2, bits % 8) - 1 # so here's the plan: # we fetch as many random bits as we'd need to fit N-1, and if the # generated number is >= N, we try again. ...
[ "returns a random # from 0 to N-1" ]
Please provide a description of the function:def read_file(self, filename): self.pack = {} with open(filename, "r") as f: for line in f: line = line.strip() if (len(line) == 0) or (line[0] == "#"): continue try: ...
[ "\n :raises IOError: passed from any file operations that fail.\n " ]
Please provide a description of the function:def generate(cls, curve=ec.SECP256R1(), progress_func=None, bits=None): if bits is not None: curve = cls._ECDSA_CURVES.get_by_key_length(bits) if curve is None: raise ValueError("Unsupported key length: {:d}".format(bi...
[ "\n Generate a new private ECDSA key. This factory function can be used to\n generate a new host key or authentication key.\n\n :param progress_func: Not used for this type of key.\n :returns: A new private key (`.ECDSAKey`) object\n " ]
Please provide a description of the function:def from_private_key_file(cls, filename, password=None): key = cls(filename=filename, password=password) return key
[ "\n Create a key object by reading a private key file. If the private\n key is encrypted and ``password`` is not ``None``, the given password\n will be used to decrypt the key (otherwise `.PasswordRequiredException`\n is thrown). Through the magic of Python, this factory method will\n ...
Please provide a description of the function:def from_private_key(cls, file_obj, password=None): key = cls(file_obj=file_obj, password=password) return key
[ "\n Create a key object by reading a private key from a file (or file-like)\n object. If the private key is encrypted and ``password`` is not\n ``None``, the given password will be used to decrypt the key (otherwise\n `.PasswordRequiredException` is thrown).\n\n :param file_obj: ...
Please provide a description of the function:def _write_private_key_file(self, filename, key, format, password=None): with open(filename, "w") as f: os.chmod(filename, o600) self._write_private_key(f, key, format, password=password)
[ "\n Write an SSH2-format private key file in a form that can be read by\n paramiko or openssh. If no password is given, the key is written in\n a trivially-encoded format (base64) which is completely insecure. If\n a password is given, DES-EDE3-CBC is used.\n\n :param str tag:\n...
Please provide a description of the function:def _check_type_and_load_cert(self, msg, key_type, cert_type): # Normalization; most classes have a single key type and give a string, # but eg ECDSA is a 1:N mapping. key_types = key_type cert_types = cert_type if isinstance(...
[ "\n Perform message type-checking & optional certificate loading.\n\n This includes fast-forwarding cert ``msg`` objects past the nonce, so\n that the subsequent fields are the key numbers; thus the caller may\n expect to treat the message as key material afterwards either way.\n\n ...
Please provide a description of the function:def load_certificate(self, value): if isinstance(value, Message): constructor = "from_message" elif os.path.isfile(value): constructor = "from_file" else: constructor = "from_string" blob = getattr(...
[ "\n Supplement the private key contents with data loaded from an OpenSSH\n public key (``.pub``) or certificate (``-cert.pub``) file, a string\n containing such a file, or a `.Message` object.\n\n The .pub contents adds no real value, since the private key\n file includes sufficie...
Please provide a description of the function:def from_file(cls, filename): with open(filename) as f: string = f.read() return cls.from_string(string)
[ "\n Create a public blob from a ``-cert.pub``-style file on disk.\n " ]
Please provide a description of the function:def from_string(cls, string): fields = string.split(None, 2) if len(fields) < 2: msg = "Not enough fields for public blob: {}" raise ValueError(msg.format(fields)) key_type = fields[0] key_blob = decodebytes(b(...
[ "\n Create a public blob from a ``-cert.pub``-style string.\n " ]
Please provide a description of the function:def from_message(cls, message): type_ = message.get_text() return cls(type_=type_, blob=message.asbytes())
[ "\n Create a public blob from a network `.Message`.\n\n Specifically, a cert-bearing pubkey auth packet, because by definition\n OpenSSH-style certificates 'are' their own network representation.\"\n " ]
Please provide a description of the function:def make_or_pipe(pipe): p1 = OrPipe(pipe) p2 = OrPipe(pipe) p1._partner = p2 p2._partner = p1 return p1, p2
[ "\n wraps a pipe into two pipe-like objects which are \"or\"d together to\n affect the real pipe. if either returned pipe is set, the wrapped pipe\n is set. when both are cleared, the wrapped pipe is cleared.\n " ]
Please provide a description of the function:def get_connection(self): conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: conn.bind(self._agent._get_filename()) conn.listen(1) (r, addr) = conn.accept() return r, addr except: ...
[ "\n Return a pair of socket object and string address.\n\n May block!\n " ]
Please provide a description of the function:def close(self): if hasattr(self, "thread"): self.thread._exit = True self.thread.join(1000) if self._conn is not None: self._conn.close()
[ "\n Close the current connection and terminate the agent\n Should be called manually\n " ]
Please provide a description of the function:def close(self): os.remove(self._file) os.rmdir(self._dir) self.thread._exit = True self.thread.join(1000) self._close()
[ "\n Terminate the agent, clean the files, close connections\n Should be called manually\n " ]
Please provide a description of the function:def set_outbound_cipher( self, block_engine, block_size, mac_engine, mac_size, mac_key, sdctr=False, ): self.__block_engine_out = block_engine self.__sdctr_out = sdctr self.__block_s...
[ "\n Switch outbound data cipher.\n " ]
Please provide a description of the function:def set_inbound_cipher( self, block_engine, block_size, mac_engine, mac_size, mac_key ): self.__block_engine_in = block_engine self.__block_size_in = block_size self.__mac_engine_in = mac_engine self.__mac_size_in = mac_si...
[ "\n Switch inbound data cipher.\n " ]
Please provide a description of the function:def set_keepalive(self, interval, callback): self.__keepalive_interval = interval self.__keepalive_callback = callback self.__keepalive_last = time.time()
[ "\n Turn on/off the callback keepalive. If ``interval`` seconds pass with\n no data read from or written to the socket, the callback will be\n executed and the timer will be reset.\n " ]
Please provide a description of the function:def start_handshake(self, timeout): if not self.__timer: self.__timer = threading.Timer(float(timeout), self.read_timer) self.__timer.start()
[ "\n Tells `Packetizer` that the handshake process started.\n Starts a book keeping timer that can signal a timeout in the\n handshake process.\n\n :param float timeout: amount of seconds to wait before timing out\n " ]
Please provide a description of the function:def handshake_timed_out(self): if not self.__timer: return False if self.__handshake_complete: return False return self.__timer_expired
[ "\n Checks if the handshake has timed out.\n\n If `start_handshake` wasn't called before the call to this function,\n the return value will always be `False`. If the handshake completed\n before a timeout was reached, the return value will be `False`\n\n :return: handshake time ou...
Please provide a description of the function:def complete_handshake(self): if self.__timer: self.__timer.cancel() self.__timer_expired = False self.__handshake_complete = True
[ "\n Tells `Packetizer` that the handshake has completed.\n " ]
Please provide a description of the function:def close(self): readfile = getattr(self, "readfile", None) if readfile is not None: readfile.close() writefile = getattr(self, "writefile", None) if writefile is not None: writefile.close()
[ "\n When a client closes a file, this method is called on the handle.\n Normally you would use this method to close the underlying OS level\n file object(s).\n\n The default implementation checks for attributes on ``self`` named\n ``readfile`` and/or ``writefile``, and if either o...
Please provide a description of the function:def _get_next_files(self): fnlist = self.__files[:16] self.__files = self.__files[16:] return fnlist
[ "\n Used by the SFTP server code to retrieve a cached directory\n listing.\n " ]
Please provide a description of the function:def generate_key_bytes(hash_alg, salt, key, nbytes): keydata = bytes() digest = bytes() if len(salt) > 8: salt = salt[:8] while nbytes > 0: hash_obj = hash_alg() if len(digest) > 0: hash_obj.update(digest) hash...
[ "\n Given a password, passphrase, or other human-source key, scramble it\n through a secure hash into some keyworthy bytes. This specific algorithm\n is used for encrypting/decrypting private key files.\n\n :param function hash_alg: A function which creates a new hash object, such\n as ``hashlib...
Please provide a description of the function:def log_to_file(filename, level=DEBUG): logger = logging.getLogger("paramiko") if len(logger.handlers) > 0: return logger.setLevel(level) f = open(filename, "a") handler = logging.StreamHandler(f) frm = "%(levelname)-.3s [%(asctime)s.%(ms...
[ "send paramiko logs to a logfile,\n if they're not already going somewhere" ]
Please provide a description of the function:def send(self, content): try: self.process.stdin.write(content) except IOError as e: # There was a problem with the child process. It probably # died and we can't proceed. The best option here is to # r...
[ "\n Write the content received from the SSH client to the standard\n input of the forked command.\n\n :param str content: string to be sent to the forked command\n " ]
Please provide a description of the function:def recv(self, size): try: buffer = b"" start = time.time() while len(buffer) < size: select_timeout = None if self.timeout is not None: elapsed = time.time() - start ...
[ "\n Read from the standard output of the forked program.\n\n :param int size: how many chars should be read\n\n :return: the string of bytes read, which may be shorter than requested\n " ]
Please provide a description of the function:def format_system_message(errno): # first some flags used by FormatMessageW ALLOCATE_BUFFER = 0x100 FROM_SYSTEM = 0x1000 # Let FormatMessageW allocate the buffer (we'll free it below) # Also, let it know we want a system error message. flags = A...
[ "\n Call FormatMessage with a system error number to retrieve\n the descriptive error message.\n " ]
Please provide a description of the function:def GetTokenInformation(token, information_class): data_size = ctypes.wintypes.DWORD() ctypes.windll.advapi32.GetTokenInformation( token, information_class.num, 0, 0, ctypes.byref(data_size) ) data = ctypes.create_string_buffer(data_size.value) ...
[ "\n Given a token, get the token information for it.\n " ]
Please provide a description of the function:def get_current_user(): process = OpenProcessToken( ctypes.windll.kernel32.GetCurrentProcess(), TokenAccess.TOKEN_QUERY ) return GetTokenInformation(process, TOKEN_USER)
[ "\n Return a TOKEN_USER for the owner of this process.\n " ]
Please provide a description of the function:def generate(bits=1024, progress_func=None): numbers = dsa.generate_private_key( bits, backend=default_backend() ).private_numbers() key = DSSKey( vals=( numbers.public_numbers.parameter_numbers.p, ...
[ "\n Generate a new private DSS key. This factory function can be used to\n generate a new host key or authentication key.\n\n :param int bits: number of bits the generated key should be.\n :param progress_func: Unused\n :return: new `.DSSKey` private key\n " ]
Please provide a description of the function:def load_system_host_keys(self, filename=None): if filename is None: # try the user's .ssh key file, and mask exceptions filename = os.path.expanduser("~/.ssh/known_hosts") try: self._system_host_keys.load(...
[ "\n Load host keys from a system (read-only) file. Host keys read with\n this method will not be saved back by `save_host_keys`.\n\n This method can be called multiple times. Each new set of host keys\n will be merged with the existing set (new replacing old if there are\n confl...
Please provide a description of the function:def load_host_keys(self, filename): self._host_keys_filename = filename self._host_keys.load(filename)
[ "\n Load host keys from a local host-key file. Host keys read with this\n method will be checked after keys loaded via `load_system_host_keys`,\n but will be saved back by `save_host_keys` (so they can be modified).\n The missing host key policy `.AutoAddPolicy` adds keys to this set an...
Please provide a description of the function:def set_missing_host_key_policy(self, policy): if inspect.isclass(policy): policy = policy() self._policy = policy
[ "\n Set policy to use when connecting to servers without a known host key.\n\n Specifically:\n\n * A **policy** is a \"policy class\" (or instance thereof), namely some\n subclass of `.MissingHostKeyPolicy` such as `.RejectPolicy` (the\n default), `.AutoAddPolicy`, `.WarningPo...
Please provide a description of the function:def _families_and_addresses(self, hostname, port): guess = True addrinfos = socket.getaddrinfo( hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM ) for (family, socktype, proto, canonname, sockaddr) in addrinfos: ...
[ "\n Yield pairs of address families and addresses to try for connecting.\n\n :param str hostname: the server to connect to\n :param int port: the server port to connect to\n :returns: Yields an iterable of ``(family, address)`` tuples\n " ]
Please provide a description of the function: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=No...
[ "\n Connect to an SSH server and authenticate to it. The server's host key\n is checked against the system host keys (see `load_system_host_keys`)\n and any local host keys (`load_host_keys`). If the server's hostname\n is not found in either set of host keys, the missing host key poli...
Please provide a description of the function:def close(self): if self._transport is None: return self._transport.close() self._transport = None if self._agent is not None: self._agent.close() self._agent = None
[ "\n Close this SSHClient and its underlying `.Transport`.\n\n .. warning::\n Failure to do this may, in some situations, cause your Python\n interpreter to hang at shutdown (often due to race conditions).\n It's good practice to `close` your client objects anytime you'...
Please provide a description of the function:def exec_command( self, command, bufsize=-1, timeout=None, get_pty=False, environment=None, ): chan = self._transport.open_session(timeout=timeout) if get_pty: chan.get_pty() cha...
[ "\n Execute a command on the SSH server. A new `.Channel` is opened and\n the requested command is executed. The command's input and output\n streams are returned as Python ``file``-like objects representing\n stdin, stdout, and stderr.\n\n :param str command: the command to exe...
Please provide a description of the function:def invoke_shell( self, term="vt100", width=80, height=24, width_pixels=0, height_pixels=0, environment=None, ): chan = self._transport.open_session() chan.get_pty(term, width, height, width...
[ "\n Start an interactive shell session on the SSH server. A new `.Channel`\n is opened and connected to a pseudo-terminal using the requested\n terminal type and size.\n\n :param str term:\n the terminal type to emulate (for example, ``\"vt100\"``)\n :param int width: ...
Please provide a description of the function:def _key_from_filepath(self, filename, klass, password): cert_suffix = "-cert.pub" # Assume privkey, not cert, by default if filename.endswith(cert_suffix): key_path = filename[: -len(cert_suffix)] cert_path = filename...
[ "\n Attempt to derive a `.PKey` from given string path ``filename``:\n\n - If ``filename`` appears to be a cert, the matching private key is\n loaded.\n - Otherwise, the filename is assumed to be a private key, and the\n matching public cert will be loaded if it exists.\n ...
Please provide a description of the function:def _auth( self, username, password, pkey, key_filenames, allow_agent, look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host, passphrase, ): saved_excep...
[ "\n Try, in order:\n\n - The key(s) passed in, if one was passed in.\n - Any key we can find through an SSH agent (if allowed).\n - Any \"id_rsa\", \"id_dsa\" or \"id_ecdsa\" key discoverable in ~/.ssh/\n (if allowed).\n - Plain username/password auth,...
Please provide a description of the function:def language(self, language): if language is None: raise ValueError("Invalid value for `language`, must not be `None`") # noqa: E501 allowed_values = ["python", "r", "rmarkdown"] # noqa: E501 if language not in allowed_values: ...
[ "Sets the language of this KernelPushRequest.\n\n The language that the kernel is written in # noqa: E501\n\n :param language: The language of this KernelPushRequest. # noqa: E501\n :type: str\n " ]
Please provide a description of the function:def kernel_type(self, kernel_type): if kernel_type is None: raise ValueError("Invalid value for `kernel_type`, must not be `None`") # noqa: E501 allowed_values = ["script", "notebook"] # noqa: E501 if kernel_type not in allowed_...
[ "Sets the kernel_type of this KernelPushRequest.\n\n The type of kernel. Cannot be changed once the kernel has been created # noqa: E501\n\n :param kernel_type: The kernel_type of this KernelPushRequest. # noqa: E501\n :type: str\n " ]
Please provide a description of the function:def competition_download_leaderboard(self, id, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competition_download_leaderboard_with_http_info(id, **kwargs) # noqa: E501 el...
[ "Download competition leaderboard # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competition_download_leaderboard(id, async_req=True)\n >>> result = thread.get()\n\n :...
Please provide a description of the function:def competition_view_leaderboard(self, id, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competition_view_leaderboard_with_http_info(id, **kwargs) # noqa: E501 else: ...
[ "VIew competition leaderboard # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competition_view_leaderboard(id, async_req=True)\n >>> result = thread.get()\n\n :param as...
Please provide a description of the function:def competitions_data_download_file(self, id, file_name, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_data_download_file_with_http_info(id, file_name, **kwargs) # n...
[ "Download competition data file # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_data_download_file(id, file_name, async_req=True)\n >>> result = thread.get()\n\n ...
Please provide a description of the function:def competitions_data_list_files(self, id, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_data_list_files_with_http_info(id, **kwargs) # noqa: E501 else: ...
[ "List competition data files # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_data_list_files(id, async_req=True)\n >>> result = thread.get()\n\n :param asy...
Please provide a description of the function:def competitions_list(self, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_list_with_http_info(**kwargs) # noqa: E501 else: (data) = self.competit...
[ "List competitions # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_list(async_req=True)\n >>> result = thread.get()\n\n :param async_req bool\n :par...
Please provide a description of the function:def competitions_submissions_list(self, id, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_submissions_list_with_http_info(id, **kwargs) # noqa: E501 else: ...
[ "List competition submissions # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_submissions_list(id, async_req=True)\n >>> result = thread.get()\n\n :param a...
Please provide a description of the function:def competitions_submissions_submit(self, blob_file_tokens, submission_description, id, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_submissions_submit_with_http_inf...
[ "Submit to competition # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_submissions_submit(blob_file_tokens, submission_description, id, async_req=True)\n >>> resu...
Please provide a description of the function:def competitions_submissions_upload(self, file, guid, content_length, last_modified_date_utc, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_submissions_upload_with_ht...
[ "Upload competition submission file # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_submissions_upload(file, guid, content_length, last_modified_date_utc, async_req=True...
Please provide a description of the function:def competitions_submissions_url(self, id, content_length, last_modified_date_utc, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.competitions_submissions_url_with_http_info(id, co...
[ "Generate competition submission URL # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.competitions_submissions_url(id, content_length, last_modified_date_utc, async_req=True)\n ...
Please provide a description of the function:def datasets_create_new(self, dataset_new_request, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_create_new_with_http_info(dataset_new_request, **kwargs) # noqa: E501 ...
[ "Create a new dataset # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_create_new(dataset_new_request, async_req=True)\n >>> result = thread.get()\n\n :param as...
Please provide a description of the function:def datasets_create_version(self, owner_slug, dataset_slug, dataset_new_version_request, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_create_version_with_http_info(owner...
[ "Create a new dataset version # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_create_version(owner_slug, dataset_slug, dataset_new_version_request, async_req=True)\n ...
Please provide a description of the function:def datasets_create_version_by_id(self, id, dataset_new_version_request, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_create_version_by_id_with_http_info(id, dataset_new...
[ "Create a new dataset version by id # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_create_version_by_id(id, dataset_new_version_request, async_req=True)\n >>> result...
Please provide a description of the function:def datasets_download(self, owner_slug, dataset_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_download_with_http_info(owner_slug, dataset_slug, **kwargs) # noqa: E...
[ "Download dataset file # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_download(owner_slug, dataset_slug, async_req=True)\n >>> result = thread.get()\n\n :para...
Please provide a description of the function:def datasets_download_file(self, owner_slug, dataset_slug, file_name, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_download_file_with_http_info(owner_slug, dataset_slug,...
[ "Download dataset file # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_download_file(owner_slug, dataset_slug, file_name, async_req=True)\n >>> result = thread.get()\...
Please provide a description of the function:def datasets_list(self, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_list_with_http_info(**kwargs) # noqa: E501 else: (data) = self.datasets_list_wi...
[ "List datasets # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_list(async_req=True)\n >>> result = thread.get()\n\n :param async_req bool\n :param str g...
Please provide a description of the function:def datasets_list_files(self, owner_slug, dataset_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_list_files_with_http_info(owner_slug, dataset_slug, **kwargs) # noq...
[ "List dataset files # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_list_files(owner_slug, dataset_slug, async_req=True)\n >>> result = thread.get()\n\n :param...
Please provide a description of the function:def datasets_status(self, owner_slug, dataset_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_status_with_http_info(owner_slug, dataset_slug, **kwargs) # noqa: E501 ...
[ "Get dataset creation status # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_status(owner_slug, dataset_slug, async_req=True)\n >>> result = thread.get()\n\n :...
Please provide a description of the function:def datasets_upload_file(self, file_name, content_length, last_modified_date_utc, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_upload_file_with_http_info(file_name, cont...
[ "Get URL and token to start uploading a data file # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_upload_file(file_name, content_length, last_modified_date_utc, async_req=Tr...
Please provide a description of the function:def datasets_view(self, owner_slug, dataset_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.datasets_view_with_http_info(owner_slug, dataset_slug, **kwargs) # noqa: E501 ...
[ "Show details about a dataset # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.datasets_view(owner_slug, dataset_slug, async_req=True)\n >>> result = thread.get()\n\n :p...
Please provide a description of the function:def kernel_output(self, user_name, kernel_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.kernel_output_with_http_info(user_name, kernel_slug, **kwargs) # noqa: E501 ...
[ "Download the latest output from a kernel # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.kernel_output(user_name, kernel_slug, async_req=True)\n >>> result = thread.get()\n\n...
Please provide a description of the function:def kernel_pull(self, user_name, kernel_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.kernel_pull_with_http_info(user_name, kernel_slug, **kwargs) # noqa: E501 else...
[ "Pull the latest code from a kernel # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.kernel_pull(user_name, kernel_slug, async_req=True)\n >>> result = thread.get()\n\n ...
Please provide a description of the function:def kernel_push(self, kernel_push_request, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.kernel_push_with_http_info(kernel_push_request, **kwargs) # noqa: E501 else: ...
[ "Push a new kernel version. Can be used to create a new kernel and update an existing one. # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.kernel_push(kernel_push_request, async_req...
Please provide a description of the function:def kernel_status(self, user_name, kernel_slug, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.kernel_status_with_http_info(user_name, kernel_slug, **kwargs) # noqa: E501 ...
[ "Get the status of the latest kernel version # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.kernel_status(user_name, kernel_slug, async_req=True)\n >>> result = thread.get()\...
Please provide a description of the function:def kernels_list(self, **kwargs): # noqa: E501 kwargs['_return_http_data_only'] = True if kwargs.get('async_req'): return self.kernels_list_with_http_info(**kwargs) # noqa: E501 else: (data) = self.kernels_list_with_...
[ "List kernels # noqa: E501\n\n This method makes a synchronous HTTP request by default. To make an\n asynchronous HTTP request, please pass async_req=True\n >>> thread = api.kernels_list(async_req=True)\n >>> result = thread.get()\n\n :param async_req bool\n :param int pag...
Please provide a description of the function:def authenticate(self): config_data = {} # Step 1: try getting username/password from environment config_data = self.read_config_environment(config_data) # Step 2: if credentials were not in env read in configuration file i...
[ "authenticate the user with the Kaggle API. This method will generate\n a configuration, first checking the environment for credential\n variables, and falling back to looking for the .kaggle/kaggle.json\n configuration file.\n " ]
Please provide a description of the function:def read_config_environment(self, config_data=None, quiet=False): # Add all variables that start with KAGGLE_ to config data if config_data is None: config_data = {} for key, val in os.environ.items(): if key.startsw...
[ "read_config_environment is the second effort to get a username\n and key to authenticate to the Kaggle API. The environment keys\n are equivalent to the kaggle.json file, but with \"KAGGLE_\" prefix\n to define a unique namespace.\n\n Parameters\n ==========\n ...
Please provide a description of the function:def _load_config(self, config_data): # Username and password are required. for item in [self.CONFIG_NAME_USER, self.CONFIG_NAME_KEY]: if item not in config_data: raise ValueError('Error: Missing %s in configuration.' % it...
[ "the final step of the authenticate steps, where we load the values\n from config_data into the Configuration object.\n\n Parameters\n ==========\n config_data: a dictionary with configuration values (keys) to read\n into self.config_values\n\n "...
Please provide a description of the function:def read_config_file(self, config_data=None, quiet=False): if config_data is None: config_data = {} if os.path.exists(self.config): try: if os.name != 'nt': permissions = os.stat(self.conf...
[ "read_config_file is the first effort to get a username\n and key to authenticate to the Kaggle API. Since we can get the\n username and password from the environment, it's not required.\n\n Parameters\n ==========\n config_data: the Configuration object to save a u...
Please provide a description of the function:def _read_config_file(self): try: with open(self.config, 'r') as f: config_data = json.load(f) except FileNotFoundError: config_data = {} return config_data
[ "read in the configuration file, a json file defined at self.config" ]
Please provide a description of the function:def _write_config_file(self, config_data, indent=2): with open(self.config, 'w') as f: json.dump(config_data, f, indent=indent)
[ "write config data to file.\n\n Parameters\n ==========\n config_data: the Configuration object to save a username and\n password, if defined\n indent: number of tab indentations to use when writing json\n " ]
Please provide a description of the function:def set_config_value(self, name, value, quiet=False): config_data = self._read_config_file() if value is not None: # Update the config file with the value config_data[name] = value # Update the instance with th...
[ "a client helper function to set a configuration value, meaning\n reading in the configuration file (if it exists), saving a new\n config value, and then writing back\n\n Parameters\n ==========\n name: the name of the value to set (key in dictionary)\n va...
Please provide a description of the function:def unset_config_value(self, name, quiet=False): config_data = self._read_config_file() if name in config_data: del config_data[name] self._write_config_file(config_data) if not quiet: self.pri...
[ "unset a configuration value\n Parameters\n ==========\n name: the name of the value to unset (remove key in dictionary)\n quiet: disable verbose output if True (default is False)\n " ]
Please provide a description of the function:def get_default_download_dir(self, *subdirs): # Look up value for key "path" in the config path = self.get_config_value(self.CONFIG_NAME_PATH) # If not set in config, default to present working directory if path is None: ...
[ " Get the download path for a file. If not defined, return default\n from config.\n\n Parameters\n ==========\n subdirs: a single (or list of) subfolders under the basepath\n " ]
Please provide a description of the function:def print_config_value(self, name, prefix='- ', separator=': '): value_out = 'None' if name in self.config_values and self.config_values[name] is not None: value_out = self.config_values[name] print(prefix + name + separator + va...
[ "print a single configuration value, based on a prefix and separator\n\n Parameters\n ==========\n name: the key of the config valur in self.config_values to print\n prefix: the prefix to print\n separator: the separator to use (default is : )\n " ]