ó
¦žbc           @€  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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyt   format(   s    	4N(   t   __name__t
   __module__t   NoneR   R   (    (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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 is saved to s     Errors are 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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyt	   finish_upl   s,    		!
+	+
c         C€  s   |  j  j | | ƒ d  S(   N(   R   R2   (   R   t   messaget   indent(    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyRA      s    	c         C€  s   |  j  j | | ƒ d  S(   N(   R   RA   (   R   RS   RT   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyR_   ¨   s    c         C€  s  | r3 |  j  d k r3 |  j d ƒ |  j | ƒ d  S| rc | d t | ƒ } | ri | d 7} qi 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! sè   

In case you have troubles running QUAST, you can write to quast.support@cab.spbu.ru
or report an issue on our GitHub repository https://github.com/ablab/quast/issues
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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyRa   ¬   s&    	c      	   C€  s)  d } t  | ƒ t k r“ d t | ƒ k r“ d t | ƒ k r“ t j r“ t j d k r“ t j d k r“ t j j d k r“ t j j	 d k r“ d } q“ n  |  j
 j rÛ |  j
 j d ƒ |  j
 j | ƒ | r|  j
 j | ƒ qn7 t j j t | ƒ d	 ƒ | rt j j | d	 ƒ n  | r%t | ƒ n  d  S(
   NR   t   NoneTypet   inti   t   macosxi   i   s/  

This seems to be a known bug when using multi-threading in Python 3.8+ on macOS!
The current workarounds are
  to switch to single-thread execution (-t 1)
or
  to downgrade your Python to 3.7 or below.
Sorry for the inconvenience!
Please find more details in https://github.com/ablab/quast/issues/175
s   
(   t   typet	   TypeErrorRK   R   t   max_threadst   platform_nameR,   t   version_infot   majort   minorR   R   Ra   t	   exceptionRA   R`   RZ   Rb   (   R   t   et	   exit_codet   extra_message(    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyRp   Ê   s    6'$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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyt   print_command_lineæ   s$    	
c   
      C€  s˜  |  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 d t j f d t j f d t j f g } x½ t | ƒ D]¯ \ } \ } }	 |	 t k	 rÑ | | d t |	 ƒ j ƒ  7} | t | ƒ d k r0| | 7} q€| d  k	 rst | ƒ | k rs| | d 7} d t | ƒ d } q€| d 7} qÑ qÑ W|  j  j | ƒ d  S(   Ns   CWD: s   Main parameters: s     t   MODEt   threadst
   eukaryotics   split scaffoldss   min contig lengths   min alignment lengths   min alignment IDYt	   ambiguitys   use all alignmentss   min local misassembly lengths    min extensive misassembly lengths   : i   s   , \
Rt   s   , (   R   RA   R:   t   getcwdR   t   get_modeRk   t
   prokaryotet   split_scaffoldst
   min_contigt   min_alignmentt   min_IDYt   ambiguity_usaget   use_all_alignmentst   local_misassembly_min_lengtht   extensive_misassembly_thresholdRv   t   FalseRK   t   lowerRw   R   (
   R   RT   Ry   Rz   R}   R~   t   optionsR   t   optiont   value(    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/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   Rl   RK   R,   Rm   t   multiprocessingt	   cpu_countt   ImportError(   R   Rœ   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/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/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyRL   :  s    c         C€  s   |  j  |  j |  j f S(   N(   R]   RN   RM   (   R   (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyt   get_numbers_of_notifications@  s    N($   R   R   R   R   R    R   RE   R   R]   RN   RM   R‘   R%   R&   R   R(   R5   R6   R@   RF   RR   R2   RA   RV   R\   R^   R_   Ra   Rp   R   R–   RD   RB   RC   RL   R    (    (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyR
   .   sD   		
		(   t
   __future__R    R:   R,   R   t
   quast_libsR   R   R   R	   R   R   R   t   objectR
   (    (    (    s<   /home/psgendb/BIRCHDEV/install/quast-5.2.0/quast_libs/log.pyt   <module>   s   		