Package entropy :: Package transceivers :: Class EntropyTransceiver

Class EntropyTransceiver

source code


Base class for Entropy transceivers. This provides a common API across
all the available URI handlers.

How to use this class:
Let's consider that we have a valid EntropyUriHandler for ftp:// protocol
already installed via "add_uri_handler".

>> txc = EntropyTransceiver("ftp://myuser:[email protected]")
>> txc.set_speed_limit(150) # set speed limit to 150kb/sec
>> handler = txc.swallow()
>> handler.download("ftp://myuser:[email protected]/myfile.txt", "/tmp")
    # download 

Instance Methods
 
__init__(self, uri)
EntropyTransceiver constructor, just pass the friggin URI(tm).
source code
 
__enter__(self)
Support for "with" statement, this method will execute swallow() and return a valid EntropyUriHandler instance.
source code
 
__exit__(self, exc_type, exc_value, traceback)
Support for "with" statement, this method will automagically close the previously created EntropyUriHandler instance connection.
source code
 
set_output_interface(self, output_interface)
Provide alternative Entropy output interface (must be based on entropy.output.TextInterface)
source code
 
set_speed_limit(self, speed_limit)
Set download/upload speed limit in kb/sec form.
source code
 
set_timeout(self, timeout)
Set transceiver tx/rx timeout value in seconds.
source code
 
set_silent(self, silent)
Disable transceivers verbosity.
source code
 
set_verbosity(self, verbosity)
Set transceiver verbosity.
source code
 
swallow(self)
Given the URI at the constructor, this method returns the first valid URI handler instance found that can be used to do required action.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods

Inherited from output.TextInterface: ask_question, edit_file, input_box, output, set_title

Static Methods
 
add_uri_handler(entropy_uri_handler_class)
Add custom URI handler to EntropyTransceiver class.
source code
 
remove_uri_handler(entropy_uri_handler_class)
Remove custom URI handler to EntropyTransceiver class.
source code
list
get_uri_handlers()
Return a copy of the internal list of URI handler instances.
source code
string
get_uri_name(uri)
Given an URI, extract and return the URI name (hostname).
source code
string
hide_sensible_data(uri)
Given an URI, hide sensible data from string and return it back.
source code
Class Variables

Inherited from output.TextInterface: OUTPUT_LOCK

Properties

Inherited from object: __class__

Method Details

add_uri_handler(entropy_uri_handler_class)
Static Method

source code 

Add custom URI handler to EntropyTransceiver class.

Parameters:
  • entropy_uri_handler_class - EntropyUriHandler based class @type entropy_uri_handler_class; EntropyUriHandler instance

remove_uri_handler(entropy_uri_handler_class)
Static Method

source code 

Remove custom URI handler to EntropyTransceiver class.

Parameters:
  • entropy_uri_handler_class - EntropyUriHandler based instance @type entropy_uri_handler_class; EntropyUriHandler instance
Raises:
  • ValueError - if provided EntropyUriHandler is not in storage.

get_uri_handlers()
Static Method

source code 

Return a copy of the internal list of URI handler instances.

Returns: list
URI handlers instances list

get_uri_name(uri)
Static Method

source code 

Given an URI, extract and return the URI name (hostname).

Parameters:
  • uri (string) - URI to handle
Returns: string
URI name
Raises:

hide_sensible_data(uri)
Static Method

source code 

Given an URI, hide sensible data from string and return it back.

Parameters:
  • uri (string) - URI to handle
Returns: string
URI cleaned
Raises:

__init__(self, uri)
(Constructor)

source code 

EntropyTransceiver constructor, just pass the friggin URI(tm).

Parameters:
  • uri (string) - URI to handle
Overrides: object.__init__

set_output_interface(self, output_interface)

source code 

Provide alternative Entropy output interface (must be based on entropy.output.TextInterface)

Parameters:
  • output_interface (entropy.output.TextInterface based instance) - new entropy.output.TextInterface instance to use
Raises:
  • AttributeError - if argument passed is not correct

set_speed_limit(self, speed_limit)

source code 

Set download/upload speed limit in kb/sec form. Zero value will be considered as "disable speed limiter".

Parameters:
  • speed_limit (int) - speed limit in kb/sec form.
Raises:
  • AttributeError - if speed_limit is not an integer

set_timeout(self, timeout)

source code 

Set transceiver tx/rx timeout value in seconds.

Parameters:
  • timeout (int) - timeout in seconds

set_silent(self, silent)

source code 

Disable transceivers verbosity.

Parameters:
  • verbosity (bool) - verbosity value

set_verbosity(self, verbosity)

source code 

Set transceiver verbosity.

Parameters:
  • verbosity (bool) - verbosity value

swallow(self)

source code 

Given the URI at the constructor, this method returns the first valid URI handler instance found that can be used to do required action.

Raises: