class documentation

class Application(object): (source)

Known subclasses: zim.applications.StartFile, zim.applications.WebBrowser, zim.gui.applications.DesktopEntryDict

View In Hierarchy

Base class for objects representing an external application or command.
Method __eq__ Undocumented
Method __init__ Constructor
Method __repr__ Undocumented
Method pipe Run the application in a sub-process and capture the output. Like run(), but connects to stdin and stdout for the sub-process.
Method run No summary
Method spawn No summary
Method tryexec No summary
Constant STATUS_OK Undocumented
Instance Variable cmd the command and arguments as a tuple or a string (when given as a string it will be parsed for quoted arguments)
Instance Variable tryexeccmd the command to check in tryexec(), if None fall back to first item of cmd
Property name Undocumented
Static Method _lookup Lookup cmd in PATH
Method _checkargs Undocumented
Method _cmd Undocumented
def __eq__(self, other): (source)
def __init__(self, cmd, tryexeccmd=None): (source)
Constructor
Parameters
cmdthe command for the external application, either a string for the command, or a tuple or list with the command and arguments
tryexeccmdcommand to check in tryexec() as string. If None will default to cmd or the first item of cmd.
def __repr__(self): (source)

Undocumented

def pipe(self, args=None, cwd=None, input=None): (source)
Run the application in a sub-process and capture the output. Like run(), but connects to stdin and stdout for the sub-process.
Parameters
argsadditional arguments to give to the command as tuple or list
cwdthe folder to set as working directory for the command
inputinput for the command as string
Returns
output as a list of lines
Raises
ApplicationErrorif the sub-process returned an error.
Note
The data read is buffered in memory, so do not use this method if the data size is large or unlimited.
def run(self, args=None, cwd=None): (source)
Run the application in a sub-process and wait for it to finish. Even when the application runs successfully, any message to stderr is logged as a warning by zim.
Parameters
argsadditional arguments to give to the command as tuple or list
cwdthe folder to set as working directory for the command
Raises
ApplicationErrorif the sub-process returned an error.
def spawn(self, args=None, callback=None, data=None, cwd=None): (source)
Start the application in the background and return immediately. This is used to start an external in parallel with zim that is not expected to exit immediatly, so we do not want to wait for it - e.g. a webbrowser to show an URL that was clicked.
Parameters
argsadditional arguments to give to the command as tuple or list
callback

optional callback can be used to trigger when the application exits. The signature is:

        callback(status, data)

where 'status' is the exit status of the process. The application object provides a constant 'STATUS_OK' which can be used to test if the application was successful or not.

dataadditional data for the callback
cwdthe folder to set as working directory for the command
Returns
the PID for the new process
def tryexec(self): (source)
Check if the executable exists without calling it. This method is used e.g. to decide what applications to show in the gui. Uses the tryexeccmd, or the first item of cmd as the executable name.
Returns
True when the executable was found
STATUS_OK: int = (source)

Undocumented

Value
0
the command and arguments as a tuple or a string (when given as a string it will be parsed for quoted arguments)
tryexeccmd = (source)
the command to check in tryexec(), if None fall back to first item of cmd
@staticmethod
def _lookup(cmd): (source)
Lookup cmd in PATH
def _checkargs(self, cwd, args): (source)

Undocumented

def _cmd(self, args): (source)

Undocumented