ó
öòUc           @  s”  d  Z  d d l m Z d d l Z e j d ƒ d d l Z y d d l Z e Wn e k
 rn 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 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 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ÿÿÿÿ(   t   print_functionNs   2.0(   t   gettext(   t   baset   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   mksig1   s    c           B  sY   e  Z d  Z i e e e f ƒ d 6e ƒ  d 6e ƒ  d 6Z d „  Z d d „ Z	 d „  Z
 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   K   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   P   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   W   s    N(   t   __name__t
   __module__t   __doc__R
   t   strt   intt   __gsignals__R   t   NoneR   R   (    (    (    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 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   t   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.pyR)      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   R.   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   R.   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.pyR;   ´   s
    c         C  s   |  j  j d |  j ƒ S(   s   Fork the process.t   envv(   R'   t   forkptyR+   (   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#   R;   R%   t   sleepR$   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt
   wait_childÃ   s    
i,  (   R   R   R   R<   R
   R   R   R   R   R)   R0   R3   R4   R   R6   R8   R:   R;   R?   RA   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   ]   s(   



											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   R-   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   RB   t   startR   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRD   ä   s    c         C  s!   t  j j |  ƒ |  j d ƒ d  S(   Ns   status-finished(   R   RB   t   stopR   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRE   è   s    c         C  s   t  |  _ d  S(   N(   R"   RC   (   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/sR1   t   totalt   speeds+   Downloading file %(current)li of %(total)lig      Y@s   status-changed(   R   RB   t   pulset   current_itemst   total_itemst   current_cpst   _t   apt_pkgt   size_to_strt   current_bytest   floatt   total_bytesR   R   R   R   RC   (   R   t   ownert   current_itemt   textR   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRI   ï   s$    	

	
(   R   R   R   R
   R   R   R   R   RD   RE   RF   RI   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR   Î   s   

				c           B  s§   e  Z d  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z 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   ExpanderRM   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     sR    



	




c         C  s4   |  j  j d ƒ |  j j d ƒ |  j j t ƒ d S(   s   Reset all status information.t    i    N(   Rc   t	   set_labelRa   t   set_fractionR[   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.(   Rn   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   openE  s    c         C  s   |  j  S(   s$   Return the install progress handler.(   Rt   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   installJ  s    c         C  s   |  j  S(   s-   Return the install progress handler for dpkg.(   Rt   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   dpkg_installO  s    c         C  s   |  j  S(   s$   Return the acquire progress handler.(   Rr   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   acquireT  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(   Ro   RM   RW   t   events_pendingt   main_iteration(   R   t   progress(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRp   Y  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(   Ro   RM   RW   R€   R   (   R   R‚   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRq   _  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(	   Rc   t   set_textR    Ra   RI   Ry   RW   R€   R   (   R   R‚   R9   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRo   e  s    c         C  s1   |  j  j t ƒ x t j ƒ  r, t j ƒ  q Wd S(   s   Called when timeout happens.N(   R[   Rz   R-   RW   R€   R   (   R   R‚   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyRu   o  s    c         C  s   |  j  j ƒ  d S(   s$   Cancel a currently running download.N(   Rs   RF   (   R   (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   cancel_downloadu  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(   R[   t   showR^   Rz   RW   R€   R   (   R   t   expanded(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   show_terminaly  s
    c         C  s.   |  j  j ƒ  x t j ƒ  r) t j ƒ  q Wd S(   s+   Hide the expander with the terminal widget.N(   R[   t   hideRW   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(   RW   t   HBoxR†   Rc   Ra   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   Rp   Rq   Ro   Ru   R…   R"   Rˆ   RŠ   R†   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyR     s   	1				
			c    	      C  s\  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ü } t d | d |  j ƒn Xt |  j ƒ d k r;| |  j d | ƒ } | j | j ƒ n  | j d	 t j ƒ t j ƒ  d S(
   s   Test functioniÿÿÿÿN(   t
   DebPackages   GtkAptProgress Demot   xterms   Exception happened:t   filei   t   destroy(   t   syst   aptt   apt.debfileR   RW   t   WindowR   t	   set_titleR_   R†   t   cachet   CacheR|   t   is_installedt   mark_deletet   mark_installRˆ   R-   t   commitR   R}   t	   Exceptiont   printt   stderrt   lent   argvR~   R(   t	   main_quitt   main(	   R‘   R’   R   t   wint   apt_progressR–   R.   t   exct   deb(    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   _test”  s0    	


	
t   __main__(    (!   R   t
   __future__R    t   pygtkt   requireRW   R   t   ImportErrorR   Rd   R%   R\   RN   R   RM   t   apt.progressR   t   __all__t   SIGNAL_RUN_FIRSTt	   TYPE_NONER
   R   R   R   R!   R   t   GDpkgInstallProgressRB   R   RX   R   R§   R   (    (    (    s5   /usr/lib/python2.7/dist-packages/apt/progress/gtk2.pyt   <module>   s6   		!n9	