Package tlib :: Package base :: Module SshFileRequestor :: Class SshFileRequestor
[hide private]
[frames] | no frames]

Class SshFileRequestor

source code

object --+
         |
        SshFileRequestor

Helper class for retrieving files from remote server

Instance Methods [hide private]
 
__init__(self, host, username=None, password=None, pkey=None, key_filename=None, path=None, keep_alive=True)
Constructor for class
source code
 
__del__(self)
Destructor for class
source code
 
ssh_connect(self)
Establish ssh connection
source code
 
ssh_disconnect(self)
Destroy ssh connection
source code
 
remote_tail(self, remote_host, path=None, length=0)
Tail the file from a remote host (current connection used for hop purpose): Please make sure the new ssh remote login does not require to input credentials
source code
 
tail(self, path=None, length=0)
Download file from server using sftp and returns file contents as a string
source code

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

Class Variables [hide private]
  _host = None
  _username = None
  _password = None
  _pkey = None
  _keyfile = None
  _path = None
  _size = None
  _start = 0
  _ssh = None
  _client = None
  _keepalive = None
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, host, username=None, password=None, pkey=None, key_filename=None, path=None, keep_alive=True)
(Constructor)

source code 

Constructor for class

Parameters:
  • host - remote hostname
  • username - login username
  • password - login password
  • pkey - private key used for login
  • key_filename - key file used for login
  • path - file path to be retrieved
  • keep_alive - establish only one connection
Overrides: object.__init__

remote_tail(self, remote_host, path=None, length=0)

source code 

Tail the file from a remote host (current connection used for hop purpose): Please make sure the new ssh remote login does not require to input credentials

Parameters:
  • remote_host - target server where the file is located
  • path - path to file on the target server
  • length - length used for tailing
Returns:
a list of last n lines of file

tail(self, path=None, length=0)

source code 

Download file from server using sftp and returns file contents as a string

Parameters:
  • path - path to file on the server
  • length - length used for tailing, tailing from last position (or beginning) if length is not provided
Returns:
a list of last n lines of file