Package qm :: Module host :: Class Host
[hide private]
[frames] | no frames]

Class Host

source code

         object --+    
                  |    
extension.Extension --+
                      |
                     Host

A 'Host' is a logical machine.

Each logical machine has a default directory. When a file is uploaded to or downloaded from the machine, and a relative path is specified, the patch is relative to the default directory. Similarly, when a program is run on the remote machine, its initial working directory is the default directory.

The interface presented by 'Host' is a lowest common denominator. The objective is not to expose all the functionality of any host; rather it is to provide an interface that can be used on many hosts.

Nested Classes [hide private]
  Executable
An 'Executable' is a simple redirected executable.

Inherited from extension.Extension: Type, __metaclass__

Instance Methods [hide private]
 
__init__(self, arguments=None, **args)
Construct a new 'Extension'.
source code
 
Run(self, path, arguments, environment=None, timeout=-1, relative=False)
Run a program on the remote host.
source code
 
UploadFile(self, local_file, remote_file=None)
Copy 'local_file' to 'remote_file'.
source code
 
DownloadFile(self, remote_file, local_file)
Copy 'remote_file' to 'local_file'.
source code
 
UploadAndRun(self, path, arguments, environment=None, timeout=-1)
Run a program on the remote host.
source code
 
DeleteFile(self, remote_file)
Delete the 'remote_file'.
source code

Inherited from extension.Extension: GetClassName, GetExplicitArguments, MakeDomDocument, MakeDomElement, Write, __getattr__

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

Class Variables [hide private]
  kind = "host"
A string giving kind of extension is implemented by the class.

Inherited from extension.Extension: arguments

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, arguments=None, **args)
(Constructor)

source code 

Construct a new 'Extension'.

'args': Keyword arguments providing values for Extension parameters. The values should be appropriate for the corresponding fields. Derived classes must pass along any unrecognized keyword arguments to this method so that additional arguments can be added in the future without necessitating changes to derived classes.

This method will place all of the arguments into this objects instance dictionary.

Derived classes may override this method, but should call this method during their processing.

Overrides: object.__init__
(inherited documentation)

Run(self, path, arguments, environment=None, timeout=-1, relative=False)

source code 

Run a program on the remote host.

'path' -- The name of the program to run, on the remote host. If 'relative' is true, or if 'path' is not an absolute path but does contain at least one directory separator, then 'path' is interpreted relative to the default directory. Otherwise, 'path' is used unmodified.

'arguments' -- The sequence of arguments that should be passed to the program.

'environment' -- If not 'None', a dictionary of pairs of strings to add to the environment of the running program.

'timeout' -- The number of seconds the program is permitted to execute. After the 'timeout' expires, the program will be terminated. However, in some cases (such as when using 'rsh') it will be the local side of the connection that is closed. The remote side of the connection may or may not continue to operate, depending on the vagaries of the remote operating system.

returns -- A pair '(status, output)'. The 'status' is the exit status returned by the program, or 'None' if the exit status is not available. The 'output' is a string giving the combined standard output and standard error output from the program.

UploadFile(self, local_file, remote_file=None)

source code 

Copy 'local_file' to 'remote_file'.

'local_file' -- The name of the file on the local machine.

'remote_file' -- The name of the file on the remote machine. The 'remote_file' must be a relative path. It is interpreted relative to the default directory. If 'None', the 'remote_file' is placed in the default directory using the basename of the 'local_file'.

If the 'local_file' and 'remote_file' are the same, then this function succeeds, but takes no action.

DownloadFile(self, remote_file, local_file)

source code 

Copy 'remote_file' to 'local_file'.

'remote_file' -- The name of the file on the remote machine. The 'remote_file' must be a relative path. It is interpreted relative to the default directory.

'local_file' -- The name of the file on the local machine. If 'None', the 'local_file' is placed in the current directory using the basename of the 'remote_file'.

If the 'local_file' and 'remote_file' are the same, then this function succeeds, but takes no action.

UploadAndRun(self, path, arguments, environment=None, timeout=-1)

source code 

Run a program on the remote host.

'path' -- The name of the program to run, as a path on the local machine.

'arguments' -- As for 'Run'.

'environment' -- As for 'Run'.

'timeout' -- As for 'Run'.

returns -- As for 'Run'.

The program is uploaded to the default directory on the remote host, run, and then deleted.

DeleteFile(self, remote_file)

source code 

Delete the 'remote_file'.

'remote_file' -- A relative path to the file to be deleted.