HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeView.cpython-38.pyc
U

٪zc�A�@s�ddlmZddlmZddlmZddlZddlm	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZze
�e
jd�e
��\ZZWne�d	�d
ZYnXes�d
Ze�dd�ze
�e
jd�Wne
jk
r�YnXe�d
e
���dd�ZGdd�dejj j!�Z!Gdd�dejj j"�Z"Gdd�de#�Z$Gdd�de#�Z%Gdd�de	�Z&ed�ed�ed�ed�ed�fGdd �d e#�Z'e(d!k�r�e!�Z)e)�*�dS)"�)�gettext)�ngettext)�get�N)�Enum)�apport_pkgfailure�zgetting the encoding failedzutf-8�LC_CTYPEzC.UTF-8zlocale: '%s' '%s'cCs0t|�}|d}|dd}|dd}|d}|dkr<d}ddddd�}|dkrftd	d
|�||d<|dkr�tdd
|�||d<|dkr�tdd|�||d<tdd|�||d<|dkr�|ddkr�|dStd�|S|dkr�|dS|dk�r|ddk�r
|dStd�|S|dk�r(|dS|dS)z; return the time a bit fuzzy (no seconds if time > 60 secs i�Qi��<rrr)�str_days�	str_hours�str_minutes�str_secondsz%li dayz%li daysrz%li hourz	%li hoursr
z
%li minutez%li minutesrz
%li secondz%li secondsrz%(str_days)s %(str_hours)s�z%(str_hours)s %(str_minutes)s)�intr�_)ZsecZdaysZhoursZminutesZseconds�map�r�=/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeView.py�FuzzyTimeToStr;s@�



