MoleQueue 0.9.0
Loading...
Searching...
No Matches
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

◆ sshCommand()

QString sshCommand ( )
Returns
The SSH command that will be run.

◆ scpCommand()

QString scpCommand ( )
Returns
The SCP command that will be run.

◆ output()

QString output ( ) const
virtual
Returns
The merged stdout and stderr of the remote command

Reimplemented from SshConnection.

◆ exitCode()

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

Reimplemented from SshConnection.

◆ waitForCompletion()

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.

◆ isComplete()

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

Reimplemented from SshConnection.

◆ setSshCommand

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.

◆ setScpCommand

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.

◆ execute

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.

◆ copyTo

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.

◆ copyFrom

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.

◆ copyDirTo

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.

◆ copyDirFrom

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.

◆ processStarted

void processStarted ( )
protectedslot

Called when the TerminalProcess enters the Running state.

◆ processFinished

void processFinished ( )
protectedslot

Called when the TerminalProcess exits the Running state.

◆ sendRequest()

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

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

◆ initializeProcess()

void initializeProcess ( )
protected

Initialize the TerminalProcess object.

◆ sshArgs()

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

Implemented in OpenSshCommand, and PuttyCommand.

◆ scpArgs()

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

Implemented in OpenSshCommand, and PuttyCommand.

◆ remoteSpec()

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

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