%PDF- %PDF-
Mini Shell

Mini Shell

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

�

=	fR��(�ddlZddlZddlZddl�ddlmZddlmZddlm	Z	ejd�ZdZejdejd	ejd
ej dej"dej$d
iZej(dej*dej,dej.dej0dej2dej4diZdZGd�d�ZGd�d�ZGd�dej>�Z d�Z!d�Z"d�Z#d!d�Z$d �Z%y)"�N)�*)�utils��
to_bytes_utf8)�queue�scanext��	TYPE_BOOL�TYPE_INT�
TYPE_FIXED�TYPE_STRING�TYPE_BUTTON�
TYPE_GROUP�	UNIT_NONE�
UNIT_PIXEL�UNIT_BIT�UNIT_MM�UNIT_DPI�UNIT_PERCENT�UNIT_MICROSECONDic�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�OptionaNClass representing a SANE option.
    Attributes:
    index -- number from 0 to n, giving the option number
    name -- a string uniquely identifying the option
    title -- single-line string containing a title for the option
    desc -- a long string describing the option; useful as a help message
    type -- type of this option.  Possible values: TYPE_BOOL,
            TYPE_INT, TYPE_STRING, and so forth.
    unit -- units of this option.  Possible values: UNIT_NONE,
            UNIT_PIXEL, etc.
    size -- size of the value in bytes
    cap -- capabilities available; CAP_EMULATED, CAP_SOFT_SELECT, etc.
    constraint -- constraint on values.  Possible values:
        None : No constraint
        (min,max,step)  Integer values, from min to max, stepping by
        list of integers or strings: only the listed values are allowed
    c
��ddl}||_|\	|_|_|_|_|_|_|_|_	|_
t
|j�t
d�k7rt|j�|_yy)Nr�)�string�
cur_device�index�name�title�desc�type�unit�size�cap�
constraint�str)�self�argsrrs    �/usr/share/hplip/scan/sane.py�__init__zOption.__init__isd���$���?C�	<��
�D�I�t�z�4�9�d�i��I�t�y�$�(�D�O���	�	�?�d�2�h�&��D�I�I��D�I�'�c�@�tj|j�S�N)r�isOptionActiver$�r's r)�isActivezOption.isActivess���%�%�d�h�h�/�/r+c�@�tj|j�Sr-)r�isOptionSettabler$r/s r)�
isSettablezOption.isSettablevs���'�'����1�1r+c�j�|j�rd}nd}|j�r(d}|jj|j�}nd}d}d|j||j
|j|jt|jt|j|j||f
zS)N�yes�noz <not available, inactive option>z�
Name:      %s
Cur value: %s
Index:     %d
Title:     %s
Desc:      %s
Type:      %s
Unit:      %s
Constr:    %s
isActive:    %s
isSettable:  %s
)r3r0r�	getOptionrrrr �TYPE_STRr!�UNIT_STRr"r%�s)r'�settable�active�curValues    r)�__repr__zOption.__repr__ys����?�?���H��H��=�=�?��F����0�0����;�H��F�9�H�	��	�	�8��j�j�$�*�*�d�i�i��t�y�y�)�8�D�I�I�+>��o�o�v�x�9�9�	9r+c	�.�|���|j���t|j�td�k(r�||jdkr@|jd}tjd|j|j||fz�nQ||jdkDr?|jd}tjd|j|j||fz�|j
j
|j|�|St|j�tg�k(r�||jvr�|jd}tj}|jD]$}t||z
�|ks�t||z
�}|}�&tjd|j|j|dj|j�|fz�|j
j
|j|�|S|j
j|j�}|S)N�rz6Invalid value for %s (%s < min value of %d). Using %d.r	z6Invalid value for %s (%s > max value of %d). Using %d.z?Invalid value for %s (%s not in constraint list: %s). Using %d.z, )r%r!�log�warnrr�	setOption�sys�maxsize�abs�joinr7)r'�value�v�min_dist�xs     r)�limitAndSetzOption.limitAndSet�s��������!<��D�O�O�$��R��0��4�?�?�1�-�-� �O�O�A�.�E��H�H�U����D�I�I�u�e�<�=�>��T�_�_�Q�/�/� �O�O�A�.�E��H�H�U����D�I�I�u�e�<�=�>����)�)�$�)�)�U�;�&��#�d�o�o�&�$�r�(�2�����/�����*�A�"�{�{�H�!�_�_�"���u�Q�w�<�(�2�'*�5��7�|�H� !�A�"�
�H�H�^����D�I�I�u�d�i�i����6P�RS�T�U�V��O�O�-�-�d�i�i��;�
���O�O�-�-�d�i�i�8�E��r+N)	�__name__�
__module__�__qualname__�__doc__r*r0r3r>rLr@r+r)rrVs ���$'�0�2��: r+rc�l�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
dd
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zy	)�
ScanDeviceaClass representing a SANE device.
    Methods:
    startScan()    -- initiate a scan, using the current settings
    cancelScan()   -- cancel an in-progress scanning operation

    Also available, but rather low-level:
    getParameters() -- get the current parameter settings of the device
    getOptions()    -- return a list of tuples describing all the options.

    Attributes:
    optlist -- list of option names

    You can also access an option name to retrieve its value, and to
    set it.  For example, if one option has a .name attribute of
    imagemode, and scanner is a ScanDevice object, you can do:
         print scanner.imagemode
         scanner.imagemode = 'Full frame'
         scanner.['imagemode'] returns the corresponding Option object.
    c�t�d|_tj|�|_i|_|j�yr-)�scan_threadr�
