Ñò
¹)~Ic        
   @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d  d k Z d Z e i i d ƒ oO e i	 i
 d ƒ Z e i	 i e ƒ p e i e ƒ n e i	 i e d ƒ Z n e  i ƒ  i e  i e ƒ ƒ d e f d „  ƒ  YZ d d „ Z d „  Z d h  d d	 „ Z d
 „  Z d „  Z d S(   iÿÿÿÿNs	   error.logt   HOMEs
   ~/.endgamet   Bufferc           B   s   e  Z d  d „ Z d „  Z RS(   t    c         C   s   | |  _  d  S(   N(   t   data(   t   selft   prefix(    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   __init__*   s    c         C   s   |  i  | 7_  d  S(   N(   R   (   R   t
   unbuffered(    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   write,   s    (   t   __name__t
   __module__R   R   (    (    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyR   )   s   c         C   s<   |  d  j o t i ƒ  }  n t i |  ƒ d t i t i S(   Nt    (   t   Nonet   timet   ctimet   tznamet   daylight(   t   when(    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   get_timestamp/   s    c         C   s+   t  i ƒ  i |  ƒ t i i |  d ƒ d  S(   Ns   
(   t   loggingt	   getLoggert   errort   syst   stderrR   (   t   error_message(    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt	   log_error4   s    c         C   s~   y |  | | Ž  SWnf t  j
 oZ } t | t ƒ o ‚  n t d |  i t ƒ  f ƒ } t i d | ƒ t | i	 ƒ | SXd  S(   Ns    Exception in function %s at %s:
t   file(
   t	   Exceptiont
   isinstancet
   SystemExitR   R	   R   t	   tracebackt	   print_excR   R   (   t   funct   argst   kwargst   on_errort   et   buffer(    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt	   safe_call8   s    
c            s   ‡  f d †  S(   Nc            s   t  |  ˆ  ƒ S(    (   t   _safe(   R    (   R#   (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   <lambda>Y   s    (    (   R#   (    (   R#   sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   safeX   s    c            s   ‡  ‡ f d †  S(   Nc             s   t  ˆ |  | ˆ  ƒ S(    (   R&   (   R!   R"   (   R#   R    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyR(   \   s    (    (   R    R#   (    (   R#   R    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyR'   [   s    (    (   R   R   R   R   t   ost   os.patht   logpatht   environt   has_keyt   patht
   expandusert	   prefs_dirt   isdirt   makedirst   joinR   t
   addHandlert   FileHandlert   objectR   R   R   R   R&   R)   R'   (    (    (    sD   /home/trcarlson/Desktop/python/endg-singularity/trunk/code/safety.pyt   <module>   s$   	 	