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: //lib/python3/dist-packages/DistUpgrade/__pycache__/telemetry.cpython-38.pyc
U

B��]�
�@sBddlZddlZddlZddlZddlZdd�ZGdd�d�ZdS)�NcCstjdkrt�t_tjS)z'Return a singleton _Telemetry instance.N)�
_Telemetry�
_telemetry�rr�7/usr/lib/python3/dist-packages/DistUpgrade/telemetry.py�gets
rc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rNc	Cs�i|_i|_|��|_tjdddgtjdd���d��|jd<|�	d�d	|_
z&td
��}|��|jd<W5QRXWnt
k
r�YnXdS)NZlsb_releasez-rz-sT)�stdoutZuniversal_newlinesrZFrom�startz/var/log/upgrade/telemetryz/var/log/installer/media-infoZInstallMedia)�_metrics�_stages_hist�_get_current_uptime�_start_time�
subprocess�Popen�PIPEZcommunicate�strip�	add_stage�
_dest_path�open�readline�FileNotFoundError)�self�frrr�__init__)s"
��

z_Telemetry.__init__c
Cspd}z,td��}t|����d�}W5QRXWn:tttfk
rj}zt�dt	|��W5d}~XYnX|S)z6Get current uptime info. None if we couldn't fetch it.Nz/proc/uptimerz)Exception while fetching current uptime: )
r�float�read�splitr�OSError�
ValueError�logging�warning�str)rZuptimer�errrr8s
"�z_Telemetry._get_current_uptimecCs6|��}|jdks|dkrdS||jt||j�<dS)z(Record installer stage with current timeN)rrr
�int)rZ
stage_nameZnowrrrrCsz_Telemetry.add_stagecCs||jd<dS)zRecord updater typeZTypeN�r	)rZupdater_typerrr�set_updater_typeJsz_Telemetry.set_updater_typecCs||jd<dS)z*Record if the user had third party sourcesZThirdPartySourcesNr#)rZusingrrr�set_using_third_party_sourcesNsz(_Telemetry.set_using_third_party_sourcesc
Cs�|j|jd<tj�|j�}zbtj�|�s2t�|�t|jd��}t	�
|j|�W5QRXt�|jtj
tjBtjBtjB�Wn4tk
r�}zt�dt|��W5d}~XYnXdS)z<Close telemetry collection

        Save to destination fileZStages�wz(Exception while storing telemetry data: N)r
r	�os�path�dirnamer�exists�makedirsr�json�dump�chmod�stat�S_IRUSR�S_IWUSR�S_IRGRP�S_IROTHrrrr )rZ
target_dirrr!rrr�doneRs$

����z_Telemetry.done)
�__name__�
__module__�__qualname__rrrrr$r%r4rrrrr%sr)rr,r'r/r
rrrrrr�<module>s