File: //lib/python2.7/site-packages/pynag/Utils/misc.pyc
�
�O�]c @@ s� d Z d d l m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l
Z
d d l m Z d d l
m Z d e f d � � YZ d e f d � � YZ d
e f d � � YZ d Z d S(
s� miscellaneous utils classes and function.
The reason they don't live in in pynag.Utils is that they have more requirements, and they do on occation import
pynag.Model og pynag.Parsers
i ( t absolute_importN( t
PynagError( t bytes2strt MiscErrorc B@ s e Z d Z RS( s% Base class for errors in this module.( t __name__t
__module__t __doc__( ( ( s4 /usr/lib/python2.7/site-packages/pynag/Utils/misc.pyR s t SandboxErrorc B@ s e Z d Z RS( sF Raised when FakeEnvironment tries to modify files outside its sandbox.( R R R ( ( ( s4 /usr/lib/python2.7/site-packages/pynag/Utils/misc.pyR s t FakeNagiosEnvironmentc B@ s� e Z d Z d d e d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d � Z d � Z
d d
d � Z d d � Z d
� Z d � Z d � Z d � Z d � Z RS( s� Creates a fake nagios environment with minimal configs in /tmp/
Example:
>>> nagios = FakeNagiosEnvironment()
>>> nagios.create_minimal_environment() # Create temporary director with minimal config
>>> nagios.update_model() # Update the global variables in pynag.Model
>>> nagios.configure_livestatus() # Configure a livestatus socket
>>> result, stdout, stderr = nagios.start() # Start up nagios
>>> config = nagios.get_config() # Returns config_parser.Config instance
>>> livestatus = nagios.get_livestatus() # Returns livestatus.Livestatus instance
>>> result, stdout, sdterr = nagios.stop() # Stop nagios
>>> nagios.terminate() # Stops nagios and cleans up everything
c C@ sm | | _ | | _ t | _ | | _ d | _ d | _ t j d � | _
t j j
| j
d � } | | _ d S( Ns nagios-environments livestatus.socket( t global_config_filet p1_filet Falset _model_is_dirtyt livestatus_module_patht Nonet livestatus_objectt configt tempfilet mkdtempt tempdirt ost patht joint livestatus_socket_path( t selfR R
t
livestatust path_to_socket( ( s4 /usr/lib/python2.7/site-packages/pynag/Utils/misc.pyt __init__0 s c C@ s | j s | j � n | j S( N( R t create_minimal_environment( R ( ( s4 /usr/lib/python2.7/site-packages/pynag/Utils/misc.pyt
get_config<