ó
›¢yZc           @€  sŸ   d  d l  m Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l Z i  a d „  Z	 d „  Z
 d e j f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   with_statementN(   t   datetime(   t   qconfigc           C€  s>   t  j t j ƒ  k r3 t t  j j j r3 t t  j St t  j S(   N(   R   t   LOGGER_META_NAMEt   _loggerst   keyst   _loggert   handlerst   LOGGER_DEFAULT_NAME(    (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   get_main_logger   s    (c         C€  s6   |  t  j ƒ  k r t  |  St |  ƒ t  |  <t  |  Sd  S(   N(   R   R   t   QLogger(   t   name(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt
   get_logger   s    t   MetaQErrorFormatterc           B€  s#   e  Z d d d d  „ Z d „  Z RS(   c         C€  s/   | |  _  | |  _ | |  _ t j j |  ƒ d  S(   N(   t   _indent_valt	   _ref_namet
   _log_fpatht   loggingt	   Formattert   __init__(   t   selft
   indent_valt   ref_namet	   log_fpath(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR   !   s    			c         C€  sD   | j  r= |  j d |  j d | j  d |  j d | _  n  | j  S(   Ns     s   : s   (details are in t   )(   t   msgR   R   R   (   R   t   record(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   format(   s    	4N(   t   __name__t
   __module__t   NoneR   R   (    (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR       s   R
   c           B€  sv  e  Z d Z d  Z d  Z d Z d Z d Z d Z	 d Z
 e Z e Z d „  Z e d d „ Z d e d „ Z d „  Z d d „ Z d „  Z d e d „ Z d  d  d	 „ Z d  d  d
 „ Z d  d  d „ Z d  d  d „ Z d  d  d „ Z d  d  d „ Z d  d e d  e d „ Z d d „ Z d  d e e d „ Z d  d e d „ Z d  d „ Z e d „ Z  d „  Z! d  d d „ Z" d „  Z# RS(   t    i    c         C€  s2   | |  _  t j | ƒ |  _ |  j j t j ƒ d  S(   N(   t   _nameR   t	   getLoggerR   t   setLevelt   DEBUG(   R   R   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR   :   s    	c         C€  s   t  |  _ | |  _ | |  _ d  S(   N(   t   Truet   _is_metaquastt   _is_parallel_runR   (   R   t   is_parallel_runR   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   set_up_metaquast?   s    		c         C€  sã   | |  _  x9 |  j j D]+ } t | t j ƒ r |  j j | ƒ q q Wt j t j ƒ } | j	 t j
 | d d ƒ ƒ | j | rŠ t j n t j ƒ |  j rÏ | j	 t | |  j |  j ƒ ƒ | j t j ƒ n  |  j j | ƒ d  S(   Ns     s   %(message)s(   R   R   R   t
   isinstanceR   t   StreamHandlert   removeHandlert   syst   stdoutt   setFormatterR   R"   R#   t   INFOR&   R   R   R   t   ERRORt
   addHandler(   R   R   t   debugt   handlert   console_handler(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   set_up_console_handlerD   s    		c         C€  s+   x$ |  j  j D] } | j t j ƒ q Wd  S(   N(   R   R   R"   R   R#   (   R   R3   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   set_up_debug_levelS   s    c         C€  s—   x9 |  j  j D]+ } t | t j ƒ r |  j  j | ƒ q q Wt j j | |  j	 d ƒ |  _
 t j |  j
 d d ƒ} | j t j ƒ |  j  j | ƒ d  S(   Ns   .logt   modet   w(   R   R   R)   R   t   FileHandlerR+   t   ost   patht   joinR    R   R"   R#   R1   (   R   t   output_dirpatht	   err_fpathR3   t   file_handler(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   set_up_file_handlerW   s    c         C€  s   |  j  d k rP |  j rP |  j j d ƒ |  j ƒ  |  j j d ƒ |  j ƒ  n  |  j d ƒ |  _ |  j j d ƒ |  j j d |  j ƒ d  S(   Ni    R   s	   Started: s   Logging to (	   R   R%   R   t   infot   print_versiont   print_system_infot   print_timestampt   _start_timeR   (   R   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   starta   s    
c         C€  s…  d } |  j  sP|  j j d |  j ƒ t j rI |  j j d t j ƒ n  |  j d ƒ } |  j j d t | |  j	 ƒ ƒ | r˜ |  j
 d d d | ƒ n
 |  j
 ƒ  |  j j d	 ƒ | rP| d  k	 rÔ | d
 d k sã |  j d k rü |  j j d ƒ d } qM| d  k	 r| d d k s'|  j d k r:|  j j d ƒ qM|  j j d ƒ qPn  x$ |  j j D] } |  j j | ƒ q]Wt |  j =| S(   Ni    s     Log saved to s     Errors saved to s
   Finished: s   Elapsed time: t   prefixs   Total t   numberss   
Thank you for using QUAST!i   sJ   
TEST FAILED! Please find non-fatal errors in the log and try to fix them.i   s   
TEST PASSED with WARNINGS!s   
TEST PASSED!(   R%   R   RA   R   R   t
   save_errort   error_log_fpathRD   t   strRE   t   print_numbers_of_notificationsR   t   _num_nf_errorst   _num_warningsR   R+   R   R    (   R   RH   t
   check_testt   test_resultt   finish_timeR3   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt	   finish_upl   s,    		!
+	+
c         C€  s   |  j  j | | ƒ d  S(   N(   R   R2   (   R   t   messaget   indent(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR2   Š   s    c         C€  s8   t  j r  |  j j | | ƒ n |  j j | | ƒ d  S(   N(   R   t   silentR   R2   RA   (   R   RS   RT   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRA      s    	c         C€  s   |  j  j | | ƒ d  S(   N(   R   RA   (   R   RS   RT   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt	   main_info”   s    c         C€  s®   x? t  |  j j ƒ D]+ } t | t j ƒ r |  j j | ƒ q q Wt |  j d ƒ  } | j	 | | d ƒ Wd  QXt j |  j d d ƒ} | j
 t j ƒ |  j j | ƒ d  S(   Nt   as   
R7   (   t   listR   R   R)   R   R9   R+   t   openR   t   writeR"   R#   R1   (   R   RS   RT   R3   t   fR?   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   info_to_file—   s    c         C€  s=   |  j  d 7_  |  j j | | r1 d t | ƒ n d ƒ d  S(   Ni   s   NOTICE: R   (   t   _num_noticesR   RA   RK   (   R   RS   RT   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   notice¤   s    c         C€  s=   |  j  d 7_  |  j j | | r1 d t | ƒ n d ƒ d  S(   Ni   s	   WARNING: R   (   RN   R   t   warningRK   (   R   RS   RT   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR_   ¨   s    c         C€  s  | r3 |  j  d k r3 |  j d ƒ |  j | ƒ d  S| rm | d t | ƒ } | rs | d 7} | d 7} qs n d } | s† |  j j r t j j | d ƒ n  |  j j	 d ƒ |  j j	 | ƒ t
 j rñ t t
 j d ƒ  } | j | ƒ Wd  QXn  | rt | ƒ n |  j d 7_ d  S(	   Ni    R   s   ERROR! sV   

In case you have troubles running QUAST, you can write to quast.support@cab.spbu.ru
s@   Please provide us with quast.log file from the output directory.s   
RW   i   (   R   RA   R^   RK   R   R   R,   t   stderrRZ   t   errorR   RJ   RY   t   exitRM   (   R   RS   t   exit_with_codet	   to_stderrRT   t   fake_if_nested_runR   R[   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRa   ¬   s(    
	c         C€  s`   |  j  j r/ |  j  j d ƒ |  j  j | ƒ n t j j t | ƒ d ƒ | r\ t | ƒ n  d  S(   NR   s   
(	   R   R   Ra   t	   exceptionR,   R`   RZ   RK   Rb   (   R   t   et	   exit_code(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRf   É   s    iP   c         C€  s  | r |  j  } n | r$ |  j } n	 |  j } d } | } x½ t | ƒ D]¯ \ }	 }
 d |
 k sj d |
 k r d |
 d | |	 <n  | |
 7} |	 t | ƒ d k r¬ | | 7} qF | d  k	 rë t | ƒ | k rë | | d 7} d t | ƒ } qF | d 7} qF W| | ƒ d  S(   NR   t    s   	t   'i   s    \
(   R2   RV   RA   t	   enumeratet   lenR   (   R   t   argsRT   t
   wrap_aftert   only_if_debugt   is_maint   outt   textt   linet   it   arg(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   print_command_lineÓ   s$    	
c   
   	   C€  sg  |  j  j d t j ƒ  ƒ |  j  j d ƒ d } | } d t j f d t j f d t j f d t j f d t j	 f d	 t j
 f d
 t j f d t j f g } x³ t | ƒ D]¥ \ } \ } }	 |	 rª | | t |	 ƒ j ƒ  7} | t | ƒ d k rÿ | | 7} qO| d  k	 rBt | ƒ | k rB| | d 7} d t | ƒ d } qO| d 7} qª qª W|  j  j | ƒ d  S(   Ns   CWD: s   Main parameters: s     s	   Threads: s   eukaryotic: s   scaffolds: s   minimum contig length: s#   minimum alignment length (Nucmer): s   ambiguity: s   use all alignments: s*   threshold for extensive misassembly size: i   s   , \
Ri   s   , (   R   RA   R:   t   getcwdR   t   max_threadst
   prokaryotet	   scaffoldst
   min_contigt   min_alignmentt   ambiguity_usaget   use_all_alignmentst   extensive_misassembly_thresholdRk   RK   t   lowerRl   R   (
   R   RT   Rn   Ro   Rr   Rs   t   optionsRt   t   optiont   value(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   print_paramsñ   s&    c         C€  s=   t  j ƒ  } | j d ƒ } |  j d ƒ |  j | | ƒ | S(   Ns   %Y-%m-%d %H:%M:%SR   (   R   t   nowt   strftimeRV   (   R   RS   R…   t   current_time(    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRD     s
    c         C€  sB   | r' t  j j d t j ƒ  d ƒ n |  j d t j ƒ  ƒ d  S(   Ns	   Version: s   
(   R,   R`   RZ   R   t   quast_versionRA   (   R   Rd   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRB     s    !c         C€  sä   |  j  j d ƒ d d  l } |  j  j d | j ƒ  d t j ƒ |  j  j d t t j d ƒ d t t j d ƒ d t t j d	 ƒ ƒ y0 d d  l } |  j  j d
 t | j	 ƒ  ƒ ƒ Wn! t
 k
 rß |  j  j d ƒ n Xd  S(   Ns   System information:iÿÿÿÿs     OS: s    (%s)s     Python version: i    t   .i   i   s     CPUs number: s7     Problem occurred when getting CPUs number information(   R   RA   t   platformR   t   platform_nameRK   R,   t   version_infot   multiprocessingt	   cpu_countt   ImportError(   R   RŠ   R   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRC     s    %	B$c         C€  s=   | s! |  j  |  j |  j f } n  |  j j | d | ƒ d  S(   Ns/   NOTICEs: %d; WARNINGs: %d; non-fatal ERRORs: %d(   R]   RN   RM   R   RA   (   R   RG   RH   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyRL   %  s    c         C€  s   |  j  |  j |  j f S(   N(   R]   RN   RM   (   R   (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   get_numbers_of_notifications+  s    N($   R   R   R   R   R    R   RE   R   R]   RN   RM   t   FalseR%   R&   R   R(   R5   R6   R@   RF   RR   R2   RA   RV   R\   R^   R_   Ra   Rf   Rv   R„   RD   RB   RC   RL   R   (    (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyR
   .   sD   		
	
	(   t
   __future__R    R:   R,   R   t
   quast_libsR   R   R   R	   R   R   R   t   objectR
   (    (    (    s=   /home/birch/BIRCH/local/install/quast-4.6.3/quast_libs/log.pyt   <module>   s   		