%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/share/hplip/__pycache__/
Upload File :
Create Path :
Current File : //usr/share/hplip/__pycache__/logcapture.cpython-312.pyc

�

=	f�0�
��ddlmZdZdZdZdZddlZddlZddlZddl	Z	ddl
Z
ddl�ddlm
Z
mZmZmZdd	lmZdd
lmZmZddl�dZdZd
ZdZeezZdZdZiZd�Zd�Z d�Z!dqd�Z"d�Z#edddfdezdddfdezdddfdde
jHe
jJe
jLe
jNe
jPg
Z)	ejTeeeee)e+fdd��Z,e,j[dgd�d �!�\Z.Z/Z0Z1Z2Z3ejrd"�re6jud#�e.D]�\Z;Z<e;d$vre"��e;d%k(r	e"d&�� e;d'k(r	e"d(��.e;d)k(re=ed*�+�e>dd ��Ge;d,vr8e<j�j��ZAe6jueA�r�{e"���e;d-vre6jud#���e;d.k(s��e<Z��ej��dk7r"e6jod/�ej��es_ed0ge�1�ZDeeDj��d�ZFeFreFj�d*�dZes#e6jod2�ej�d3�ej�j�e�sd4Zd5ezZJe6j�d6eJz�e
j�eJ�\ZMZNeMdk7r&e6jod7ez�ej�d3�e
j�d8ez�\ZMZNeMdk7re6jod9ez�d:ezd;zee<d<ed=<eD]�ZOe
j�d>e�d?eO���\ZMZNeMdk7r&e6jod7ez�ej�d3�e
j�d@e�d?eO���\ZMZNeMdk7s�je6jodAe�d?eO�dB����e �e�siej�dCgdD�dE�\ZQZReQreRdFk(r*e!�e6j�dG�ej�d3�eQreRdEk(re#dH�e#dI�e#dJ�	e
jj�e
jj��dK�ZVe6j�e6j�dL��ej�dMdEdFgdE�\ZQZReQreRdEk(rn2eQreRdFk(r*e!�e6j�dG�ej�d3���e
j�dN�\ZMZNeMdk7re6jodO�e6j�dPez�e�s�ej�j�dH�r1e
j�dQez�\ZMZNeMdk7re6jodRdHz�ej�j�dI�r1e
j�dSez�\ZMZNeMdk7re6jodRdIz�ej�j�dJ�r�e
j�dTez�\ZMZNeMdk7r�e6jodRdJz�n�e6j�dU�dVeVzZJej�eJdWezz�ZMeMdk7re6jodX�e6j�dY�dZeVzZJej�eJd[ezz�ZMeMdk7re6jod\�eD]!ZOej�d]eeO�d^e�d?eO�d_��ZM�#e
j�d`ez�\ZMZNeMdk7re6jodadbz�dcezZJej�eJ�ZMeMdk7re6jod9ez�dde�dee��ZJe6j�dfeJz�e
j�eJ�\Z[ZNe[dk7re6jodgez�n�e6j�dhez�e
j�diez�\ZMZNeMdk7re6jodjez�e6j�dk�e
j�dlez�\ZMZNeMdk7re6jodmez�e!�e6j�d�e6j�d�e[dk(rWe6j�e6j�dnej���d?e�do���e6j�e6j�dp��n5e6j�e6j�dnej���d?e����e6j�d�y#ejh$r-Z5e6joe5jp�e"�YdZ5[5���dZ5[5wwxYw)r�)�print_functionz1.0zHPLIP logs capture Utilityz
hp-logcapturezCaptures the HPLIP log files.N)�*)�utils�tui�module�os_utils)�to_string_utf8)�Popen�PIPEz/etc/cups/cupsd.confz/etc/cups/cupsd.conf_orginalz./�hplip_troubleshoot_logsz/var/spool/cups/tmp�c��ttt�}|j�|j}|j
}|dk(r	|dk\rd}|Sd}|S)N�fedoraz 21TF)�CoreInstall�MODE_INSTALLER�INTERACTIVE_MODE�
get_distro�distro_name�distro_version)�corer�
distro_ver�journals    �/usr/share/hplip/logcapture.py�
is_journalr3sV����(8�9�D��O�O���"�"�K��$�$�J��h��:��#5����N����N�c��d}dt�dt��}tjd|z�t	j
|�\}}|dk7rtj
dtz�dtz}tjd|z�t	j
|�\}}|dk(�rhd	tz}tjd
|z�tj|�}|dk7rtj
dtz�d}t	jd�r7tjjt	jd�d�d
z}n�t	jd�r>tjjt	jd�d�dtzz}n7tjjd�rd}ntj
d�|r7tjd|z�t	j
|�\}}|dk(rd}|S)NF�cp -f � zBackup CUPS conf file. cmd =%srz Failed to take back cups file=%szgrep 'LogLevel warn' %szcmd= %sz;sed -i 's/LogLevel.*warn/LogLevel debug
hpLogLevel 15/' %s z%Changing 'Log level' to debug. cmd=%sz-Failed to update Loglevel to Debug in cups=%s�service�
 cups restart�	systemctl� restart %s.service�/etc/init.d/cups�/etc/init.d/cups restart�:service command not found.. Please restart cups manually..�CUPS restart cmd = %sT)�	CUPS_FILE�CUPS_BACKUP_FILE�log�debugr�run�error�os�system�which�path�join�service_name�exists��result�cmd�sts�outs    r�
enable_logr9As���
�F� �!1�2�C��I�I�.�s�2�3��I�I�c�N�G�C��
�a�x��	�	�4�Y�>�?�	"�)�+�C��I�I�y��}���I�I�c�N�G�C��
�a�x�L�Y�V���	�	�9�#�=�>�
�Y�Y�s�^���!�8��9�9�D�Y�N�O����;�;�y�!������e�k�k�)�4�i�@��P�3�
�[�[��
%������e�k�k�+�6��D�EZ�[g�Eg�g�3�
�W�W�^�^�.�
/�+�3��9�9�Q�R���9�9�,�S�0�1��Y�Y�s�^�7�3�s��Q�h��v��Mrc���d}dt�dt��}tjd|z�t	j
|�\}}|dk(r[dtz}tjd|z�t	j
|�\}}|dk7r9tj
dtz�ntjd	tz�tjd
�d}t	jd�r7tjjt	jd�d�dz}n�t	jd
�r>tjjt	jd
�d
�dtzz}n7tjjd�rd}ntjd�|r7tjd|z�t	j
|�\}}|dk(rd}|S)NFrrz Restoring CUPS conf file. cmd=%srzrm -f %sz Removing Temporary file.. cmd=%sz-Failed to remove the Temporary backup file=%sz'Failed to restore cups config file = %szRestarting CUPS servicerr r!r"r#r$r%r&T)r(r'r)r*rr+�warnr,r/r-r0r1r2r3r4s    r�restore_loglevelsr<isd��
�F�'�	�2�C��I�I�0��4�5��y�y��~�H�C��
�a�x��&�&�s�
�y�y�3�C�7�8����3��w�s�3�

��(��H�H�D�EU�U�V�
�y�y�:�9�D�E��I�I�'�(��C��{�{�9��
�W�W�\�\�%�+�+�i�0�)�
<�_�
L�s�	���[�	!�
�W�W�\�\�%�+�+�k�2�K�
@�AV�Wc�Ac�
c�s�	�����*�	+�
'�s�
�y�y�M�N�
��	�	�)�#�-�.��)�)�C�.���C��!�8��6��Mrc���|dk(rtjtt�tjt
|ttt�tjd�y)N�textr)	r�	log_title�	__title__�__version__�format_text�USAGE�__mod__�sys�exit)�typs r�usagerH�s8��
�f�}�
���	�;�/�	���e�S�)�W�k�B��H�H�Q�Krc�r�tjj|��r�d}tjjd||fz�s$tjjd||fz�rO|dz
}tjjd||fz�r�*tjjd||fz�r�Otjd|||fz�\}}|dk7rt
j
d|z�yd|z}tj|�}|dk7rt
jd|z�tjd	�rZtjd
||fz�\}}|dk7rt
jd|||fz�yt
jd|||fz�yt
jd|||fz�yy)
N�z%s.%dz%s.%d.gzzcp %s %s.%drzFailed to archive %s log filezcat /dev/null > %szFailed to clear the %s log file�gzipz
gzip %s.%dz$Existing %s log file copied to %s.%dz'Existing %s log file copied to %s.%d.gz)r-r0r3rr+r)r,r�executer;r/�info)�strLog�iArchr7r8r6s     r�backup_clearLogrP�sv��	�w�w�~�~�f�����g�g�n�n�W�f�e�_�4�5������
�TZ�\a�Sb�Hb�9c��A�I�E��g�g�n�n�W�f�e�_�4�5������
�TZ�\a�Sb�Hb�9c��)�)�M�6�6�5�*A�A�B���C��!�8��I�I�5�f�<�=�&��/�C��"�"�3�'�C��a�x����:�6�A�B��{�{�6�"��)�)�\�6�5�/�%A�B���C��!�8��H�H�C�V�V�UZ�D[�[�\��H�H�F��PV�X]�G^�^�_����?���QV�@W�W�X�'r�nameTz-Usage: [su -c /sudo] %s [USER INFO] [OPTIONS]�summaryze.g. su -c '%s')z[USER INFO]r
�headingF)z)User name for which logs to be collected:z--user=<username> �optionF)�run_as_root_ok�quietzhl:g:r)�helpz	help-restzhelp-manz	help-desczlogging=r*zuser=F)�handle_device_printer�HPLIP_DEBUGr*)z-hz--helpz--help-rest�restz
--help-man�manz--help-descr)�end)z-lz	--logging)z-gz--debugz--userzIlogCapture needs root permissions since cups service restart requires....�who)�stdoutzAFailed to get the user name. Try again by passing '--user' optionrJz/tmpzmkdir -p %sz"Creating temporary logs folder =%sz'Failed to create directory =%s. Exitingz
chmod 755  %sz$Failed to change permissions for %s.z/home/z/.hplipz/root/.hplip�rootz	mkdir -p �/zchmod 755  z!Failed to change permissions for �.zVArchiving system logs (i.e. syslog, message, error_log). Press (y=yes*, n=no, q=quit):)�y�n�qrbrdz	User exitz/var/log/syslogz/var/log/messagesz/var/log/cups/error_logz%Y-%m-%d %H:%M:%SzT
Please perform the tasks (Print, scan, fax) for which you need to collect the logs.z1Are you done with tasks?. Press (y=yes*, q=quit):zhp-checkzFailed to run hp-check commandz$Copying logs to Temporary folder =%sz#cp -f /var/log/syslog %s/syslog.logzFailed to capture %s log file.z'cp -f /var/log/messages %s/messages.logz3cp -f /var/log/cups/error_log %s/cups_error_log.logz(Collecting cups logs from system journalz+journalctl -u cups.service -e --since '%s' z> %s/cups_error.logz#Failed to capture logs from journalz'Collecting messages from system journalzjournalctl --since '%s' z> %s/messages.logz'Failed to capture messages from journalrz/*.log  z 2>/devnull zmv -f ./hp-check.log %szFailed to capture %s log files.z./hp-check.logzchmod 666  %s/*.logz	tar -zcf z.tar.gz zCompressing logs. cmd =%szFailed to compress %s folder.z$Changing Permissions of ./%s.tar.gz zchmod 666 -R ./%s.tar.gzz+Failed to change permissions for %s.tar.gz.zRemoving Temporary log files..z	rm -rf %sz2Failed to remove temporary files. Remove manually.zLogs are saved as z.tar.gzzXPlease create a bug @https://bugs.launchpad.net/hplip/+filebug and upload this log file.)r>)]�
__future__rrAr@rD�__doc__r-rE�getopt�glob�datetime�base.g�baserrrr�base.sixextr	�
subprocessr
r�installer.core_installr'r(�LOG_FOLDER_PATH�LOG_FOLDER_NAME�	LOG_FILES�TMP_DIR�	USER_NAME�USERSrr9r<rHrP�
USAGE_OPTIONS�
USAGE_HELP�USAGE_LOGGING1�USAGE_LOGGING2�USAGE_LOGGING3rC�Moduler�mod�parseStdOpts�opts�
device_uri�printer_name�mode�
ui_toolkit�loc�GetoptError�er)r,�msg�getenv�	set_level�o�a�print�
clean_exit�lower�strip�	log_level�getuidrF�pout�communicate�output�splitr0r3r6r*r+r7r8�u�enter_choice�ok�
user_inputr;�strftime�now�log_timerM�boldr.rL�sts_compress�getcwd�rr�<module>r�s���,&���(�	�
��
-��	�
�
����+�+�&�"�$�
 �	�/����)��
�O�
+�	�
��
�	���	�#�P�B�Y�0�2�v�t�	$�
9�G�
C�R��TX�	Y�
�G�
#�B�y��	6�	.�	]�	�	�	�	�	�	�	�	�	�u�3�3�U�5I�5I�	
���
�&�-�-���K��%�%�'�t�4�I�C�����*u�MR��S�:�D�*�l�D�*�c�
�2�9�9�]���M�M�'����D�A�q����
��	
�m�	�
�f�
�	
�l�	�
�e��	
�m�	�
�g�3���1�U��	
�!�	!��G�G�I�O�O�%�	��}�}�Y�'��G�	
��	��
�
�g��	
�h���	�/�6
�2�9�9�;�!���I�I�Y�Z��C�H�H�J���%���&�D�
�D�,�,�.�q�1�
2�F�
��L�L��%�a�(�	���	�	�U�V�������	�w�w�~�~�g���G��I����	�	�
.�s�
2�3��5�9�9�S�>���S��!�8��9�9�
6�y�
@�A��3�8�8�A�;�
�%�)�)�O�I�-�
.���C��!�8��I�I�4�i�@�A��)�#�I�-��i����f�
�	�K�A��u�y�y�9�Q�7�8�H�C��
�a�x�
�y�y�:�9�D�E��s�x�x��{��e�i�i�I�a�8�9�G�C��
�a�x��	�	�Y�q�I�J�K����|�$�C�$�$�%}�M�OR�S�M�B�z�
��s�"��������������	�j�C���)�*��+�,��1�2�
�� � �)�)�(�*;�*;�*?�*?�*A�BU�V�H��H�H�S�X�X�m�
n�o�#�3�#�#�$W�Y\�]`�Xa�cf�g�M�B�z�	�j�C��
�
�:��$����������������%�)�)�J�
���C��!�8��I�I�.�/��	�	�
0��
:�;��|�	�w�w�~�~�'�(��%�)�)�B�9�L�M���C��!�8��9�9�5�7H�I�J�	�w�w�~�~�)�*��%�)�)�E�i�O�P���C��!�8��9�9�5�7J�K�L�	�w�w�~�~�/�0��%�)�)�Q�R[�[�\���C��!�8��9�9�5�7P�Q�R��I�I�8�9�
7��
A�C�
�"�)�)�C�/�	�9�9�
:�C�
�a�x��	�	�7�8��I�I�7�8�
$�h�
.�C�
�"�)�)�C�-�i�7�7�
8�C�
�a�x��	�	�;�<�	�P�A�
�"�)�)��q��)�A�N�
O�C�P��%�)�)�-�i�7�
8���C��!�8��I�I�/�1A�B�C��i�'���h���s����!�8��I�I�4�i�@�A�� /�y�9���	�	�
%�c�
)�*��5�9�9�S�>���S��1���I�I�-�y�9�:��I�I�4�_�D�E��e�i�i�2�O�D�E�G�C��
�a�x��	�	�?��K�L��I�I�.�/��e�i�i��I�-�.�G�C��
�a�x��	�	�F�	�R�S��������������1���H�H�S�X�X������_�U�
V�W��H�H�S�X�X�p�
q�r��H�H�S�X�X������_�M�
N�O�������e�����I�I�a�e�e��	�G�G���s�;8b�c�"b=�=c

Zerion Mini Shell 1.0