rcsZeZdZ�fdd�Z�fdd�Z�fdd�Zdd�Zd�fd
d�	Zdd
�Zdd�Z	�Z
S)�AcquireProgresscstt|���d|_dS)N�)�superr�__init__�	est_speed��self��	__class__rrr�szAcquireProgress.__init__cs*tt|���d|_d|_d|_d|_dS)NrF)rr�startr�eta�percent�release_file_download_errorrrrrr �s
zAcquireProgress.startcsdtt|��||||�|tjkr`t�d|�|�d�sB|�d�r`dD]}|�|�rFd|_	q`qFdS)Nz update_status: dlFailed on '%s' zRelease.gpgZRelease)ZhttpZftpZmirrorT)
rr�
update_status�apt_pkgZSTAT_FAILED�loggingZwarning�endswith�
startswithr#)rZuriZdescrZ
shortDescrZstatusZnetrrrr$�s

zAcquireProgress.update_statuscCsdS)NTr)r�argrrr�pulse_items�szAcquireProgress.pulse_itemsNcsvtt|��|�|j|jdt|j|j�|_|j	|j
krP|j
|j	d|_
|j	dkrr|j|jt|j	�|_dS)NgY@g@rT)rr�pulseZ
current_bytesZ
current_items�floatZtotal_bytesZtotal_itemsr"Zcurrent_cpsrr!)r�ownerrrrr+�s�

�zAcquireProgress.pulsecCs
|jdkS)Nr)rrrrr�isDownloadSpeedEstimated�sz(AcquireProgress.isDownloadSpeedEstimatedcCsP|jdkr6|d}|d}td�t|�t|�f}|Std�t||j�}|S)z! get the estimated download time rg�@gAz[This download will take about %s with a 1Mbit DSL connection and about %s with a 56k modem.z7This download will take about %s with your connection. )rrr)rZrequired_downloadZ	timeModemZtimeDSL�srrr�estimatedDownloadTime�s
�z%AcquireProgress.estimatedDownloadTime)N)�__name__�
__module__�__qualname__rr r$r*r+r.r0�
__classcell__rrrrrs
rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�InstallProgressz_ Base class for InstallProgress that supports some fancy
      stuff like apport integration
  cCstjjj�|�d|_dS�N)�apt�progress�baser5rZ	master_fdrrrrr�szInstallProgress.__init__c
Cs�zt�|jggg|j�Wn6tjk
rP}z|jdtjkr@�W5d}~XYnX|��z&t�	|j
tj�\}}||j
kr~Wq�Wqtk
r�}z&|jtjkr��|jtj
kr�WY�q�W5d}~XYqXq|S)z�Wait for child progress to exit.

      The return values is the full status returned from os.waitpid()
      (not only the return code).
      rN)�selectZstatusfdZselect_timeout�error�args�errnoZEINTRZupdate_interface�os�waitpid�	child_pid�WNOHANG�OSErrorZECHILD)r�e�pid�resrrr�
wait_child�s 
zInstallProgress.wait_childcCs�|��}|dkr�t�tjtj�z|�|j�}Wnftk
r�}zHtd|�t�	d�t
dd��}|�t|��W5QRXt
�|j�W5d}~XYnXt
�|�||_t
�|���}|S)Nrz!Exception during pm.DoInstall(): zException during pm.DoInstall()z./var/run/ubuntu-release-upgrader-apt-exception�w)�fork�signal�SIGPIPE�SIG_IGNZ
do_installZwritefd�	Exception�printr&�	exception�open�write�strr>�_exitZ
RESULT_FAILEDr@�WEXITSTATUSrF)rZpmrDrErC�frrr�run�s


zInstallProgress.runcCs�tjjj�|||�t�d||f�d|kr:tj�|�}|�	d�d�
�rdd�|�	d�dd��}d|krz|�	d�d}t||�dS)z install error from a package z*got an error from dpkg for pkg: '%s': '%s'�/�-rrNr)
r7r8r9r5r;r&r>�path�basename�split�isdigit�joinr)r�pkgZerrormsgrrrr;�szInstallProgress.errorN)r1r2r3�__doc__rrFrUr;rrrrr5�s
r5c@seZdZddd�ZdS)�DumbTerminalFcCsddl}|�|�dS)z7 expects a command in the subprocess style (as a list) rN)�
subprocess�call)r�cmdZhiddenr`rrrra�szDumbTerminal.callN)F)r1r2r3rarrrrr_�sr_c@s$eZdZdd�Zdd�Zdd�ZdS)�
DummyHtmlViewcCsdSr6r)rZurlrrrrO�szDummyHtmlView.opencCsdSr6rrrrr�show�szDummyHtmlView.showcCsdSr6rrrrr�hideszDummyHtmlView.hideN)r1r2r3rOrdrerrrrrc�srcc@s(eZdZdZdZdZdZdZdZdZ	dS)	�Stepr�r����N)
r1r2r3ZPREPAREZMODIFY_SOURCESZFETCHZINSTALLZCLEANUPZREBOOT�NrrrrrfsrfzPreparing to upgradezGetting new software channelszGetting new packageszInstalling the upgradeszCleaning upc@s�eZdZdZdd�Zdd�Zdd�Zd/d	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd0dd�Zd1dd�Zd2d d!�Zd"d#�Zd3d$d%�Zd4d&d'�Zd(d)�Zd5d+d,�Zd-d.�ZdS)6�DistUpgradeViewz" abstraction for the upgrade view cCs
d|_dS)NF)Zneeds_screenrrrrrszDistUpgradeView.__init__cCstjj��S)z5 return a OpProgress() subclass for the given graphic)r7r8r9Z
OpProgressrrrr�getOpCacheProgresssz"DistUpgradeView.getOpCacheProgresscCst�S)z# return an acquire progress object )rrrrr�getAcquireProgresssz"DistUpgradeView.getAcquireProgressNcCst�S)z" return a install progress object )r5)r�cacherrr�getInstallProgress sz"DistUpgradeView.getInstallProgresscCst�Sr6)r_rrrr�getTerminal#szDistUpgradeView.getTerminalcCst�Sr6)rcrrrr�getHtmlView%szDistUpgradeView.getHtmlViewcCsdS)z\ update the current status of the distUpgrade based
            on the current view
        Nr)r�msgrrr�updateStatus'szDistUpgradeView.updateStatuscCsdS)z8 provide a visual feedback that the upgrade was aborted Nrrrrr�abort,szDistUpgradeView.abortcCst��|j�dS)z� we have 6 steps current for a upgrade:
        1. Analyzing the system
        2. Updating repository information
        3. fetch packages
        3. Performing the upgrade
        4. Post upgrade stuff
        5. Complete
        N)�
