ó
è™xTc           @   sÃ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l Z d  d l Z d  d l Z d „  Z	 d „  Z
 d „  Z e d	 k r¿ e	 ƒ  e
 ƒ  d
 e j k r· d GHe ƒ  n  d GHn  d S(   iÿÿÿÿ(   t   division(   t   runtime_utils(   t   easy_pickle(   t   easy_runNc          C   s›  t  j j ƒ  }  d } xV t rm t j j t j ƒ  d | ƒ } t j j | ƒ r\ | d 7} q t j	 | ƒ Pq Wt  j
 | ƒ } | |  _ t |  _ | |  _ t j j | d ƒ |  _ t j j | d ƒ } t  j j d |  ƒ } | j d t | d ƒ ƒ t j |  j | ƒ t j d	 | ƒ t  j |  ƒ } | j ƒ  | j j ƒ  d
 k sKt ‚ | j d k s`t ‚ g  | j D] } | j ^ qjd d d d g k s—t ‚ d  S(   Ni    s   simple_run%di   s   run.pkls   run.efft   python_objectt   outt   ws   libtbx.start_process %s &s`   current is 44444.444444
current is 50000.000000
current is 57142.857143
current is 66666.666667
i   s   run 0s   run 1s   run 2s   run 3(   R   t   process_master_philt   extractt   Truet   ost   patht   joint   getcwdt   existst   makedirst
   simple_runt
   output_dirt   Falset   buffer_stdoutt   tmp_dirt   run_filet   formatt   showt   openR   t   dumpR   t   callt   simple_clientt   runR   t   getvaluet   AssertionErrort   n_cbt   _accumulated_callbackst   message(   t   paramst   iR   R   t   eff_filet   working_philt   clientt   cb(    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_runtime_utils.pyt   exercise	   s2    				
c          C   sK   t  j d ƒ }  t j d |  ƒ t j d ƒ j } | d d k sG t ‚ d  S(   Niš  s
   myfunc.pkls&   libtbx.run_pickled_function myfunc.pkli    t   666(   R   t   simple_funcR   R   R   t   fully_bufferedt   stdout_linesR   (   t   ft   f_out(    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_runtime_utils.pyt	   exercise2*   s
    c    	      C   sR  d }  xV t  r^ t j j t j ƒ  d |  ƒ } t j j | ƒ rM |  d 7}  q	 t j | ƒ Pq	 Wt j | ƒ } t j	 j
 ƒ  } t j | | ƒ } d d l m } | j d d d | ƒ } | j ƒ  t j | ƒ } | j ƒ  | j j ƒ  d	 k sõ t ‚ | j d
 k s
t ‚ t j d ƒ g  | j D] } | j ^ q!d d d d g k sNt ‚ d  S(   Ni    s   simple_run%di   iÿÿÿÿ(   t   generict   namet   tst_runtime_utilst   targets`   current is 44444.444444
current is 50000.000000
current is 57142.857143
current is 66666.666667
i   s   run 0s   run 1s   run 2s   run 3(   R	   R
   R   R   R   R   R   R   R   R   R   t   detached_process_servert   libtbx.queuing_system_utilsR0   t   qsubt   startR   R   R   R   R   R   t   timet   sleepR    R!   (	   R#   R   R   R"   t   servert   queuingt   jobR&   R'   (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_runtime_utils.pyt	   exercise32   s.    			

t   __main__s   -qs"   Testing queueing system support...t   OK(   t
   __future__R    t   libtbxR   R   R   R8   R
   t   sysR(   R/   R=   t   __name__t   argv(    (    (    sF   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/libtbx/tst_runtime_utils.pyt   <module>   s    	!		
