MoleQueue  0.8.0
 All Classes Functions Variables Enumerations Enumerator Pages
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
SshCommand Class Referenceabstract

#include <molequeue/sshcommand.h>

Inheritance diagram for SshCommand:
SshConnection OpenSshCommand PuttyCommand

Public Slots

void setSshCommand (const QString &command)
 
void setScpCommand (const QString &command)
 
virtual bool execute (const QString &command)
 
virtual bool copyTo (const QString &localFile, const QString &remoteFile)
 
virtual bool copyFrom (const QString &remoteFile, const QString &localFile)
 
virtual bool copyDirTo (const QString &localDir, const QString &remoteDir)
 
virtual bool copyDirFrom (const QString &remoteDir, const QString &localDir)
 
- Public Slots inherited from SshConnection
void setPersistent (bool persist)
 
void setUserName (const QString &newUserName)
 
void setHostName (const QString &newHostName)
 
void setIdentityFile (const QString &newIdentityFile)
 
void setPortNumber (int newPortNumber)
 
virtual bool execute (const QString &command)
 
virtual bool copyTo (const QString &localFile, const QString &remoteFile)
 
virtual bool copyFrom (const QString &remoteFile, const QString &localFile)
 
virtual bool copyDirTo (const QString &localDir, const QString &remoteDir)
 
virtual bool copyDirFrom (const QString &remoteDir, const QString &localDir)
 

Public Member Functions

 SshCommand (QObject *parentObject, QString sshCommand, QString scpCommand)
 
QString sshCommand ()
 
QString scpCommand ()
 
QString output () const
 
int exitCode () const
 
bool waitForCompletion (int msecs=30000)
 
bool isComplete () const
 
- Public Member Functions inherited from SshConnection
 SshConnection (QObject *parentObject=0)
 
bool isPersistent () const
 
QString userName () const
 
QString hostName () const
 
QString identityFile () const
 
int portNumber () const
 
virtual bool isValid () const
 
QVariant & data ()
 
const QVariant & data () const
 
void setData (const QVariant &newData)
 

Protected Slots

void processStarted ()
 
void processFinished ()
 

Protected Member Functions

virtual void sendRequest (const QString &command, const QStringList &args)
 
void initializeProcess ()
 
virtual QStringList sshArgs ()=0
 
virtual QStringList scpArgs ()=0
 
QString remoteSpec ()
 

Protected Attributes

QString m_sshCommand
 
QString m_scpCommand
 
QString m_output
 
int m_exitCode
 
TerminalProcessm_process
 
bool m_isComplete
 
- Protected Attributes inherited from SshConnection
bool m_persistent
 
QVariant m_data
 
QString m_userName
 
QString m_hostName
 
QString m_identityFile
 
int m_portNumber
 

Additional Inherited Members

- Signals inherited from SshConnection
void requestSent ()
 
void requestComplete ()
 
- Static Protected Member Functions inherited from SshConnection
static bool debug ()
 

Detailed Description

Abstract subclass of SshConnection providing base implementaton using commandline ssh/scp.

Author
Marcus D. Hanwell, David C. Lonie, Chris Harris

The SshCommand provides an base implementation of the SshConnection interface that calls the commandline ssh and scp executables in a TerminalProcess.

When writing code that needs ssh functionality, the code should use the SshConnection interface instead.

Member Function Documentation

QString sshCommand ( )
Returns
The SSH command that will be run.
QString scpCommand ( )
Returns
The SCP command that will be run.
QString output ( ) const
virtual
Returns
The merged stdout and stderr of the remote command

Reimplemented from SshConnection.

int exitCode ( ) const
virtual
Returns
The exit code returned from the remote command.

Reimplemented from SshConnection.

bool waitForCompletion ( int  msecs = 30000)
virtual

Wait until the request has been completed.

Parameters
msecsTimeout in milliseconds. Default is 30 seconds.
Returns
True if request finished, false on timeout.

Reimplemented from SshConnection.

bool isComplete ( ) const
virtual
Returns
True if the request has completed. False otherwise.

Reimplemented from SshConnection.

void setSshCommand ( const QString &  command)
slot

Set the SSH command for the class. Defaults to 'ssh', and would execute the SSH commnand in the user's path.

void setScpCommand ( const QString &  command)
slot

Set the SCP command for the class. Defaults to 'scp', and would execute the SCP commnand in the user's path.

virtual bool execute ( const QString &  command)
virtualslot

Execute the supplied command on the remote host.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
commandThe command to execute.
Returns
True on success, false on failure.
virtual bool copyTo ( const QString &  localFile,
const QString &  remoteFile 
)
virtualslot

Copy a local file to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localFileThe path of the local file.
remoteFileThe path of the file on the remote system.
Returns
True on success, false on failure.
virtual bool copyFrom ( const QString &  remoteFile,
const QString &  localFile 
)
virtualslot

Copy a remote file to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteFileThe path of the file on the remote system.
localFileThe path of the local file.
Returns
True on success, false on failure.
virtual bool copyDirTo ( const QString &  localDir,
const QString &  remoteDir 
)
virtualslot

Copy a local directory recursively to the remote system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
localDirThe path of the local directory.
remoteDirThe path of the directory on the remote system.
Returns
True on success, false on failure.
virtual bool copyDirFrom ( const QString &  remoteDir,
const QString &  localDir 
)
virtualslot

Copy a remote directory recursively to the local system.

Note
The command is executed asynchronously, see requestComplete() or waitForCompletion() for results.
See Also
requestSent() requestCompleted() waitForCompeletion()
Parameters
remoteDirThe path of the directory on the remote system.
localFileThe path of the local directory.
Returns
True on success, false on failure.
void processStarted ( )
protectedslot

Called when the TerminalProcess enters the Running state.

void processFinished ( )
protectedslot

Called when the TerminalProcess exits the Running state.

virtual void sendRequest ( const QString &  command,
const QStringList &  args 
)
protectedvirtual

Send a request. This launches the process and connects the completion signals

void initializeProcess ( )
protected

Initialize the TerminalProcess object.

virtual QStringList sshArgs ( )
protectedpure virtual
Returns
the arguments to be passed to the SSH command.

Implemented in OpenSshCommand, and PuttyCommand.

virtual QStringList scpArgs ( )
protectedpure virtual
Returns
the arguments to be passed to the SCP command.

Implemented in OpenSshCommand, and PuttyCommand.

QString remoteSpec ( )
protected
Returns
the remote specification, e.g. "user@host" or "host"

The documentation for this class was generated from the following file: