ó
Qº’Nc           @   s  d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z d  d l Z d  d l	 Z	 d  d l
 m	 Z d  d l m Z d e e j j j f d „  ƒ  YZ d e j j j f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ e d k re ƒ  Z e d d d ƒGHe ƒ  Z e j d d d ƒ GHe j d d d ƒ GHe  j d ƒ e j ƒ  e j ƒ  Z e j ƒ  Z e j e ƒ Z  x# e  j! d D] Z" e e" j# ƒ  qŠWe j$ e e  ƒ e  j d ƒ e j% ƒ  j& d d d g ƒ e j' d d d ƒ e j( d g  d ƒ e j d d ƒ GHn  d S(   iÿÿÿÿN(   t   DistUpgradeViewt   InstallProgresst   FetchProgress(   t   gettext(   t   twrapt   TextFetchProgressc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s'   t  j j j j |  ƒ t j |  ƒ d  S(   N(   t   aptt   progresst   textt   AcquireProgresst   __init__R   (   t   self(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR
   %   s    c         C   s-   t  j j j j |  | ƒ t j |  | ƒ t S(   N(   R   R   R   R	   t   pulseR   t   True(   R   t   owner(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR   (   s    (   t   __name__t
   __module__R
   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR   $   s   	t   TextCdromProgressAdapterc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s     Report the cdrom add progress  c         C   s-   | r) d | | t  |  j ƒ d f GHn  d S(   s;    update is called regularly so that the gui can be redrawn s   %s (%f)id   N(   t   floatt
   totalSteps(   R   R   t   step(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   update/   s    c         C   s
   t  d f S(   Nt    (   t   False(   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   askCdromName3   s    c         C   s   t  S(   N(   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   changeCdrom5   s    (   R   R   t   __doc__R   R   R   (    (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR   -   s   		t   DistUpgradeViewTextc           B   s³   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d d „ Z d d „ Z d „  Z d e d „ Z d d „ Z d „  Z RS(   s'    text frontend of the distUpgrade tool c         C   sï   t  |  _ t j j d ƒ s+ d t j d <n  | sO t j j t j ƒ  d ƒ } n d } y! t j	 d | ƒ t j
 d ƒ Wn$ t k
 rœ } t j d | ƒ n Xd |  _ t j j j ƒ  |  _ t ƒ  |  _ t ƒ  |  _ t ƒ  |  _ |  j t _ d  S(   Nt   DEBIAN_FRONTENDt   dialogt   mos    /usr/share/locale/update-managers   update-managers   Error setting locales (%s)i    (   R   t   needs_screent   ost   environt   has_keyt   patht   joint   getcwdR   t   bindtextdomaint
   textdomaint	   Exceptiont   loggingt   warningt	   last_stepR   R   R   t
   OpProgresst   _opCacheProgressR   t   _fetchProgressR   t   _cdromProgressR   t   _installProgresst   _handleExceptiont   syst
   excepthook(   R   t   datadirt   logdirt	   localedirt   e(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR
   ;   s"    		c         C   su   d d  l  } H| j | | | ƒ } t j d d j | ƒ ƒ |  j t d ƒ t d ƒ d j | ƒ ƒ t j d ƒ d  S(   Niÿÿÿÿs   not handled exception:
%ss   
s   A fatal error occurredsæ   Please report this as a bug and include the files /var/log/dist-upgrade/main.log and /var/log/dist-upgrade/apt.log in your report. The upgrade has aborted.
Your original sources.list was saved in /etc/apt/sources.list.distUpgrade.i   (   t	   tracebackt   format_exceptionR)   t   errorR$   t   _R2   t   exit(   R   t   typet   valuet   tbR8   t   lines(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR1   U   s    	c         C   s   |  j  S(   N(   R.   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   getFetchProgressd   s    c         C   s   | |  j  _ |  j  S(   N(   R0   t   _cache(   R   t   cache(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   getInstallProgressf   s    c         C   s   |  j  S(   N(   R-   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   getOpCacheProgressi   s    c         C   s   |  j  S(   N(   R/   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   getCdromProgressk   s    c         C   s   H| GHt  j j ƒ  d  S(   N(   R2   t   stdoutt   flush(   R   t   msg(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   updateStatusm   s    c         C   s   Ht  d ƒ GHd  S(   Nt   Aborting(   R;   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   abortq   s    c         C   s   | |  _  d  S(   N(   R+   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   setStept   s    c         C   s0   |  j  | | t d ƒ t d j | ƒ ƒ ƒ d  S(   Ns	   Demoted:
s   , (   t   informationR;   R   R$   (   R   t   summaryRI   t	   demotions(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   showDemotionsv   s    c         C   sG   Ht  | ƒ GHt  | ƒ GH| r+ t  | ƒ GHn  t d ƒ GHt j j ƒ  d  S(   Ns    To continue please press [ENTER](   R   R;   R2   t   stdint   readline(   R   RO   RI   t   extended_msg(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyRN   y   s    c         C   s/   Ht  | ƒ GHt  | ƒ GH| r+ t  | ƒ GHn  t S(   N(   R   R   (   R   RO   RI   RT   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR:      s    c         C   s{   xo d d g D]a } t  j j | ƒ r t j | d g d t j ƒ} | j j | ƒ | j j ƒ  | j	 ƒ  d Sq W| GHd S(   s!    helper to show output in a pagers   /usr/bin/sensible-pagers	   /bin/moret   -RR   N(
   R    R#   t   existst
   subprocesst   Popent   PIPERR   t   writet   closet   wait(   R   t   outputt   pagert   p(    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   showInPagerˆ   s    
c   
      C   sÿ  t  j |  | | | | | ƒ Ht | ƒ GHt |  j ƒ GHd t d ƒ t d ƒ f Gx¨t rút j j ƒ  } | j	 ƒ  j
 ƒ  j t d ƒ ƒ r t S| j	 ƒ  j
 ƒ  j t d ƒ ƒ r² t S| j	 ƒ  j
 ƒ  j t d ƒ ƒ rÝd } t |  j ƒ d k r=| d	 7} | t t d
 ƒ d j g  |  j D] }	 |	 j ^ qƒ d d ƒ7} n  t |  j ƒ d k r¡| d	 7} | t t d ƒ d j g  |  j D] }	 |	 j ^ q{ƒ d d ƒ7} n  t |  j ƒ d k r| t t d ƒ d j g  |  j D] }	 |	 j ^ qÕƒ d d ƒ7} | d	 7} n  t |  j ƒ d k ri| d	 7} | t t d ƒ d j g  |  j D] }	 |	 j ^ qCƒ d d ƒ7} n  t |  j ƒ d k rÍ| d	 7} | t t d ƒ d j g  |  j D] }	 |	 j ^ q§ƒ d d ƒ7} n  |  j | ƒ n  d t d ƒ t d ƒ f GqS Wd  S(   Ns    %s %ss   Continue [yN] s   Details [d]t   yt   nt   dR   i    s   
s   No longer supported: %s
t    t   subsequent_indents     s   Remove: %s
s   Remove (was auto installed) %ss   Install: %s
s   Upgrade: %s
s   %s %s(   R    t   confirmChangesR   t   confirmChangesMessageR;   R   R2   RR   RS   t   stript   lowert
   startswithR   t   lenRP   R$   t   namet   toRemovet   toRemoveAutot	   toInstallt	   toUpgradeR`   (
   R   RO   t   changesRP   t   downloadSizet   actionst   removal_boldt   resR]   R_   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyRf   ”   sR    
	!!!
2
22

2
2t   Noc         C   s«   Ht  | ƒ GHt  | ƒ GH| d k re t d ƒ Gt j j ƒ  } | j ƒ  j ƒ  j t d ƒ ƒ ra t St	 St d ƒ Gt j j ƒ  } | j ƒ  j ƒ  j t d ƒ ƒ r£ t	 St Sd  S(   NRv   s   Continue [yN] Ra   s   Continue [Yn] Rb   (
   R   R;   R2   RR   RS   Rh   Ri   Rj   R   R   (   R   RO   RI   t   defaultRu   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   askYesNoQuestionÃ   s    
!
!c         C   s"   |  j  t d ƒ t d ƒ d d ƒS(   Ns   Restart requireds]   To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.Rw   Rv   (   Rx   R;   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   confirmRestartâ   s    N(   R   R   R   t   NoneR
   R1   RA   RD   RE   RF   RJ   RL   RM   RQ   RN   R:   R`   R   Rf   Rx   Ry   (    (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyR   9   s"   										.t   __main__sÀ   89 packages are going to be upgraded.
You have to download a total of 82.7M.
This download will take about 10 minutes with a 1Mbit DSL connection and about 3 hours 12 minutes with a 56k modem.Re   Rd   t   hellos	   Icecream?Rv   t   Yesi    i   t   dpkgs   --configures   -at   shortt   longs²  asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended
t   xxid   ()   R2   R)   RW   R   R    R    R   R   t   apt.progressR   t   DistUpgradeGettextR;   t   utilsR   R   R   R	   R   t   baset   CdromProgressR   R   R   t   viewRx   R<   Ry   t   CacheRC   RA   t   fpRD   t   ipt   argvt   pkgt   mark_installt   committ   getTerminalt   callR:   Rf   (    (    (    sC   /usr/lib/python2.7/dist-packages/DistUpgrade/DistUpgradeViewText.pyt   <module>   s@   "	±		