get_telemetryZ	add_stage�name�r�steprrr�setStep/s	zDistUpgradeView.setStepcCsdS)z" hide a certain step from the GUI Nrryrrr�hideStep:szDistUpgradeView.hideStepcCsdS)z" show a certain step from the GUI Nrryrrr�showStep=szDistUpgradeView.showStepTc
Cs�d|_||_g|_g|_g|_g|_g|_g|_|D]�}|jrL|j�	|�q4|j
r`|j�	|�q4|jrt|j�	|�q4|jr�|j
j�|j�r�|j�	|�q�|j�	|�q4|jr4|j�	|�q4|j|j|_|j��|j��|j��|j��|j��d}t|j�t|j�}	t|j�t|j�}
t|j�}t|j�dk�rl|tddt|j��dt|j�i7}|d7}|	dk�r�|tdd	|	�|	7}|d
7}|
dk�r�|tdd|
�|
7}|d
7}|dk�r�|td
d|�|7}|d
7}|dk�r*t�|�}t|t��r|�t�}|td�|7}||���|�7}||
dk�r|||
|	dk�r||�����rj|dtd�7}n|dtd�7}n|	dk�r�|dtd�7}||
|	dk�r�td�}td�}|�||�dS||_dS)zm display the list of changed packages (apt.Package) and
            return if the user confirms them
        r�
rzo%(amount)d installed package is no longer supported by Canonical. You can still get support from the community.zq%(amount)d installed packages are no longer supported by Canonical. You can still get support from the community.Zamountz

z"%d package is going to be removed.z$%d packages are going to be removed.� z(%d new package is going to be installed.z*%d new packages are going to be installed.z#%d package is going to be upgraded.z%%d packages are going to be upgraded.z&

You have to download a total of %s. �dz

%sznInstalling the upgrade can take several hours. Once the download has finished, the process cannot be canceled.z{Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be canceled.z.Removing the packages can take several hours. rz,The software on this computer is up to date.zRThere are no upgrades available for your system. The upgrade will now be canceled.FT) ZconfirmChangesMessage�	demotionsZ	toInstallZtoReinstallZ	toUpgradeZtoRemoveZtoRemoveAutoZtoDowngradeZmarked_install�appendZmarked_upgradeZmarked_reinstallZ
marked_deleteZ_pcacheZ	_depcacheZis_auto_installedZ_pkgZmarked_downgrade�sort�lenrr%Zsize_to_str�
isinstance�bytes�decode�ENCODINGrror0r.r;)
r�summaryZchangesr�ZdownloadSizeZactionsZremoval_boldr]rtZpkgs_removeZ	pkgs_instZpkgs_upgradeZdownloadSizeStrrrr�confirmChanges@s�





��
��
��
��


� 
zDistUpgradeView.confirmChanges�NocCsdS)z0 ask a Yes/No question and return True on 'Yes' Nr�rr�rt�defaultrrr�askYesNoQuestion�sz DistUpgradeView.askYesNoQuestion�CancelcCsdS)z= ask a Cancel/Continue question and return True on 'Continue'Nrr�rrr�askCancelContinueQuestion�sz)DistUpgradeView.askCancelContinueQuestioncCstd�}td�}|�||�S)z2 generic ask about the restart, can be overridden zReboot requiredzMThe upgrade is finished and a reboot is required. Do you want to do this now?)rr�)rr�rtrrr�confirmRestart�szDistUpgradeView.confirmRestartcCsdS)z display a error Nr�rr�rtZextended_msgrrrr;�szDistUpgradeView.errorcCsdS)z display a information msgNrr�rrr�information�szDistUpgradeView.informationcCsdS)zQ process gui events (to keep the gui alive during a long
            computation Nrrrrr�
processEvents�szDistUpgradeView.processEventsFcCsdS)zX do a progress pulse (e.g. bounce a bar back and forth, show
          a spinner)
      Nr)rZfinishedrrr�
pulseProgress�szDistUpgradeView.pulseProgresscCs|�||d�|��dS)zr
      show demoted packages to the user, default implementation
      is to just show a information dialog
      r~N)r�r\)rr�rtr�rrr�
showDemotions�szDistUpgradeView.showDemotions)N)NT)r�)r�)N)N)F)r1r2r3r^rrnrorqrrrsrurvr{r|r}r�r�r�r�r;r�r�r�r�rrrrrms.
�
c




rm�__main__)+ZDistUpgradeGettextrrrZ	telemetryrrwr7�enumrr=r>r%Zlocaler&rIr:ZDistUpgradeApportr�	setlocale�LC_ALLZgetdefaultlocale�coder�rN�putenvr	r;�infoZ	getlocalerr8r9rr5�objectr_rcrfrmr1�fpr+rrrr�<module>sV

D6@�3