CasperSecurity

Current Path : /lib/python3/dist-packages/DistUpgrade/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/DistUpgrade/__pycache__/DistUpgradeViewNonInteractive.cpython-310.pyc

o

��*d&6�@sRddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
mZddl	mZmZddlmZmZmZddlmZddlmZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�Zedkr�e�Ze�Ze�Ze� dd�e�!�Z"ej#dd�D]Z$e"e$�%�q�e"�&ee�e�'d�e�(d�dSdS)�N)�NoSectionError�
NoOptionError)�PIPE�Popen�)�DistUpgradeView�InstallProgress�AcquireProgress)�get)�DistUpgradeConfigc@seZdZdd�ZdS)�NonInteractiveAcquireProgresscCs\t�|||||�|tjkr*td||jt�t|j��f�t	j
��r,t	j
��dSdSdS)Nzfetched %s (%.2f/100) at %sb/s)
r	�
update_status�apt_pkg�	STAT_DONE�print�percent�size_to_str�int�current_cps�sys�stdout�isatty�flush)�self�uri�descr�
shortDescr�status�r�K/usr/lib/python3/dist-packages/DistUpgrade/DistUpgradeViewNonInteractive.pyr
,s
�
�z+NonInteractiveAcquireProgress.update_statusN)�__name__�
__module__�__qualname__r
rrrrr+src@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�NonInteractiveInstallProgressz� 
    Non-interactive version of the install progress class
    
    This ensures that conffile prompts are handled and that
    hanging scripts are killed after a (long) timeout via ctrl-c
    c	Cs�t�|�t�d�dtjvrdtjd<dtjd<dtjd<td�|_||_d	|_	z|j�
d
dd�r9tj�d
d�Wnt
tfyEYnwd|_z|j�d
d�|_WdSty^YdSw)Nz*setting up environ for non-interactive use�DEBIAN_FRONTEND�noninteractive�none�APT_LISTCHANGES_FRONTEND�1�RELEASE_UPRADER_NO_APPORT�.r�NonInteractive�ForceOverwriteFzDPkg::Options::z--force-overwritei`	�TerminalTimeout)r�__init__�logging�debug�os�environr�config�logdir�install_run_number�getWithDefaultr�setrr�timeout�getint�	Exception)rr4rrrr.>s,






���z&NonInteractiveInstallProgress.__init__cCs�t�d||f�|j�ddd�sdSt�tj�}d|d<g}d|vr1d}d	}d
}d|||f}n?d|vrBd
}d}d}d||f}n.d|vrTd}d}d}d|||f}nd|vrfd}d}d}d|||f}n
td||f�dStj�	|�st�d|�dSt
|��}	|	��dd����
�d}
Wd�n1s�wYd|
vs�d|
vr�dg}nd|
vr�dg}d|d <nt�d!|
�t
|��}	|	��}Wd�n1s�wYd"|vr�d#|d$<d%|d&<d'}
d(dg}|�|
�|�|�|�|�|�|�|d	k�r"td)|d*td*d+���d}
|
�r!|�|
�
d,d-�d-���n0|dk�rRtj�|�}|�
d.�d}td/|d*td*d+���d}
|
�rR|�|
�
d,d-�d-���t�d0||f�tj||d1�}t�d2||f�dS)3Nz)got a error from dpkg for pkg: '%s': '%s'r+�DebugBrokenScriptsFr0�	PYCENTRALzpost-installationz/var/lib/dpkg/info/�postinst�	configurez%s/%s.%szpre-installationz/var/lib/dpkg/tmp.ci/�preinst�installz%s/%szpre-removal�prerm�removezpost-removal�postrmz3UNKNOWN (trigger?) dpkg/script failure for %s (%s) z+can not find failed maintainer script '%s' �r�bashz/bin/shz-ex�perlz-dzAutoTrace NonStop�PERLDB_OPTSzunknown interpreter: '%s'z. /usr/share/debconf/confmodule�	developer�
DEBCONF_DEBUGr(�DEBIAN_HAS_FRONTENDz/usr/share/debconf/frontend�shz%dpkg-query -s %s|grep ^Config-VersionT)�shellr�universal_newlines�:r�_zdpkg-query -s %s|grep ^Versionzre-running '%s' (%s))�envz%s script returned: %s)r/�errorr3r6�copyr1r2r�path�exists�open�readline�strip�split�warning�read�append�extendrr�communicate�basenamer0�
subprocess�call)r�pkg�errormsgr2�cmd�prefix�name�argument�maintainer_script�f�interp�
debug_opts�maintainer_script_text�version�retrrrrQWs��
�


�




���
��z#NonInteractiveInstallProgress.errorc
Cspt�d|�t�d�zt�|jd�t�d|�WdSty7}zt�d|�WYd}~dSd}~ww)Nz.got a conffile-prompt from dpkg for file: '%s'�sn
z0replied no to the conffile-prompt for file: '%s'z/error '%s' when trying to write to the conffile)	r/rY�time�sleepr1�write�	master_fdr:rQ)r�current�new�errr�conffile�s�
���z&NonInteractiveInstallProgress.conffilecCs�t�|�t��|_|j�ddd�}|r-tj�|j	d|j
�}t�d|�t
|d�|_nt
tjd�|_|j�dt���dS)Nr+�DpkgProgressLogFzdpkg-progress.%s.logz!writing dpkg progress log to '%s'�wz
%s: Start
)r�start_updatero�
last_activityr3r6r1rS�joinr4r5r/r0rU�dpkg_progress_log�devnullrq)r�progress_log�fullpathrrrry�s

z*NonInteractiveInstallProgress.start_updatecCs:t�|�|j�dt���|j��|jd7_dS)Nz
%s: Finished
r)r�
finish_updater|rqro�closer5�rrrrr��s

z+NonInteractiveInstallProgress.finish_updatecCs |j�dt��|||f�dS)Nz%s:%s:%s:%s
)r|rqro)rrar�
status_strrrr�
status_change�s
�z+NonInteractiveInstallProgress.status_changecCs�t�|�|jdkrdS|j|jt��kr*t�d|j|jf�t	�
|jtd��t
�
|jgggd�}t|d�dkrvt��|_zt	�|jd�}tj�
d|jt��dd��Wn
tycYdSwt
�
|jgggd�}t|d�dks<tj��dS)	Nz,no activity %s seconds (%s) - sending ctrl-c�g�������?rrz%s�ignore)�errors)r�update_interface�statusfdrzr8ror/rYrr1rqrr�chr�select�lenrZrr�decode�locale�getpreferredencoding�OSErrorr)r�res�srrrr��s,

�
���
z.NonInteractiveInstallProgress.update_interfacecCsNt�d�dtjd<dtjd<t��\|_|_|jdkr$t�d|j�|jS)Nzdoing a pty.fork()�dumb�TERM�true�PAGERrz
pid is: %s)r/r0r1r2�pty�fork�pidrrr�rrrr��s



z"NonInteractiveInstallProgress.forkN)r r!r"�__doc__r.rQrvryr�r�r�r�rrrrr#6s`
r#cs�eZdZdZd dd�Zdd�Zdd�Zd	d
�Zd!dd�Zd
d�Z	�fdd�Z
	d"dd�Zd#dd�Zd$dd�Z
