gsdview.ptc.core

Tools for running external processes.

Functions

StringIO StringIO([s]) – Return a StringIO-like stream for reading or writing

Classes

BaseOutputHandler([loggername]) Base class for output handlers
BaseToolController([loggername]) Base class for controlling command line tools
GenericToolDescriptor(executable[, cwd, ...]) Generic tool descriptor
ToolDescriptor(executable[, cwd, env, ...]) Command line tool desctiptor
class gsdview.ptc.core.BaseOutputHandler(loggername='externaltool')

Base class for output handlers

close()
Force processing of all buffered data and reset the instance.
feed(data)

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_line(data)

Handle output lines

This method is not meant to be directly called by the user.

The user, anyway, can provide a custom implementation in derived classes.

Parameters :
  • data: an entire output line (including the trailing “end of line” character).
handle_progress(data)

Handle progress data.

This method is not meant to be called by the user.

The user, anyway, can provide a custom implementation in derived classes.

Parameters :
  • data: a list containing an item for each named group in the “progress” regular expression and buffer content without whitespaces and ‘r’, ‘n’ chars: (pulse, percentage, text, basedata) for the default implementation. Each of first three items can be None.
reset()

Reset the handler instance

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

class gsdview.ptc.core.ToolDescriptor(executable, cwd=None, env=None, isextraenv=True, stdout_handler=None, stderr_handler=None)

Command line tool desctiptor

Attributes :
  • executable: full path of the tool executable or just the tool

    program name if it is in the system search path

  • cwd: program working directory

  • env: environment for subprocess. It’s full or extra environment

    according to isextraenv

  • isextraenv: True if env items must be added to os environment

  • stdout_handler: the OutputHandler for the stdout of the tool

  • stderr_handler: the OutputHandler for the stderr of the tool

cmdline(*args)

Generate the complete command-line for the tool

This method is meant to be used together with “subprocess” so the “comman-line” actually is a list of strings.

If you need a command-line in single string form use something like:

str(tooldescriptorinstance)

or:

' '.join(tooldescriptorinstance.cmdline(arg1, arg2, arg3))
env
class gsdview.ptc.core.GenericToolDescriptor(executable, cwd=None, env=None, isextraenv=True, stdout_handler=None, stderr_handler=None)

Generic tool descriptor

The command line can be entirely defined by means of arguments passed to the cmdline method.

cmdline(*args, **kwargs)

Generate the complete command-line for the tool

This method is meant to be used together with “subprocess” so the “comman-line” actually is a list of strings.

If the executable attribute is not set (evaluate false) then the first non-keyword argument is considered to be the executable tool name.

The command line is build as follows:

executable keyword-arguments args

If you need a command-line in single string form use something like:

' '.join(tooldescriptorinstance.cmdline(arg1, arg2, arg3))

Previous topic

gsdview.ptc

Next topic

gsdview.ptc.qt

This Page