colorout
index
/usr/local/lib/python2.7/site-packages/dshell/lib/output/colorout.py

@author: amm

 
Modules
       
cgi
datetime
dshell
output
string
sys
util

 
Classes
       
output.TextOutput(output.FileOutput)
ColorOutput

 
class ColorOutput(output.TextOutput)
    Color-coded Output module
use with --output=colorout
Output to STDOUT will use XTERM color tags, if possible.
Output to FILE will use HTML
 
Decoders should call self.out.write() with string data and the following kwargs:
        formatTag:  H1 and H2 are currently implemented
        direction:  cs / sc
        timestamp:  specify unix timestamp for current object being written
        time:       (bool) to display timestamp
 
Note Regarding Timestamps:
-------------------------
Decoders should *always* specify timestamp information if available in their
calls to write.  (If passing a full blob or connection, colorout will extract
this information from those objects.)  In HTML output mode, the timestamps will
always be embedded in the HTML with a javascript option to show/hide them.
Initial display is govered by the boolean kwarg 'time' specified in calls
to write().  (Defaults to hidden unless a single 'true' value is passed.)
 
Instantiation options
---------------------
keyword title: specify HTML title
keyword force: specify force=true color output (e.g for piping to less -R)
keyword html:  specify html=true for HTML output, even when writing to STDOUT
 
HTML Generator Mode:
        This mode makes the HTML generation/formatting available
        as a utility to other code:
        1) Instantiate with keyword htmlgenerator=True:
              colorout.ColorOutput(htmlgenerator=True, title="test")
        2) After one or more calls to write(), call close()
        3) Dump HTML with htmldump()
 
 
Method resolution order:
ColorOutput
output.TextOutput
output.FileOutput
output.Output
__builtin__.object

Methods defined here:
__init__(self, *args, **kwargs)
close(self)
errorH(self, **x)
# Custom error handler for data reassembly --- ignores all errors
htmldump(self)
For use in HTML Generator Mode:
In this mode, HTML generated by calls to write() is buffered.  This
  function returns the contents of and clears the buffer.
setColorMode(self)
write(self, *args, **kw)

Methods inherited from output.TextOutput:
alert(self, *args, **kw)
write an alert record
we pass in the decoder object and args/dict

Methods inherited from output.Output:
dispatch(self, m, *args, **kwargs)
dispatch from Q pop
dump(self, pkt=None, **kw)
dump raw packet data to an output
override this if you want a format other than pcap
log(self, msg, level=20, *args, **kw)
write a message to the log
passes all args and kwargs thru to logging
except for level= is used to set logging level
parse(self, *args, **kw)
parse the input args/kwargs into a record dict according to format string
- timestamps are formatted to date/time strings
        - fields not in the input will be defined but blank
        - extra fields in the record will be formatted into a
               "name=value name2=value2..." string and put in 'extra'
        - args will go into 'data'
        - format keyword can contain a new format string to use (this also sets format for future output)
setformat(self, formatstr=None, typemap=None)
parse a format string and extract the field info
        if no string given, reverts to default for class
   will set self.fields to be a list of (name,type,spec) tuples
   self.fieldnames to a list of fieldnames
        and self.fieldmap to a list of key=in value=out mappings
format string can also map in field to out field with %(in:out)spectype
 or specify an explicit out type with %(in:out)specintype:outtype
(note this breaks compatibility with text formatting,
  but useful for db or other output modules)
  a typemap of [intype]=outtype (or [in]=(newintype,outtype)
                  can be used to map and replace types

Data descriptors inherited from output.Output:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
obj = class ColorOutput(output.TextOutput)
    Color-coded Output module
use with --output=colorout
Output to STDOUT will use XTERM color tags, if possible.
Output to FILE will use HTML
 
Decoders should call self.out.write() with string data and the following kwargs:
        formatTag:  H1 and H2 are currently implemented
        direction:  cs / sc
        timestamp:  specify unix timestamp for current object being written
        time:       (bool) to display timestamp
 
Note Regarding Timestamps:
-------------------------
Decoders should *always* specify timestamp information if available in their
calls to write.  (If passing a full blob or connection, colorout will extract
this information from those objects.)  In HTML output mode, the timestamps will
always be embedded in the HTML with a javascript option to show/hide them.
Initial display is govered by the boolean kwarg 'time' specified in calls
to write().  (Defaults to hidden unless a single 'true' value is passed.)
 
Instantiation options
---------------------
keyword title: specify HTML title
keyword force: specify force=true color output (e.g for piping to less -R)
keyword html:  specify html=true for HTML output, even when writing to STDOUT
 
HTML Generator Mode:
        This mode makes the HTML generation/formatting available
        as a utility to other code:
        1) Instantiate with keyword htmlgenerator=True:
              colorout.ColorOutput(htmlgenerator=True, title="test")
        2) After one or more calls to write(), call close()
        3) Dump HTML with htmldump()
 
 
Method resolution order:
ColorOutput
output.TextOutput
output.FileOutput
output.Output
__builtin__.object

Methods defined here:
__init__(self, *args, **kwargs)
close(self)
errorH(self, **x)
# Custom error handler for data reassembly --- ignores all errors
htmldump(self)
For use in HTML Generator Mode:
In this mode, HTML generated by calls to write() is buffered.  This
  function returns the contents of and clears the buffer.
setColorMode(self)
write(self, *args, **kw)

Methods inherited from output.TextOutput:
alert(self, *args, **kw)
write an alert record
we pass in the decoder object and args/dict

Methods inherited from output.Output:
dispatch(self, m, *args, **kwargs)
dispatch from Q pop
dump(self, pkt=None, **kw)
dump raw packet data to an output
override this if you want a format other than pcap
log(self, msg, level=20, *args, **kw)
write a message to the log
passes all args and kwargs thru to logging
except for level= is used to set logging level
parse(self, *args, **kw)
parse the input args/kwargs into a record dict according to format string
- timestamps are formatted to date/time strings
        - fields not in the input will be defined but blank
        - extra fields in the record will be formatted into a
               "name=value name2=value2..." string and put in 'extra'
        - args will go into 'data'
        - format keyword can contain a new format string to use (this also sets format for future output)
setformat(self, formatstr=None, typemap=None)
parse a format string and extract the field info
        if no string given, reverts to default for class
   will set self.fields to be a list of (name,type,spec) tuples
   self.fieldnames to a list of fieldnames
        and self.fieldmap to a list of key=in value=out mappings
format string can also map in field to out field with %(in:out)spectype
 or specify an explicit out type with %(in:out)specintype:outtype
(note this breaks compatibility with text formatting,
  but useful for db or other output modules)
  a typemap of [intype]=outtype (or [in]=(newintype,outtype)
                  can be used to map and replace types

Data descriptors inherited from output.Output:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Data
        __warningregistry__ = {("Not importing directory '/wrkdirs/usr/ports/net/...k/Dshell-46e691c/lib/output': missing __init__.py", <type 'exceptions.ImportWarning'>, 5): True}