repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
bitprophet/ssh | ssh/transport.py | Transport._send_kex_init | def _send_kex_init(self):
"""
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
"""
self.clear_to_send_lock.acquire()
try:
self.clear_to_send.clear()
finally:
self.clear_to_send_lock.r... | python | def _send_kex_init(self):
"""
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
"""
self.clear_to_send_lock.acquire()
try:
self.clear_to_send.clear()
finally:
self.clear_to_send_lock.r... | [
"def",
"_send_kex_init",
"(",
"self",
")",
":",
"self",
".",
"clear_to_send_lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"clear_to_send",
".",
"clear",
"(",
")",
"finally",
":",
"self",
".",
"clear_to_send_lock",
".",
"release",
"(",
")",
"s... | announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support. | [
"announce",
"to",
"the",
"other",
"side",
"that",
"we",
"d",
"like",
"to",
"negotiate",
"keys",
"and",
"what",
"kind",
"of",
"key",
"negotiation",
"we",
"support",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/transport.py#L1698-L1737 |
bitprophet/ssh | ssh/primes.py | _generate_prime | def _generate_prime(bits, rng):
"primtive attempt at prime generation"
hbyte_mask = pow(2, bits % 8) - 1
while True:
# loop catches the case where we increment n into a higher bit-range
x = rng.read((bits+7) // 8)
if hbyte_mask > 0:
x = chr(ord(x[0]) & hbyte_mask) + x[1:]... | python | def _generate_prime(bits, rng):
"primtive attempt at prime generation"
hbyte_mask = pow(2, bits % 8) - 1
while True:
# loop catches the case where we increment n into a higher bit-range
x = rng.read((bits+7) // 8)
if hbyte_mask > 0:
x = chr(ord(x[0]) & hbyte_mask) + x[1:]... | [
"def",
"_generate_prime",
"(",
"bits",
",",
"rng",
")",
":",
"hbyte_mask",
"=",
"pow",
"(",
"2",
",",
"bits",
"%",
"8",
")",
"-",
"1",
"while",
"True",
":",
"# loop catches the case where we increment n into a higher bit-range",
"x",
"=",
"rng",
".",
"read",
... | primtive attempt at prime generation | [
"primtive",
"attempt",
"at",
"prime",
"generation"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L29-L44 |
bitprophet/ssh | ssh/primes.py | _roll_random | def _roll_random(rng, n):
"returns a random # from 0 to N-1"
bits = util.bit_length(n-1)
bytes = (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. in the worst... | python | def _roll_random(rng, n):
"returns a random # from 0 to N-1"
bits = util.bit_length(n-1)
bytes = (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. in the worst... | [
"def",
"_roll_random",
"(",
"rng",
",",
"n",
")",
":",
"bits",
"=",
"util",
".",
"bit_length",
"(",
"n",
"-",
"1",
")",
"bytes",
"=",
"(",
"bits",
"+",
"7",
")",
"//",
"8",
"hbyte_mask",
"=",
"pow",
"(",
"2",
",",
"bits",
"%",
"8",
")",
"-",
... | returns a random # from 0 to N-1 | [
"returns",
"a",
"random",
"#",
"from",
"0",
"to",
"N",
"-",
"1"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/primes.py#L46-L65 |
bitprophet/ssh | ssh/pkey.py | PKey._write_private_key_file | def _write_private_key_file(self, tag, filename, data, password=None):
"""
Write an SSH2-format private key file in a form that can be read by
ssh or openssh. If no password is given, the key is written in
a trivially-encoded format (base64) which is completely insecure. If
a p... | python | def _write_private_key_file(self, tag, filename, data, password=None):
"""
Write an SSH2-format private key file in a form that can be read by
ssh or openssh. If no password is given, the key is written in
a trivially-encoded format (base64) which is completely insecure. If
a p... | [
"def",
"_write_private_key_file",
"(",
"self",
",",
"tag",
",",
"filename",
",",
"data",
",",
"password",
"=",
"None",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
",",
"0600",
")",
"# grrr... the mode doesn't always take hold",
"os",
".",
"chmod... | Write an SSH2-format private key file in a form that can be read by
ssh or openssh. If no password is given, the key is written in
a trivially-encoded format (base64) which is completely insecure. If
a password is given, DES-EDE3-CBC is used.
@param tag: C{"RSA"} or C{"DSA"}, the tag ... | [
"Write",
"an",
"SSH2",
"-",
"format",
"private",
"key",
"file",
"in",
"a",
"form",
"that",
"can",
"be",
"read",
"by",
"ssh",
"or",
"openssh",
".",
"If",
"no",
"password",
"is",
"given",
"the",
"key",
"is",
"written",
"in",
"a",
"trivially",
"-",
"enc... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/pkey.py#L331-L353 |
bitprophet/ssh | ssh/buffered_pipe.py | BufferedPipe.set_event | def set_event(self, event):
"""
Set an event on this buffer. When data is ready to be read (or the
buffer has been closed), the event will be set. When no data is
ready, the event will be cleared.
@param event: the event to set/clear
@type event: Event
... | python | def set_event(self, event):
"""
Set an event on this buffer. When data is ready to be read (or the
buffer has been closed), the event will be set. When no data is
ready, the event will be cleared.
@param event: the event to set/clear
@type event: Event
... | [
"def",
"set_event",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_event",
"=",
"event",
"if",
"len",
"(",
"self",
".",
"_buffer",
")",
">",
"0",
":",
"event",
".",
"set",
"(",
")",
"else",
":",
"event",
".",
"clear",
"(",
")"
] | Set an event on this buffer. When data is ready to be read (or the
buffer has been closed), the event will be set. When no data is
ready, the event will be cleared.
@param event: the event to set/clear
@type event: Event | [
"Set",
"an",
"event",
"on",
"this",
"buffer",
".",
"When",
"data",
"is",
"ready",
"to",
"be",
"read",
"(",
"or",
"the",
"buffer",
"has",
"been",
"closed",
")",
"the",
"event",
"will",
"be",
"set",
".",
"When",
"no",
"data",
"is",
"ready",
"the",
"e... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L51-L64 |
bitprophet/ssh | ssh/buffered_pipe.py | BufferedPipe.feed | def feed(self, data):
"""
Feed new data into this pipe. This method is assumed to be called
from a separate thread, so synchronization is done.
@param data: the data to add
@type data: str
"""
self._lock.acquire()
try:
if self._event ... | python | def feed(self, data):
"""
Feed new data into this pipe. This method is assumed to be called
from a separate thread, so synchronization is done.
@param data: the data to add
@type data: str
"""
self._lock.acquire()
try:
if self._event ... | [
"def",
"feed",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_lock",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"_event",
"is",
"not",
"None",
":",
"self",
".",
"_event",
".",
"set",
"(",
")",
"self",
".",
"_buffer",
".",
"fro... | Feed new data into this pipe. This method is assumed to be called
from a separate thread, so synchronization is done.
@param data: the data to add
@type data: str | [
"Feed",
"new",
"data",
"into",
"this",
"pipe",
".",
"This",
"method",
"is",
"assumed",
"to",
"be",
"called",
"from",
"a",
"separate",
"thread",
"so",
"synchronization",
"is",
"done",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/buffered_pipe.py#L66-L81 |
bitprophet/ssh | ssh/sftp_handle.py | SFTPHandle.read | def read(self, offset, length):
"""
Read up to C{length} bytes from this file, starting at position
C{offset}. The offset may be a python long, since SFTP allows it
to be 64 bits.
If the end of the file has been reached, this method may return an
empty string to signify... | python | def read(self, offset, length):
"""
Read up to C{length} bytes from this file, starting at position
C{offset}. The offset may be a python long, since SFTP allows it
to be 64 bits.
If the end of the file has been reached, this method may return an
empty string to signify... | [
"def",
"read",
"(",
"self",
",",
"offset",
",",
"length",
")",
":",
"readfile",
"=",
"getattr",
"(",
"self",
",",
"'readfile'",
",",
"None",
")",
"if",
"readfile",
"is",
"None",
":",
"return",
"SFTP_OP_UNSUPPORTED",
"try",
":",
"if",
"self",
".",
"__te... | Read up to C{length} bytes from this file, starting at position
C{offset}. The offset may be a python long, since SFTP allows it
to be 64 bits.
If the end of the file has been reached, this method may return an
empty string to signify EOF, or it may also return L{SFTP_EOF}.
Th... | [
"Read",
"up",
"to",
"C",
"{",
"length",
"}",
"bytes",
"from",
"this",
"file",
"starting",
"at",
"position",
"C",
"{",
"offset",
"}",
".",
"The",
"offset",
"may",
"be",
"a",
"python",
"long",
"since",
"SFTP",
"allows",
"it",
"to",
"be",
"64",
"bits",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L72-L107 |
bitprophet/ssh | ssh/sftp_handle.py | SFTPHandle.write | def write(self, offset, data):
"""
Write C{data} into this file at position C{offset}. Extending the
file past its original end is expected. Unlike python's normal
C{write()} methods, this method cannot do a partial write: it must
write all of C{data} or else return an error.
... | python | def write(self, offset, data):
"""
Write C{data} into this file at position C{offset}. Extending the
file past its original end is expected. Unlike python's normal
C{write()} methods, this method cannot do a partial write: it must
write all of C{data} or else return an error.
... | [
"def",
"write",
"(",
"self",
",",
"offset",
",",
"data",
")",
":",
"writefile",
"=",
"getattr",
"(",
"self",
",",
"'writefile'",
",",
"None",
")",
"if",
"writefile",
"is",
"None",
":",
"return",
"SFTP_OP_UNSUPPORTED",
"try",
":",
"# in append mode, don't car... | Write C{data} into this file at position C{offset}. Extending the
file past its original end is expected. Unlike python's normal
C{write()} methods, this method cannot do a partial write: it must
write all of C{data} or else return an error.
The default implementation checks for an at... | [
"Write",
"C",
"{",
"data",
"}",
"into",
"this",
"file",
"at",
"position",
"C",
"{",
"offset",
"}",
".",
"Extending",
"the",
"file",
"past",
"its",
"original",
"end",
"is",
"expected",
".",
"Unlike",
"python",
"s",
"normal",
"C",
"{",
"write",
"()",
"... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_handle.py#L109-L147 |
bitprophet/ssh | ssh/sftp_si.py | SFTPServerInterface.canonicalize | def canonicalize(self, path):
"""
Return the canonical form of a path on the server. For example,
if the server's home folder is C{/home/foo}, the path
C{"../betty"} would be canonicalized to C{"/home/betty"}. Note
the obvious security issues: if you're serving files only from ... | python | def canonicalize(self, path):
"""
Return the canonical form of a path on the server. For example,
if the server's home folder is C{/home/foo}, the path
C{"../betty"} would be canonicalized to C{"/home/betty"}. Note
the obvious security issues: if you're serving files only from ... | [
"def",
"canonicalize",
"(",
"self",
",",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
":",
"out",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"path",
")",
"else",
":",
"out",
"=",
"os",
".",
"path",
".",
"normpat... | Return the canonical form of a path on the server. For example,
if the server's home folder is C{/home/foo}, the path
C{"../betty"} would be canonicalized to C{"/home/betty"}. Note
the obvious security issues: if you're serving files only from a
specific folder, you probably don't want... | [
"Return",
"the",
"canonical",
"form",
"of",
"a",
"path",
"on",
"the",
"server",
".",
"For",
"example",
"if",
"the",
"server",
"s",
"home",
"folder",
"is",
"C",
"{",
"/",
"home",
"/",
"foo",
"}",
"the",
"path",
"C",
"{",
"..",
"/",
"betty",
"}",
"... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_si.py#L259-L280 |
bitprophet/ssh | ssh/agent.py | AgentClientProxy.connect | def connect(self):
"""
Method automatically called by the run() method of the AgentProxyThread
"""
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
retry_on_signal(lambd... | python | def connect(self):
"""
Method automatically called by the run() method of the AgentProxyThread
"""
if ('SSH_AUTH_SOCK' in os.environ) and (sys.platform != 'win32'):
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
try:
retry_on_signal(lambd... | [
"def",
"connect",
"(",
"self",
")",
":",
"if",
"(",
"'SSH_AUTH_SOCK'",
"in",
"os",
".",
"environ",
")",
"and",
"(",
"sys",
".",
"platform",
"!=",
"'win32'",
")",
":",
"conn",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_UNIX",
",",
"socket",... | Method automatically called by the run() method of the AgentProxyThread | [
"Method",
"automatically",
"called",
"by",
"the",
"run",
"()",
"method",
"of",
"the",
"AgentProxyThread"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/agent.py#L199-L219 |
bitprophet/ssh | ssh/client.py | SSHClient.save_host_keys | def save_host_keys(self, filename):
"""
Save the host keys back to a file. Only the host keys loaded with
L{load_host_keys} (plus any added directly) will be saved -- not any
host keys loaded with L{load_system_host_keys}.
@param filename: the filename to save to
@type ... | python | def save_host_keys(self, filename):
"""
Save the host keys back to a file. Only the host keys loaded with
L{load_host_keys} (plus any added directly) will be saved -- not any
host keys loaded with L{load_system_host_keys}.
@param filename: the filename to save to
@type ... | [
"def",
"save_host_keys",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"'# SSH host keys collected by ssh\\n'",
")",
"for",
"hostname",
",",
"keys",
"in",
"self",
".",
"_host_keys",
".",... | Save the host keys back to a file. Only the host keys loaded with
L{load_host_keys} (plus any added directly) will be saved -- not any
host keys loaded with L{load_system_host_keys}.
@param filename: the filename to save to
@type filename: str
@raise IOError: if the file could... | [
"Save",
"the",
"host",
"keys",
"back",
"to",
"a",
"file",
".",
"Only",
"the",
"host",
"keys",
"loaded",
"with",
"L",
"{",
"load_host_keys",
"}",
"(",
"plus",
"any",
"added",
"directly",
")",
"will",
"be",
"saved",
"--",
"not",
"any",
"host",
"keys",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L179-L195 |
bitprophet/ssh | ssh/client.py | SSHClient.exec_command | def exec_command(self, command, bufsize=-1):
"""
Execute a command on the SSH server. A new L{Channel} is opened and
the requested command is executed. The command's input and output
streams are returned as python C{file}-like objects representing
stdin, stdout, and stderr.
... | python | def exec_command(self, command, bufsize=-1):
"""
Execute a command on the SSH server. A new L{Channel} is opened and
the requested command is executed. The command's input and output
streams are returned as python C{file}-like objects representing
stdin, stdout, and stderr.
... | [
"def",
"exec_command",
"(",
"self",
",",
"command",
",",
"bufsize",
"=",
"-",
"1",
")",
":",
"chan",
"=",
"self",
".",
"_transport",
".",
"open_session",
"(",
")",
"chan",
".",
"exec_command",
"(",
"command",
")",
"stdin",
"=",
"chan",
".",
"makefile",... | Execute a command on the SSH server. A new L{Channel} is opened and
the requested command is executed. The command's input and output
streams are returned as python C{file}-like objects representing
stdin, stdout, and stderr.
@param command: the command to execute
@type comman... | [
"Execute",
"a",
"command",
"on",
"the",
"SSH",
"server",
".",
"A",
"new",
"L",
"{",
"Channel",
"}",
"is",
"opened",
"and",
"the",
"requested",
"command",
"is",
"executed",
".",
"The",
"command",
"s",
"input",
"and",
"output",
"streams",
"are",
"returned"... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L348-L369 |
bitprophet/ssh | ssh/client.py | SSHClient._auth | def _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_keys):
"""
Try, in order:
- The key passed in, if one was passed in.
- Any key we can find through an SSH agent (if allowed).
- Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if all... | python | def _auth(self, username, password, pkey, key_filenames, allow_agent, look_for_keys):
"""
Try, in order:
- The key passed in, if one was passed in.
- Any key we can find through an SSH agent (if allowed).
- Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if all... | [
"def",
"_auth",
"(",
"self",
",",
"username",
",",
"password",
",",
"pkey",
",",
"key_filenames",
",",
"allow_agent",
",",
"look_for_keys",
")",
":",
"saved_exception",
"=",
"None",
"two_factor",
"=",
"False",
"allowed_types",
"=",
"[",
"]",
"if",
"pkey",
... | Try, in order:
- The key passed in, if one was passed in.
- Any key we can find through an SSH agent (if allowed).
- Any "id_rsa" or "id_dsa" key discoverable in ~/.ssh/ (if allowed).
- Plain username/password auth, if a password was given.
(The password might b... | [
"Try",
"in",
"order",
":"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/client.py#L413-L516 |
bitprophet/ssh | ssh/message.py | Message.get_bytes | def get_bytes(self, n):
"""
Return the next C{n} bytes of the Message, without decomposing into
an int, string, etc. Just the raw bytes are returned.
@return: a string of the next C{n} bytes of the Message, or a string
of C{n} zero bytes, if there aren't C{n} bytes remainin... | python | def get_bytes(self, n):
"""
Return the next C{n} bytes of the Message, without decomposing into
an int, string, etc. Just the raw bytes are returned.
@return: a string of the next C{n} bytes of the Message, or a string
of C{n} zero bytes, if there aren't C{n} bytes remainin... | [
"def",
"get_bytes",
"(",
"self",
",",
"n",
")",
":",
"b",
"=",
"self",
".",
"packet",
".",
"read",
"(",
"n",
")",
"if",
"len",
"(",
"b",
")",
"<",
"n",
":",
"return",
"b",
"+",
"'\\x00'",
"*",
"(",
"n",
"-",
"len",
"(",
"b",
")",
")",
"re... | Return the next C{n} bytes of the Message, without decomposing into
an int, string, etc. Just the raw bytes are returned.
@return: a string of the next C{n} bytes of the Message, or a string
of C{n} zero bytes, if there aren't C{n} bytes remaining.
@rtype: string | [
"Return",
"the",
"next",
"C",
"{",
"n",
"}",
"bytes",
"of",
"the",
"Message",
"without",
"decomposing",
"into",
"an",
"int",
"string",
"etc",
".",
"Just",
"the",
"raw",
"bytes",
"are",
"returned",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L103-L115 |
bitprophet/ssh | ssh/message.py | Message.add_int | def add_int(self, n):
"""
Add an integer to the stream.
@param n: integer to add
@type n: int
"""
self.packet.write(struct.pack('>I', n))
return self | python | def add_int(self, n):
"""
Add an integer to the stream.
@param n: integer to add
@type n: int
"""
self.packet.write(struct.pack('>I', n))
return self | [
"def",
"add_int",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"packet",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"'>I'",
",",
"n",
")",
")",
"return",
"self"
] | Add an integer to the stream.
@param n: integer to add
@type n: int | [
"Add",
"an",
"integer",
"to",
"the",
"stream",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L219-L227 |
bitprophet/ssh | ssh/message.py | Message.add_string | def add_string(self, s):
"""
Add a string to the stream.
@param s: string to add
@type s: str
"""
self.add_int(len(s))
self.packet.write(s)
return self | python | def add_string(self, s):
"""
Add a string to the stream.
@param s: string to add
@type s: str
"""
self.add_int(len(s))
self.packet.write(s)
return self | [
"def",
"add_string",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"add_int",
"(",
"len",
"(",
"s",
")",
")",
"self",
".",
"packet",
".",
"write",
"(",
"s",
")",
"return",
"self"
] | Add a string to the stream.
@param s: string to add
@type s: str | [
"Add",
"a",
"string",
"to",
"the",
"stream",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/message.py#L250-L259 |
bitprophet/ssh | ssh/channel.py | Channel.resize_pty | def resize_pty(self, width=80, height=24):
"""
Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous L{get_pty} call.
@param width: new width (in characters) of the terminal screen
@type width: int
@p... | python | def resize_pty(self, width=80, height=24):
"""
Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous L{get_pty} call.
@param width: new width (in characters) of the terminal screen
@type width: int
@p... | [
"def",
"resize_pty",
"(",
"self",
",",
"width",
"=",
"80",
",",
"height",
"=",
"24",
")",
":",
"if",
"self",
".",
"closed",
"or",
"self",
".",
"eof_received",
"or",
"self",
".",
"eof_sent",
"or",
"not",
"self",
".",
"active",
":",
"raise",
"SSHExcept... | Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous L{get_pty} call.
@param width: new width (in characters) of the terminal screen
@type width: int
@param height: new height (in characters) of the terminal screen
... | [
"Resize",
"the",
"pseudo",
"-",
"terminal",
".",
"This",
"can",
"be",
"used",
"to",
"change",
"the",
"width",
"and",
"height",
"of",
"the",
"terminal",
"emulation",
"created",
"in",
"a",
"previous",
"L",
"{",
"get_pty",
"}",
"call",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L242-L267 |
bitprophet/ssh | ssh/channel.py | Channel.recv_exit_status | def recv_exit_status(self):
"""
Return the exit status from the process on the server. This is
mostly useful for retrieving the reults of an L{exec_command}.
If the command hasn't finished yet, this method will wait until
it does, or until the channel is closed. If no exit stat... | python | def recv_exit_status(self):
"""
Return the exit status from the process on the server. This is
mostly useful for retrieving the reults of an L{exec_command}.
If the command hasn't finished yet, this method will wait until
it does, or until the channel is closed. If no exit stat... | [
"def",
"recv_exit_status",
"(",
"self",
")",
":",
"self",
".",
"status_event",
".",
"wait",
"(",
")",
"assert",
"self",
".",
"status_event",
".",
"isSet",
"(",
")",
"return",
"self",
".",
"exit_status"
] | Return the exit status from the process on the server. This is
mostly useful for retrieving the reults of an L{exec_command}.
If the command hasn't finished yet, this method will wait until
it does, or until the channel is closed. If no exit status is
provided by the server, -1 is retu... | [
"Return",
"the",
"exit",
"status",
"from",
"the",
"process",
"on",
"the",
"server",
".",
"This",
"is",
"mostly",
"useful",
"for",
"retrieving",
"the",
"reults",
"of",
"an",
"L",
"{",
"exec_command",
"}",
".",
"If",
"the",
"command",
"hasn",
"t",
"finishe... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L282-L297 |
bitprophet/ssh | ssh/channel.py | Channel.send_exit_status | def send_exit_status(self, status):
"""
Send the exit status of an executed command to the client. (This
really only makes sense in server mode.) Many clients expect to
get some sort of status code back from an executed command after
it completes.
@param status... | python | def send_exit_status(self, status):
"""
Send the exit status of an executed command to the client. (This
really only makes sense in server mode.) Many clients expect to
get some sort of status code back from an executed command after
it completes.
@param status... | [
"def",
"send_exit_status",
"(",
"self",
",",
"status",
")",
":",
"# in many cases, the channel will not still be open here.",
"# that's fine.",
"m",
"=",
"Message",
"(",
")",
"m",
".",
"add_byte",
"(",
"chr",
"(",
"MSG_CHANNEL_REQUEST",
")",
")",
"m",
".",
"add_in... | Send the exit status of an executed command to the client. (This
really only makes sense in server mode.) Many clients expect to
get some sort of status code back from an executed command after
it completes.
@param status: the exit code of the process
@type status: int... | [
"Send",
"the",
"exit",
"status",
"of",
"an",
"executed",
"command",
"to",
"the",
"client",
".",
"(",
"This",
"really",
"only",
"makes",
"sense",
"in",
"server",
"mode",
".",
")",
"Many",
"clients",
"expect",
"to",
"get",
"some",
"sort",
"of",
"status",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L299-L319 |
bitprophet/ssh | ssh/channel.py | Channel.recv | def recv(self, nbytes):
"""
Receive data from the channel. The return value is a string
representing the data received. The maximum amount of data to be
received at once is specified by C{nbytes}. If a string of length zero
is returned, the channel stream has closed.
... | python | def recv(self, nbytes):
"""
Receive data from the channel. The return value is a string
representing the data received. The maximum amount of data to be
received at once is specified by C{nbytes}. If a string of length zero
is returned, the channel stream has closed.
... | [
"def",
"recv",
"(",
"self",
",",
"nbytes",
")",
":",
"try",
":",
"out",
"=",
"self",
".",
"in_buffer",
".",
"read",
"(",
"nbytes",
",",
"self",
".",
"timeout",
")",
"except",
"PipeTimeout",
",",
"e",
":",
"raise",
"socket",
".",
"timeout",
"(",
")"... | Receive data from the channel. The return value is a string
representing the data received. The maximum amount of data to be
received at once is specified by C{nbytes}. If a string of length zero
is returned, the channel stream has closed.
@param nbytes: maximum number of bytes to re... | [
"Receive",
"data",
"from",
"the",
"channel",
".",
"The",
"return",
"value",
"is",
"a",
"string",
"representing",
"the",
"data",
"received",
".",
"The",
"maximum",
"amount",
"of",
"data",
"to",
"be",
"received",
"at",
"once",
"is",
"specified",
"by",
"C",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L593-L622 |
bitprophet/ssh | ssh/channel.py | Channel.sendall | def sendall(self, s):
"""
Send data to the channel, without allowing partial results. Unlike
L{send}, this method continues to send data from the given string until
either all data has been sent or an error occurs. Nothing is returned.
@param s: data to send.
@type s: ... | python | def sendall(self, s):
"""
Send data to the channel, without allowing partial results. Unlike
L{send}, this method continues to send data from the given string until
either all data has been sent or an error occurs. Nothing is returned.
@param s: data to send.
@type s: ... | [
"def",
"sendall",
"(",
"self",
",",
"s",
")",
":",
"while",
"s",
":",
"if",
"self",
".",
"closed",
":",
"# this doesn't seem useful, but it is the documented behavior of Socket",
"raise",
"socket",
".",
"error",
"(",
"'Socket is closed'",
")",
"sent",
"=",
"self",... | Send data to the channel, without allowing partial results. Unlike
L{send}, this method continues to send data from the given string until
either all data has been sent or an error occurs. Nothing is returned.
@param s: data to send.
@type s: str
@raise socket.timeout: if sen... | [
"Send",
"data",
"to",
"the",
"channel",
"without",
"allowing",
"partial",
"results",
".",
"Unlike",
"L",
"{",
"send",
"}",
"this",
"method",
"continues",
"to",
"send",
"data",
"from",
"the",
"given",
"string",
"until",
"either",
"all",
"data",
"has",
"been... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L767-L791 |
bitprophet/ssh | ssh/channel.py | Channel.sendall_stderr | def sendall_stderr(self, s):
"""
Send data to the channel's "stderr" stream, without allowing partial
results. Unlike L{send_stderr}, this method continues to send data
from the given string until all data has been sent or an error occurs.
Nothing is returned.
@... | python | def sendall_stderr(self, s):
"""
Send data to the channel's "stderr" stream, without allowing partial
results. Unlike L{send_stderr}, this method continues to send data
from the given string until all data has been sent or an error occurs.
Nothing is returned.
@... | [
"def",
"sendall_stderr",
"(",
"self",
",",
"s",
")",
":",
"while",
"s",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"socket",
".",
"error",
"(",
"'Socket is closed'",
")",
"sent",
"=",
"self",
".",
"send_stderr",
"(",
"s",
")",
"s",
"=",
"s",
"... | Send data to the channel's "stderr" stream, without allowing partial
results. Unlike L{send_stderr}, this method continues to send data
from the given string until all data has been sent or an error occurs.
Nothing is returned.
@param s: data to send to the client as "stderr" o... | [
"Send",
"data",
"to",
"the",
"channel",
"s",
"stderr",
"stream",
"without",
"allowing",
"partial",
"results",
".",
"Unlike",
"L",
"{",
"send_stderr",
"}",
"this",
"method",
"continues",
"to",
"send",
"data",
"from",
"the",
"given",
"string",
"until",
"all",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/channel.py#L793-L815 |
bitprophet/ssh | demos/demo.py | agent_auth | def agent_auth(transport, username):
"""
Attempt to authenticate to the given transport using any of the private
keys available from an SSH agent.
"""
agent = ssh.Agent()
agent_keys = agent.get_keys()
if len(agent_keys) == 0:
return
for key in agent_keys:
pr... | python | def agent_auth(transport, username):
"""
Attempt to authenticate to the given transport using any of the private
keys available from an SSH agent.
"""
agent = ssh.Agent()
agent_keys = agent.get_keys()
if len(agent_keys) == 0:
return
for key in agent_keys:
pr... | [
"def",
"agent_auth",
"(",
"transport",
",",
"username",
")",
":",
"agent",
"=",
"ssh",
".",
"Agent",
"(",
")",
"agent_keys",
"=",
"agent",
".",
"get_keys",
"(",
")",
"if",
"len",
"(",
"agent_keys",
")",
"==",
"0",
":",
"return",
"for",
"key",
"in",
... | Attempt to authenticate to the given transport using any of the private
keys available from an SSH agent. | [
"Attempt",
"to",
"authenticate",
"to",
"the",
"given",
"transport",
"using",
"any",
"of",
"the",
"private",
"keys",
"available",
"from",
"an",
"SSH",
"agent",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/demos/demo.py#L37-L55 |
bitprophet/ssh | ssh/sftp_file.py | SFTPFile._read_prefetch | def _read_prefetch(self, size):
"""
read data out of the prefetch buffer, if possible. if the data isn't
in the buffer, return None. otherwise, behaves like a normal read.
"""
# while not closed, and haven't fetched past the current position, and haven't reached EOF...
... | python | def _read_prefetch(self, size):
"""
read data out of the prefetch buffer, if possible. if the data isn't
in the buffer, return None. otherwise, behaves like a normal read.
"""
# while not closed, and haven't fetched past the current position, and haven't reached EOF...
... | [
"def",
"_read_prefetch",
"(",
"self",
",",
"size",
")",
":",
"# while not closed, and haven't fetched past the current position, and haven't reached EOF...",
"while",
"True",
":",
"offset",
"=",
"self",
".",
"_data_in_prefetch_buffers",
"(",
"self",
".",
"_realpos",
")",
... | read data out of the prefetch buffer, if possible. if the data isn't
in the buffer, return None. otherwise, behaves like a normal read. | [
"read",
"data",
"out",
"of",
"the",
"prefetch",
"buffer",
"if",
"possible",
".",
"if",
"the",
"data",
"isn",
"t",
"in",
"the",
"buffer",
"return",
"None",
".",
"otherwise",
"behaves",
"like",
"a",
"normal",
"read",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L120-L147 |
bitprophet/ssh | ssh/sftp_file.py | SFTPFile.chmod | def chmod(self, mode):
"""
Change the mode (permissions) of this file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param mode: new permissions
@type mode: int
"""
self.sftp._log(DEBUG, 'chmod(%s, %r)' % (... | python | def chmod(self, mode):
"""
Change the mode (permissions) of this file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param mode: new permissions
@type mode: int
"""
self.sftp._log(DEBUG, 'chmod(%s, %r)' % (... | [
"def",
"chmod",
"(",
"self",
",",
"mode",
")",
":",
"self",
".",
"sftp",
".",
"_log",
"(",
"DEBUG",
",",
"'chmod(%s, %r)'",
"%",
"(",
"hexlify",
"(",
"self",
".",
"handle",
")",
",",
"mode",
")",
")",
"attr",
"=",
"SFTPAttributes",
"(",
")",
"attr"... | Change the mode (permissions) of this file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param mode: new permissions
@type mode: int | [
"Change",
"the",
"mode",
"(",
"permissions",
")",
"of",
"this",
"file",
".",
"The",
"permissions",
"are",
"unix",
"-",
"style",
"and",
"identical",
"to",
"those",
"used",
"by",
"python",
"s",
"C",
"{",
"os",
".",
"chmod",
"}",
"function",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L230-L242 |
bitprophet/ssh | ssh/sftp_file.py | SFTPFile.chown | def chown(self, uid, gid):
"""
Change the owner (C{uid}) and group (C{gid}) of this file. As with
python's C{os.chown} function, you must pass both arguments, so if you
only want to change one, use L{stat} first to retrieve the current
owner and group.
@param uid: new o... | python | def chown(self, uid, gid):
"""
Change the owner (C{uid}) and group (C{gid}) of this file. As with
python's C{os.chown} function, you must pass both arguments, so if you
only want to change one, use L{stat} first to retrieve the current
owner and group.
@param uid: new o... | [
"def",
"chown",
"(",
"self",
",",
"uid",
",",
"gid",
")",
":",
"self",
".",
"sftp",
".",
"_log",
"(",
"DEBUG",
",",
"'chown(%s, %r, %r)'",
"%",
"(",
"hexlify",
"(",
"self",
".",
"handle",
")",
",",
"uid",
",",
"gid",
")",
")",
"attr",
"=",
"SFTPA... | Change the owner (C{uid}) and group (C{gid}) of this file. As with
python's C{os.chown} function, you must pass both arguments, so if you
only want to change one, use L{stat} first to retrieve the current
owner and group.
@param uid: new owner's uid
@type uid: int
@para... | [
"Change",
"the",
"owner",
"(",
"C",
"{",
"uid",
"}",
")",
"and",
"group",
"(",
"C",
"{",
"gid",
"}",
")",
"of",
"this",
"file",
".",
"As",
"with",
"python",
"s",
"C",
"{",
"os",
".",
"chown",
"}",
"function",
"you",
"must",
"pass",
"both",
"arg... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L244-L259 |
bitprophet/ssh | ssh/sftp_file.py | SFTPFile.utime | def utime(self, times):
"""
Set the access and modified times of this file. If
C{times} is C{None}, then the file's access and modified times are set
to the current time. Otherwise, C{times} must be a 2-tuple of numbers,
of the form C{(atime, mtime)}, which is used to set the a... | python | def utime(self, times):
"""
Set the access and modified times of this file. If
C{times} is C{None}, then the file's access and modified times are set
to the current time. Otherwise, C{times} must be a 2-tuple of numbers,
of the form C{(atime, mtime)}, which is used to set the a... | [
"def",
"utime",
"(",
"self",
",",
"times",
")",
":",
"if",
"times",
"is",
"None",
":",
"times",
"=",
"(",
"time",
".",
"time",
"(",
")",
",",
"time",
".",
"time",
"(",
")",
")",
"self",
".",
"sftp",
".",
"_log",
"(",
"DEBUG",
",",
"'utime(%s, %... | Set the access and modified times of this file. If
C{times} is C{None}, then the file's access and modified times are set
to the current time. Otherwise, C{times} must be a 2-tuple of numbers,
of the form C{(atime, mtime)}, which is used to set the access and
modified times, respective... | [
"Set",
"the",
"access",
"and",
"modified",
"times",
"of",
"this",
"file",
".",
"If",
"C",
"{",
"times",
"}",
"is",
"C",
"{",
"None",
"}",
"then",
"the",
"file",
"s",
"access",
"and",
"modified",
"times",
"are",
"set",
"to",
"the",
"current",
"time",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_file.py#L261-L279 |
bitprophet/ssh | ssh/file.py | BufferedFile.flush | def flush(self):
"""
Write out any data in the write buffer. This may do nothing if write
buffering is not turned on.
"""
self._write_all(self._wbuffer.getvalue())
self._wbuffer = StringIO()
return | python | def flush(self):
"""
Write out any data in the write buffer. This may do nothing if write
buffering is not turned on.
"""
self._write_all(self._wbuffer.getvalue())
self._wbuffer = StringIO()
return | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"_write_all",
"(",
"self",
".",
"_wbuffer",
".",
"getvalue",
"(",
")",
")",
"self",
".",
"_wbuffer",
"=",
"StringIO",
"(",
")",
"return"
] | Write out any data in the write buffer. This may do nothing if write
buffering is not turned on. | [
"Write",
"out",
"any",
"data",
"in",
"the",
"write",
"buffer",
".",
"This",
"may",
"do",
"nothing",
"if",
"write",
"buffering",
"is",
"not",
"turned",
"on",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L86-L93 |
bitprophet/ssh | ssh/file.py | BufferedFile.readline | def readline(self, size=None):
"""
Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the tr... | python | def readline(self, size=None):
"""
Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the tr... | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"# it's almost silly how complex this function is.",
"if",
"self",
".",
"_closed",
":",
"raise",
"IOError",
"(",
"'File is closed'",
")",
"if",
"not",
"(",
"self",
".",
"_flags",
"&",
"self",
... | Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the trailing newline) and an
incomplete line may ... | [
"Read",
"one",
"entire",
"line",
"from",
"the",
"file",
".",
"A",
"trailing",
"newline",
"character",
"is",
"kept",
"in",
"the",
"string",
"(",
"but",
"may",
"be",
"absent",
"when",
"a",
"file",
"ends",
"with",
"an",
"incomplete",
"line",
")",
".",
"If... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L165-L242 |
bitprophet/ssh | ssh/file.py | BufferedFile._set_mode | def _set_mode(self, mode='r', bufsize=-1):
"""
Subclasses call this method to initialize the BufferedFile.
"""
# set bufsize in any event, because it's used for readline().
self._bufsize = self._DEFAULT_BUFSIZE
if bufsize < 0:
# do no buffering by default, bec... | python | def _set_mode(self, mode='r', bufsize=-1):
"""
Subclasses call this method to initialize the BufferedFile.
"""
# set bufsize in any event, because it's used for readline().
self._bufsize = self._DEFAULT_BUFSIZE
if bufsize < 0:
# do no buffering by default, bec... | [
"def",
"_set_mode",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"bufsize",
"=",
"-",
"1",
")",
":",
"# set bufsize in any event, because it's used for readline().",
"self",
".",
"_bufsize",
"=",
"self",
".",
"_DEFAULT_BUFSIZE",
"if",
"bufsize",
"<",
"0",
":",
"... | Subclasses call this method to initialize the BufferedFile. | [
"Subclasses",
"call",
"this",
"method",
"to",
"initialize",
"the",
"BufferedFile",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L391-L429 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.from_transport | def from_transport(cls, t):
"""
Create an SFTP client channel from an open L{Transport}.
@param t: an open L{Transport} which is already authenticated
@type t: L{Transport}
@return: a new L{SFTPClient} object, referring to an sftp session
(channel) across the transpo... | python | def from_transport(cls, t):
"""
Create an SFTP client channel from an open L{Transport}.
@param t: an open L{Transport} which is already authenticated
@type t: L{Transport}
@return: a new L{SFTPClient} object, referring to an sftp session
(channel) across the transpo... | [
"def",
"from_transport",
"(",
"cls",
",",
"t",
")",
":",
"chan",
"=",
"t",
".",
"open_session",
"(",
")",
"if",
"chan",
"is",
"None",
":",
"return",
"None",
"chan",
".",
"invoke_subsystem",
"(",
"'sftp'",
")",
"return",
"cls",
"(",
"chan",
")"
] | Create an SFTP client channel from an open L{Transport}.
@param t: an open L{Transport} which is already authenticated
@type t: L{Transport}
@return: a new L{SFTPClient} object, referring to an sftp session
(channel) across the transport
@rtype: L{SFTPClient} | [
"Create",
"an",
"SFTP",
"client",
"channel",
"from",
"an",
"open",
"L",
"{",
"Transport",
"}",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L92-L106 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.listdir_attr | def listdir_attr(self, path='.'):
"""
Return a list containing L{SFTPAttributes} objects corresponding to
files in the given C{path}. The list is in arbitrary order. It does
not include the special entries C{'.'} and C{'..'} even if they are
present in the folder.
The ... | python | def listdir_attr(self, path='.'):
"""
Return a list containing L{SFTPAttributes} objects corresponding to
files in the given C{path}. The list is in arbitrary order. It does
not include the special entries C{'.'} and C{'..'} even if they are
present in the folder.
The ... | [
"def",
"listdir_attr",
"(",
"self",
",",
"path",
"=",
"'.'",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'listdir(%r)'",
"%",
"path",
")",
"t",
",",
"msg",
"=",
"self",
".",
"_reques... | Return a list containing L{SFTPAttributes} objects corresponding to
files in the given C{path}. The list is in arbitrary order. It does
not include the special entries C{'.'} and C{'..'} even if they are
present in the folder.
The returned L{SFTPAttributes} objects will each have an a... | [
"Return",
"a",
"list",
"containing",
"L",
"{",
"SFTPAttributes",
"}",
"objects",
"corresponding",
"to",
"files",
"in",
"the",
"given",
"C",
"{",
"path",
"}",
".",
"The",
"list",
"is",
"in",
"arbitrary",
"order",
".",
"It",
"does",
"not",
"include",
"the"... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L152-L194 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.remove | def remove(self, path):
"""
Remove the file at the given path. This only works on files; for
removing folders (directories), use L{rmdir}.
@param path: path (absolute or relative) of the file to remove
@type path: str
@raise IOError: if the path refers to a folder (dir... | python | def remove(self, path):
"""
Remove the file at the given path. This only works on files; for
removing folders (directories), use L{rmdir}.
@param path: path (absolute or relative) of the file to remove
@type path: str
@raise IOError: if the path refers to a folder (dir... | [
"def",
"remove",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'remove(%r)'",
"%",
"path",
")",
"self",
".",
"_request",
"(",
"CMD_REMOVE",
",",
"path",
")"
] | Remove the file at the given path. This only works on files; for
removing folders (directories), use L{rmdir}.
@param path: path (absolute or relative) of the file to remove
@type path: str
@raise IOError: if the path refers to a folder (directory) | [
"Remove",
"the",
"file",
"at",
"the",
"given",
"path",
".",
"This",
"only",
"works",
"on",
"files",
";",
"for",
"removing",
"folders",
"(",
"directories",
")",
"use",
"L",
"{",
"rmdir",
"}",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L255-L267 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.rmdir | def rmdir(self, path):
"""
Remove the folder named C{path}.
@param path: name of the folder to remove
@type path: str
"""
path = self._adjust_cwd(path)
self._log(DEBUG, 'rmdir(%r)' % path)
self._request(CMD_RMDIR, path) | python | def rmdir(self, path):
"""
Remove the folder named C{path}.
@param path: name of the folder to remove
@type path: str
"""
path = self._adjust_cwd(path)
self._log(DEBUG, 'rmdir(%r)' % path)
self._request(CMD_RMDIR, path) | [
"def",
"rmdir",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'rmdir(%r)'",
"%",
"path",
")",
"self",
".",
"_request",
"(",
"CMD_RMDIR",
",",
"path",
")"
] | Remove the folder named C{path}.
@param path: name of the folder to remove
@type path: str | [
"Remove",
"the",
"folder",
"named",
"C",
"{",
"path",
"}",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L305-L314 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.stat | def stat(self, path):
"""
Retrieve information about a file on the remote system. The return
value is an object whose attributes correspond to the attributes of
python's C{stat} structure as returned by C{os.stat}, except that it
contains fewer fields. An SFTP server may return... | python | def stat(self, path):
"""
Retrieve information about a file on the remote system. The return
value is an object whose attributes correspond to the attributes of
python's C{stat} structure as returned by C{os.stat}, except that it
contains fewer fields. An SFTP server may return... | [
"def",
"stat",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'stat(%r)'",
"%",
"path",
")",
"t",
",",
"msg",
"=",
"self",
".",
"_request",
"(",
"CMD_STAT",
... | Retrieve information about a file on the remote system. The return
value is an object whose attributes correspond to the attributes of
python's C{stat} structure as returned by C{os.stat}, except that it
contains fewer fields. An SFTP server may return as much or as little
info as it w... | [
"Retrieve",
"information",
"about",
"a",
"file",
"on",
"the",
"remote",
"system",
".",
"The",
"return",
"value",
"is",
"an",
"object",
"whose",
"attributes",
"correspond",
"to",
"the",
"attributes",
"of",
"python",
"s",
"C",
"{",
"stat",
"}",
"structure",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L316-L340 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.lstat | def lstat(self, path):
"""
Retrieve information about a file on the remote system, without
following symbolic links (shortcuts). This otherwise behaves exactly
the same as L{stat}.
@param path: the filename to stat
@type path: str
@return: an object containing a... | python | def lstat(self, path):
"""
Retrieve information about a file on the remote system, without
following symbolic links (shortcuts). This otherwise behaves exactly
the same as L{stat}.
@param path: the filename to stat
@type path: str
@return: an object containing a... | [
"def",
"lstat",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'lstat(%r)'",
"%",
"path",
")",
"t",
",",
"msg",
"=",
"self",
".",
"_request",
"(",
"CMD_LSTAT",... | Retrieve information about a file on the remote system, without
following symbolic links (shortcuts). This otherwise behaves exactly
the same as L{stat}.
@param path: the filename to stat
@type path: str
@return: an object containing attributes about the given file
@rty... | [
"Retrieve",
"information",
"about",
"a",
"file",
"on",
"the",
"remote",
"system",
"without",
"following",
"symbolic",
"links",
"(",
"shortcuts",
")",
".",
"This",
"otherwise",
"behaves",
"exactly",
"the",
"same",
"as",
"L",
"{",
"stat",
"}",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L342-L358 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.symlink | def symlink(self, source, dest):
"""
Create a symbolic link (shortcut) of the C{source} path at
C{destination}.
@param source: path of the original file
@type source: str
@param dest: path of the newly created symlink
@type dest: str
"""
dest = se... | python | def symlink(self, source, dest):
"""
Create a symbolic link (shortcut) of the C{source} path at
C{destination}.
@param source: path of the original file
@type source: str
@param dest: path of the newly created symlink
@type dest: str
"""
dest = se... | [
"def",
"symlink",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"dest",
"=",
"self",
".",
"_adjust_cwd",
"(",
"dest",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'symlink(%r, %r)'",
"%",
"(",
"source",
",",
"dest",
")",
")",
"if",
"type",
"(... | Create a symbolic link (shortcut) of the C{source} path at
C{destination}.
@param source: path of the original file
@type source: str
@param dest: path of the newly created symlink
@type dest: str | [
"Create",
"a",
"symbolic",
"link",
"(",
"shortcut",
")",
"of",
"the",
"C",
"{",
"source",
"}",
"path",
"at",
"C",
"{",
"destination",
"}",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L360-L374 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.chmod | def chmod(self, path, mode):
"""
Change the mode (permissions) of a file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param path: path of the file to change the permissions of
@type path: str
@param mode: new per... | python | def chmod(self, path, mode):
"""
Change the mode (permissions) of a file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param path: path of the file to change the permissions of
@type path: str
@param mode: new per... | [
"def",
"chmod",
"(",
"self",
",",
"path",
",",
"mode",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'chmod(%r, %r)'",
"%",
"(",
"path",
",",
"mode",
")",
")",
"attr",
"=",
"SFTPAttrib... | Change the mode (permissions) of a file. The permissions are
unix-style and identical to those used by python's C{os.chmod}
function.
@param path: path of the file to change the permissions of
@type path: str
@param mode: new permissions
@type mode: int | [
"Change",
"the",
"mode",
"(",
"permissions",
")",
"of",
"a",
"file",
".",
"The",
"permissions",
"are",
"unix",
"-",
"style",
"and",
"identical",
"to",
"those",
"used",
"by",
"python",
"s",
"C",
"{",
"os",
".",
"chmod",
"}",
"function",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L376-L391 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.readlink | def readlink(self, path):
"""
Return the target of a symbolic link (shortcut). You can use
L{symlink} to create these. The result may be either an absolute or
relative pathname.
@param path: path of the symbolic link file
@type path: str
@return: target path
... | python | def readlink(self, path):
"""
Return the target of a symbolic link (shortcut). You can use
L{symlink} to create these. The result may be either an absolute or
relative pathname.
@param path: path of the symbolic link file
@type path: str
@return: target path
... | [
"def",
"readlink",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'readlink(%r)'",
"%",
"path",
")",
"t",
",",
"msg",
"=",
"self",
".",
"_request",
"(",
"CMD_R... | Return the target of a symbolic link (shortcut). You can use
L{symlink} to create these. The result may be either an absolute or
relative pathname.
@param path: path of the symbolic link file
@type path: str
@return: target path
@rtype: str | [
"Return",
"the",
"target",
"of",
"a",
"symbolic",
"link",
"(",
"shortcut",
")",
".",
"You",
"can",
"use",
"L",
"{",
"symlink",
"}",
"to",
"create",
"these",
".",
"The",
"result",
"may",
"be",
"either",
"an",
"absolute",
"or",
"relative",
"pathname",
".... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L453-L474 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.normalize | def normalize(self, path):
"""
Return the normalized path (on the server) of a given path. This
can be used to quickly resolve symbolic links or determine what the
server is considering to be the "current folder" (by passing C{'.'}
as C{path}).
@param path: path to be n... | python | def normalize(self, path):
"""
Return the normalized path (on the server) of a given path. This
can be used to quickly resolve symbolic links or determine what the
server is considering to be the "current folder" (by passing C{'.'}
as C{path}).
@param path: path to be n... | [
"def",
"normalize",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"self",
".",
"_adjust_cwd",
"(",
"path",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'normalize(%r)'",
"%",
"path",
")",
"t",
",",
"msg",
"=",
"self",
".",
"_request",
"(",
"CMD... | Return the normalized path (on the server) of a given path. This
can be used to quickly resolve symbolic links or determine what the
server is considering to be the "current folder" (by passing C{'.'}
as C{path}).
@param path: path to be normalized
@type path: str
@retu... | [
"Return",
"the",
"normalized",
"path",
"(",
"on",
"the",
"server",
")",
"of",
"a",
"given",
"path",
".",
"This",
"can",
"be",
"used",
"to",
"quickly",
"resolve",
"symbolic",
"links",
"or",
"determine",
"what",
"the",
"server",
"is",
"considering",
"to",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L476-L498 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient.get | def get(self, remotepath, localpath, callback=None):
"""
Copy a remote file (C{remotepath}) from the SFTP server to the local
host as C{localpath}. Any exception raised by operations will be
passed through. This method is primarily provided as a convenience.
@param remotepath:... | python | def get(self, remotepath, localpath, callback=None):
"""
Copy a remote file (C{remotepath}) from the SFTP server to the local
host as C{localpath}. Any exception raised by operations will be
passed through. This method is primarily provided as a convenience.
@param remotepath:... | [
"def",
"get",
"(",
"self",
",",
"remotepath",
",",
"localpath",
",",
"callback",
"=",
"None",
")",
":",
"fr",
"=",
"self",
".",
"file",
"(",
"remotepath",
",",
"'rb'",
")",
"file_size",
"=",
"self",
".",
"stat",
"(",
"remotepath",
")",
".",
"st_size"... | Copy a remote file (C{remotepath}) from the SFTP server to the local
host as C{localpath}. Any exception raised by operations will be
passed through. This method is primarily provided as a convenience.
@param remotepath: the remote file to copy
@type remotepath: str
@param loc... | [
"Copy",
"a",
"remote",
"file",
"(",
"C",
"{",
"remotepath",
"}",
")",
"from",
"the",
"SFTP",
"server",
"to",
"the",
"local",
"host",
"as",
"C",
"{",
"localpath",
"}",
".",
"Any",
"exception",
"raised",
"by",
"operations",
"will",
"be",
"passed",
"throu... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L589-L627 |
bitprophet/ssh | ssh/sftp_client.py | SFTPClient._adjust_cwd | def _adjust_cwd(self, path):
"""
Return an adjusted path if we're emulating a "current working
directory" for the server.
"""
if type(path) is unicode:
path = path.encode('utf-8')
if self._cwd is None:
return path
if (len(path) > 0) and (pa... | python | def _adjust_cwd(self, path):
"""
Return an adjusted path if we're emulating a "current working
directory" for the server.
"""
if type(path) is unicode:
path = path.encode('utf-8')
if self._cwd is None:
return path
if (len(path) > 0) and (pa... | [
"def",
"_adjust_cwd",
"(",
"self",
",",
"path",
")",
":",
"if",
"type",
"(",
"path",
")",
"is",
"unicode",
":",
"path",
"=",
"path",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"self",
".",
"_cwd",
"is",
"None",
":",
"return",
"path",
"if",
"(",
"l... | Return an adjusted path if we're emulating a "current working
directory" for the server. | [
"Return",
"an",
"adjusted",
"path",
"if",
"we",
"re",
"emulating",
"a",
"current",
"working",
"directory",
"for",
"the",
"server",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_client.py#L714-L728 |
bitprophet/ssh | ssh/resource.py | ResourceManager.register | def register(self, obj, resource):
"""
Register a resource to be closed with an object is collected.
When the given C{obj} is garbage-collected by the python interpreter,
the C{resource} will be closed by having its C{close()} method called.
Any exceptions are ignored.
... | python | def register(self, obj, resource):
"""
Register a resource to be closed with an object is collected.
When the given C{obj} is garbage-collected by the python interpreter,
the C{resource} will be closed by having its C{close()} method called.
Any exceptions are ignored.
... | [
"def",
"register",
"(",
"self",
",",
"obj",
",",
"resource",
")",
":",
"def",
"callback",
"(",
"ref",
")",
":",
"try",
":",
"resource",
".",
"close",
"(",
")",
"except",
":",
"pass",
"del",
"self",
".",
"_table",
"[",
"id",
"(",
"resource",
")",
... | Register a resource to be closed with an object is collected.
When the given C{obj} is garbage-collected by the python interpreter,
the C{resource} will be closed by having its C{close()} method called.
Any exceptions are ignored.
@param obj: the object to track
... | [
"Register",
"a",
"resource",
"to",
"be",
"closed",
"with",
"an",
"object",
"is",
"collected",
".",
"When",
"the",
"given",
"C",
"{",
"obj",
"}",
"is",
"garbage",
"-",
"collected",
"by",
"the",
"python",
"interpreter",
"the",
"C",
"{",
"resource",
"}",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/resource.py#L46-L68 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray._request | def _request(self, method, path, data=None, reestablish_session=True):
"""Perform HTTP request for REST API."""
if path.startswith("http"):
url = path # For cases where URL of different form is needed.
else:
url = self._format_path(path)
headers = {"Content-Type... | python | def _request(self, method, path, data=None, reestablish_session=True):
"""Perform HTTP request for REST API."""
if path.startswith("http"):
url = path # For cases where URL of different form is needed.
else:
url = self._format_path(path)
headers = {"Content-Type... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
"=",
"None",
",",
"reestablish_session",
"=",
"True",
")",
":",
"if",
"path",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"url",
"=",
"path",
"# For cases where URL of different form ... | Perform HTTP request for REST API. | [
"Perform",
"HTTP",
"request",
"for",
"REST",
"API",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L149-L196 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray._check_rest_version | def _check_rest_version(self, version):
"""Validate a REST API version is supported by the library and target array."""
version = str(version)
if version not in self.supported_rest_versions:
msg = "Library is incompatible with REST API version {0}"
raise ValueError(msg.f... | python | def _check_rest_version(self, version):
"""Validate a REST API version is supported by the library and target array."""
version = str(version)
if version not in self.supported_rest_versions:
msg = "Library is incompatible with REST API version {0}"
raise ValueError(msg.f... | [
"def",
"_check_rest_version",
"(",
"self",
",",
"version",
")",
":",
"version",
"=",
"str",
"(",
"version",
")",
"if",
"version",
"not",
"in",
"self",
".",
"supported_rest_versions",
":",
"msg",
"=",
"\"Library is incompatible with REST API version {0}\"",
"raise",
... | Validate a REST API version is supported by the library and target array. | [
"Validate",
"a",
"REST",
"API",
"version",
"is",
"supported",
"by",
"the",
"library",
"and",
"target",
"array",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L202-L215 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray._choose_rest_version | def _choose_rest_version(self):
"""Return the newest REST API version supported by target array."""
versions = self._list_available_rest_versions()
versions = [LooseVersion(x) for x in versions if x in self.supported_rest_versions]
if versions:
return max(versions)
el... | python | def _choose_rest_version(self):
"""Return the newest REST API version supported by target array."""
versions = self._list_available_rest_versions()
versions = [LooseVersion(x) for x in versions if x in self.supported_rest_versions]
if versions:
return max(versions)
el... | [
"def",
"_choose_rest_version",
"(",
"self",
")",
":",
"versions",
"=",
"self",
".",
"_list_available_rest_versions",
"(",
")",
"versions",
"=",
"[",
"LooseVersion",
"(",
"x",
")",
"for",
"x",
"in",
"versions",
"if",
"x",
"in",
"self",
".",
"supported_rest_ve... | Return the newest REST API version supported by target array. | [
"Return",
"the",
"newest",
"REST",
"API",
"version",
"supported",
"by",
"target",
"array",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L217-L226 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray._list_available_rest_versions | def _list_available_rest_versions(self):
"""Return a list of the REST API versions supported by the array"""
url = "https://{0}/api/api_version".format(self._target)
data = self._request("GET", url, reestablish_session=False)
return data["version"] | python | def _list_available_rest_versions(self):
"""Return a list of the REST API versions supported by the array"""
url = "https://{0}/api/api_version".format(self._target)
data = self._request("GET", url, reestablish_session=False)
return data["version"] | [
"def",
"_list_available_rest_versions",
"(",
"self",
")",
":",
"url",
"=",
"\"https://{0}/api/api_version\"",
".",
"format",
"(",
"self",
".",
"_target",
")",
"data",
"=",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"url",
",",
"reestablish_session",
"=",
"F... | Return a list of the REST API versions supported by the array | [
"Return",
"a",
"list",
"of",
"the",
"REST",
"API",
"versions",
"supported",
"by",
"the",
"array"
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L228-L233 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray._obtain_api_token | def _obtain_api_token(self, username, password):
"""Use username and password to obtain and return an API token."""
data = self._request("POST", "auth/apitoken",
{"username": username, "password": password},
reestablish_session=False)
ret... | python | def _obtain_api_token(self, username, password):
"""Use username and password to obtain and return an API token."""
data = self._request("POST", "auth/apitoken",
{"username": username, "password": password},
reestablish_session=False)
ret... | [
"def",
"_obtain_api_token",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"data",
"=",
"self",
".",
"_request",
"(",
"\"POST\"",
",",
"\"auth/apitoken\"",
",",
"{",
"\"username\"",
":",
"username",
",",
"\"password\"",
":",
"password",
"}",
",",
... | Use username and password to obtain and return an API token. | [
"Use",
"username",
"and",
"password",
"to",
"obtain",
"and",
"return",
"an",
"API",
"token",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L235-L240 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_snapshots | def create_snapshots(self, volumes, **kwargs):
"""Create snapshots of the listed volumes.
:param volumes: List of names of the volumes to snapshot.
:type volumes: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the ... | python | def create_snapshots(self, volumes, **kwargs):
"""Create snapshots of the listed volumes.
:param volumes: List of names of the volumes to snapshot.
:type volumes: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the ... | [
"def",
"create_snapshots",
"(",
"self",
",",
"volumes",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"source\"",
":",
"volumes",
",",
"\"snap\"",
":",
"True",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
... | Create snapshots of the listed volumes.
:param volumes: List of names of the volumes to snapshot.
:type volumes: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**POST volume**
... | [
"Create",
"snapshots",
"of",
"the",
"listed",
"volumes",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L381-L397 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_volume | def create_volume(self, volume, size, **kwargs):
"""Create a volume and return a dictionary describing it.
:param volume: Name of the volume to be created.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
... | python | def create_volume(self, volume, size, **kwargs):
"""Create a volume and return a dictionary describing it.
:param volume: Name of the volume to be created.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
... | [
"def",
"create_volume",
"(",
"self",
",",
"volume",
",",
"size",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"size\"",
":",
"size",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
",",
... | Create a volume and return a dictionary describing it.
:param volume: Name of the volume to be created.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
:type size: int or str
:param \*\*kwargs: See t... | [
"Create",
"a",
"volume",
"and",
"return",
"a",
"dictionary",
"describing",
"it",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L399-L444 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.extend_volume | def extend_volume(self, volume, size):
"""Extend a volume to a new, larger size.
:param volume: Name of the volume to be extended.
:type volume: str
:type size: int or str
:param size: Size in bytes, or string representing the size of the
volume to be create... | python | def extend_volume(self, volume, size):
"""Extend a volume to a new, larger size.
:param volume: Name of the volume to be extended.
:type volume: str
:type size: int or str
:param size: Size in bytes, or string representing the size of the
volume to be create... | [
"def",
"extend_volume",
"(",
"self",
",",
"volume",
",",
"size",
")",
":",
"return",
"self",
".",
"set_volume",
"(",
"volume",
",",
"size",
"=",
"size",
",",
"truncate",
"=",
"False",
")"
] | Extend a volume to a new, larger size.
:param volume: Name of the volume to be extended.
:type volume: str
:type size: int or str
:param size: Size in bytes, or string representing the size of the
volume to be created.
:returns: A dictionary mapping "name" ... | [
"Extend",
"a",
"volume",
"to",
"a",
"new",
"larger",
"size",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L529-L573 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.truncate_volume | def truncate_volume(self, volume, size):
"""Truncate a volume to a new, smaller size.
:param volume: Name of the volume to truncate.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
:type size: int or... | python | def truncate_volume(self, volume, size):
"""Truncate a volume to a new, smaller size.
:param volume: Name of the volume to truncate.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
:type size: int or... | [
"def",
"truncate_volume",
"(",
"self",
",",
"volume",
",",
"size",
")",
":",
"return",
"self",
".",
"set_volume",
"(",
"volume",
",",
"size",
"=",
"size",
",",
"truncate",
"=",
"True",
")"
] | Truncate a volume to a new, smaller size.
:param volume: Name of the volume to truncate.
:type volume: str
:param size: Size in bytes, or string representing the size of the
volume to be created.
:type size: int or str
:returns: A dictionary mapping "name" ... | [
"Truncate",
"a",
"volume",
"to",
"a",
"new",
"smaller",
"size",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L726-L750 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.connect_host | def connect_host(self, host, volume, **kwargs):
"""Create a connection between a host and a volume.
:param host: Name of host to connect to volume.
:type host: str
:param volume: Name of volume to connect to host.
:type volume: str
:param \*\*kwargs: See the REST API Gui... | python | def connect_host(self, host, volume, **kwargs):
"""Create a connection between a host and a volume.
:param host: Name of host to connect to volume.
:type host: str
:param volume: Name of volume to connect to host.
:type volume: str
:param \*\*kwargs: See the REST API Gui... | [
"def",
"connect_host",
"(",
"self",
",",
"host",
",",
"volume",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
",",
"\"host/{0}/volume/{1}\"",
".",
"format",
"(",
"host",
",",
"volume",
")",
",",
"kwargs",
")"
] | Create a connection between a host and a volume.
:param host: Name of host to connect to volume.
:type host: str
:param volume: Name of volume to connect to host.
:type volume: str
:param \*\*kwargs: See the REST API Guide on your array for the
documen... | [
"Create",
"a",
"connection",
"between",
"a",
"host",
"and",
"a",
"volume",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L776-L793 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.connect_hgroup | def connect_hgroup(self, hgroup, volume, **kwargs):
"""Create a shared connection between a host group and a volume.
:param hgroup: Name of hgroup to connect to volume.
:type hgroup: str
:param volume: Name of volume to connect to hgroup.
:type volume: str
:param \*\*kwa... | python | def connect_hgroup(self, hgroup, volume, **kwargs):
"""Create a shared connection between a host group and a volume.
:param hgroup: Name of hgroup to connect to volume.
:type hgroup: str
:param volume: Name of volume to connect to hgroup.
:type volume: str
:param \*\*kwa... | [
"def",
"connect_hgroup",
"(",
"self",
",",
"hgroup",
",",
"volume",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
",",
"\"hgroup/{0}/volume/{1}\"",
".",
"format",
"(",
"hgroup",
",",
"volume",
")",
",",
"kwargs",
... | Create a shared connection between a host group and a volume.
:param hgroup: Name of hgroup to connect to volume.
:type hgroup: str
:param volume: Name of volume to connect to hgroup.
:type volume: str
:param \*\*kwargs: See the REST API Guide on your array for the
... | [
"Create",
"a",
"shared",
"connection",
"between",
"a",
"host",
"group",
"and",
"a",
"volume",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L952-L969 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.get_offload | def get_offload(self, name, **kwargs):
"""Return a dictionary describing the connected offload target.
:param offload: Name of offload target to get information about.
:type offload: str
:param \*\*kwargs: See the REST API Guide on your array for the
documenta... | python | def get_offload(self, name, **kwargs):
"""Return a dictionary describing the connected offload target.
:param offload: Name of offload target to get information about.
:type offload: str
:param \*\*kwargs: See the REST API Guide on your array for the
documenta... | [
"def",
"get_offload",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"# Unbox if a list to accommodate a bug in REST 1.14",
"result",
"=",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"\"offload/{0}\"",
".",
"format",
"(",
"name",
")",
",",
"kwa... | Return a dictionary describing the connected offload target.
:param offload: Name of offload target to get information about.
:type offload: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**... | [
"Return",
"a",
"dictionary",
"describing",
"the",
"connected",
"offload",
"target",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1222-L1242 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_subnet | def create_subnet(self, subnet, prefix, **kwargs):
"""Create a subnet.
:param subnet: Name of subnet to be created.
:type subnet: str
:param prefix: Routing prefix of subnet to be created.
:type prefix: str
:param \*\*kwargs: See the REST API Guide on your array for the
... | python | def create_subnet(self, subnet, prefix, **kwargs):
"""Create a subnet.
:param subnet: Name of subnet to be created.
:type subnet: str
:param prefix: Routing prefix of subnet to be created.
:type prefix: str
:param \*\*kwargs: See the REST API Guide on your array for the
... | [
"def",
"create_subnet",
"(",
"self",
",",
"subnet",
",",
"prefix",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"prefix\"",
":",
"prefix",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
"... | Create a subnet.
:param subnet: Name of subnet to be created.
:type subnet: str
:param prefix: Routing prefix of subnet to be created.
:type prefix: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | [
"Create",
"a",
"subnet",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1347-L1374 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_vlan_interface | def create_vlan_interface(self, interface, subnet, **kwargs):
"""Create a vlan interface
:param interface: Name of interface to be created.
:type interface: str
:param subnet: Subnet associated with interface to be created
:type subnet: str
:param \*\*kwargs: See the RES... | python | def create_vlan_interface(self, interface, subnet, **kwargs):
"""Create a vlan interface
:param interface: Name of interface to be created.
:type interface: str
:param subnet: Subnet associated with interface to be created
:type subnet: str
:param \*\*kwargs: See the RES... | [
"def",
"create_vlan_interface",
"(",
"self",
",",
"interface",
",",
"subnet",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"subnet\"",
":",
"subnet",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"P... | Create a vlan interface
:param interface: Name of interface to be created.
:type interface: str
:param subnet: Subnet associated with interface to be created
:type subnet: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentatio... | [
"Create",
"a",
"vlan",
"interface"
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1496-L1518 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.set_password | def set_password(self, admin, new_password, old_password):
"""Set an admin's password.
:param admin: Name of admin whose password is to be set.
:type admin: str
:param new_password: New password for admin.
:type new_password: str
:param old_password: Current password of ... | python | def set_password(self, admin, new_password, old_password):
"""Set an admin's password.
:param admin: Name of admin whose password is to be set.
:type admin: str
:param new_password: New password for admin.
:type new_password: str
:param old_password: Current password of ... | [
"def",
"set_password",
"(",
"self",
",",
"admin",
",",
"new_password",
",",
"old_password",
")",
":",
"return",
"self",
".",
"set_admin",
"(",
"admin",
",",
"password",
"=",
"new_password",
",",
"old_password",
"=",
"old_password",
")"
] | Set an admin's password.
:param admin: Name of admin whose password is to be set.
:type admin: str
:param new_password: New password for admin.
:type new_password: str
:param old_password: Current password of admin.
:type old_password: str
:returns: A dictionary... | [
"Set",
"an",
"admin",
"s",
"password",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1888-L1903 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.disable_directory_service | def disable_directory_service(self, check_peer=False):
"""Disable the directory service.
:param check_peer: If True, disables server authenticity
enforcement. If False, disables directory
service integration.
:type check_peer: bool, optional... | python | def disable_directory_service(self, check_peer=False):
"""Disable the directory service.
:param check_peer: If True, disables server authenticity
enforcement. If False, disables directory
service integration.
:type check_peer: bool, optional... | [
"def",
"disable_directory_service",
"(",
"self",
",",
"check_peer",
"=",
"False",
")",
":",
"if",
"check_peer",
":",
"return",
"self",
".",
"set_directory_service",
"(",
"check_peer",
"=",
"False",
")",
"return",
"self",
".",
"set_directory_service",
"(",
"enabl... | Disable the directory service.
:param check_peer: If True, disables server authenticity
enforcement. If False, disables directory
service integration.
:type check_peer: bool, optional
:returns: A dictionary describing the status of the dire... | [
"Disable",
"the",
"directory",
"service",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1907-L1921 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.enable_directory_service | def enable_directory_service(self, check_peer=False):
"""Enable the directory service.
:param check_peer: If True, enables server authenticity
enforcement. If False, enables directory
service integration.
:type check_peer: bool, optional
... | python | def enable_directory_service(self, check_peer=False):
"""Enable the directory service.
:param check_peer: If True, enables server authenticity
enforcement. If False, enables directory
service integration.
:type check_peer: bool, optional
... | [
"def",
"enable_directory_service",
"(",
"self",
",",
"check_peer",
"=",
"False",
")",
":",
"if",
"check_peer",
":",
"return",
"self",
".",
"set_directory_service",
"(",
"check_peer",
"=",
"True",
")",
"return",
"self",
".",
"set_directory_service",
"(",
"enabled... | Enable the directory service.
:param check_peer: If True, enables server authenticity
enforcement. If False, enables directory
service integration.
:type check_peer: bool, optional
:returns: A dictionary describing the status of the directo... | [
"Enable",
"the",
"directory",
"service",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L1923-L1937 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_snmp_manager | def create_snmp_manager(self, manager, host, **kwargs):
"""Create an SNMP manager.
:param manager: Name of manager to be created.
:type manager: str
:param host: IP address or DNS name of SNMP server to be used.
:type host: str
:param \*\*kwargs: See the REST API Guide o... | python | def create_snmp_manager(self, manager, host, **kwargs):
"""Create an SNMP manager.
:param manager: Name of manager to be created.
:type manager: str
:param host: IP address or DNS name of SNMP server to be used.
:type host: str
:param \*\*kwargs: See the REST API Guide o... | [
"def",
"create_snmp_manager",
"(",
"self",
",",
"manager",
",",
"host",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"host\"",
":",
"host",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
... | Create an SNMP manager.
:param manager: Name of manager to be created.
:type manager: str
:param host: IP address or DNS name of SNMP server to be used.
:type host: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on th... | [
"Create",
"an",
"SNMP",
"manager",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2335-L2353 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.connect_array | def connect_array(self, address, connection_key, connection_type, **kwargs):
"""Connect this array with another one.
:param address: IP address or DNS name of other array.
:type address: str
:param connection_key: Connection key of other array.
:type connection_key: str
... | python | def connect_array(self, address, connection_key, connection_type, **kwargs):
"""Connect this array with another one.
:param address: IP address or DNS name of other array.
:type address: str
:param connection_key: Connection key of other array.
:type connection_key: str
... | [
"def",
"connect_array",
"(",
"self",
",",
"address",
",",
"connection_key",
",",
"connection_type",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"management_address\"",
":",
"address",
",",
"\"connection_key\"",
":",
"connection_key",
",",
"\"type\"",
... | Connect this array with another one.
:param address: IP address or DNS name of other array.
:type address: str
:param connection_key: Connection key of other array.
:type connection_key: str
:param connection_type: Type(s) of connection desired.
:type connection_type: li... | [
"Connect",
"this",
"array",
"with",
"another",
"one",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2448-L2478 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_pgroup_snapshot | def create_pgroup_snapshot(self, source, **kwargs):
"""Create snapshot of pgroup from specified source.
:param source: Name of pgroup of which to take snapshot.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on ... | python | def create_pgroup_snapshot(self, source, **kwargs):
"""Create snapshot of pgroup from specified source.
:param source: Name of pgroup of which to take snapshot.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on ... | [
"def",
"create_pgroup_snapshot",
"(",
"self",
",",
"source",
",",
"*",
"*",
"kwargs",
")",
":",
"# In REST 1.4, support was added for snapshotting multiple pgroups. As a",
"# result, the endpoint response changed from an object to an array of",
"# objects. To keep the response type cons... | Create snapshot of pgroup from specified source.
:param source: Name of pgroup of which to take snapshot.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**POST pgroup**
... | [
"Create",
"snapshot",
"of",
"pgroup",
"from",
"specified",
"source",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2552-L2579 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.send_pgroup_snapshot | def send_pgroup_snapshot(self, source, **kwargs):
""" Send an existing pgroup snapshot to target(s)
:param source: Name of pgroup snapshot to send.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | python | def send_pgroup_snapshot(self, source, **kwargs):
""" Send an existing pgroup snapshot to target(s)
:param source: Name of pgroup snapshot to send.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | [
"def",
"send_pgroup_snapshot",
"(",
"self",
",",
"source",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"name\"",
":",
"[",
"source",
"]",
",",
"\"action\"",
":",
"\"send\"",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
... | Send an existing pgroup snapshot to target(s)
:param source: Name of pgroup snapshot to send.
:type source: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**POST pgroup**
:type \*\*k... | [
"Send",
"an",
"existing",
"pgroup",
"snapshot",
"to",
"target",
"(",
"s",
")"
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2581-L2601 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.create_pgroup_snapshots | def create_pgroup_snapshots(self, sources, **kwargs):
"""Create snapshots of pgroups from specified sources.
:param sources: Names of pgroups of which to take snapshots.
:type sources: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
... | python | def create_pgroup_snapshots(self, sources, **kwargs):
"""Create snapshots of pgroups from specified sources.
:param sources: Names of pgroups of which to take snapshots.
:type sources: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
... | [
"def",
"create_pgroup_snapshots",
"(",
"self",
",",
"sources",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"source\"",
":",
"sources",
",",
"\"snap\"",
":",
"True",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_req... | Create snapshots of pgroups from specified sources.
:param sources: Names of pgroups of which to take snapshots.
:type sources: list of str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**POST ... | [
"Create",
"snapshots",
"of",
"pgroups",
"from",
"specified",
"sources",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2603-L2623 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.eradicate_pgroup | def eradicate_pgroup(self, pgroup, **kwargs):
"""Eradicate a destroyed pgroup.
:param pgroup: Name of pgroup to be eradicated.
:type pgroup: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | python | def eradicate_pgroup(self, pgroup, **kwargs):
"""Eradicate a destroyed pgroup.
:param pgroup: Name of pgroup to be eradicated.
:type pgroup: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | [
"def",
"eradicate_pgroup",
"(",
"self",
",",
"pgroup",
",",
"*",
"*",
"kwargs",
")",
":",
"eradicate",
"=",
"{",
"\"eradicate\"",
":",
"True",
"}",
"eradicate",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"DELETE\"",
",",... | Eradicate a destroyed pgroup.
:param pgroup: Name of pgroup to be eradicated.
:type pgroup: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**DELETE pgroup/:pgroup**
:type \*\*kwargs:... | [
"Eradicate",
"a",
"destroyed",
"pgroup",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L2708-L2728 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.clone_pod | def clone_pod(self, source, dest, **kwargs):
"""Clone an existing pod to a new one.
:param source: Name of the pod the be cloned.
:type source: str
:param dest: Name of the target pod to clone into
:type dest: str
:param \*\*kwargs: See the REST API Guide on your array f... | python | def clone_pod(self, source, dest, **kwargs):
"""Clone an existing pod to a new one.
:param source: Name of the pod the be cloned.
:type source: str
:param dest: Name of the target pod to clone into
:type dest: str
:param \*\*kwargs: See the REST API Guide on your array f... | [
"def",
"clone_pod",
"(",
"self",
",",
"source",
",",
"dest",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"\"source\"",
":",
"source",
"}",
"data",
".",
"update",
"(",
"kwargs",
")",
"return",
"self",
".",
"_request",
"(",
"\"POST\"",
",",
... | Clone an existing pod to a new one.
:param source: Name of the pod the be cloned.
:type source: str
:param dest: Name of the target pod to clone into
:type dest: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the r... | [
"Clone",
"an",
"existing",
"pod",
"to",
"a",
"new",
"one",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3017-L3038 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.remove_pod | def remove_pod(self, pod, array, **kwargs):
"""Remove arrays from a pod.
:param pod: Name of the pod.
:type pod: str
:param array: Array to remove from pod.
:type array: str
:param \*\*kwargs: See the REST API Guide on your array for the
docume... | python | def remove_pod(self, pod, array, **kwargs):
"""Remove arrays from a pod.
:param pod: Name of the pod.
:type pod: str
:param array: Array to remove from pod.
:type array: str
:param \*\*kwargs: See the REST API Guide on your array for the
docume... | [
"def",
"remove_pod",
"(",
"self",
",",
"pod",
",",
"array",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"DELETE\"",
",",
"\"pod/{0}/array/{1}\"",
".",
"format",
"(",
"pod",
",",
"array",
")",
",",
"kwargs",
")"
] | Remove arrays from a pod.
:param pod: Name of the pod.
:type pod: str
:param array: Array to remove from pod.
:type array: str
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**DE... | [
"Remove",
"arrays",
"from",
"a",
"pod",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3125-L3144 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.get_certificate | def get_certificate(self, **kwargs):
"""Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:retu... | python | def get_certificate(self, **kwargs):
"""Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:retu... | [
"def",
"get_certificate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rest_version",
">=",
"LooseVersion",
"(",
"\"1.12\"",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"\"cert/{0}\"",
".",
"format",
"(",
"kw... | Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:returns: A dictionary describing the configured arra... | [
"Get",
"the",
"attributes",
"of",
"the",
"current",
"array",
"certificate",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3211-L3232 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.list_certificates | def list_certificates(self):
"""Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:returns: A l... | python | def list_certificates(self):
"""Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:returns: A l... | [
"def",
"list_certificates",
"(",
"self",
")",
":",
"# This call takes no parameters.",
"if",
"self",
".",
"_rest_version",
">=",
"LooseVersion",
"(",
"\"1.12\"",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"\"cert\"",
")",
"else",
":",
"#... | Get the attributes of the current array certificate.
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert**
:type \*\*kwargs: optional
:returns: A list of dictionaries describing all confi... | [
"Get",
"the",
"attributes",
"of",
"the",
"current",
"array",
"certificate",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3234-L3260 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.get_certificate_signing_request | def get_certificate_signing_request(self, **kwargs):
"""Construct a certificate signing request (CSR) for signing by a
certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | python | def get_certificate_signing_request(self, **kwargs):
"""Construct a certificate signing request (CSR) for signing by a
certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | [
"def",
"get_certificate_signing_request",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rest_version",
">=",
"LooseVersion",
"(",
"\"1.12\"",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"GET\"",
",",
"\"cert/certificate_signing_req... | Construct a certificate signing request (CSR) for signing by a
certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**GET cert/certificate_signing_request**
:type \*\*kwarg... | [
"Construct",
"a",
"certificate",
"signing",
"request",
"(",
"CSR",
")",
"for",
"signing",
"by",
"a",
"certificate",
"authority",
"(",
"CA",
")",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3262-L3289 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.set_certificate | def set_certificate(self, **kwargs):
"""Modify an existing certificate, creating a new self signed one
or importing a certificate signed by a certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | python | def set_certificate(self, **kwargs):
"""Modify an existing certificate, creating a new self signed one
or importing a certificate signed by a certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
... | [
"def",
"set_certificate",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_rest_version",
">=",
"LooseVersion",
"(",
"\"1.12\"",
")",
":",
"return",
"self",
".",
"_request",
"(",
"\"PUT\"",
",",
"\"cert/{0}\"",
".",
"format",
"(",
"kw... | Modify an existing certificate, creating a new self signed one
or importing a certificate signed by a certificate authority (CA).
:param \*\*kwargs: See the REST API Guide on your array for the
documentation on the request:
**PUT cert**
:typ... | [
"Modify",
"an",
"existing",
"certificate",
"creating",
"a",
"new",
"self",
"signed",
"one",
"or",
"importing",
"a",
"certificate",
"signed",
"by",
"a",
"certificate",
"authority",
"(",
"CA",
")",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3291-L3317 |
PureStorage-OpenConnect/rest-client | purestorage/purestorage.py | FlashArray.page_through | def page_through(page_size, function, *args, **kwargs):
"""Return an iterator over all pages of a REST operation.
:param page_size: Number of elements to retrieve per call.
:param function: FlashArray function that accepts limit as an argument.
:param \*args: Positional arguments to be ... | python | def page_through(page_size, function, *args, **kwargs):
"""Return an iterator over all pages of a REST operation.
:param page_size: Number of elements to retrieve per call.
:param function: FlashArray function that accepts limit as an argument.
:param \*args: Positional arguments to be ... | [
"def",
"page_through",
"(",
"page_size",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"\"limit\"",
"]",
"=",
"page_size",
"def",
"get_page",
"(",
"token",
")",
":",
"page_kwargs",
"=",
"kwargs",
".",
"copy",
"(",... | Return an iterator over all pages of a REST operation.
:param page_size: Number of elements to retrieve per call.
:param function: FlashArray function that accepts limit as an argument.
:param \*args: Positional arguments to be passed to function.
:param \*\*kwargs: Keyword arguments to... | [
"Return",
"an",
"iterator",
"over",
"all",
"pages",
"of",
"a",
"REST",
"operation",
"."
] | train | https://github.com/PureStorage-OpenConnect/rest-client/blob/097d5f2bc6facf607d7e4a92567b09fb8cf5cb34/purestorage/purestorage.py#L3632-L3683 |
bitprophet/ssh | ssh/sftp_server.py | SFTPServer.set_file_attr | def set_file_attr(filename, attr):
"""
Change a file's attributes on the local filesystem. The contents of
C{attr} are used to change the permissions, owner, group ownership,
and/or modification & access time of the file, depending on which
attributes are present in C{attr}.
... | python | def set_file_attr(filename, attr):
"""
Change a file's attributes on the local filesystem. The contents of
C{attr} are used to change the permissions, owner, group ownership,
and/or modification & access time of the file, depending on which
attributes are present in C{attr}.
... | [
"def",
"set_file_attr",
"(",
"filename",
",",
"attr",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"# mode operations are meaningless on win32",
"if",
"attr",
".",
"_flags",
"&",
"attr",
".",
"FLAG_PERMISSIONS",
":",
"os",
".",
"chmod",
"(",
... | Change a file's attributes on the local filesystem. The contents of
C{attr} are used to change the permissions, owner, group ownership,
and/or modification & access time of the file, depending on which
attributes are present in C{attr}.
This is meant to be a handy helper function for t... | [
"Change",
"a",
"file",
"s",
"attributes",
"on",
"the",
"local",
"filesystem",
".",
"The",
"contents",
"of",
"C",
"{",
"attr",
"}",
"are",
"used",
"to",
"change",
"the",
"permissions",
"owner",
"group",
"ownership",
"and",
"/",
"or",
"modification",
"&",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/sftp_server.py#L144-L169 |
bitprophet/ssh | ssh/packet.py | Packetizer.read_all | def read_all(self, n, check_rekey=False):
"""
Read as close to N bytes as possible, blocking as long as necessary.
@param n: number of bytes to read
@type n: int
@return: the data read
@rtype: str
@raise EOFError: if the socket was closed before all the bytes cou... | python | def read_all(self, n, check_rekey=False):
"""
Read as close to N bytes as possible, blocking as long as necessary.
@param n: number of bytes to read
@type n: int
@return: the data read
@rtype: str
@raise EOFError: if the socket was closed before all the bytes cou... | [
"def",
"read_all",
"(",
"self",
",",
"n",
",",
"check_rekey",
"=",
"False",
")",
":",
"out",
"=",
"''",
"# handle over-reading from reading the banner line",
"if",
"len",
"(",
"self",
".",
"__remainder",
")",
">",
"0",
":",
"out",
"=",
"self",
".",
"__rema... | Read as close to N bytes as possible, blocking as long as necessary.
@param n: number of bytes to read
@type n: int
@return: the data read
@rtype: str
@raise EOFError: if the socket was closed before all the bytes could
be read | [
"Read",
"as",
"close",
"to",
"N",
"bytes",
"as",
"possible",
"blocking",
"as",
"long",
"as",
"necessary",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/packet.py#L191-L239 |
bitprophet/ssh | ssh/packet.py | Packetizer.readline | def readline(self, timeout):
"""
Read a line from the socket. We assume no data is pending after the
line, so it's okay to attempt large reads.
"""
buf = self.__remainder
while not '\n' in buf:
buf += self._read_timeout(timeout)
n = buf.index('\n')
... | python | def readline(self, timeout):
"""
Read a line from the socket. We assume no data is pending after the
line, so it's okay to attempt large reads.
"""
buf = self.__remainder
while not '\n' in buf:
buf += self._read_timeout(timeout)
n = buf.index('\n')
... | [
"def",
"readline",
"(",
"self",
",",
"timeout",
")",
":",
"buf",
"=",
"self",
".",
"__remainder",
"while",
"not",
"'\\n'",
"in",
"buf",
":",
"buf",
"+=",
"self",
".",
"_read_timeout",
"(",
"timeout",
")",
"n",
"=",
"buf",
".",
"index",
"(",
"'\\n'",
... | Read a line from the socket. We assume no data is pending after the
line, so it's okay to attempt large reads. | [
"Read",
"a",
"line",
"from",
"the",
"socket",
".",
"We",
"assume",
"no",
"data",
"is",
"pending",
"after",
"the",
"line",
"so",
"it",
"s",
"okay",
"to",
"attempt",
"large",
"reads",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/packet.py#L271-L284 |
bitprophet/ssh | ssh/packet.py | Packetizer.send_message | def send_message(self, data):
"""
Write a block of data using the current cipher, as an SSH block.
"""
# encrypt this sucka
data = str(data)
cmd = ord(data[0])
if cmd in MSG_NAMES:
cmd_name = MSG_NAMES[cmd]
else:
cmd_name = '$%x' % ... | python | def send_message(self, data):
"""
Write a block of data using the current cipher, as an SSH block.
"""
# encrypt this sucka
data = str(data)
cmd = ord(data[0])
if cmd in MSG_NAMES:
cmd_name = MSG_NAMES[cmd]
else:
cmd_name = '$%x' % ... | [
"def",
"send_message",
"(",
"self",
",",
"data",
")",
":",
"# encrypt this sucka",
"data",
"=",
"str",
"(",
"data",
")",
"cmd",
"=",
"ord",
"(",
"data",
"[",
"0",
"]",
")",
"if",
"cmd",
"in",
"MSG_NAMES",
":",
"cmd_name",
"=",
"MSG_NAMES",
"[",
"cmd"... | Write a block of data using the current cipher, as an SSH block. | [
"Write",
"a",
"block",
"of",
"data",
"using",
"the",
"current",
"cipher",
"as",
"an",
"SSH",
"block",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/packet.py#L286-L328 |
bitprophet/ssh | ssh/packet.py | Packetizer.read_message | def read_message(self):
"""
Only one thread should ever be in this function (no other locking is
done).
@raise SSHException: if the packet is mangled
@raise NeedRekeyException: if the transport should rekey
"""
header = self.read_all(self.__block_size_in, check_r... | python | def read_message(self):
"""
Only one thread should ever be in this function (no other locking is
done).
@raise SSHException: if the packet is mangled
@raise NeedRekeyException: if the transport should rekey
"""
header = self.read_all(self.__block_size_in, check_r... | [
"def",
"read_message",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"read_all",
"(",
"self",
".",
"__block_size_in",
",",
"check_rekey",
"=",
"True",
")",
"if",
"self",
".",
"__block_engine_in",
"!=",
"None",
":",
"header",
"=",
"self",
".",
"__blo... | Only one thread should ever be in this function (no other locking is
done).
@raise SSHException: if the packet is mangled
@raise NeedRekeyException: if the transport should rekey | [
"Only",
"one",
"thread",
"should",
"ever",
"be",
"in",
"this",
"function",
"(",
"no",
"other",
"locking",
"is",
"done",
")",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/packet.py#L330-L404 |
bitprophet/ssh | setup_helper.py | make_tarball | def make_tarball(base_name, base_dir, compress='gzip',
verbose=False, dry_run=False):
"""Create a tar file from all the files under 'base_dir'.
This file may be compressed.
:param compress: Compression algorithms. Supported algorithms are:
'gzip': (the default)
'compress'
... | python | def make_tarball(base_name, base_dir, compress='gzip',
verbose=False, dry_run=False):
"""Create a tar file from all the files under 'base_dir'.
This file may be compressed.
:param compress: Compression algorithms. Supported algorithms are:
'gzip': (the default)
'compress'
... | [
"def",
"make_tarball",
"(",
"base_name",
",",
"base_dir",
",",
"compress",
"=",
"'gzip'",
",",
"verbose",
"=",
"False",
",",
"dry_run",
"=",
"False",
")",
":",
"# XXX GNU tar 1.13 has a nifty option to add a prefix directory.",
"# It's pretty new, though, so we certainly ca... | Create a tar file from all the files under 'base_dir'.
This file may be compressed.
:param compress: Compression algorithms. Supported algorithms are:
'gzip': (the default)
'compress'
'bzip2'
None
For 'gzip' and 'bzip2' the internal tarfile module will be used.
For 'comp... | [
"Create",
"a",
"tar",
"file",
"from",
"all",
"the",
"files",
"under",
"base_dir",
".",
"This",
"file",
"may",
"be",
"compressed",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/setup_helper.py#L34-L89 |
bitprophet/ssh | ssh/auth_handler.py | AuthHandler.auth_interactive | def auth_interactive(self, username, handler, event, submethods=''):
"""
response_list = handler(title, instructions, prompt_list)
"""
self.transport.lock.acquire()
try:
self.auth_event = event
self.auth_method = 'keyboard-interactive'
self.use... | python | def auth_interactive(self, username, handler, event, submethods=''):
"""
response_list = handler(title, instructions, prompt_list)
"""
self.transport.lock.acquire()
try:
self.auth_event = event
self.auth_method = 'keyboard-interactive'
self.use... | [
"def",
"auth_interactive",
"(",
"self",
",",
"username",
",",
"handler",
",",
"event",
",",
"submethods",
"=",
"''",
")",
":",
"self",
".",
"transport",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"auth_event",
"=",
"event",
"self",... | response_list = handler(title, instructions, prompt_list) | [
"response_list",
"=",
"handler",
"(",
"title",
"instructions",
"prompt_list",
")"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/auth_handler.py#L97-L110 |
bitprophet/ssh | ssh/hostkeys.py | HostKeyEntry.from_line | def from_line(cls, line):
"""
Parses the given line of text to find the names for the host,
the type of key, and the key data. The line is expected to be in the
format used by the openssh known_hosts file.
Lines are expected to not have leading or trailing whitespace.
We... | python | def from_line(cls, line):
"""
Parses the given line of text to find the names for the host,
the type of key, and the key data. The line is expected to be in the
format used by the openssh known_hosts file.
Lines are expected to not have leading or trailing whitespace.
We... | [
"def",
"from_line",
"(",
"cls",
",",
"line",
")",
":",
"fields",
"=",
"line",
".",
"split",
"(",
"' '",
")",
"if",
"len",
"(",
"fields",
")",
"<",
"3",
":",
"# Bad number of fields",
"return",
"None",
"fields",
"=",
"fields",
"[",
":",
"3",
"]",
"n... | Parses the given line of text to find the names for the host,
the type of key, and the key data. The line is expected to be in the
format used by the openssh known_hosts file.
Lines are expected to not have leading or trailing whitespace.
We don't bother to check for comments or empty l... | [
"Parses",
"the",
"given",
"line",
"of",
"text",
"to",
"find",
"the",
"names",
"for",
"the",
"host",
"the",
"type",
"of",
"key",
"and",
"the",
"key",
"data",
".",
"The",
"line",
"is",
"expected",
"to",
"be",
"in",
"the",
"format",
"used",
"by",
"the",... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L51-L85 |
bitprophet/ssh | ssh/hostkeys.py | HostKeyEntry.to_line | def to_line(self):
"""
Returns a string in OpenSSH known_hosts file format, or None if
the object is not in a valid state. A trailing newline is
included.
"""
if self.valid:
return '%s %s %s\n' % (','.join(self.hostnames), self.key.get_name(),
... | python | def to_line(self):
"""
Returns a string in OpenSSH known_hosts file format, or None if
the object is not in a valid state. A trailing newline is
included.
"""
if self.valid:
return '%s %s %s\n' % (','.join(self.hostnames), self.key.get_name(),
... | [
"def",
"to_line",
"(",
"self",
")",
":",
"if",
"self",
".",
"valid",
":",
"return",
"'%s %s %s\\n'",
"%",
"(",
"','",
".",
"join",
"(",
"self",
".",
"hostnames",
")",
",",
"self",
".",
"key",
".",
"get_name",
"(",
")",
",",
"self",
".",
"key",
".... | Returns a string in OpenSSH known_hosts file format, or None if
the object is not in a valid state. A trailing newline is
included. | [
"Returns",
"a",
"string",
"in",
"OpenSSH",
"known_hosts",
"file",
"format",
"or",
"None",
"if",
"the",
"object",
"is",
"not",
"in",
"a",
"valid",
"state",
".",
"A",
"trailing",
"newline",
"is",
"included",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L88-L97 |
bitprophet/ssh | ssh/hostkeys.py | HostKeys.load | def load(self, filename):
"""
Read a file of known SSH host keys, in the format used by openssh.
This type of file unfortunately doesn't exist on Windows, but on
posix, it will usually be stored in
C{os.path.expanduser("~/.ssh/known_hosts")}.
If this method is called mul... | python | def load(self, filename):
"""
Read a file of known SSH host keys, in the format used by openssh.
This type of file unfortunately doesn't exist on Windows, but on
posix, it will usually be stored in
C{os.path.expanduser("~/.ssh/known_hosts")}.
If this method is called mul... | [
"def",
"load",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
"for",
"line",
"in",
"f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"(",
"len",
"(",
"line",
")",
"==",
"0",
")",
"or",
... | Read a file of known SSH host keys, in the format used by openssh.
This type of file unfortunately doesn't exist on Windows, but on
posix, it will usually be stored in
C{os.path.expanduser("~/.ssh/known_hosts")}.
If this method is called multiple times, the host keys are merged,
... | [
"Read",
"a",
"file",
"of",
"known",
"SSH",
"host",
"keys",
"in",
"the",
"format",
"used",
"by",
"openssh",
".",
"This",
"type",
"of",
"file",
"unfortunately",
"doesn",
"t",
"exist",
"on",
"Windows",
"but",
"on",
"posix",
"it",
"will",
"usually",
"be",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L146-L170 |
bitprophet/ssh | ssh/hostkeys.py | HostKeys.save | def save(self, filename):
"""
Save host keys into a file, in the format used by openssh. The order of
keys in the file will be preserved when possible (if these keys were
loaded from a file originally). The single exception is that combined
lines will be split into individual k... | python | def save(self, filename):
"""
Save host keys into a file, in the format used by openssh. The order of
keys in the file will be preserved when possible (if these keys were
loaded from a file originally). The single exception is that combined
lines will be split into individual k... | [
"def",
"save",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"for",
"e",
"in",
"self",
".",
"_entries",
":",
"line",
"=",
"e",
".",
"to_line",
"(",
")",
"if",
"line",
":",
"f",
".",
"write",
"(",
... | Save host keys into a file, in the format used by openssh. The order of
keys in the file will be preserved when possible (if these keys were
loaded from a file originally). The single exception is that combined
lines will be split into individual key lines, which is arguably a bug.
@p... | [
"Save",
"host",
"keys",
"into",
"a",
"file",
"in",
"the",
"format",
"used",
"by",
"openssh",
".",
"The",
"order",
"of",
"keys",
"in",
"the",
"file",
"will",
"be",
"preserved",
"when",
"possible",
"(",
"if",
"these",
"keys",
"were",
"loaded",
"from",
"a... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L172-L191 |
bitprophet/ssh | ssh/hostkeys.py | HostKeys.lookup | def lookup(self, hostname):
"""
Find a hostkey entry for a given hostname or IP. If no entry is found,
C{None} is returned. Otherwise a dictionary of keytype to key is
returned. The keytype will be either C{"ssh-rsa"} or C{"ssh-dss"}.
@param hostname: the hostname (or IP) to ... | python | def lookup(self, hostname):
"""
Find a hostkey entry for a given hostname or IP. If no entry is found,
C{None} is returned. Otherwise a dictionary of keytype to key is
returned. The keytype will be either C{"ssh-rsa"} or C{"ssh-dss"}.
@param hostname: the hostname (or IP) to ... | [
"def",
"lookup",
"(",
"self",
",",
"hostname",
")",
":",
"class",
"SubDict",
"(",
"UserDict",
".",
"DictMixin",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"hostname",
",",
"entries",
",",
"hostkeys",
")",
":",
"self",
".",
"_hostname",
"=",
"hostna... | Find a hostkey entry for a given hostname or IP. If no entry is found,
C{None} is returned. Otherwise a dictionary of keytype to key is
returned. The keytype will be either C{"ssh-rsa"} or C{"ssh-dss"}.
@param hostname: the hostname (or IP) to lookup
@type hostname: str
@retu... | [
"Find",
"a",
"hostkey",
"entry",
"for",
"a",
"given",
"hostname",
"or",
"IP",
".",
"If",
"no",
"entry",
"is",
"found",
"C",
"{",
"None",
"}",
"is",
"returned",
".",
"Otherwise",
"a",
"dictionary",
"of",
"keytype",
"to",
"key",
"is",
"returned",
".",
... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L193-L240 |
bitprophet/ssh | ssh/hostkeys.py | HostKeys.check | def check(self, hostname, key):
"""
Return True if the given key is associated with the given hostname
in this dictionary.
@param hostname: hostname (or IP) of the SSH server
@type hostname: str
@param key: the key to check
@type key: L{PKey}
@return: C{T... | python | def check(self, hostname, key):
"""
Return True if the given key is associated with the given hostname
in this dictionary.
@param hostname: hostname (or IP) of the SSH server
@type hostname: str
@param key: the key to check
@type key: L{PKey}
@return: C{T... | [
"def",
"check",
"(",
"self",
",",
"hostname",
",",
"key",
")",
":",
"k",
"=",
"self",
".",
"lookup",
"(",
"hostname",
")",
"if",
"k",
"is",
"None",
":",
"return",
"False",
"host_key",
"=",
"k",
".",
"get",
"(",
"key",
".",
"get_name",
"(",
")",
... | Return True if the given key is associated with the given hostname
in this dictionary.
@param hostname: hostname (or IP) of the SSH server
@type hostname: str
@param key: the key to check
@type key: L{PKey}
@return: C{True} if the key is associated with the hostname; C{F... | [
"Return",
"True",
"if",
"the",
"given",
"key",
"is",
"associated",
"with",
"the",
"given",
"hostname",
"in",
"this",
"dictionary",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L242-L261 |
bitprophet/ssh | ssh/hostkeys.py | HostKeys.hash_host | def hash_host(hostname, salt=None):
"""
Return a "hashed" form of the hostname, as used by openssh when storing
hashed hostnames in the known_hosts file.
@param hostname: the hostname to hash
@type hostname: str
@param salt: optional salt to use when hashing (must be 20 ... | python | def hash_host(hostname, salt=None):
"""
Return a "hashed" form of the hostname, as used by openssh when storing
hashed hostnames in the known_hosts file.
@param hostname: the hostname to hash
@type hostname: str
@param salt: optional salt to use when hashing (must be 20 ... | [
"def",
"hash_host",
"(",
"hostname",
",",
"salt",
"=",
"None",
")",
":",
"if",
"salt",
"is",
"None",
":",
"salt",
"=",
"rng",
".",
"read",
"(",
"SHA",
".",
"digest_size",
")",
"else",
":",
"if",
"salt",
".",
"startswith",
"(",
"'|1|'",
")",
":",
... | Return a "hashed" form of the hostname, as used by openssh when storing
hashed hostnames in the known_hosts file.
@param hostname: the hostname to hash
@type hostname: str
@param salt: optional salt to use when hashing (must be 20 bytes long)
@type salt: str
@return: the... | [
"Return",
"a",
"hashed",
"form",
"of",
"the",
"hostname",
"as",
"used",
"by",
"openssh",
"when",
"storing",
"hashed",
"hostnames",
"in",
"the",
"known_hosts",
"file",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/hostkeys.py#L305-L326 |
bitprophet/ssh | ssh/util.py | inflate_long | def inflate_long(s, always_positive=False):
"turns a normalized byte string into a long-int (adapted from Crypto.Util.number)"
out = 0L
negative = 0
if not always_positive and (len(s) > 0) and (ord(s[0]) >= 0x80):
negative = 1
if len(s) % 4:
filler = '\x00'
if negative:
... | python | def inflate_long(s, always_positive=False):
"turns a normalized byte string into a long-int (adapted from Crypto.Util.number)"
out = 0L
negative = 0
if not always_positive and (len(s) > 0) and (ord(s[0]) >= 0x80):
negative = 1
if len(s) % 4:
filler = '\x00'
if negative:
... | [
"def",
"inflate_long",
"(",
"s",
",",
"always_positive",
"=",
"False",
")",
":",
"out",
"=",
"0L",
"negative",
"=",
"0",
"if",
"not",
"always_positive",
"and",
"(",
"len",
"(",
"s",
")",
">",
"0",
")",
"and",
"(",
"ord",
"(",
"s",
"[",
"0",
"]",
... | turns a normalized byte string into a long-int (adapted from Crypto.Util.number) | [
"turns",
"a",
"normalized",
"byte",
"string",
"into",
"a",
"long",
"-",
"int",
"(",
"adapted",
"from",
"Crypto",
".",
"Util",
".",
"number",
")"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/util.py#L49-L64 |
bitprophet/ssh | ssh/util.py | deflate_long | def deflate_long(n, add_sign_padding=True):
"turns a long-int into a normalized byte string (adapted from Crypto.Util.number)"
# after much testing, this algorithm was deemed to be the fastest
s = ''
n = long(n)
while (n != 0) and (n != -1):
s = struct.pack('>I', n & 0xffffffffL) + s
... | python | def deflate_long(n, add_sign_padding=True):
"turns a long-int into a normalized byte string (adapted from Crypto.Util.number)"
# after much testing, this algorithm was deemed to be the fastest
s = ''
n = long(n)
while (n != 0) and (n != -1):
s = struct.pack('>I', n & 0xffffffffL) + s
... | [
"def",
"deflate_long",
"(",
"n",
",",
"add_sign_padding",
"=",
"True",
")",
":",
"# after much testing, this algorithm was deemed to be the fastest",
"s",
"=",
"''",
"n",
"=",
"long",
"(",
"n",
")",
"while",
"(",
"n",
"!=",
"0",
")",
"and",
"(",
"n",
"!=",
... | turns a long-int into a normalized byte string (adapted from Crypto.Util.number) | [
"turns",
"a",
"long",
"-",
"int",
"into",
"a",
"normalized",
"byte",
"string",
"(",
"adapted",
"from",
"Crypto",
".",
"Util",
".",
"number",
")"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/util.py#L66-L93 |
bitprophet/ssh | ssh/util.py | generate_key_bytes | def generate_key_bytes(hashclass, 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 hashclass: class from L{Crypto.Hash} t... | python | def generate_key_bytes(hashclass, 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 hashclass: class from L{Crypto.Hash} t... | [
"def",
"generate_key_bytes",
"(",
"hashclass",
",",
"salt",
",",
"key",
",",
"nbytes",
")",
":",
"keydata",
"=",
"''",
"digest",
"=",
"''",
"if",
"len",
"(",
"salt",
")",
">",
"8",
":",
"salt",
"=",
"salt",
"[",
":",
"8",
"]",
"while",
"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 hashclass: class from L{Crypto.Hash} that can be used as a secure
hashing function (like C{MD5} ... | [
"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",
"/",
"dec... | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/util.py#L151-L183 |
bitprophet/ssh | ssh/util.py | retry_on_signal | def retry_on_signal(function):
"""Retries function until it doesn't raise an EINTR error"""
while True:
try:
return function()
except EnvironmentError, e:
if e.errno != errno.EINTR:
raise | python | def retry_on_signal(function):
"""Retries function until it doesn't raise an EINTR error"""
while True:
try:
return function()
except EnvironmentError, e:
if e.errno != errno.EINTR:
raise | [
"def",
"retry_on_signal",
"(",
"function",
")",
":",
"while",
"True",
":",
"try",
":",
"return",
"function",
"(",
")",
"except",
"EnvironmentError",
",",
"e",
":",
"if",
"e",
".",
"errno",
"!=",
"errno",
".",
"EINTR",
":",
"raise"
] | Retries function until it doesn't raise an EINTR error | [
"Retries",
"function",
"until",
"it",
"doesn",
"t",
"raise",
"an",
"EINTR",
"error"
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/util.py#L274-L281 |
bitprophet/ssh | ssh/rsakey.py | RSAKey.generate | def generate(bits, progress_func=None):
"""
Generate a new private RSA key. This factory function can be used to
generate a new host key or authentication key.
@param bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optional fun... | python | def generate(bits, progress_func=None):
"""
Generate a new private RSA key. This factory function can be used to
generate a new host key or authentication key.
@param bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optional fun... | [
"def",
"generate",
"(",
"bits",
",",
"progress_func",
"=",
"None",
")",
":",
"rsa",
"=",
"RSA",
".",
"generate",
"(",
"bits",
",",
"rng",
".",
"read",
",",
"progress_func",
")",
"key",
"=",
"RSAKey",
"(",
"vals",
"=",
"(",
"rsa",
".",
"e",
",",
"... | Generate a new private RSA key. This factory function can be used to
generate a new host key or authentication key.
@param bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optional function to call at key points in
key generation (u... | [
"Generate",
"a",
"new",
"private",
"RSA",
"key",
".",
"This",
"factory",
"function",
"can",
"be",
"used",
"to",
"generate",
"a",
"new",
"host",
"key",
"or",
"authentication",
"key",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/rsakey.py#L127-L145 |
bitprophet/ssh | ssh/rsakey.py | RSAKey._pkcs1imify | def _pkcs1imify(self, data):
"""
turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
"""
SHA1_DIGESTINFO = '\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'
size = len(util.deflat... | python | def _pkcs1imify(self, data):
"""
turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
"""
SHA1_DIGESTINFO = '\x30\x21\x30\x09\x06\x05\x2b\x0e\x03\x02\x1a\x05\x00\x04\x14'
size = len(util.deflat... | [
"def",
"_pkcs1imify",
"(",
"self",
",",
"data",
")",
":",
"SHA1_DIGESTINFO",
"=",
"'\\x30\\x21\\x30\\x09\\x06\\x05\\x2b\\x0e\\x03\\x02\\x1a\\x05\\x00\\x04\\x14'",
"size",
"=",
"len",
"(",
"util",
".",
"deflate_long",
"(",
"self",
".",
"n",
",",
"0",
")",
")",
"fil... | turn a 20-byte SHA1 hash into a blob of data as large as the key's N,
using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre. | [
"turn",
"a",
"20",
"-",
"byte",
"SHA1",
"hash",
"into",
"a",
"blob",
"of",
"data",
"as",
"large",
"as",
"the",
"key",
"s",
"N",
"using",
"PKCS1",
"s",
"\\",
"emsa",
"-",
"pkcs1",
"-",
"v1_5",
"\\",
"encoding",
".",
"totally",
"bizarre",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/rsakey.py#L152-L160 |
bitprophet/ssh | ssh/dsskey.py | DSSKey.generate | 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 bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optiona... | python | 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 bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optiona... | [
"def",
"generate",
"(",
"bits",
"=",
"1024",
",",
"progress_func",
"=",
"None",
")",
":",
"dsa",
"=",
"DSA",
".",
"generate",
"(",
"bits",
",",
"rng",
".",
"read",
",",
"progress_func",
")",
"key",
"=",
"DSSKey",
"(",
"vals",
"=",
"(",
"dsa",
".",
... | Generate a new private DSS key. This factory function can be used to
generate a new host key or authentication key.
@param bits: number of bits the generated key should be.
@type bits: int
@param progress_func: an optional function to call at key points in
key generation (u... | [
"Generate",
"a",
"new",
"private",
"DSS",
"key",
".",
"This",
"factory",
"function",
"can",
"be",
"used",
"to",
"generate",
"a",
"new",
"host",
"key",
"or",
"authentication",
"key",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/dsskey.py#L151-L167 |
bitprophet/ssh | ssh/config.py | SSHConfig.parse | def parse(self, file_obj):
"""
Read an OpenSSH config from the given file object.
@param file_obj: a file-like object to read the config file from
@type file_obj: file
"""
configs = [self._config[0]]
for line in file_obj:
line = line.rstrip('\n').lstr... | python | def parse(self, file_obj):
"""
Read an OpenSSH config from the given file object.
@param file_obj: a file-like object to read the config file from
@type file_obj: file
"""
configs = [self._config[0]]
for line in file_obj:
line = line.rstrip('\n').lstr... | [
"def",
"parse",
"(",
"self",
",",
"file_obj",
")",
":",
"configs",
"=",
"[",
"self",
".",
"_config",
"[",
"0",
"]",
"]",
"for",
"line",
"in",
"file_obj",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
"'\\n'",
")",
".",
"lstrip",
"(",
")",
"if",
... | Read an OpenSSH config from the given file object.
@param file_obj: a file-like object to read the config file from
@type file_obj: file | [
"Read",
"an",
"OpenSSH",
"config",
"from",
"the",
"given",
"file",
"object",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/config.py#L46-L85 |
bitprophet/ssh | ssh/config.py | SSHConfig.lookup | def lookup(self, hostname):
"""
Return a dict of config options for a given hostname.
The host-matching rules of OpenSSH's C{ssh_config} man page are used,
which means that all configuration options from matching host
specifications are merged, with more specific hostmasks takin... | python | def lookup(self, hostname):
"""
Return a dict of config options for a given hostname.
The host-matching rules of OpenSSH's C{ssh_config} man page are used,
which means that all configuration options from matching host
specifications are merged, with more specific hostmasks takin... | [
"def",
"lookup",
"(",
"self",
",",
"hostname",
")",
":",
"matches",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"_config",
"if",
"fnmatch",
".",
"fnmatch",
"(",
"hostname",
",",
"x",
"[",
"'host'",
"]",
")",
"]",
"# Move * to the end",
"_star",
"="... | Return a dict of config options for a given hostname.
The host-matching rules of OpenSSH's C{ssh_config} man page are used,
which means that all configuration options from matching host
specifications are merged, with more specific hostmasks taking
precedence. In other words, if C{"Port... | [
"Return",
"a",
"dict",
"of",
"config",
"options",
"for",
"a",
"given",
"hostname",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/config.py#L87-L117 |
bitprophet/ssh | ssh/config.py | SSHConfig._expand_variables | def _expand_variables(self, config, hostname ):
"""
Return a dict of config options with expanded substitutions
for a given hostname.
Please refer to man ssh_config(5) for the parameters that
are replaced.
@param config: the config for the hostname
@type hostnam... | python | def _expand_variables(self, config, hostname ):
"""
Return a dict of config options with expanded substitutions
for a given hostname.
Please refer to man ssh_config(5) for the parameters that
are replaced.
@param config: the config for the hostname
@type hostnam... | [
"def",
"_expand_variables",
"(",
"self",
",",
"config",
",",
"hostname",
")",
":",
"if",
"'hostname'",
"in",
"config",
":",
"config",
"[",
"'hostname'",
"]",
"=",
"config",
"[",
"'hostname'",
"]",
".",
"replace",
"(",
"'%h'",
",",
"hostname",
")",
"else"... | Return a dict of config options with expanded substitutions
for a given hostname.
Please refer to man ssh_config(5) for the parameters that
are replaced.
@param config: the config for the hostname
@type hostname: dict
@param hostname: the hostname that the config belong... | [
"Return",
"a",
"dict",
"of",
"config",
"options",
"with",
"expanded",
"substitutions",
"for",
"a",
"given",
"hostname",
"."
] | train | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/config.py#L119-L176 |
Spirent/py-stcrestclient | stcrestclient/resthttp.py | RestHttp.url | def url(proto, server, port=None, uri=None):
"""Construct a URL from the given components."""
url_parts = [proto, '://', server]
if port:
port = int(port)
if port < 1 or port > 65535:
raise ValueError('invalid port value')
if not ((proto == 'ht... | python | def url(proto, server, port=None, uri=None):
"""Construct a URL from the given components."""
url_parts = [proto, '://', server]
if port:
port = int(port)
if port < 1 or port > 65535:
raise ValueError('invalid port value')
if not ((proto == 'ht... | [
"def",
"url",
"(",
"proto",
",",
"server",
",",
"port",
"=",
"None",
",",
"uri",
"=",
"None",
")",
":",
"url_parts",
"=",
"[",
"proto",
",",
"'://'",
",",
"server",
"]",
"if",
"port",
":",
"port",
"=",
"int",
"(",
"port",
")",
"if",
"port",
"<"... | Construct a URL from the given components. | [
"Construct",
"a",
"URL",
"from",
"the",
"given",
"components",
"."
] | train | https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L112-L129 |
Spirent/py-stcrestclient | stcrestclient/resthttp.py | RestHttp.make_url | def make_url(self, container=None, resource=None, query_items=None):
"""Create a URL from the specified parts."""
pth = [self._base_url]
if container:
pth.append(container.strip('/'))
if resource:
pth.append(resource)
else:
pth.append('')
... | python | def make_url(self, container=None, resource=None, query_items=None):
"""Create a URL from the specified parts."""
pth = [self._base_url]
if container:
pth.append(container.strip('/'))
if resource:
pth.append(resource)
else:
pth.append('')
... | [
"def",
"make_url",
"(",
"self",
",",
"container",
"=",
"None",
",",
"resource",
"=",
"None",
",",
"query_items",
"=",
"None",
")",
":",
"pth",
"=",
"[",
"self",
".",
"_base_url",
"]",
"if",
"container",
":",
"pth",
".",
"append",
"(",
"container",
".... | Create a URL from the specified parts. | [
"Create",
"a",
"URL",
"from",
"the",
"specified",
"parts",
"."
] | train | https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L166-L181 |
Spirent/py-stcrestclient | stcrestclient/resthttp.py | RestHttp.head_request | def head_request(self, container, resource=None):
"""Send a HEAD request."""
url = self.make_url(container, resource)
headers = self._make_headers(None)
try:
rsp = requests.head(url, headers=self._base_headers,
verify=self._verify, timeout=sel... | python | def head_request(self, container, resource=None):
"""Send a HEAD request."""
url = self.make_url(container, resource)
headers = self._make_headers(None)
try:
rsp = requests.head(url, headers=self._base_headers,
verify=self._verify, timeout=sel... | [
"def",
"head_request",
"(",
"self",
",",
"container",
",",
"resource",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"make_url",
"(",
"container",
",",
"resource",
")",
"headers",
"=",
"self",
".",
"_make_headers",
"(",
"None",
")",
"try",
":",
"rsp"... | Send a HEAD request. | [
"Send",
"a",
"HEAD",
"request",
"."
] | train | https://github.com/Spirent/py-stcrestclient/blob/80ee82bddf2fb2808f3da8ff2c80b7d588e165e8/stcrestclient/resthttp.py#L183-L197 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.