Package paramiko :: Class Message
[show private | hide private]
[frames | no frames]

Type Message

object --+
         |
        Message


An SSH2 Message is a stream of bytes that encodes some combination of strings, integers, bools, and infinite-precision integers (known in python as longs). This class builds or breaks down such a byte stream.

Normally you don't need to deal with anything this low-level, but it's exposed for people implementing custom extensions, or features that paramiko doesn't support yet.
Method Summary
  __init__(self, content)
Create a new SSH2 Message.
string __repr__(self)
Returns a string representation of this object, for debugging.
string __str__(self)
Return the byte stream content of this Message, as a string.
  add(self, *seq)
Add a sequence of items to the stream.
  add_boolean(self, b)
Add a boolean value to the stream.
  add_byte(self, b)
Write a single byte to the stream, without any formatting.
  add_bytes(self, b)
Write bytes to the stream, without any formatting.
  add_int(self, n)
Add an integer to the stream.
  add_int64(self, n)
Add a 64-bit int to the stream.
  add_list(self, l)
Add a list of strings to the stream.
  add_mpint(self, z)
Add a long int to the stream, encoded as an infinite-precision integer.
  add_string(self, s)
Add a string to the stream.
bool get_boolean(self)
Fetch a boolean from the stream.
string get_byte(self)
Return the next byte of the Message, without decomposing it.
string get_bytes(self, n)
Return the next n bytes of the Message, without decomposing into an int, string, etc.
int get_int(self)
Fetch an int from the stream.
long get_int64(self)
Fetch a 64-bit int from the stream.
list of strings get_list(self)
Fetch a list of strings from the stream.
long get_mpint(self)
Fetch a long int (mpint) from the stream.
string get_remainder(self)
Return the bytes of this Message that haven't already been parsed and returned.
string get_so_far(self)
Returns the bytes of this Message that have been parsed and returned.
string get_string(self)
Fetch a string from the stream.
  rewind(self)
Rewind the message to the beginning as if no items had been parsed out of it yet.
  _add(self, i)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value

Method Details

__init__(self, content=None)
(Constructor)

Create a new SSH2 Message.
Parameters:
content - the byte stream to use as the Message content (passed in only when decomposing a Message).
           (type=string)
Overrides:
__builtin__.object.__init__

__repr__(self)
(Representation operator)

Returns a string representation of this object, for debugging.
Returns:
string
Overrides:
__builtin__.object.__repr__

__str__(self)
(Informal representation operator)

Return the byte stream content of this Message, as a string.
Returns:
the contents of this Message.
           (type=string)
Overrides:
__builtin__.object.__str__

add(self, *seq)

Add a sequence of items to the stream. The values are encoded based on their type: str, int, bool, list, or long.
Parameters:
seq - the sequence of items
           (type=sequence)

Bug: longs are encoded non-deterministically. Don't use this method.

add_boolean(self, b)

Add a boolean value to the stream.
Parameters:
b - boolean value to add
           (type=bool)

add_byte(self, b)

Write a single byte to the stream, without any formatting.
Parameters:
b - byte to add
           (type=str)

add_bytes(self, b)

Write bytes to the stream, without any formatting.
Parameters:
b - bytes to add
           (type=str)

add_int(self, n)

Add an integer to the stream.
Parameters:
n - integer to add
           (type=int)

add_int64(self, n)

Add a 64-bit int to the stream.
Parameters:
n - long int to add
           (type=long)

add_list(self, l)

Add a list of strings to the stream. They are encoded identically to a single string of values separated by commas. (Yes, really, that's how SSH2 does it.)
Parameters:
l - list of strings to add
           (type=list(str))

add_mpint(self, z)

Add a long int to the stream, encoded as an infinite-precision integer. This method only works on positive numbers.
Parameters:
z - long int to add
           (type=long)

add_string(self, s)

Add a string to the stream.
Parameters:
s - string to add
           (type=str)

get_boolean(self)

Fetch a boolean from the stream.
Returns:
True or False (from the Message).
           (type=bool)

get_byte(self)

Return the next byte of the Message, without decomposing it. This is equivalent to get_bytes(1).
Returns:
the next byte of the Message, or '' if there aren't any bytes remaining.
           (type=string)

get_bytes(self, n)

Return the next n bytes of the Message, without decomposing into an int, string, etc. Just the raw bytes are returned.
Returns:
a string of the next n bytes of the Message, or a string of n zero bytes, if there aren't n bytes remaining.
           (type=string)

get_int(self)

Fetch an int from the stream.
Returns:
a 32-bit unsigned integer.
           (type=int)

get_int64(self)

Fetch a 64-bit int from the stream.
Returns:
a 64-bit unsigned integer.
           (type=long)

get_list(self)

Fetch a list of strings from the stream. These are trivially encoded as comma-separated values in a string.
Returns:
a list of strings.
           (type=list of strings)

get_mpint(self)

Fetch a long int (mpint) from the stream.
Returns:
an arbitrary-length integer.
           (type=long)

get_remainder(self)

Return the bytes of this Message that haven't already been parsed and returned.
Returns:
a string of the bytes not parsed yet.
           (type=string)

get_so_far(self)

Returns the bytes of this Message that have been parsed and returned. The string passed into a Message's constructor can be regenerated by concatenating get_so_far and get_remainder.
Returns:
a string of the bytes parsed so far.
           (type=string)

get_string(self)

Fetch a string from the stream. This could be a byte string and may contain unprintable characters. (It's not unheard of for a string to contain another byte-stream Message.)
Returns:
a string.
           (type=string)

rewind(self)

Rewind the message to the beginning as if no items had been parsed out of it yet.

Generated by Epydoc 2.1 on Sun Dec 4 11:16:46 2005 http://epydoc.sf.net