ó
¸‹Nc           @   sõ  d  Z  d d l Z d d l Z d d l Z e j d ƒ d d l Z y d d l Z Wn e k
 rr d d l Z n Xd d l Z d d l	 Z	 d d l Z d d l
 Z
 d d l Z d d l m Z d d l m Z m Z d d l m Z e j rd d l m Z n  d d	 d
 d g Z d e j e j d „ Z d
 e j e j f d „  ƒ  YZ d	 e j e j f d „  ƒ  YZ e Z d e j e j f d „  ƒ  YZ  e j r¹d e j e j! f d „  ƒ  YZ" n  d e j# f d „  ƒ  YZ$ d „  Z% e& d k rñe% ƒ  n  d S(   s:   GObject-powered progress classes and a GTK+ status widget.iÿÿÿÿNs   2.0(   t   gettext(   t   function_deprecated_byt   AttributeDeprecatedBy(   t   base(   t   oldt   GAcquireProgresst   GInstallProgresst   GOpProgresst   GtkAptProgressc         C   s   | | |  f S(   sé   Simplified Create a gobject signal.

    This allows us to write signals easier, because we just need to define the
    type of the parameters (in most cases).

    ``params`` is a tuple which defines the types of the arguments.
    (    (   t   paramst   runt   rettype(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   mksig5   s    c           B   s}   e  Z d  Z i e e e f ƒ d 6e ƒ  d 6e ƒ  d 6Z d „  Z d	 d „ Z	 d „  Z
 e j r{ e d ƒ Z e d ƒ Z n  RS(
   sÂ   Operation progress with GObject signals.

    Signals:

        * status-changed(str: operation, int: percent)
        * status-started()  - Not Implemented yet
        * status-finished()

    s   status-changeds   status-starteds   status-finishedc         C   s3   t  j j |  ƒ t j j |  ƒ t j ƒ  |  _ d  S(   N(   R   t
   OpProgresst   __init__t   gobjectt   GObjectt   glibt   main_context_defaultt   _context(   t   self(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   O   s    c         C   sS   t  j j |  | ƒ |  j d |  j |  j ƒ x  |  j j ƒ  rN |  j j ƒ  q/ Wd S(   s$   Called to update the percentage dones   status-changedN(	   R   R   t   updatet   emitt   opt   percentR   t   pendingt	   iteration(   R   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   T   s    c         C   s!   t  j j |  ƒ |  j d ƒ d S(   s(   Called when all operation have finished.s   status-finishedN(   R   R   t   doneR   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   [   s    t   subopR   N(   t   __name__t
   __module__t   __doc__R   t   strt   intt   __gsignals__R   t   NoneR   R   t   apt_pkgt   _COMPAT_0_7R   t   subOpt   Op(    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   @   s   	
			c           B   s  e  Z d  Z d Z i e e e f ƒ d 6e ƒ  d 6e ƒ  d 6e ƒ  d 6e ƒ  d 6e ƒ  d 6Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e j re e ƒ Z e e ƒ Z e e ƒ Z e e ƒ Z e e ƒ Z e e	 ƒ Z n  RS(   sû   Installation progress with GObject signals.

    Signals:

        * status-changed(str: status, int: percent)
        * status-started()
        * status-finished()
        * status-timeout()
        * status-error()
        * status-conffile()

    i   i<   s   status-changeds   status-starteds   status-timeouts   status-errors   status-conffiles   status-finishedc         C   sŒ   t  j j |  ƒ t j j |  ƒ t |  _ d |  _ t j ƒ  |  _	 | |  _
 |  j
 j d |  j ƒ d |  j d d g |  _ t j ƒ  |  _ d  S(   Niÿÿÿÿs   child-exiteds   VTE_PTY_KEEP_FD=%ss   DEBIAN_FRONTEND=gnomes   APT_LISTCHANGES_FRONTEND=gtk(   R   t   InstallProgressR   R   R   t   Falset   finishedt
   apt_statust   timet   time_last_updatet   termt   connectt   child_exitedt   writefdt   envR   R   R   (   R   R.   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   |   s    			
c         C   s   | j  ƒ  |  _ t |  _ d S(   s!   Called when a child process exitsN(   t   get_child_exit_statusR+   t   TrueR*   (   R   R.   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR0   ‰   s    c         C   s   |  j  d ƒ d S(   sE   Called when an error happens.

        Emits: status-error()
        s   status-errorN(   R   (   R   t   pkgt   errormsg(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   errorŽ   s    c         C   s   |  j  d ƒ d S(   sB   Called during conffile.

        Emits: status-conffile()
        s   status-conffileN(   R   (   R   t   currentt   new(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   conffile•   s    c         C   s   |  j  d ƒ d S(   sH   Called when the update starts.

        Emits: status-started()
        s   status-startedN(   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   start_updateœ   s    c         C   s   t  |  _ t j j |  | ƒ S(   s   Run.(   R)   R*   R   R(   R
   (   R   t   obj(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR
   £   s    	c         C   s   |  j  d ƒ d S(   sK   Called when the update finished.

        Emits: status-finished()
        s   status-finishedN(   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   finish_update¨   s    c         C   s   |  j  d d | d ƒ d S(   s)   Called when entering a new stage in dpkg.s   status-changeds   Installing %s...iÿÿÿÿN(   R   (   R   R5   t   stage(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt
   processing¯   s    c         C   s&   t  j  ƒ  |  _ |  j d | | ƒ d S(   sX   Called when the status changed.

        Emits: status-changed(status, percent)
        s   status-changedN(   R,   R-   R   (   R   R5   R   t   status(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   status_change´   s    c         C   sc   t  j j |  ƒ x  |  j j ƒ  r2 |  j j ƒ  q W|  j |  j t j ƒ  k  r_ |  j	 d ƒ n  d S(   so   Called periodically to update the interface.

        Emits: status-timeout() [When a timeout happens]
        s   status-timeoutN(
   R   R(   t   update_interfaceR   R   R   R-   t   INSTALL_TIMEOUTR,   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRB   ¼   s
    c         C   s   |  j  j d |  j ƒ S(   s   Fork the process.t   envv(   R.   t   forkptyR2   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   forkÇ   s    c         C   s.   x$ |  j  s& |  j ƒ  t j d ƒ q W|  j S(   s#   Wait for the child process to exit.g{®Gáz”?(   R*   RB   R,   t   sleepR+   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt
   wait_childË   s    
i,  (   R   R   R   RC   R   R    R!   R"   R   R0   R7   R:   R;   R
   R=   R?   RA   RB   RF   RH   R$   R%   R   t   updateInterfacet   startUpdatet   finishUpdatet   statusChanget	   waitChildt   childExited(    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   e   s6   



													c           B   sh   e  Z d  Z i e e e f ƒ d 6e ƒ  d 6e ƒ  d 6Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   s»   A Fetch Progress with GObject signals.

    Signals:

        * status-changed(str: description, int: percent)
        * status-started()
        * status-finished()

    DEPRECATED.
    s   status-changeds   status-starteds   status-finishedc         C   s<   t  j j |  ƒ t j j |  ƒ t |  _ t j ƒ  |  _	 d  S(   N(
   R   t   AcquireProgressR   R   R   R4   t	   _continueR   R   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   î   s    	c         C   s!   t  j j |  ƒ |  j d ƒ d  S(   Ns   status-started(   R   RO   t   startR   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRQ   ô   s    c         C   s!   t  j j |  ƒ |  j d ƒ d  S(   Ns   status-finished(   R   RO   t   stopR   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRR   ø   s    c         C   s   t  |  _ d  S(   N(   R)   RP   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   cancelü   s    c         C   s  t  j j |  | ƒ |  j d } | |  j k r; |  j } n  |  j d k r t d ƒ i | d 6|  j d 6t j |  j ƒ d 6} n! t d ƒ i | d 6|  j d 6} |  j	 |  j d t
 |  j |  j ƒ } |  j d	 | | ƒ x  |  j j ƒ  rÿ |  j j ƒ  qà W|  j S(
   Ni   i    s<   Downloading file %(current)li of %(total)li with %(speed)s/sR8   t   totalt   speeds+   Downloading file %(current)li of %(total)lig      Y@s   status-changed(   R   RO   t   pulset   current_itemst   total_itemst   current_cpst   _R$   t   size_to_strt   current_bytest   floatt   total_bytesR   R   R   R   RP   (   R   t   ownert   current_itemt   textR   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRV   ÿ   s$    	

	
(   R   R   R   R   R    R!   R"   R   RQ   RR   RS   RV   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   Þ   s   

				t   GFetchProgressc           B   sh   e  Z d  Z i e e e f ƒ d 6e ƒ  d 6e ƒ  d 6Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(	   sÓ   A Fetch Progress with GObject signals.

        Signals:

            * status-changed(str: description, int: percent)
            * status-started()
            * status-finished()

        DEPRECATED.
        s   status-changeds   status-starteds   status-finishedc         C   s<   t  j j |  ƒ t j j |  ƒ t |  _ t j ƒ  |  _	 d  S(   N(
   R   t   FetchProgressR   R   R   R4   RP   R   R   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   (  s    	c         C   s   |  j  d ƒ d  S(   Ns   status-started(   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRQ   .  s    c         C   s   |  j  d ƒ d  S(   Ns   status-finished(   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRR   1  s    c         C   s   t  |  _ d  S(   N(   R)   RP   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRS   4  s    c         C   sß   t  j j |  ƒ |  j d } | |  j k r8 |  j } n  |  j d k r~ t d ƒ i | d 6|  j d 6t j |  j	 ƒ d 6} n! t d ƒ i | d 6|  j d 6} |  j
 d | |  j ƒ x  |  j j ƒ  r× |  j j ƒ  q¸ W|  j S(	   Ni   i    s<   Downloading file %(current)li of %(total)li with %(speed)s/sR8   RT   RU   s+   Downloading file %(current)li of %(total)lis   status-changed(   R   Rc   RV   t   currentItemst
   totalItemsRY   RZ   R$   R[   t
   currentCPSR   R   R   R   R   RP   (   R   R`   Ra   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRV   7  s     	

	
(   R   R   R   R   R    R!   R"   R   RQ   RR   RS   RV   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRb     s   

				c           B   sÂ   e  Z d  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e	 j
 rf e d „  ƒ Z n  e d „  ƒ Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z e d „ Z d „  Z d „  Z RS(   s¼   Graphical progress for installation/fetch/operations.

    This widget provides a progress bar, a terminal and a status bar for
    showing the progress of package manipulation tasks.
    c         C   sN  t  j j |  ƒ |  j d ƒ t  j t d ƒ ƒ |  _ t j ƒ  |  _	 |  j j
 |  j	 ƒ t  j ƒ  |  _ t  j ƒ  |  _ t j ƒ  } | j t j t j d d ƒ ƒ |  j j | ƒ |  j j t j ƒ |  j j d d ƒ |  j |  j t ƒ |  j |  j t ƒ |  j |  j t ƒ t ƒ  |  _ |  j j d |  j ƒ |  j j d |  j ƒ |  j j d |  j ƒ t  ƒ  |  _! |  j! j d |  j ƒ |  j! j d |  j ƒ |  j! j d |  j ƒ d  |  _# t$ |  j	 ƒ |  _% |  j% j d |  j ƒ |  j% j d |  j ƒ |  j% j d |  j ƒ |  j% j d |  j& ƒ |  j% j d	 |  j& ƒ |  j% j d
 |  j& ƒ d  S(   Ni   t   Detailsi    iÿÿÿÿs   status-changeds   status-starteds   status-finisheds   status-timeouts   status-errors   status-conffile('   t   gtkt   VBoxR   t   set_spacingt   ExpanderRZ   t	   _expandert   vtet   Terminalt	   _terminalt   addt   ProgressBart   _progressbart   Labelt   _labelt   pangot   AttrListt   insertt	   AttrStylet   STYLE_ITALICt   set_attributest   set_ellipsizet   ELLIPSIZE_ENDt   set_alignmentt
   pack_startR)   R   t   _progress_openR/   t   _on_status_changedt   _on_status_startedt   _on_status_finishedR   t   _progress_acquireR#   t   _progress_fetchR   t   _progress_installt   _on_status_timeout(   R   t	   attr_list(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   S  sR    



	




c         C   s4   |  j  j d ƒ |  j j d ƒ |  j j t ƒ d S(   s   Reset all status information.t    i    N(   Rt   t	   set_labelRr   t   set_fractionRl   t   set_expandedR)   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   clear„  s    c         C   s   |  j  S(   s*   Return the cache opening progress handler.(   R   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   openŠ  s    c         C   s   |  j  S(   s$   Return the install progress handler.(   R…   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   install  s    c         C   s   |  j  S(   s-   Return the install progress handler for dpkg.(   R…   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   dpkg_install”  s    c         C   sg   |  j  d k r` t ƒ  |  _  |  j  j d |  j ƒ |  j  j d |  j ƒ |  j  j d |  j ƒ n  |  j  S(   s"   Return the fetch progress handler.s   status-changeds   status-starteds   status-finishedN(   R„   R#   Rb   R/   R€   R   R‚   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   fetch›  s    

c         C   s   |  j  S(   s$   Return the acquire progress handler.(   Rƒ   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   acquire¨  s    c         C   s:   |  j  | t d ƒ d ƒ x t j ƒ  r5 t j ƒ  q Wd S(   s   Called when something starts.s   Starting...i    N(   R€   RZ   Rh   t   events_pendingt   main_iteration(   R   t   progress(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   ­  s    c         C   s:   |  j  | t d ƒ d ƒ x t j ƒ  r5 t j ƒ  q Wd S(   s   Called when something finished.t   Completeid   N(   R€   RZ   Rh   R’   R“   (   R   R”   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR‚   ³  s    c         C   sm   |  j  j | ƒ | d k s( | d k r8 |  j j ƒ  n |  j j | d ƒ x t j ƒ  rh t j ƒ  qO Wd S(   s   Called when the status changed.iÿÿÿÿg      Y@N(	   Rt   t   set_textR#   Rr   RV   RŠ   Rh   R’   R“   (   R   R”   R@   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR€   ¹  s    c         C   s1   |  j  j t ƒ x t j ƒ  r, t j ƒ  q Wd S(   s   Called when timeout happens.N(   Rl   R‹   R4   Rh   R’   R“   (   R   R”   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR†   Ã  s    c         C   s   |  j  j ƒ  d S(   s$   Cancel a currently running download.N(   R„   RS   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   cancel_downloadÉ  s    c         C   sK   |  j  j ƒ  |  j j ƒ  |  j  j | ƒ x t j ƒ  rF t j ƒ  q- Wd S(   s   Show the expander for the terminal.

        Show an expander with a terminal widget which provides a way
        to interact with dpkg
        N(   Rl   t   showRo   R‹   Rh   R’   R“   (   R   t   expanded(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   show_terminalÍ  s
    c         C   s.   |  j  j ƒ  x t j ƒ  r) t j ƒ  q Wd S(   s+   Hide the expander with the terminal widget.N(   Rl   t   hideRh   R’   R“   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   hide_terminalÙ  s    c         C   sK   t  j j |  ƒ |  j j ƒ  |  j j ƒ  x t  j ƒ  rF t  j ƒ  q- Wd S(   s   Show the BoxN(   Rh   t   HBoxR˜   Rt   Rr   R’   R“   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR˜   ß  s
    (   R   R   R   R   RŒ   t   propertyR   RŽ   R   R$   R%   R   R‘   R   R‚   R€   R†   R—   R)   Rš   Rœ   R˜   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   L  s"   	1					
			c    	      C   sY  d d l  }  d d l } d d l m } t j ƒ  } t ƒ  } | j d ƒ | j | ƒ | j	 ƒ  | j	 ƒ  | j
 j | j ƒ } | d } | j r  | j ƒ  n
 | j ƒ  | j t ƒ y | j | j | j ƒ Wn& t k
 rù } |  j d I| IJn Xt |  j ƒ d k r8| |  j d | ƒ } | j | j ƒ n  | j d t j ƒ t j ƒ  d S(	   s   Test functioniÿÿÿÿN(   t
   DebPackages   GtkAptProgress Demot   xterms   Exception happened:i   t   destroy(   t   syst   aptt   apt.debfileRŸ   Rh   t   WindowR   t	   set_titleRp   R˜   t   cachet   CacheR   t   is_installedt   mark_deletet   mark_installRš   R4   t   commitR‘   RŽ   t	   Exceptiont   stderrt   lent   argvR   R/   t	   main_quitt   main(	   R¢   R£   RŸ   t   wint   apt_progressR§   R5   t   exct   deb(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   _testè  s0    	


	
t   __main__(    ('   R   t   osR,   t   pygtkt   requireRh   R   t   ImportErrorR   Ru   Rm   R$   R    RZ   t   apt.deprecationR   R   t   apt.progressR   R%   R   t   __all__t   SIGNAL_RUN_FIRSTt	   TYPE_NONER   R   R   R   R(   R   t   GDpkgInstallProgressRO   R   Rc   Rb   Ri   R   R·   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   <module>   s@   			%v8	"4œ	