exectools.qt4

Tools for running external processes in a Qt4 GUI.

Functions

level2tag(level)

Classes

BaseOutputHandler([logger]) Base class for output handlers
BaseToolController([logger]) Base class for controlling command line tools.
Qt4Blinker([parent, flags]) Qt4 linker.
Qt4DialogLoggingHandler([dialog, parent]) Qt4 handler for the logging dialog.
Qt4LoggingHandler(textview) Custom handler for logging on Qt4 textviews.
Qt4OutputHandler([logger, statusbar, ...]) Qt4 Output Handler.
Qt4OutputPlane([parent])
Qt4ToolController([logger, parent]) Qt4 tool controller.
class exectools.qt4.Qt4Blinker(parent=None, flags=<PyQt4.QtCore.WindowFlags object at 0x4118440>, **kwargs)[source]

Bases: PyQt4.QtGui.QLabel

Qt4 linker.

Slots :
flush()[source]
pulse()[source]

A blinker pulse.

C++ signature:void pulse()
reset()[source]

Reset the blinker.

class exectools.qt4.Qt4OutputPlane(parent=None, **kwargs)[source]

Bases: PyQt4.QtGui.QTextEdit

contextMenuEvent(event)[source]
planeHideRequest

SIGNAL: emits a hide request.

C++ signature:void planeHideRequest()
save()[source]

Save a file.

class exectools.qt4.Qt4OutputHandler(logger=None, statusbar=None, progressbar=None, blinker=None, parent=None, **kwargs)[source]

Bases: PyQt4.QtCore.QObject, exectools.BaseOutputHandler

Qt4 Output Handler.

Signals :
close()[source]

Reset the instance.

feed(data)[source]

Feed some data to the parser.

It is processed insofar as it consists of complete elements; incomplete data is buffered until more data is fed or close() is called.

handle_progress(data)[source]

Handle progress data.

Parameters:data – a list containing an item for each named group in the “progress” regular expression: (pulse, percentage, text) for the default implementation. Each item can be None.
percentageChanged

SIGNAL: it is emitted when the progress percentage changes

Parameters:percentage (float) – the new completion percentage [0, 100]
C++ signature:void percentageChanged(float)
pulse

SIGNAL: it is emitted to signal some kind of activity of the external process

Parameters:text (str) – an optional text describing the kind activity of the external process
C++ signature:void pulse(QString)
reset()[source]

Reset the handler instance.

Loses all unprocessed data. This is called implicitly at instantiation time.

class exectools.qt4.Qt4LoggingHandler(textview)[source]

Bases: logging.Handler

Custom handler for logging on Qt4 textviews.

emit(record)[source]
class exectools.qt4.Qt4DialogLoggingHandler(dialog=None, parent=None)[source]

Bases: logging.Handler

Qt4 handler for the logging dialog.

emit(record)[source]
levelsmap = {0: 1, 40: 3, 10: 1, 50: 3, 20: 1, 30: 2}
class exectools.qt4.Qt4ToolController(logger=None, parent=None, **kwargs)[source]

Bases: PyQt4.QtCore.QObject, exectools.BaseToolController

Qt4 tool controller.

Signals :
Slots :
finalize_run(exitCode=None, exitStatus=None)[source]

Perform finalization actions.

This method is called when the controlled process terminates to perform finalization actions like:

  • read and handle residual data in buffers,
  • flush and close output handlers,
  • close subprocess file descriptors
  • run the “finalize_run_hook” method
  • reset the controller instance

If one just needs to perfor some additional finalization action it should be better to use a custom “finalize_run_hook” instead of overriging “finalize_run”.

C++ signature:finalize_run(int, QProcess::ExitStatus)
finished

SIGNAL: it is emitted when the processing is finished.

Parameters:exitcode (int) – the external proces exit code
C++ signature:void finished(int exitCode)
handle_error(error)[source]

Handle a error in process execution.

Can be handle different types of errors:

  • starting failed
  • crashing after starts successfully
  • timeout elapsed
  • write error
  • read error
  • unknow error
C++ signature:void handle_error(QProcess::ProcessError)
handle_stderr()[source]

Handle standard error.

C++ signature:void handle_stderr()
handle_stdout()[source]

Handle standard output.

C++ signature:void handle_stdout()
isbusy[source]

If True then the controller is already running a subprocess.

run_tool(tool, *args, **kwargs)[source]

Run an external tool in controlled way.

The output of the child process is handled by the controller and, optionally, notifications can be achieved at sub-process termination.

stop_tool(force=True)[source]

Stop the execution of controlled subprocess.

When this method is invoked the controller instance is always reset even if the controller is unable to stop the subprocess.

When possible the controller try to kill the subprocess in a polite way. If this fails it also tryes brute killing by default (force=True). This behaviour can be controlled using the force parameter.

C++ signature:void stop_tool(bool)

Get GSDView at SourceForge.net. Fast, secure and Free Open Source software downloads

Previous topic

exectools.std

Next topic

exectools.gtk2

This Page