403Webshell
Server IP : 209.205.66.10  /  Your IP : 216.73.216.173
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ammon 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
User :  ( 1006)
PHP Version : 8.5.8
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/hplip/scan/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/hplip/scan/__pycache__/sane.cpython-310.pyc
o

�K0jR�@sddlZddlZddlZddlTddlmZddlmZddlm	Z	e�
d�ZdZej
dejd	ejd
ejdejdejd
iZejdejdejdejdejdejdejdiZdZGdd�d�ZGdd�d�ZGdd�dej�Z dd�Z!dd�Z"d d!�Z#d&d"d#�Z$d$d%�Z%dS)'�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@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�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
Cs\ddl}||_|\	|_|_|_|_|_|_|_|_	|_
t|j�td�kr,t|j�|_dSdS)Nr�)�string�
cur_device�index�name�title�desc�type�unit�size�cap�
constraint�str)�self�argsrr�r&�/usr/share/hplip/scan/sane.py�__init__is��zOption.__init__cC�t�|j�S�N)r�isOptionActiver!�r$r&r&r'�isActives�zOption.isActivecCr)r*)r�isOptionSettabler!r,r&r&r'�
isSettablevr.zOption.isSettablecCsh|��rd}nd}|��rd}|j�|j�}nd}d}d|j||j|j|jt|j	t
|j|j||f
S)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
)r0r-r�	getOptionrrrr�TYPE_STRr�UNIT_STRrr"�s)r$�settable�active�curValuer&r&r'�__repr__ys	��zOption.__repr__c	Cs@|dur�|jdur�t|j�td�krO||jdkr,|jd}t�d|j|j||f�n||jdkrE|jd}t�d|j|j||f�|j�|j|�|St|j�tg�kr�||jvr�|jd}tj}|jD]}t	||�|krzt	||�}|}qht�d|j|j|d�
|j�|f�|j�|j|�|S|j�|j�}|S)Nr&rz6Invalid value for %s (%s < min value of %d). Using %d.rz6Invalid 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�joinr3)r$�value�v�min_dist�xr&r&r'�limitAndSet�s<
�
��


���zOption.limitAndSetN)	�__name__�
__module__�__qualname__�__doc__r(r-r0r:rFr&r&r&r'rVs
rc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
d"dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�ZdS)#�
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.
    cCs$d|_t�|�|_i|_|��dSr*)�scan_threadr�
openDevice�dev�options�_ScanDevice__load_options_dict)r$rNr&r&r'r(�szScanDevice.__init__cCs>|j}|j��}|D]}t||�}|jtjkr|||j<q
dSr*)rOrN�
getOptionsrrrrr)r$�opts�opt_list�t�or&r&r'�__load_options_dict�s


��zScanDevice.__load_options_dictcCs�|j}||vr
|||<dS||}|jtjkrt�d|�t�|j�s+t�d|�t�|j�s8t�d|�t|�t	krH|jtj
krHt|�}z|j�
|j|�|_Wntjygt�d||f�YdSw|jtj@rt|��dSdS)NzGroups can't be set: %s�Inactive option: %sz#Option can't be set by software: %sz#Unable to set option %s to value %s)rOrrrr;�errorr+r!r/�intr�floatrNr=r�last_opt�INFO_RELOAD_OPTIONSrP)r$�keyrBrR�optr&r&r'r=�s,��zScanDevice.setOptioncCs�|j}|dkr
t|���S|dkr!|d|df|d|dffS||vr+td|��||}|jtjkr;td|��|jtjkrGtd	|��t�|j	�sStd
|��|j
�|j�S)N�optlist�areaztl-xztl-yzbr-xzbr-yzNo such attribute: %szButtons don't have values: %szGroups don't have values: %s rW)
rO�list�keys�AttributeErrorrrr
rr+r!rNr3r)r$r]rRr^r&r&r'r3s zScanDevice.getOptioncCs|j}||vr||SdSr*)rO)r$r]rRr&r&r'�getOptionObj5s�zScanDevice.getOptionObjcC�
|j��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
        )rN�
getParametersr,r&r&r'rf;s
zScanDevice.getParameterscCre)z<Return a list of tuples describing all the available options)rNrQr,r&r&r'rQI�
zScanDevice.getOptions�BGRANcCsz|��s7|j��}|j��\|_|_|_|_|_|_	|_
t|j|||�|_d|j_
|j��d|j|j
|fSddtjfS)z]
            Perform a scan with the current device.
            Calls sane_start().
        TFr)�isScanActiverN�	startScanrf�format�format_name�
last_frame�pixels_per_line�lines�depth�bytes_per_line�
ScanThreadrL�scan_active�startr�SANE_STATUS_DEVICE_BUSY)r$�byte_format�update_queue�event_queue�statusr&r&r'rjNs
�
zScanDevice.startScancCre)z)Cancel an in-progress scanning operation.)rN�
cancelScanr,r&r&r'rzargzScanDevice.cancelScanc
Cs>|��s|j}|j|j|j|j|j|j|j|j	|j
|jf
SdS)z6Get the output buffer and info about a completed scan.N)rirL�bufferrkrlrnrorprq�	pad_bytes�
total_read�total_write�r$r6r&r&r'�getScanfs��zScanDevice.getScanc	CsH|��s"|j}z|j��t�|j�WdSttfy!YdSwdS)z-Cleanup the scan file after a completed scan.N)	rirLr{�close�os�remove�buffer_path�IOErrorrcrr&r&r'�freeScanos
��zScanDevice.freeScancCs |jdur|j��o
|jjSdS)NF)rL�is_aliversr,r&r&r'ri{s
zScanDevice.isScanActivecCsN|jdur!|j��r#|jjr%z|j��WdSty YdSwdSdSdSr*)rLr�rsrA�KeyboardInterruptr,r&r&r'�waitForScanDone�s
����zScanDevice.waitForScanDonecCs2|jdur	|j��r|jjrdSt�d�qdS)NT皙�����?)rLr�rs�time�sleepr,r&r&r'�waitForScanActive�s

�
��zScanDevice.waitForScanActivecCs|j��dS)z#Close the SANE device after a scan.N)rN�	closeScanr,r&r&r'r��szScanDevice.closeScan�rhNN)rGrHrIrJr(rPr=r3rdrfrQrjrzr�r�rir�r�r�r&r&r&r'rK�s"!
	rKc@s.eZdZddd�Zdd�Zdd�Zd	d
�ZdS)rrrhNcCs�tj�|�d|_||_||_||_tjdd�\|_	|_
t�|j	d�|_
d|_d|_d|_d|_d|_d|_d|_d|_d|_||_d|_dS)NT�hpscan)�prefixzw+b���rr)�	threading�Threadr(rsrNrwrxr�make_temp_file�	buffer_fdr�r��fdopenr{rkrlrmrnrorprqr|r}rvr~)r$�devicervrwrxr&r&r'r(�s$
zScanThread.__init__c	CsJ|jdur#zt|�}Wn
ttfyd}Ynw|j�||f�dSdS)Nr�)rwrY�
ValueError�	TypeError�put)r$ry�
bytes_readr&r&r'�updateQueue�s
��zScanThread.updateQueuec
s�ddlm}|j��\|_|_|_|_|_|_	|_
t�d|j�t�d|j�t�d|j�t�d|j�t�d|j�t�d|j	�t�d	|j
�t�d
|j
�|jj}|j
}|jtjk�r4|j	dk�r2|j
d|j|_t�d
|j�d�|j
dkr�d�z
|j�|�\}�Wntjy�}z|jd}|�|d�WYd}~nd}~ww|tjk�r2�r�t��}|d���fdd�td||jd�D���|j|7_|j|||jd7_|�||j�t�d|j�nt�d�z
|j�|�\}�Wn tj�y&}z|jd}|�||j�WYd}~nd}~ww|���r-n|tjks��n�|jtj k�r�|j	dk�r�|j
|jdd|_t�d
|j�z
|j�|�\}�Wntj�y}}z|jd}|�|d�WYd}~nd}~ww|tjk�r���r�t��}|d��fdd�td||j�D���|j|7_|j||jd7_|�||j�t�d|j�nt�d�z
|j�|�\}�Wn tj�y�}z|jd}|�||j�WYd}~nd}~ww|���r�n|tjk�s�n�|j	dk�r�|j
|j|_t�d
|j�z
|j�|�\}�Wntj�y=}z|jd}|�|d�WYd}~nd}~ww|tjk�r���r�t��}|d��fdd�td||j�D���|j|7_|j||jd7_|�||j�t�d|j�nt�d�z
|j�|�\}�Wn tj�y�}z|jd}|�||j�WYd}~nd}~ww|���r�n|tjk�sD|j�!d�d|_"t�d�dS)Nrrz	format=%dzformat_name=%sz
last_frame=%dzppl=%dzlines=%dzdepth=%dzbpl=%dzbyte_format=%s��zpad_bytes=%dr��RGBAr�cs"g|]
}�||d��d�qS)r���r&��.0r��dirrTr&r'�
<listcomp>�s"z"ScanThread.run.<locals>.<listcomp>zColor Read %d bytesr��cs&g|]�d���fdd�dD���qS)r�cs,g|]}|t���d��@rdnd�qS)rs�s����)�ord)r��k)rrTr&r'r�s,z-ScanThread.run.<locals>.<listcomp>.<listcomp>)��@� �r���r)rA)r��rT)rr'r�s&r�zLineart Read %d bytescs$g|]}d�||d�d�qS)r�rr�r&r�r�r&r'r�+s$r�zGray Read %d bytesFzScan thread exiting...)#�base.sixextrrNrfrkrlrmrnrorprqr;�debugrvr{�writer�	FRAME_RGBr|�readScanrXr%r��SANE_STATUS_GOOD�lenrA�ranger}r~r�r��checkCancel�
FRAME_GRAY�seekrs)r$r�w�
readbuffer�st�stObj�len_tr&r�r'�run�s��

��,

��

��
��(

��
��
��(

��
�zScanThread.runcCsdd}|j��r0z|j�d�}|tkrd}t�d�|j��Wntj	y*Y|Sw|j��s|S)NFrTzCancel pressed!)
rx�qsize�get�EVENT_SCAN_CANCELEDr;r�rN�	canclScanr�Empty)r$�canceled�eventr&r&r'r�Ds


��
�zScanThread.checkCancelr�)rGrHrIr(r�r�r�r&r&r&r'rr�s

~rrcC�t��Sr*)r�initr&r&r&r'r�V�r�cCr�r*)r�deInitr&r&r&r'r�Zr�r�cCst|�S)zOpen a device for scanning)rK)rNr&r&r'rM^srMcCs
t�|�Sr*)r�
getDevices)�
local_onlyr&r&r'r�cs
r�cCst�dt�|�|f�dS)NzSANE: %s (code=%d))r;rXr�getErrorMessage)�coder&r&r'�reportErrorgsr�)r)&r�r�r��base.g�baserr�r�base.sixext.movesr�
import_extrr�r	r
rrr
rr4rrrrrrrr5�MAX_READSIZErrKr�rrr�r�rMr�r�r&r&r&r'�<module>s@8
��	}S2


Youez - 2016 - github.com/yon3zu
LinuXploit