Sindbad~EG File Manager

Current Path : /usr/share/hplip/__pycache__/
Upload File :
Current File : //usr/share/hplip/__pycache__/unload.cpython-310.pyc

o

�/�a4a�@sJdZdZdZdZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
zddlZWn	ey?YnwddlTddlmZerVe�d�e�d	�dd
lmZmZmZmZddlmZGdd
�d
e	j�Zdd�Ze� eeeede!e"e#fe$fddd�
Z%e%j&ej'dgdgd�e%�(ddg�\Z)Z*Z+Z,Z-Z.ddl/m0Z0e�1�Z2e)D]
\Z3Z4e3dvr�e4Z2q�e,e!kr�e�5�s�e"Z,e,e!kr�e-dkr�e�d�e�d	�e,e"e#fv�r��z�e%j6e*e+de
j7d	fid�Z*e*s�e�d	�e�8de*�z	e0�9de*e+�Z:Wn e;�yZ<ze�de<j=�e�d	�WYdZ<[<ndZ<[<wwe:�>e?�ze:�@�Wne;�yCe�d�e:�A�e�d	�Ynwe�8e�Bd e:jj*��e�8e�Bd!��ejC�DejC�EejC�Fe2���Z2ze�Ge2�WneH�y�eIe�Bd"e2��e�d	�Ynwe,e"k�r�ee:�ZJz5zeJ�K�Wn(eL�y�e�d#�YneM�y�Z<z
e�d$e<�WYdZ<[<ndZ<[<wwWe:�A�n�e:�A�weId%e�1��z�e:�N�ZOeI�ePeO�dk�rtdZQeOD]ZReSeQePeRd��ZQ�q�e�TeQd&d&d'�d(d&ejTjUd)�d(d&d'�f�ZVeI�eIe�BeV�Wd*���dZXeOD]$ZReIeV�Wd+eRde�YeRd	�d,eRd&eRd-ff��eXeRd	7ZX�qeIe�Bd.ePeO�e�YeXd�f��eIe�Bd/��e:�ZeOedd�\ZXZ[Z\eIe�Bd0e�YeX�e[eXd1e[f��We:�A�ne:�A�wW�neL�y�e�d2�Y�nwzddl]Tdd3l^m_Z_Wne�y�e�d4�e�d	�Ynwe`eja�Zbec�debeed5�ebefd6��e.du�r�eg�hd7d8d9�Z.e.�i�d9k�r�ejek�l��Z.e�md:e.�e.�i�d;k�r9d<Z<ze.�nd=�\ZoZpd=�qeoe<g�Z.Wner�ye.Zod=�qe.e<g�Z.Ynwe�md>e.�esd�Ztd?eoZue�md@eu�et�veuewjx�Zyey�r7eb�zet�nd;Z.e.d;k�rDe�mdA�n)e�mdBe.�e{�|e{e.��e.ew_lzel�}elj~el�e.��Wnelj;�ylYnwz
e_��dCge*e+�Z�Wne;�y�e�dD�e�d	�Ynweb��e��e����eb���e�8dE�e�8dF�dS)Gz3.3z	hp-unloadzPhoto Card Access Utilityz�Access inserted photo cards on supported HPLIP printers. This provides an alternative for older devices that do not support USB mass storage or for access to photo cards over a network.�N)�*)�PY3z:This functionality is not spported in python3 environment.�)�device�utils�tui�module)�cupsc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�ZdVd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!dWdAdB�Z"dCdD�Z#dEdF�Z$dGdH�Z%dIdJ�Z&dKdL�Z'dMdN�Z(dOdP�Z)dQdR�Z*dSdT�Z+dUS)X�ConsolecCsVtj�|�d|_||_|j��}|d|_|jrt�d�t�	d|j�
��|_dS)Nz8Type 'help' for a list of commands. Type 'exit' to quit.�zPhoto card is write protected.�pcard: %s > )�cmd�Cmd�__init__�intro�pc�info�
write_protect�log�warning�bold�pwd�prompt)�selfr�	disk_info�r�/usr/share/hplip/unload.pyr@s


zConsole.__init__cCst|j�dS)z/Print a list of commands that have been enteredN)�print�_hist�r�argsrrr�do_histK�zConsole.do_histcC�dS�zExits from the console���rrrrr�do_exitO�zConsole.do_exitcCr#r$rrrrr�do_quitSr'zConsole.do_quitcC�
|�|�S)z$Exit on system end of file character)r&rrrr�do_EOFX�
zConsole.do_EOFcCstj�||�dS)z�Get help on commands
           'help' or '?' with no arguments prints a list of commands for which help is available
           'help <command>' or '? <command>' gives help on <command>
        N)r
r�do_helprrrrr,\szConsole.do_helpcCs"tj�|�g|_i|_i|_dS)z�Initialization before prompting user for commands.
           Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub.
        N)r
r�preloopr�_locals�_globals�rrrrr-es
zConsole.preloopcCstj�|�td�dS)z�Take care of any unfinished business.
           Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
        z
Exiting...N)r
r�postlooprr0rrrr1nszConsole.postloopcCs|j|��g7_|S)z� This method is called after the line has been input but before
            it has been interpreted. If you want to modifdy the input line
            before execution (for example, variable substitution) do it here.
        )r�strip�r�linerrr�precmduszConsole.precmdcCs|S)z�If you want to stop the console, return something that evaluates to true.
           If you want to do some post command processing, do it here.
        r)r�stopr4rrr�postcmd}szConsole.postcmdcCr#)zDo nothing on empty input lineNrr0rrr�	emptyline�r'zConsole.emptylinecCstt�d��dS)Nz9ERROR: Unrecognized command. Use 'help' to list commands.)rrrr3rrr�default�szConsole.defaultcC�t�d�dS�z List local directory contents.zls -lN��os�systemrrrr�do_ldir�r"zConsole.do_ldircCr:r;r<rrrr�do_lls�r"zConsole.do_llscCr))zSynonym for the ls command.)�do_lsrrrr�do_dir�r+zConsole.do_dirc
Cs*|����}|j�d|�}d}t�ddd�ddtjjd�ddd�f�}t�tt�	|�
d	���d}|j��D]#}|dd
vrLt|�
|dddf��q7t|�
|dd
ddf��q7|j��D]#}t|�
|dt�
|d�|j�|d�f��|d7}||d7}q`tt�	d|t�
|d�f��dS)z#List photo card directory contents.Tr����width�margin��rFrG�	alignment���Name�Size�Type)�.�..��	directory�/rz
% d files, %sN)r2�lowerr�lsr�
TextFormatter�RIGHTrrr�compose�current_directories�
current_files�format_bytes�
classify_file)rr �files�
total_size�	formatter�	num_files�d�frrrrA�s*��."z
Console.do_lscCs@|j��}|����dkrt�|�}nt�|�}td|�dS)zgDisplay free space on photo card.
        Options:
        -h	Display in human readable format
        z-hzFreespace = %s BytesN)r�dfr2rUrr\�commafyr)rr �	freespace�fsrrr�do_df�s


