Table of Contents

Module: commands ./src/peak/running/commands.py

Base classes for Main Programs (i.e. processes invoked from the OS)

Imported modules   
from __future__ import generators
from interfaces import *
import options
import os
from os.path import isfile
from peak.api import *
from peak.cli.options import InvocationError
from peak.util.decorators import decorate
from peak.util.imports import importObject
import sys
from types import ClassType, FunctionType
Functions   
appAsFactory
appAsMainFactory
callableAsFactory
factoryAsMainFactory
lookupCommand
rerunnableAsFactory
runMain
  appAsFactory 
appAsFactory ( app )

Convert an ICmdLineApp to an ICmdLineAppFactory

  appAsMainFactory 
appAsMainFactory ( ob )

Build IMainCmdFactory that just returns an existing app object

  callableAsFactory 
callableAsFactory ( ob )

Convert a callable object to an ICmdLineAppFactory

  factoryAsMainFactory 
factoryAsMainFactory ( ob )

Build IMainCmdFactory that creates a config root per-invocation

  lookupCommand 
lookupCommand (
        command,
        name,
        default,
        acceptURLs=False,
        )

Lookup name as a command shortcut or URL; may raise InvalidName

command.getCommandParent() is used as the lookup context.

Exceptions   
exceptions.InvalidName( "URL not allowed" )
  rerunnableAsFactory 
rerunnableAsFactory ( runnable )

Convert an IRerunnable to an ICmdLineAppFactory

  runMain 
runMain ( factory )

Use factory to create and run a "main" program

factory must be adaptable to ICmdLineApp, ICmdLineAppFactory, or IMainCmdFactory. In each case, it will be used to create and run a "main program", whose run() method's return code will be passed to sys.exit(). Example usage:

        from peak.running import commands

        class MyCommand(commands.AbstractCommand):
            def _run(self):
                print "Hello world!"

        if __name__ == '__main__':
            commands.runMain(MyCommand)

To support "child processes" created with PEAK's process management tools, this function will check the run() method's return code to see if it is another ICmdLineApp, ICmdLineAppFactory, or IMainCmdFactory. If so, it will create and run a new "main program" based on that result, after allowing the previous "main program" to be garbage collected. This looping will continue until run() returns a non-command object.

Classes   

AbstractCommand

Simple, commandline-driven process

AbstractInterpreter

Creates and runs a subcommand by interpreting 'argv[1]

Alias

A factory for executables that aliases some other command

Bootstrap

Invoke and use an arbitrary IExecutable object

CGICommand

Run CGI/FastCGI in an event-driven loop

CGIInterpreter

Run an application as a CGI, by adapting it to IWSGIApplication

CallableAsCommand

Adapts callables to 'ICmdLineApp

ErrorSubcommand

Subcommand that displays an error/usage message

EventDriven

Run an event-driven main loop after setup

FastCGIAcceptor

Accept FastCGI connections

IniInterpreter

Interpret an .ini file as a command-line app

InvalidSubcommandName

Subcommand that says its command name is invalid

NoSuchSubcommand

Subcommand that says there's no such command

RerunnableAsCommand

Adapts IRerunnable to 'ICmdLineApp

TestRunner

WSGIAsRerunnableCGI

WSGIInterpreter

Run arbitrary WSGI applications by declaring them IWSGIApplication

ZConfigInterpreter

Load a ZConfig schema and run it as a sub-interpreter


Table of Contents

This document was automatically generated on Mon Jun 24 01:11:18 2019 by HappyDoc version 2.1