Package osh :: Module api
[frames] | no frames]

Module api

source code

The osh API (Application Programming Interface) supports the use of osh from Python code. The recommended form of import is from osh.api import *. This imports the functions documented here as well as the symbols from the module osh.builtins, the Process class, and processes function.

In general, the function F() can be found in the module osh.command.F. See documentation for the package osh.command for information on each function.

Functions
 
osh(*ops)
Invoke osh interpreter.
source code
 
return_list(unwrap_singleton=True)
Input tuples are accumulated in a list which is returned as the value of the osh() invocation.
source code
 
set_error_handler(handler)
Replaces the standard error handler (which prints to stderr).
source code
 
set_exception_handler(handler)
Replaces the standard exception handler (which prints to stderr).
source code
 
debug(verbosity)
Control osh debugging: 0 = off, 1 = parse tree, 2 = command execution.
source code
Function Details

osh(*ops)

source code 

Invoke osh interpreter. Each argument is a function invocation identifying a command. The command sequence corresponds to the sequence of arguments.

return_list(unwrap_singleton=True)

source code 

Input tuples are accumulated in a list which is returned as the value of the osh() invocation. If unwrap_singleton is True, then items in the list that are 1-object sequences are unwrapped, e.g. (419,) -> 419.

set_error_handler(handler)

source code 

Replaces the standard error handler (which prints to stderr). An error handler takes these arguments:

  • line: A line printed to stderr by the failing operation.
  • op: The failing operation.
  • input: The input to the failing operation.
  • host: The host on which the error occurred (in case of remote execution).

set_exception_handler(handler)

source code 

Replaces the standard exception handler (which prints to stderr). An exception handler takes these arguments:

  • exception: The exception being handled.
  • op: The operation that caused the exception.
  • input: The input to the operation that caused the exception.
  • host: The host on which the exception occurred (in case of remote execution).