z
Console.do_dfFcCst|����}|j�|�}t|�dkrtd�dS|j�|||j|j�\}}tt	�
dt�|�||d|f��dS)a
Copy files from photo card to current local directory.
        Usage:
        	cp FILENAME(S)|GLOB PATTERN(S)
        Example:
        	Copy all JPEG and GIF files and a file named thumbs.db from photo card to local directory:
        	cp *.jpg *.gif thumbs.db
        r�ERROR: File(s) not found.z$
%s transfered in %d sec (%d KB/sec)�N)
r2rUr�match_files�lenr�cp_multiple�cp_status_callback�rm_status_callbackrrrr\)rr �remove_after_copy�
matched_files�total�deltarrr�do_cp�s*z
Console.do_cpc

Cs�|������}d}d|vr|jjrt�d�dSd}|j��}t�t	|�dkr�d|vr�d}|D]}t
|t	|d��}q1t�|ddd	�d
dtjj
d�d
dd	�f�}t�tt�|�d���d}|D]#}t|�d
|dt�|d�d|d|dff��||d7}qdtt�dt	|�t�|d�f��dStt�dt	|���|j�||j|j|�\}}}	tt�dt�|�||d|f��dStd�dS)z�Unload all image files from photocard to current local directory.
        Note:
        	Subdirectories on photo card are not preserved
        Options:
        -x	Don't remove files after copy
        -p	Print unload list but do not copy or remove filesFz-xz.Photo card is write protected. -x not allowed.NTrz-prDrErHrIrL�%sr�%s/%s�zFound %d files to unload, %szUnloading %d files...�"
