Package commons :: Module startup
[hide private]
[frames] | no frames]

Module startup

source code

Program startup functions and wrappers.

Classes [hide private]
  UnsetError
Functions [hide private]
 
get_arg_or_env(var, argv, error_name=None)
Get a value based from argv[1]; if that is unavailable, try looking at the corresponding environment variable var.
source code
 
config_psyco()
Try to enable Psyco profiling if the USE_PSYCO environment variable is non-empty.
source code
 
get_config_path(file_env, file_default, dir_env='ASSORTED_CONF', dir_default='.assorted')
Get the path to a configuration file.
source code
 
get_usr_conf(*args, **kwargs)
Gets a config file from $HOME.
source code
 
get_sys_conf(env, default)
Gets a config file from /etc/.
source code
 
dump_stack(*args)
Useful for debugging your program if it's spinning into infinite loops.
source code
 
command_name() source code
 
run_main(main=None, do_force=False, runner=None, use_sigquit_handler=False, handle_exceptions=False)
A feature-ful program starter.
source code
Variables [hide private]
  ITIMER_PROF = 2
  ITIMER_REAL = 0
  ITIMER_VIRTUAL = 1
  NSIG = 65
  SIGABRT = 6
  SIGALRM = 14
  SIGBUS = 7
  SIGCHLD = 17
  SIGCLD = 17
  SIGCONT = 18
  SIGFPE = 8
  SIGHUP = 1
  SIGILL = 4
  SIGINT = 2
  SIGIO = 29
  SIGIOT = 6
  SIGKILL = 9
  SIGPIPE = 13
  SIGPOLL = 29
  SIGPROF = 27
  SIGPWR = 30
  SIGQUIT = 3
  SIGRTMAX = 64
  SIGRTMIN = 34
  SIGSEGV = 11
  SIGSTOP = 19
  SIGSYS = 31
  SIGTERM = 15
  SIGTRAP = 5
  SIGTSTP = 20
  SIGTTIN = 21
  SIGTTOU = 22
  SIGURG = 23
  SIGUSR1 = 10
  SIGUSR2 = 12
  SIGVTALRM = 26
  SIGWINCH = 28
  SIGXCPU = 24
  SIGXFSZ = 25
  SIG_DFL = 0
  SIG_IGN = 1
  __package__ = 'commons'
Function Details [hide private]

get_arg_or_env(var, argv, error_name=None)

source code 

Get a value based from argv[1]; if that is unavailable, try looking at the corresponding environment variable var.

To Do: This is a weird, weird function. Do I really use it anywhere?

get_config_path(file_env, file_default, dir_env='ASSORTED_CONF', dir_default='.assorted')

source code 

Get the path to a configuration file. This tries the following:

  1. environ[file_env]
  2. environ[dir_env]/file_default
  3. $HOME/dir_default/file_default

dump_stack(*args)

source code 

Useful for debugging your program if it's spinning into infinite loops. Install this signal handler and issue your program a SIGQUIT to dump the main thread's stack, so you can see where it is.

run_main(main=None, do_force=False, runner=None, use_sigquit_handler=False, handle_exceptions=False)

source code 

A feature-ful program starter. Configures logging and psyco, then runs the main function defined in the caller's module, passing in sys.argv. If the PYDBG environment variable is set, then runs main in pdb. If the PYPROF environment variable is set, then runs main in cProfile. Finally, exits with main's return value.

For example:

   def main(argv):
       print "Hello " + argv[1]
   run_main()