Transfer class

Transfer

Use Transfer to download a file from a server.

Syntax

Transfer(protocol=‘’, host=‘’, source=‘’, dest=‘’, vrf=‘’, login_timeout=10, user=‘’, password=‘’)

Parameters

protocol: Specifies the protocol used to download a file:

host: Specifies the IP address of the remote server.

source: Specifies the name of the file to be downloaded from the remote server.

dest: Specifies a name for the downloaded file.

vrf: Specifies the VPN instance to which the remote server belongs. This argument is a case-sensitive string of 1 to 31 characters. If the server belongs to the public network, do not specify this argument.

login_timeout: Specifies the timeout for the operation, in seconds. The default is 10.

user: Specifies the username for logging in to the server.

password: Specifies the login password.

Returns

Transfer object

Examples

# Download the test.cfg file from TFTP server 192.168.1.26.

<Sysname> python
Python 2.7.3 (default, May 24 2014, 14:37:26)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import comware
>>> comware.Transfer('tftp', '192.168.1.26', 'test.cfg', 'flash:/test.cfg', user='', password='')

Sample output

<comware.Transfer object at 0xb7f700e0>

get_error

Use get_error to get the error information from the download operation.

Syntax

Transfer.get_error()

Returns

If there is no error information, None is returned.

Examples

# Download the test.cfg file from TFTP server 1.1.1.1 and get the error information from the operation.

<Sysname> python
Python 2.7.3 (default, May 24 2014, 14:37:26)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import comware
>>> c = comware.Transfer('tftp', '1.1.1.1', 'test.cfg', 'flash:/test.cfg', user='', password='')
>>> c.get_error()

Sample output

'Timeout was reached'