openDevice�dev�options�_ScanDevice__load_options_dict)r'rVs  r)r*zScanDevice.__init__�s/������%�%�c�*������� � �"r+c���|j}|jj�}|D];}t||�}|jt
jk7s�-|||j<�=yr-)rWrV�
getOptionsrr!rrr)r'�opts�opt_list�t�os     r)�__load_options_dictzScanDevice.__load_options_dict�sV���|�|���8�8�&�&�(���	!�A��q�$��A��v�v��+�+�+� ��Q�V�V��		!r+c��|j}||vr|||<y||}|jtjk(rtjd|z�tj
|j�stjd|z�tj|j�stjd|z�t|�tk(r(|jtjk(rt|�}	|jj|j|�|_|jtj zr|j#�yy#tj
$rtjd|�d|���YywxYw)NzGroups can't be set: %s�Inactive option: %sz#Option can't be set by software: %szUnable to set option z
 to value )rWr!rrrA�errorr.r$r2�intr�floatrVrCr�last_opt�INFO_RELOAD_OPTIONSrX)r'�keyrHr[�opts     r)rCzScanDevice.setOption�s(���|�|���d�?��D��I���3�i���8�8�w�)�)�)��I�I�/�#�5�6��%�%�c�g�g�.��I�I�+�c�1�2��'�'����0��I�I�;�c�A�B���;�#��#�(�(�g�.@�.@�"@��%�L�E�	� �H�H�.�.�s�y�y�%�@�D�M��=�=�7�6�6�6��$�$�&�7���}�}�	��I�I�s�E�J�K��	�s�:+E�.F�Fc��|j}|dk(rt|j��S|dk(r|d|df|d|dffS||vrtd|z��||}|jt
jk(rtd|z��|jt
jk(rtd	|z��t
j|j�std
|z��|jj|j�S)N�optlist�areaztl-xztl-yzbr-xzbr-yzNo such attribute: %szButtons don't have values: %szGroups don't have values: %s ra)
rW�list�keys�AttributeErrorr!rrrr.r$rVr7r)r'rgr[rhs    r)r7zScanDevice.getOptions����|�|���)����	�	��$�$��&�=���L�$�v�,�/�$�v�,��V��1M�M�M��d�?� �!8�3�!>�?�?��3�i���8�8�w�*�*�*� �!@�3�!F�G�G��8�8�w�)�)�)� �!@�3�!F�G�G��%�%�c�g�g�.� �!6��!<�=�=��x�x�!�!�#�)�)�,�,r+c�.�|j}||vr||Syr-)rW)r'rgr[s   r)�getOptionObjzScanDevice.getOptionObj5s!���|�|���$�;���9��r+c�6�|jj�S)a?Return a 6-tuple holding all the current device settings:
           (format, format_name, last_frame, (pixels_per_line, lines), depth, bytes_per_line)

            - format is the SANE frame type
            - format is one of 'grey', 'color' (RGB), 'red', 'green', 'blue'.
            - last_frame [bool] indicates if this is the last frame of a multi frame image
            - (pixels_per_line, lines) specifies the size of the scanned image (x,y)
            - lines denotes the number of scanlines per frame
            - depth gives number of pixels per sample
        )rV�
