Ñò
áJœOc           @   s¢   d  d k  l Z d d k l Z d  d k l Z l Z d  d k l	 Z	 l
 Z
 d  d k l Z l Z l Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d S(   iÿÿÿÿ(   t   wrapsi   (   t   VERSION(   t   VersionMismatchErrort   AuthenticationRequired(   t	   INFO_FILEt	   LOCK_FILE(   t
   checkTokent   checkTicketst   RenewTicketsTimerc         C   s   t  |  _ |  S(   N(   t   Truet   _export(   t   obj(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   exported   s    	c         C   s	   |  GHd  S(   N(    (   t   msg(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   error   s    c            s   t  ˆ  ƒ ‡  f d †  ƒ } | S(   Nc            s/   |  i  i i ƒ  z ˆ  |  | | Ž SWd  QXd  S(   N(   t   lockt   __exit__t	   __enter__(   t   selft   argst   kwargs(   t   func(    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   do   s    (   R    (   R   R   (    (   R   s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   sync   s    c         C   sD   t  |  t ƒ p t d ƒ ‚ n |  t j o t t |  ƒ ‚ n d  S(   Ns   Version must be an int(   t
   isinstancet   intt	   TypeErrort   server_versionR   (   t   version(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   assertCompatable   s    c         C   s-   t  |  ƒ p t ƒ  o t d ƒ ‚ n d  S(   Ns   Invalid token.(   R   R   R   (   t   token(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   assertAuthenticated   s    c   	   %   C   s#  d d  k  } d d  k } d d  k } | i | i t ƒ | i | i t ƒ h t d 6} | i |  i ƒ  ƒ d  } z%y* | i
 t | i | i B| i Bd ƒ } Wn. t t f j
 o d  } d GHt d ƒ n Xy | i | | i | i Bƒ Wn( t t f j
 o d GHt d ƒ n Xy  | i | t | i ƒ  ƒ ƒ Wn( t t f j
 o d GHt d ƒ n Xy | i | d ƒ Wn( t t f j
 o d	 GHt d ƒ n XyP t
 t d
 d ƒ i i ƒ  } z* | ~ } | i d „  | i ƒ  Dƒ ƒ Wd  QXWn" t j
 o d GHt d ƒ n Xy | i | | i | i Bƒ Wn( t t f j
 o d GHt d ƒ n Xt |  i ƒ } z | i  ƒ  |  i! ƒ  Wd  | i" ƒ  XWd  | d  j	 o1 y | i# | ƒ WqÖt t f j
 o qÖXn | i$ i% t ƒ o | i& t ƒ n | i$ i% t ƒ o | i& t ƒ n Xd  S(   NiÿÿÿÿR   i    s   Failed to create lock.i   s   Failed to lock lock.s   Failed to write PID to lock.i€  s   Failed to make lock readable.s   w+c         s   s   x |  ] } d  | Vq Wd S(   s   %s='%s'
N(    (   t   .0t   i(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pys	   <genexpr>F   s   	 s   Failed to write info file.s   Failed to make lock shared.('   t   fcntlt   ost   signalt   SIGHUPt   exitt   SIGTERMR   t   updatet   getInfot   Nonet   openR   t   O_WRONLYt   O_CREATt   O_EXCLt   IOErrort   OSErrort   flockt   LOCK_EXt   LOCK_NBt   writet   strt   getpidt   fchmodR   R   R   t
   writelinest	   iteritemst   LOCK_SHR   t   shutdownt   startt   serve_forevert   stopt   closet   patht   existst   remove(	   t   serverR"   R#   R$   t   info_contentst   lck_fdt   _[1]t	   info_filet   ticket_timer(    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt	   runserver   sj    $* )'
	N(   t	   functoolsR    t    R   R   t
   exceptionsR   R   t   settingsR   R   t   authR   R   R   R   R   R   R   R   RI   (    (    (    s@   /mit/zmobile/testing/lib/python2.6/site-packages/zserv/common.pyt   <module>   s   					