dd�Zd!dd�Zdd�Z�ZS)%�DistUpgradeViewNonInteractivez- non-interactive version of the upgrade view NcCsLt�|�t��d�td�|_t�|_t|�|_	t
jj�
�|_|jt_dS)Nr+r*)rr.�
get_telemetry�set_updater_typerr3r�_acquireProgressr#�_installProgress�apt�progress�base�
OpProgress�_opProgress�
excepthookr�__excepthook__)r�datadirr4rrrr.s


z&DistUpgradeViewNonInteractive.__init__cCsHddl}t�d||f�|�|||�}t�dd�|��|��dS)z2 on uncaught exceptions -> print error and reboot rNzgot exception '%s': %s znot handled exception:
%s�)�	tracebackr/�	exception�format_exceptionrQr{�confirmRestart)r�type�value�tbr��linesrrrr�s
z(DistUpgradeViewNonInteractive.excepthookcC�|jS)z5 return a OpProgress() subclass for the given graphic)r�r�rrr�getOpCacheProgress�z0DistUpgradeViewNonInteractive.getOpCacheProgresscCr�)z# return an acquire progress object )r�r�rrr�getAcquireProgressr�z0DistUpgradeViewNonInteractive.getAcquireProgresscCr�)z" return a install progress object )r�)r�cacherrr�getInstallProgressr�z0DistUpgradeViewNonInteractive.getInstallProgresscC�dS)z\ update the current status of the distUpgrade based
            on the current view
        Nr)r�msgrrr�updateStatussz*DistUpgradeViewNonInteractive.updateStatuscstt|��|�dS)z� we have 5 steps current for a upgrade:
        1. Analyzing the system
        2. Updating repository information
        3. Performing the upgrade
        4. Post upgrade stuff
        5. Complete
        N)�superr��setStep)r�step��	__class__rrr�sz%DistUpgradeViewNonInteractive.setStepTcCsft�||||||�t�ddd�|jD��t�ddd�|jD��t�ddd�|jD��dS)	Nztoinstall: '%s'cS�g|]}|j�qSr�re��.0�prrr�
<listcomp>,�z@DistUpgradeViewNonInteractive.confirmChanges.<locals>.<listcomp>ztoupgrade: '%s'cSr�rr�r�rrrr�-r�ztoremove: '%s'cSr�rr�r�rrrr�.r�T)r�confirmChangesr/r0�	toInstall�	toUpgrade�toRemove)r�summary�changes�	demotions�downloadSize�actions�removal_boldrrrr�(s�z,DistUpgradeViewNonInteractive.confirmChanges�NocCr�)z0 ask a Yes/No question and return True on 'Yes' Tr�rr�r��defaultrrr�askYesNoQuestion0sz.DistUpgradeViewNonInteractive.askYesNoQuestion�CancelcCr��NTrr�rrr�askCancelContinueQuestion7sz7DistUpgradeViewNonInteractive.askCancelContinueQuestioncCst�d�|j�ddd�S)z2 generic ask about the restart, can be overridden zconfirmRestart() calledr+�
RealRebootF)r/r0r3r6r�rrrr�9s
z,DistUpgradeViewNonInteractive.confirmRestartcCst�d|||f�dS)z display a error z
%s %s (%s)N�r/rQ)rr�r��extended_msgrrrrQ>sz#DistUpgradeViewNonInteractive.errorcCst�d�dS)Nzview.abort calledr�r�rrr�abortAsz#DistUpgradeViewNonInteractive.abort)NN)Nr�)r�)r�)r r!r"r�r.r�r�r�r�r�r�r�r�r�r�rQr��
__classcell__rrr�rr��s 


�


r��__main__zxserver-xorgzpre-installation script failedrD))r�rr/r�rorr1r�r�r_rR�apt.progress�configparserrrrrrrr	�	telemetryr
r��DistUpgradeConfigParserrrr#r�r �view�ap�iprQ�Cacher��argvra�mark_install�commitrp�exitrrrr�<module>sBIG
�
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY