%PDF- %PDF-
Mini Shell

Mini Shell

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

�

=	fuT��.�ddlZddlZddlZddlZddlZddl�ddl�ddlmZm	Z	m
Z
	ddlZdZdZd	Zd
ZdZdZdezZd
ezZGd�d�ZGd�d�Zy#e$r6e
jd�s"ej!d�ej%d�Y�ewxYw)�N)�*)�device�utils�exif�HPLIP_BUILDz>PCARDEXT could not be loaded. Please check HPLIP installation.��i�� i��c�4�eZdZdd�Zd�Zd	d�Zd�Zd�Zd�Zy)
�
PhotoCardFileNc�4�d|_d|_d|_||_t	jd�|_|�|j
|�t|_|j
jtj|jd|j��y)NrT�c)
�pos�closed�	file_size�pc�array�buffer�open�INITIAL_PCARDFILE_BUFFER�buffer_size�
fromstring�pcardext�read�name)�selfrrs   �#/usr/share/hplip/pcard/photocard.py�__init__zPhotoCardFile.__init__:sp���������������k�k�#�&������I�I�d�O�3��������x�}�}�T�Y�Y��4�;K�;K�L�M�c� �d|_||_y�NF)rr�rrs  r rzPhotoCardFile.openHs�������	r"c��|dk(r||_y|dk(r|xj|z
c_y|dk(r|j|z
|_yy)Nrrr
)rr)r�offset�whences   r �seekzPhotoCardFile.seekLs?���Q�;��D�H�
�q�[��H�H���H�
�q�[��~�~��.�D�H�r"c��|jS�N)r�rs r �tellzPhotoCardFile.tellWs���x�x�r"c�4�|dkD�r|j|z|jkrK|j|j|j|zj�}|xj|z
c_|S|j|z|jk\r~|jj	tj|j|jt��|xjtz
c_|j|z|jk\r�~|j
|�Sy�Nr)	rrr�tostringrrrr�INCREMENTAL_PCARDFILE_BUFFER)r�size�datas   r rzPhotoCardFile.read[s����!�8��x�x�$���!1�!1�1��{�{�4�8�8�d�h�h��o�>�G�G�I�����D� �����h�h��o��)9�)9�9��K�K�*�*�8�=�=����D�DT�DT�Vr�+s�t��$�$�(D�D�$��h�h��o��)9�)9�9��y�y���&�r"c� �d|_d|_y)NTr)rrr,s r �closezPhotoCardFile.closeis�������r"r+)r)	�__name__�
__module__�__qualname__r!rr)r-rr5�r"r rr7s!��N����'�r"rc�*�eZdZd-d�Zd.d�Zd/d�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd0d�Zd�Zd�Zd�Zd�Zd�Zd�Zd1d�Zd2d�Zd2d�Zd�Zd3d�Zd�Zd2d�Zd�Zd1d�Zd1d�Z d4d �Z!d!�Z"d"�Z#d#�Z$d1d$�Z%d%�Z&d5d&�Z'd'�Z(d(�Z)d)�Z*d*�Z+d+�Z,d,�Z-y)6�	PhotoCardNc��|�=tj||�|_|jj�d|_n||_d|_t	j
�|_g|_|jj|_d|_	g|_
i|_i|_d|_
d|_d|_d|_y)NTF)r�Devicer�close_devicer�Stack�	dir_stack�current_dir�
device_uri�
pcard_mounted�	saved_pwd�
sector_buffer�sector_buffer_counts�
cache_flag�
write_protect�callback�channel_opened)r�dev_objrB�printer_names    r r!zPhotoCard.__init__ps����?� �-�-�
�L�A�D�K��K�K���� $�D��!�D�K� %�D������������+�+�0�0���"���������$&��!����"�����
�#��r"c��yr+r9r%s  r �START_OPERATIONzPhotoCard.START_OPERATION�s��r"c�D�|jr|r|j�yyyr+)rJ�
close_channel)rr�flags   r �
END_OPERATIONzPhotoCard.END_OPERATION�s!�����4���� �$(�r"c��||_yr+)rI)rrIs  r �set_callbackzPhotoCard.set_callback�s	�� ��
r"c��tjd||fz�|jr�t|||z�D]}||jvs�n�d}t|||z�D]x}dj||j|g�}tjd|z�|j|}|dz|j|<|j��i|j��z|S|j�|j�|js|j�tjd||fz�tt|||z��}tjdd|zzt|g|���}|j�|j�|jj|�}tjd|z�|jj!d	�}	tj"d
|	�d}
tjd|
z�|
d
k(�ra|jj!d�}	tj"d|	�\}}tjd|
||fz�dd|t$z}}
}|
|kr^|jj!|�}	|
t'|	�z
}
dj||	g�}|j�|j�|
|kr�^|jr�d}t|||z�D]o}|||t$z|j|<|jj)|d�}|dz|j|<|t$z
}|j��`|j��q|j+|�|Stj-d|
z�y)Nz%read pcard sector: sector=%d count=%d�zCached sector read sector=%drz%Normal sector read sector=%d count=%dz!HH�Iz%d bytes writtenr
�!HrzReturn code: %xi�z!IHzcode=0x%x, nsector=%d, ver=%dzError code: %d)�log�debugrG�rangerE�joinrFrIrJ�open_channel�list�struct�pack�READ_CMDr�
writePCard�	readPCard�unpack�SECTOR_SIZE�len�get�_check_cache�error)r�sector�nsector�sr�count�sectors_to_read�request�
bytes_writtenr3�code�nsector_read�ver�	data_read�
total_to_read�is                r �_readzPhotoCard._read�s7���	�	�9�V�W�<M�M�N��?�?��6�6�'�>�2�
���D�.�.�.��
����v�v�g�~�6�(�A��W�W�f�d�.@�.@��.C�%D�E�F��I�I�<�q�@�A� �5�5�a�8�E�38��7�D�-�-�a�0��}�}�0��
�
��(��
��=�=�$��M�M�O��"�"������	�	�9�V�W�<M�M�N��u�V�V�G�^�<�=���+�+�e�c�'�k�1�8�W�W��W���=�=�$��M�M�O����.�.�w�7�
��	�	�$�}�4�5��{�{�$�$�Q�'���}�}�T�4�(��+���	�	�#�d�*�+��6�>��;�;�(�(��+�D� &�
�
�e�T� :��L�#��I�I�5��|�S�8Q�Q�R�/1�1�g��6K�}�I�F��}�,��{�{�,�,�]�;���S��Y�&�	����&�$��0���=�=�,��M�M�O��}�,�������v�v��'<�=�(�A�,2�1�q��}�,E�D�&�&�q�)� �5�5�9�9�!�Q�?�E�38��7�D�-�-�a�0���$�A��}�}�0��
�
��(��!�!�'�*��M��I�I�&��-�.�r"c�P�tjd||t|�fz�|js|j	�tt
|||z��}tjdd|zzt|dg|���}dj||g�}|j�|j�|jj|�|jjd�}|j�|j�tjd|�d}|t k7r�|j"r�d}t
|||z�D]K}	tjd|z�|||t$z|j&|	<d	|j(|	<|t$z
}�M|j�|j�|j+|�y|j"r/t
|||z�D]}		|j&|	=|j(|	=�tj/d
�|j1�y	#t,$rY�QwxYw)Nz-write pcard sector: sector=%d count=%d len=%dz!HHHrWrrVr
rXzCaching sector %drz5Photo card write failed (Card may be write protected))rZr[rgrJr^r_r\r`ra�	WRITE_CMDr]rIrrcrdre�NAKrGrfrErFri�KeyErrorrjrP)
rrkrlr�sectors_to_writerpr3rrrwrms
          r �_writezPhotoCard._write�s���	�	�	�A�V�W�VY�Z`�Va�Db�b�c��"�"����� ��f�f�W�n� =�>���+�+�f�s�7�{�2�I�w��]�L\�]���'�'�7�F�+�,���=�=�$��M�M�O������w�'��{�{�$�$�Q�'���=�=�$��M�M�O��}�}�T�4�(��+���3�;�������v�v�g�~�6�%�A��I�I�1�F�:�;�,2�1�Q�{�]�,C�D�&�&�q�)�34�D�-�-�a�0���$�A�	%��=�=�,��M�M�O��!�!�'�*������v�v�g�~�6��A�� �.�.�q�1� �5�5�a�8��
�I�I�M�N���� ���$����s�H�	H%�$H%c�H�t|j�tkDr�t|jj	��ddd}}|D]X}|j
|dk(s�|j|=|j
|=|dz
}||k\ry|j��I|j
��Zyy)Nrr)rgrE�	MAX_CACHEr_�keysrFrI)rrl�t�nrms     r rizPhotoCard._check_caches����t�!�!�"�Y�.���*�*�/�/�1�2�1�5�q�q�A��
(���,�,�Q�/�1�4��*�*�1�-��1�1�!�4���F�A��G�|���}�}�0��
�
��
(�/r"c��|jSr+)rFr,s r �
cache_infozPhotoCard.cache_info/s���(�(�(r"c�:�|jj|d�Sr/)rFrh)rrks  r �cache_checkzPhotoCard.cache_check2s���(�(�,�,�V�Q�7�7r"c�L�||_|js|j�yyr+)rG�cache_reset)r�controls  r �
cache_controlzPhotoCard.cache_control5s!��!����������r"c��|jSr+)rGr,s r �cache_statezPhotoCard.cache_state;s�����r"c�l�|jj�|jj�yr+)rE�clearrFr,s r r�zPhotoCard.cache_reset>s&����� � �"��!�!�'�'�)r"c��d}|jd�	tj�}|jd�|S#|jd�|ccYSxYw)Nr�df)rNrr�rR)rr�s  r r�zPhotoCard.dfBsO��
�����T�"�	�����B����t�$��I��
���t�$��I�s	�<�Ac��|sd}|r=|jd�	tj�|_|j	d|�|jD���cgc]\}}}|j�||f��c}}}|_|dk(r|jS|j
�j�j�D�cgc]"}tj|j|���$c}dS#|j	d|�wxYwcc}}}wcc}w)Nr�lsr)
rNrr�rArR�lower�strip�split�fnmatch�filter)r�
force_read�	glob_list�	opencloser��arm�xs        r r�zPhotoCard.lsKs�����I��� � ��&�
4�#+�;�;�=�� ��"�"�4��3�;?�;K�;K�L�L���1�Q�Q�W�W�Y�q��O�L�������#�#�#�=F�_�_�=N�=T�=T�=V�=\�=\�=^�_�����t�/�/��3�_�`a�b�b���"�"�4��3��L��
`s�C(�C?�;'D�(C<c�X�|jD]}||k(s�	|j|dcSy)Nr
r�rA)rr�fs   r r2zPhotoCard.size\s9���!�!�	.�A��D�y��'�'��*�1�-�-�	.�r"c�R�|jD�cgc]
}|ddk7s�|��c}Scc}w�Nr�dr��rr�s  r �
current_fileszPhotoCard.current_filesb�&���+�+�;�a�q��t�s�{��;�;��;��
$�$c�R�|jD�cgc]
}|ddk(s�|��c}Scc}wr�r�r�s  r �current_directorieszPhotoCard.current_directorieser�r�c��t|�dkDrq|j�D�cgc]}|d��	}}|j�j�j	�D�cgc]}tj||���c}dSgScc}wcc}wr/)rgr�r�r�r�r�r�)rr�r�r�s    r �match_fileszPhotoCard.match_fileshsw���y�>�A��+/�+=�+=�+?�@�a�Q�q�T�@�M�@�>G�o�o�>O�>U�>U�>W�>]�>]�>_�`��G�N�N�=�!�4�`�ab�c�c��	��A��`��B�Bc��t|�dkDrq|j�D�cgc]}|d��	}}|j�j�j	�D�cgc]}tj||���c}dSgScc}wcc}wr/)rgr�r�r�r�r�r�)rr�r��current_dirss    r �
match_dirszPhotoCard.match_dirsnsw���y�>�A��*.�*B�*B�*D�E�Q�A�a�D�E�L�E�=F�_�_�=N�=T�=T�=V�=\�=\�=^�_��G�N�N�<��3�_�`a�b�b��	��F��_r�c�<�tj|�d}|�y|S)Nrzunknown/unknown)�	mimetypes�
guess_type)r�filenamer�s   r �
classify_filezPhotoCard.classify_filets$��� � ��*�1�-���9�$��r"c�
�|jd�d}	t|d�}tj||j	��}|j�|j
d|�|S#|j
d|�|ccYSxYw)N�cpr�w)rNrrr��filenor5rR)rr�
local_filer��totalr�s      r r�zPhotoCard.cp{ss�����T�"���	��Z��%�A��K�K��a�h�h�j�1�E�
�G�G�I����t�Y�/��L��
���t�Y�/��L�s�AA)�)Bc��d\}}|jd�tj�}	|D]�}|j||d�}	|rf|tjj|j
�|�tjjtj�|�|	�||	z
}|s��tj|���tj�}
|
|z
}|r|jddd�|jd�||fS#|r|jddd�|jd�||fccYSxYw)N�rr�cp_multipleFTr)rN�timer��os�pathr]�pwd�getcwdr�rmr�rR)r�filelist�remove_after_copy�cp_status_callback�rm_status_callback�deltar��t1r�r2�t2s           r r�zPhotoCard.cp_multiple�s�����u����]�+�
�Y�Y�[��	"��
#���w�w�q�!�U�+��%�&�r�w�w�|�|�D�H�H�J��'B�B�G�G�L�L�QS�QZ�QZ�Q\�^_�D`�bf�g���
��%��K�K��N�
#�����B��r�E�E� �����c�5�)����}�-��5�>�!��!�����c�5�)����}�-��5�>�!�s�BD�40D�-D=c���|j�d\}}|jd�tj�}	|D]�}|jd�dd}	|jd�d}
|	D]}|j	|d��|j|
|
d�}|�:||tjjtj�|
�|�||z
}|rtj|
�|�||�|j	dd���tj�}
|
|z
}|j�|jd�||fS#|j�|jd�||fccYSxYw)Nr��cp_list�/���F)�save_wdrNr�r��cdr�r�r�r]r�rr��
restore_wdrR)rr�r�r�r�r�r�r�r��	path_listr��pr2r�s              r r�zPhotoCard.cp_list�sS���������u����Y�'�
�Y�Y�[��	"��
$���G�G�C�L��"�-�	��7�7�3�<��+��"�&�A��G�G�A�u�%�&��w�w�x��5�9��%�1�&�q�"�'�'�,�,�r�y�y�{�H�*M�t�T���
��$��K�K��)�)�5�*�1�-�����U�#�+
$�.����B��r�E�E�
�O�O�����y�)��5�>�!��
�O�O�����y�)��5�>�!�s�C(E	�	(E3c��d}|jd�	tj||�}|jd�|S#|jd�|ccYSxYw)Nr�cp_fd)rNrr�rR)rr�fdr�s    r r�zPhotoCard.cp_fd�sT�������W�%�	��K�K��b�)�E����w�'��L��
���w�'��L�s	�>�Ac	���d}|j�|jd�d}tj�}|D�]h}|r�|\}	}
}}|	jd�}
|
dd}|
d}|j	dd�|�k|t
jj|j�|�t
jjt
j�|�d�rd}�n�t|�dkDr|D]}|j	|d��t
jjt
jjt
j�|��r|d}	t
jjt
jjt
j�|d|zz��sn|d	z
}�\||j||d|zzd�z
}n||j||d�z
}|�j|t
jj|j�|�t
jjt
j�|�|
�rd}nP|r�� |�4|t
jj|j�|��|j|dd���ktj�}|jd�|jdd
d�|j!d�|||z
|fS)NF�unloadrr�r�Tr
z (%d)rr)r�rNr�r�r�r�r�r]r�r�rg�existsr�r�r�r�rR)r�unload_listr�r��dont_remove�
was_cancelledr�r�r�rr2�typ�subtypr��dirsr�r�rwr�s                   r r�zPhotoCard.unload�sc���
��������X�&���
�Y�Y�[���+	4�A� �*+�'��d�C���J�J�s�O����"�v���R�5������U�#�%�1�)�"�'�'�,�,�t�x�x�z�8�*L�,.�G�G�L�L�����h�,O�QR�T�(,�
���t�9�q�=�!�*������5�)�*��7�7�>�>�"�'�'�,�,�r�y�y�{�H�"E�F��A��!�w�w�~�~�b�g�g�l�l�2�9�9�;��SZ�]^�S^�H^�._�`�!��Q���	��T�W�W�X�x�'�A�+�/E�u�M�M�E��T�W�W�X�x��?�?�E�%�1�)�"�'�'�,�,�t�x�x�z�8�*L�,.�G�G�L�L�����h�,O�QU�W�(,�
��"�)�5�*�2�7�7�<�<����
�H�+M�N��G�G�H�e�U�3�W+	4�\�Y�Y�[�����������c�5�!����8�$��r�"�u�}�,�,r"c�D�|j�}|j|�Sr+)�tree�_PhotoCard__build_unload_list)rr�s  r �get_unload_listzPhotoCard.get_unload_lists���y�y�{���'�'��-�-r"c���|�g}tj�}|D]�}t||�ti�k(r8|j|�|j	||||�|j��U|j
|�jd�\}}|dvs�}|j�}djdj|�|g�}|j|||||f���|S)Nr�)�image�audio�video)rr?�type�pushr��popr�r��as_listr]�append)	rr�r��outr�r�r�r�rs	         r �__build_unload_listzPhotoCard.__build_unload_lists����<��C��;�;�=�D��
	=�A��D��G�}��R��(��	�	�!���(�(��a��$��<����
�"�0�0��3�9�9�#�>���V��5�5�����A��8�8�S�X�X�a�[�!�$4�5�D��J�J��d�1�g�s�F�;�<�
	=��
r"c�*�tj�Sr+)r�infor,s r r�zPhotoCard.info)s���}�}��r"c�t�|jd�	tj|�}|rf|dk(r|jj	�n3|jd�}|D]}|jj
|��|jddd�|jd|�y#|jd|�wxYw)Nr�r�TrF)	rNrr�r@r�r�r�r�rR)rr�r��statr�s     r r�zPhotoCard.cd-s������T�"�	0��;�;�t�$�D���3�;��N�N�(�(�*� �:�:�c�?�D�!�/�����+�+�A�.�/�����c�5�)�
���t�Y�/��D���t�Y�/�s�A=B#�#B7c���t|jj��dk(r|jd|�S|jj	�|jd�	t
jd�|jj�D]}t
j|��|jddd�|jd|�y#|jd|�wxYw)Nrr��cdupTrF)	rgr@r�r�r�rNrr�rR�rr�r�s   r r�zPhotoCard.cdup@s����t�~�~�%�%�'�(�A�-��7�7�3�	�*�*����������V�$�	2��K�K����^�^�+�+�-�
�����A��
�
�G�G�D�#�u�%����v�y�1��D���v�y�1�s
�%AC�C(c���|j�	tj|�}|r|jddd�|j	|�|S#|j	|�ccYSxYw)NTrF)rNrr�r�rR)rr�refresh_dirr��rs     r r�zPhotoCard.rmPs^������	����D�!�A������c�5�)����y�)��H��
���y�)��H�s�*A�A'c�d�tjd�|jd�	tj|j
|j�}tj�}|d|_tjd|z�|dk(rL|jr|j�d|_
tjd�|jddd	�nd	|_
tt��	|jr|jd�yy#|jr|jd�wwxYw)
NzMounting photocard...�mount�zstat=%drTr�rF)rZr[rNrr�rxr~r�rHr^rCr�r��Error�'ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATIONrR)rr��	disk_infos   r r�zPhotoCard.mount[s����	�	�)�*����W�%�	,��>�>�$�*�*�d�k�k�:�D� �
�
��I�!*�1��D���I�I�i�$�&�'��q�y��%�%��%�%�'�%)��"����C� �����c�5�)�&+��"��C�D�D�	*��!�!��"�"�7�+�"��t�!�!��"�"�7�+�"�s�CD� D/c�Z�ddj|jj��zS�Nr�)r]r@r�r,s r r�z
PhotoCard.pwdys#���S�X�X�d�n�n�4�4�6�7�7�7r"c�H�|jj�dd|_yr+)r@r�rDr,s r r�zPhotoCard.save_wd}s�����/�/�1�!�4��r"c�n�|jd|�|jD]}|j||��yr)r�rDr�s   r r�zPhotoCard.restore_wd�s1������Y�����	"�A��G�G�A�y�!�	"r"c���|jd�i}	|j�|j�}|jd�|j	d�|S#|j	d�|ccYSxYw)Nr�F)rNr��_PhotoCard__treer�rR)r�dir_trees  r r�zPhotoCard.tree�sd�����V�$���	��L�L�N��{�{�}�H��O�O�E�"����v�&��O��
���v�&��O�s�1A�A1c�r�|�i}tjd�tj�D]�}|dj�}|j�|j	�|dvs�7|ddk(r@|j|d�i||<|j||�||<|j
d��|d||<��|S)Nr�r)�.z..rr�Fr
)rr�r�r�rIrr�)r�
_PhotoCard__dr��fnames    r �__treezPhotoCard.__tree�s����;��C��K�K�������	&�A��a�D�J�J�L�E��}�}�(��
�
���K�'��Q�4�3�;��G�G�E�5�)�!#�C��J�!%���S��Z�!8�C��J��I�I�e�$�"#�1��C��J�	&� �
r"c��i}|jd�d}	t||�}tj|�}|�|j	�|jd�|S#|�|j	�|jd�|ccYSxYw)N�get_exif)rNrr�process_filer5rR)rr�	exif_info�pcfs    r rzPhotoCard.get_exif�s����	����Z�(���	���d�+�C��)�)�#�.�I����	�	�����z�*�������	�	�����z�*���s�!A�(Bc���i}|jd�|j�	|jd�dd}|jd�d}|D]}|j|d��t	||�}tj|�}|jd�|j�|jd�|S#|jd�j�|jd�|ccYSxYw)N�
get_exif_pathr�r�F)
rNr�r�r�rrr
r�r5rR)rrrr�r�r�rs       r rzPhotoCard.get_exif_path�s����	����_�-�����	��
�
�3����,�I��z�z�#��r�*�H��
"������5�!�
"� ��h�/�C��)�)�#�.�I�
�O�O�E�"��I�I�K�����/����
�O�O�E�"��I�I�K�����/���s�A"B;�;7C4c��|jd�	|j|d�}|jd�|S#|jd�ccYSxYw)Nrkr)rNrxrR)rrkr3s   r rkzPhotoCard.sector�sO�����X�&�	��:�:�f�a�(�D����x�(��K��
���x�(��K�s	�8�Ac�:�tj�d|_yr$)r�umountrCr,s r rzPhotoCard.umount�s������"��r"c�F�d|_|jj�y)NT)rJr�	openPCardr,s r r^zPhotoCard.open_channel�s��"��������r"c�F�d|_|jj�yr$)rJr�
closePCardr,s r rPzPhotoCard.close_channel�s��#�������� r")NNN)rV)rVT)TrT)T)NN)NNF)TTr+).r6r7r8r!rNrRrTrxr~rir�r�r�r�r�r�r�r2r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrkrr^rPr9r"r r;r;ns���$�2
�!�!�T�l3�l(� )�8���*��c�"�<�<����	�"�6$"�P�:-�z.�
�&�0�&2� 	�,�<8�5�"�	��0��,�#� �!r"r;)r`r�r�r�r�base.g�
base.codes�baserrrr�ImportErrorr��getenvrZrj�sys�exit�ACKr{rbrzrfr�rr1rr;r9r"r �<module>r!s���*�������$�$���
�������	���
�	��k�>�� ��}��4�4�nq	!�q	!��Y��
�9�9�]�#��	�	�R�S��������s�A�8B�B

Zerion Mini Shell 1.0