getParametersr/s r)rrzScanDevice.getParameters;s���x�x�%�%�'�'r+c�6�|jj�S)z<Return a list of tuples describing all the available options)rVrZr/s r)rZzScanDevice.getOptionsI����x�x�"�"�$�$r+Nc���|j�s�|jj�}|jj�\|_|_|_|_|_|_	|_
t|j|||�|_d|j_
|jj�d|j|jz|fSddtj fS)z]
            Perform a scan with the current device.
            Calls sane_start().
        TFr)�isScanActiverV�	startScanrr�format�format_name�
last_frame�pixels_per_line�lines�depth�bytes_per_line�
ScanThreadrT�scan_active�startr�SANE_STATUS_DEVICE_BUSY)r'�byte_format�update_queue�event_queue�statuss     r)rwzScanDevice.startScanNs���
� � �"��X�X�'�'�)�F�:>�(�(�:P�:P�:R�
8�D�K��)�4�?�D�<P��J��
�D�$7�)�$�(�(�K��{�[�D��+/�D���(����"�"�$�����d�&9�&9�9�6�A�A��!�W�<�<�<�<r+c�6�|jj�S)z)Cancel an in-progress scanning operation.)rV�
cancelScanr/s r)r�zScanDevice.cancelScanartr+c
��|j�s||j}|j|j|j|j
|j|j|j|j|j|jf
Sy)z6Get the output buffer and info about a completed scan.N)rvrT�bufferrxryr{r|r}r~�	pad_bytes�
total_read�total_write�r'r:s  r)�getScanzScanDevice.getScanfsl��� � �"�� � �A��8�8�Q�X�X�q�}�}�a�6G�6G�������!�"2�"2�A�K�K����q�}�}�]�
]�#r+c���|j�sG|j}	|jj�t	j
|j�yy#ttf$rYywxYw)z-Cleanup the scan file after a completed scan.N)	rvrTr��close�os�remove�buffer_path�IOErrorrnr�s  r)�freeScanzScanDevice.freeScanosZ��� � �"�� � �A�
������ ��	�	�!�-�-�(�#���^�,�
��
�s�9A�A+�*A+c��|j�2|jj�xr|jjSy)NF)rT�is_aliver�r/s r)rvzScanDevice.isScanActive{s7�����'��#�#�,�,�.�O�4�3C�3C�3O�3O�O�r+c���|j�N|jj�r3|jjr	|jj�yyyy#t$rYywxYwr-)rTr�r�rG�KeyboardInterruptr/s r)�waitForScanDonezScanDevice.waitForScanDone�si�����'����%�%�'����(�(�
�� � �%�%�'�
)�
(�(��%�
��
�s�A�	A(�'A(c��|j�H	|jj�r|jjrytjd��Gy)N皙�����?)rTr�r��time�sleepr/s r)�waitForScanActivezScanDevice.waitForScanActive�sL�����'���#�#�,�,�.��$�$�0�0���
�
�3���(r+c�8�|jj�y)z#Close the SANE device after a scan.N)rV�	closeScanr/s r)r�zScanDevice.closeScan�s�������r+��BGRANN)rMrNrOrPr*rXrCr7rprrrZrwr�r�r�rvr�r�r�r@r+r)rRrR�sT���(#�!�'�B-�4�(�%�
=�&%�
]�	���
 �$r+rRc�&�eZdZdd�Zd�Zd�Zd�Zy)rNc��tjj|�d|_||_||_||_tjd��\|_	|_
tj|jd�|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_||_d|_y)NT�hpscan)�prefixzw+b���rr)�	threading�Threadr*r�rVr�r�r�make_temp_file�	buffer_fdr�r��fdopenr�rxryrzr{r|r}r~r�r�r�r�)r'�devicer�r�r�s     r)r*zScanThread.__init__�s������!�!�$�'�������(���&���+0�+?�+?�x�+P�(����(��i�i�����6������������!�����
���
� ���������&�����r+c��|j�*	t|�}|jj	||f�yy#ttf$rd}Y�2wxYw)Nr�)r�rc�
ValueError�	TypeError�put)r'r��
bytes_reads   r)�updateQueuezScanThread.updateQueue�sW�����(�
��V���
���!�!�6�:�"6�7�
)���	�*�
���
�s�8�A�Ac��ddlm}|jj�\|_|_|_|_|_|_	|_
tjd|jz�tjd|j
z�tjd|jz�tjd|jz�tjd|jz�tjd|jz�tjd	|jz�tjd
|jz�|jj}|j}|jt j"k(�r�|jdk(�r^|jd|jzz
|_tjd
|j$z�d}|jdk(rd}	|jj'|�\}}|t j.k(�r�r�t1|�}|dj3t5d||j$z
d�D�	cgc]}	||	|	dz|�dz��c}	��|xj6|z
c_|xj8|||j$z
dzzz
c_|j-||j6�tjd|j6z�nt;j<d�	|jj'|�\}}|j?�r�n�|t j.k(r��-�n�|jt j@k(�r�|jdk(�r�|j|jdzdzz
|_tjd
|j$z�	|jj'|�\}}|t j.k(�r�r�t1|�}|dj3t5d||j$z
�D�	�
cgc]7}	dj3dD�
cgc]}
|
tC||	|	dz�zrdnd��c}
���9c}
}	��|xj6|z
c_|xj8||j$z
dzz
c_|j-||j6�tjd|j6z�nt;j<d�	|jj'|�\}}|j?�r�n�|t j.k(r��R�n�|jdk(�r�|j|jz
|_tjd
|j$z�	|jj'|�\}}|t j.k(�r(r�t1|�}|dj3t5d||j$z
�D�	cgc]}	d||	|	dzzdz��c}	��|xj6|z
c_|xj8||j$z
dzz
c_|j-||j6�tjd|j6z�nt;j<d�	|jj'|�\}}|j?�rn|t j.k(r��(|jjEd�d|_#tjd�y#t j($r,}|j*d}|j-|d�Yd}~��[d}~wwxYwcc}	w#t j($r5}|j*d}|j-||j6�Yd}~��d}~wwxYw#t j($r,}|j*d}|j-|d�Yd}~��d}~wwxYwcc}
wcc}
}	w#t j($r6}|j*d}|j-||j6�Yd}~��[d}~wwxYw#t j($r,}|j*d}|j-|d�Yd}~���d}~wwxYwcc}	w#t j($r6}|j*d}|j-||j6�Yd}~���d}~wwxYw)Nrrz	format=%dzformat_name=%sz
last_frame=%dzppl=%dzlines=%dzdepth=%dzbpl=%dzbyte_format=%s��zpad_bytes=%dr��RGBAr	r+��zColor Read %d bytesr��)��@� �r���r	s�s����r�zLineart Read %d bytesr�zGray Read %d bytesFzScan thread exiting...)$�base.sixextrrVrrrxryrzr{r|r}r~rA�debugr�r��writer�	FRAME_RGBr��readScanrbr(r��SANE_STATUS_GOOD�lenrG�ranger�r�r�r��checkCancel�
FRAME_GRAY�ord�seekr�)r'r�w�
readbuffer�dir�str]�stObj�len_tr�ks           r)�runzScanThread.run�sV��-�;?�(�(�:P�:P�:R�	8���T�%�t���8L��J��
�D�$7��	�	�+����+�,��	�	�"�T�%5�%5�5�6��	�	�/�D�O�O�3�4��	�	�(�T�1�1�1�2��	�	�*�t�z�z�)�*��	�	�*�t�z�z�)�*��	�	�(�T�0�0�0�1��	�	�"�T�%5�%5�5�6��K�K�����(�(�
��;�;�'�+�+�+��z�z�Q��!%�!4�!4�q�4�;O�;O�7O�!O����	�	�.�4�>�>�9�:����#�#�v�-��C�,� �H�H�-�-�j�9�E�B��
�G�4�4�4�� #�A����#�(�(�PU�VW�X]�`d�`n�`n�Xn�op�Pq�#r�u�A�e�E�!�G�C�&7�$8�7�$B�#r�s�t����5�0���(�(�U�E�D�N�N�4J�A�3M�-M�M�(��(�(��T�_�_�=��	�	�"7�$�/�/�"I�J��
�
�3��� $��� 1� 1�*� =���A��'�'�)��)�G�4�4�4�,�[�[�G�.�.�
.��z�z�Q��!%�!4�!4��8L�8L�q�8P�UV�7V�!V����	�	�.�4�>�>�9�:�,� �H�H�-�-�j�9�E�B��
�G�4�4�4�� #�A����#�(�(�~C�DE�GL�OS�O]�O]�G]�~^�$_�uz�C�H�H�Bn�.o�|}�Q��Q�u�UZ�[\�U\�M]�I^�E^�.A�dw�.w�.o�%p�$_�`�a����5�0���(�(�e�d�n�n�.D��-J�K�(��(�(��T�_�_�=��	�	�"9�D�O�O�"K�L��
�
�3��� $��� 1� 1�*� =���A��'�'�)��'�G�4�4�4�(���q��!%�!4�!4�t�7K�7K�!K����	�	�.�4�>�>�9�:�,� �H�H�-�-�j�9�E�B���G�4�4�4�� #�A����#�(�(�e�TU�W\�_c�_m�_m�Wm�Nn�#o�U�A�a��e�A�g�&6�$6��$@�#o�p�q����5�0���(�(�e�t�~�~�.E��-J�K�(��(�(��T�_�_�=��	�	�"6����"H�I��
�
�3��� $��� 1� 1�*� =���A��'�'�)��'�G�4�4�4�,	
������� ����	�	�*�+��y�}�}�,����A��B��$�$�R��+�+��,��$s��#�=�=��"�Z�Z��]���(�(��T�_�_�=�����"�}�}�,����A��B��$�$�R��+�+��,��.o��$_��#�=�=��"�Z�Z��]���(�(��T�_�_�=������}�}�,����A��B��$�$�R��+�+��,��$p��#�=�=��"�Z�Z��]���(�(��T�_�_�=����s��]�+^�^	�_�`�`�4	`�`!�0a-�b/�b4�^�!]<�<^�	_�+_�_�`�'!`�`�`�!a*�4+a%�%a*�-b,�!b'�'b,�4c=�+c8�8c=c�T�d}|jj�rq	|jjd�}|tk(r1d}tjd�|jj�|jj�r�q|S#tj$rY|SwxYw)NFrTzCancel pressed!)
r��qsize�get�EVENT_SCAN_CANCELEDrAr�rV�	canclScanr�Empty)r'�canceled�events   r)r�zScanThread.checkCancelDs��������$�$�&�	
��(�(�,�,�Q�/���/�/�#�H��I�I�/�0��H�H�&�&�(�
���$�$�&�����;�;�
����
�s�AB�B'�&B'r�)rMrNrOr*r�r�r�r@r+r)rr�s���*8�z,�|r+rc�*�tj�Sr-)r�initr@r+r)r�r�Vs���<�<�>�r+c�*�tj�Sr-)r�deInitr@r+r)r�r�Zs���>�>��r+c��t|�S)zOpen a device for scanning)rR)rVs r)rUrU^s���c�?�r+c�,�tj|�Sr-)r�
getDevices)�
local_onlys r)r�r�cs�����j�)�)r+c�^�tjdtj|�|fz�y)NzSANE: %s (code=%d))rArbr�getErrorMessage)�codes r)�reportErrorr�gs$���I�I�"�g�&=�&=�d�&C�T�%J�J�Kr+)r)&r�r�r��base.g�baserr�r�base.sixext.movesr�
import_extrr�r
rrr
rrr8rrrrrrrr9�MAX_READSIZErrRr�rr�r�rUr�r�r@r+r)�<module>r�s#��r��	���%�#�
�%�
�
�9�
%����
�
�
�+��1A�1A�j�
�
�
�,��1D�1D�m�
�
 �
 �-��1C�1C�l�U���
�
�{�
�
�
�|�
�
�
�z�
�_�_�y�
�
�
�z�
�
!�
!�~�
�
%�
%�'9�
<����`�`�zN�N�dm��!�!�m�b���
*�Lr+

Zerion Mini Shell 1.0