Package gmisclib :: Module die
[frames] | no frames]

Module die

source code

Classes
  counter
Functions
 
die(s)
Output a fatal error message and terminate.
source code
 
warn(s)
Output a non-fatal warning.
source code
 
info(s)
Output useful information.
source code
 
catch(extext=None)
Call this inside an except statement.
source code
 
catchexit(extext=None, n=1, text=None)
Call this inside an except statement.
source code
 
dbg(s)
Output debugging information, if debug is nonzero.
source code
 
exit(n, text=None)
Exit, after dumping accumulated notes.
source code
 
flush()
Flush out any accumulated messages.
source code
 
note(key, value)
Memorize a note, which will be output along with the next error/warning/info message.
source code
whatever was memorized
get(key)
Get the most recent value memorized by a call to note.
source code
 
uprint(s)
Like a print statement, except it prints in utf-8 encoding instead of ASCII.
source code
 
se_write(s)
Like sys.stderr.write(), except it prints in utf-8 encoding instead of ASCII.
source code
 
so_write(s)
Like sys.stdout.write(), except it prints in utf-8 encoding instead of ASCII.
source code
Variables
  debug = True
Set to False to disable dbg() messages.
  nocompress = False
False means that only the first of repeated messages are displayed; True displays all.
  Threads = False
  __package__ = 'gmisclib'

Imports: os, sys, traceback, threading, U


Function Details

die(s)

source code 

Output a fatal error message and terminate. Before the error message, it summarizes all the calls to note.

Parameters:
  • s (str) - error message

warn(s)

source code 

Output a non-fatal warning. Before the warning, it summarizes all the calls to note.

Parameters:
  • s (str) - warning message

info(s)

source code 

Output useful information. Before the message, it summarizes all the calls to note.

Parameters:
  • s (str) - message

catch(extext=None)

source code 

Call this inside an except statement. It will report the exception and any other information it has.

catchexit(extext=None, n=1, text=None)

source code 

Call this inside an except statement. It will report all information and then exit.

dbg(s)

source code 

Output debugging information, if debug is nonzero. Before the debugging info, it prints all information given to note.

Parameters:
  • s (str) - debug message

exit(n, text=None)

source code 

Exit, after dumping accumulated notes.

Parameters:
  • n (int) - the processes' exit code
  • text (str or None) - something to print

flush()

source code 

Flush out any accumulated messages. Should be called shortly before exit.

Note: This matters when nocompress=False under conditions where sys.stderr or sys.stdout may be closed before the program terminates. Under those conditions, you might get a "last message repeated %d times" message produced into a closed file descriptor, which would lead to an IOError.

note(key, value)

source code 

Memorize a note, which will be output along with the next error/warning/info message. These will be printed in the form '#NOTE key = value', with value converted to a string at the time of printing. Note that only the most recent note is kept for each key.

Parameters:
  • value (anything)
  • key (str)

get(key)

source code 

Get the most recent value memorized by a call to note.

Parameters:
  • key (str)
Returns: whatever was memorized