%s unloaded in %d sec (%d KB/sec)rjz&No image, audio, or video files found.)rUr2�splitrrr�error�get_unload_listrrl�maxrrWrXrrYr\�unloadrnro)
rr �dont_remove�unload_list�max_len�ur`rrrs�
was_cancelledrrr�	do_unload�s>

��6&*zConsole.do_unloadcCs@|dkrt�tt�d|��dStd||t�|�f�dS�Nrz
Copying %s...z
Copied %s to %s (%s)...�rrrrr\)r�src�trg�sizerrrrn�zConsole.cp_status_callbackcCstd|�dS)NzRemoving %s...)r)rr�rrrro�zConsole.rm_status_callbackcCsj|jjrt�d�dS|����}|j�|�}t|�dkr"td�n|D]	}|j�	|d�q$|j�
�dS)zRemove files from photo card.z.Photo card is write protected. rm not allowed.NrriF)rrrrzr2rUrkrlr�rmrV)rr rqrcrrr�do_rms

z
Console.do_rmcCs&|jjrt�d�dS|�|d�dS)zMove files off photocardz.Photo card is write protected. mv not allowed.NT)rrrrzrtrrrr�do_mv,s
z
Console.do_mvcCstt���dS)z.Print name of local current/working directory.N)rr=�getcwdrrrr�do_lpwd3szConsole.do_lpwdcCsDz	t�|���Wntytt�d��Ynwtt���dS)z'Change current local working directory.zERROR: Directory not found.N)r=�chdirr2�OSErrorrrrr�rrrr�do_lcd7s�zConsole.do_lcdcCst|j���dS)zOPrint name of photo card current/working directory
        Usage:
        	>pwdN)rrrrrrr�do_pwd?szConsole.do_pwdcCs�|����}|dkr|j��dkr|j��n4|dkrn/|dkr'|j�d�n$|j�|�}t|�dkr8td�nt|�dkrCtd�n|j�|d�t	�
d|j���|_d	S)
z�Change current working directory on photo card.
        Note:
        	You may only specify one directory level at a time.
        Usage:
        	cd <directory>
        rQrTrPrzDirectory not foundrz'Pattern matches more than one directoryrN)rUr2rr�cdup�cd�
match_dirsrlrrrr)rr �matched_dirsrrr�do_cdEs 
�

z
Console.do_cdcCs|�d�dS)zChange to parent directory.rQN)r�rrrr�do_cdupfr"zConsole.do_cdupc	Cs�|����}|dkr|j�d�d
S|dkr|j�d�d
S|j��rr|j��}t|���}|��t	�|D]}t	d|||f�q7t	t
�dt�
t|�d�t�
tjd�f��t	t
�dt�t|��t�tj�f��d
St	d	�d
S)z�Display current cache entries, or turn cache on/off.
        Usage:
        	Display: cache
        	Turn on: cache on
        	Turn off: cache off
        �onT�offFzsector %d (%d hits)z"Total cache usage: %s (%s maximum)izTotal cache sectors: %s of %sz
Cache is off.N)r2rUr�
cache_control�cache_state�
cache_info�list�keys�sortrrrrr\rl�	photocard�	MAX_CACHEre)rr r��t�srrr�do_cachens

0,zConsole.do_cachecCsj|����}d}zt|�}Wntytd�YdSw|j�|�dkr)td�tt|j�|���dS)zIDisplay sector data.
        Usage:
        	sector <sector num>
        Fz$Sector must be specified as a numberNrz
Cached sector)	r2rU�int�
ValueErrorrr�cache_check�repr�sector)rr �cachedr�rrr�	do_sector�s�zConsole.do_sectorcCs|j��}t�|�|�dS)z"Display photo card directory tree.N)r�treer�
print_tree)rr r�rrr�do_tree�s
zConsole.do_treercCsR|D]$}t||�ti�kr&td�d|d|dg��|�|||d�qdS)NrR� �rTr)�typer�joinr�)rr��levelrbrrrr��s��zConsole.print_treecCs|j��dS)zReset the cache.N)r�cache_resetrrrr�do_reset�r"zConsole.do_resetcCs�t�td|jjj�td|jjj�td|j���|j��}td|d�td|d�td|d	�td
|d�td|d
�td|d�td|d�td|d�td|d�tdt�t	|j�
����dS)zPrint info about photocard.zDevice URI = %sz
Model = %szWorking dir = %szOEM ID = %srzBytes/sector = %drzSectors/cluster = %drDzReserved sectors = %drwzRoot entries = %dr�zSectors/FAT = %d�zVolume label = %s�zSystem ID = %s�zWrite protected = %drzCached sectors = %sN)rrr�
device_uri�model_uirrrrerlr�)rr rrrr�do_card�s
 zConsole.do_cardcCs�|����}|j�|�}t|�dkrB|j�|��d�d}|dkr<t��\}}|j�	||�t
�d|�t
�|�d	St
d�d	St|�dkrNt
d�d	St
d�d	S)
zMDisplay an image with ImageMagick.
        Usage:
        	display <filename>rrTr�image�
display %szFile is not an image.�File not found.z5Only one file at a time may be specified for display.N)r2rUrrkrlr]ryr�make_temp_file�cpr=r>�remover)rr rq�typ�fd�	temp_namerrr�
do_display�szConsole.do_displaycC�|�|�dS)z Synonym for the display command.N)r�rrrr�do_show�r"zConsole.do_showcCs:|����}|j�|�}t|�dkr�|j�|��d�\}}|dkr�|dvr�|j�|�}tj	�|�\}}tj	�
|�\}}	d|vr]t��\}
}t
|d��|d�t�d|�t�|�dSd|vrt��\}
}t
|d��|d�t�d|�t�|�dStd	�dStd
�dSt|�dkr�td�dStd
�dS)z�Display an embedded thumbnail image with ImageMagick.
        Note:
        	Only works with JPEG/JFIF images with embedded JPEG/TIFF thumbnails
        Usage:
        	thumbnail <filename>rrTr���jpeg�tiff�
JPEGThumbnail�wbr��
TIFFThumbnailzNo thumbnail found.�"Incorrect file type for thumbnail.rr��?Only one file at a time may be specified for thumbnail display.N)r2rUrrkrlr]ry�get_exifr=�path�splitextrr��open�writer>r�r)rr rqr��subtyp�	exif_info�dir_name�	file_name�
photo_name�	photo_ext�temp_file_fd�temp_file_namerrr�do_thumbnail�s.zConsole.do_thumbnailcCr�)z"Synonym for the thumbnail command.N)r�rrrr�do_thumbr"zConsole.do_thumbc	Cs�|����}|j�|�}t|�dkrm|j�|��d�\}}|dkrg|dvrg|j�|�}t�	ddd�ddd�f�}t
�t
t�|�
d���t|���}|��|D]}|d	vrdt
|�
|d
||f��qQdSt
d�dSt|�dkryt
d
�dSt
d�dS)zCDisplay EXIF info for file.
        Usage:
        	exif <filename>rrTr�r��(rDrE)�Tag�Value)r�r��Filenamerur�rr�r�N)r2rUrrkrlr]ryr�rrWrrrrYr�r�r�)	rr rqr�r�r�r`�ee�errr�do_exifs0����zConsole.do_exifcCr�)zSynonym for the exif command.N)r�rrrr�do_info7r"zConsole.do_infocCst�tt�dS)N)r�	log_title�	__title__�__version__rrrr�do_about;r�zConsole.do_aboutN)F)r),�__name__�
