Home | Trees | Indices | Help |
|
---|
|
OS abstractions and related.
This module contains, in partiular, the interface for having "easy subcommands" using argparse. The idea is to use the exposedFunction decorator on functions that should be callable from the command line as subcommands; the functions must all have the same signature. For example, if they all took the stuff returned by argparse, you could say in the module containing them:
args = makeCLIParser(globals()).parse_args() args.subAction(args)
To specify the command line arguments to the function, use Args. See admin.py for an example.
Classes | |
HTTPSHandler | |
Arg an argument/option to a subcommand. |
Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Variables | |
__package__ =
|
Function Details |
syncs and closes the python file f. You generally want to use this rather than a plain close() before overwriting a file with a new version. |
opens fName for "safe replacement". Safe replacement means that you can write to the object returned, and when everything works out all right, what you have written replaces the old content of fName, where the old mode is preserved if possible. When there are errors, however, the old content remains.
|
works like urllib2.urlopen, except only http, https, and ftp URLs are handled. The function also massages the error messages of urllib2 a bit. urllib2 errors always become IOErrors (which is more convenient within the DC). creds may be a pair of username and password. Those credentials will be presented in http basic authentication to any server that cares to ask. For both reasons, don't use any valuable credentials here. |
returns the mtime of the file below fileobj. This raises an os.error if that file cannot be fstated. |
makes sure that dirPath exists and is a directory. If dirPath does not exist, it is created, and its permissions are set to mode with group ownership setGroupTo if those are given. setGroupTo must be a numerical gid if given. This function may raise all kinds of os.errors if something goes wrong. These probably should be handed through all the way to the user since when something fails here, there's usually little the program can safely do to recover. |
a decorator exposing a function to parseArgs. argSpecs is a sequence of Arg objects. This defines the command line interface to the function. The decorated function itself must accept a single argument, the args object returned by argparse's parse_args. |
returns a command line parser parsing subcommands from functions. functions is a dictionary (as returned from globals()). Subcommands will be generated from all objects that have a subparseArgs attribute; furnish them using the commandWithArgs decorator. This attribute must contain a sequence of Arg items (see above). |
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu May 2 07:29:09 2019 | http://epydoc.sourceforge.net |