Importing and using the Comware 7 extended Python API
To use the Comware 7 extended Python API, you must import the API to Python.
Use either of the following methods to import and use the Comware 7 extended Python API:
Use import comware to import the entire API and use comware.API to execute an API.
For example, to use the extended API Transfer to 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='') <comware.Transfer object at 0xb7eab0e0>
Use from comware import API to import an API and use API to execute the API.
For example, to use the extended API Transfer to 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. >>> from comware import Transfer >>> Transfer('tftp', '192.168.1.26', 'test.cfg', 'flash:/test.cfg', user='', password='') <comware.Transfer object at 0xb7e5e0e0>