__module__�__qualname__rr!r&r(r*r,r-r1r5r7r8r9r?r@rBrArhrtr�rnror�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr
>sT		 
6!
)(r
cCs@|dkrt�tt�d|��dStd||t�|�f�dSr�r�)r�r�r�rrr�status_callback?r�r�FT)zOutput directory:zV-o<dir> or --output=<dir> (Defaults to current directory)(Only used for non-GUI modes)�optionFz
hp-toolbox)�
extra_options�
see_also_list�ozoutput=)r�)z-oz--output�qt4zA%s does not support Qt4. Please use Qt3 or run in -i or -n modes.z
pcard-type)�filterzUsing device : %s
z%Unable to start photocard session: %szkUnable to mount photo card on device. Check that device is powered on and photo card is correctly inserted.z
Photocard on device %s mountedz4DO NOT REMOVE PHOTO CARD UNTIL YOU EXIT THIS PROGRAMz%ERROR: Output directory %s not found.zAborted.zAn error occured: %szOutput directory is %srDrErHrIrLrurvrwzFound %d files to unload, %s
zUnloading files...
rxrjz	User exit)�
unloadformz,Unable to load Qt3 support. Is it installed?zlastWindowClosed()zquit()�ui�locr>zUsing system locale: %s�c�utf8rPz&Trying to load .qm file for %s locale.zhplip_%s.qmzName of .qm file: %szUsing default 'C' localezUsing locale: %sr	zEUnable to connect to HPLIP I/O. Please (re)start HPLIP and try again.rRzDone.)�r��__mod__r��__doc__�sysr=�os.path�getopt�rer
�time�fnmatch�string�operator�readline�ImportError�base.g�base.sixextrrrz�exit�baserrrr�prntr	rr
r��Module�GUI_MODE�INTERACTIVE_MODE�NON_INTERACTIVE_MODE�UI_TOOLKIT_QT3�mod�setUsage�USAGE_FLAG_DEVICE_ARGS�parseStdOpts�optsr��printer_name�mode�
ui_toolkitr��pcardr�r��
output_dirr��a�canEnterGUIMode�getDeviceUri�eqr�	PhotoCardr�Errorr��msg�set_callback�update_spinner�mount�umountrr��realpath�normpath�
expanduserr�r�r�console�cmdloop�KeyboardInterrupt�	Exceptionr{rrlr�r�r|rWrXr`rYrrr\r}rsr��qtr�r��QApplication�argv�app�QObject�connect�SIGNAL�SLOT�	user_conf�getrU�str�
QTextCodec�locale�debugry�l�xr�r��QTranslator�trans�qm_file�load�prop�localization_dir�loaded�installTranslator�QLocale�
setDefault�	setlocale�LC_ALL�	normalize�
UnloadForm�w�
setMainWidget�show�	exec_looprrrr�<module>sl�

		
����

�
��

��
�����6"&���
�

�
�
�



Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists