404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.144.18.59: ~ $
3

�f�M�'@s�ddlZddlZddlZddlmZmZmZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZyddlmZWn ek
r�ddlmZYnXdZyddlZeje�dZWnPeefk
�r,ejd	�Zdd
l m!Z!dZ"ej#de!e"d
dd�d�YnXdZ$ddddddddddddddddd d!d"d#d$d%d&gZ%d'd(�Z&dPd)d*�Z'd+d&�Z(dQd-d�Z)dVd3d4�Z*d5d�Z+dWd6d�Z,d7d�Z-dXd8d�Z.e$dddddddddf
d9d%�Z/dYd:d�Z0dZd;d$�Z1d[d=d�Z2ej3fd>d?�Z4d@d�Z5dAd�Z6dBd �Z7dCd!�Z8dDd�Z9ej:dE�dFd"�Z;dGd�Z<gfdHd#�Z=GdIdJ�dJ�Z>GdKdL�dLe
j?�Z@GdMd�deA�ZBGdNd�d�ZCGdOd�deD�ZEdS)\�N)�Popen�PIPE�STDOUT)�closing)�deque)�parse)�
parse_versionFT�sos)�fillz�WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module.
�
�H)Zreplace_whitespacei,�TIMEOUT_DEFAULT�ImporterHelper�SoSTimeoutError�TempFileUtil�bold�file_is_binary�fileobj�find�get_human_readable�grep�
import_module�
is_executable�listdirr�path_exists�
path_isdir�path_isfile�path_islink�	path_join�recursive_dict_values_by_key�	shell_out�sos_get_command_output�tailcCs�tjd�}yB|j|dd�\}}}|s(|Stjdd|�jd�}|�d|��}|Stk
r�}ztjd|�d	|���|Sd
}~XnXd
S)z< Convert the version into a PEP440 compliant version scheme.z2^([0-9][0-9.]*(?:(?:a|b|rc|.post|.dev)[0-9]+)*)\+?�)�maxsplitz[+~]+�.�-�+zUnable to format z to pep440 format: N)�re�compile�split�sub�strip�	Exception�log�debug)�verZpublic_version_re�_ZpublicZlocalZsanitized_localZpep440_version�err�r3�/usr/lib/python3.6/utilities.py�format_version_to_pep440Lsr5cCs|rt|�}t|�St|�S)z6 Converts the version to PEP440 format before parsing )r5r)r0Zpep440Z
ver_pep440r3r3r4�sos_parse_version]sr6c
Cs<t|d��(}tj|�j|kr*|j|d�|j�SQRXdS)z,Returns the last number_of_bytes of filename�rb�N)�open�os�stat�st_size�seek�read)�filenameZnumber_of_bytes�fr3r3r4r"fs�rcCsXt|t�rLy
t||�Stk
rHtjd�}|jd|�ttj	��SXnt|�SdS)z@Returns a file-like object that can be used as a context managerr	zfileobj: %s could not be openedN)
�
isinstance�strr9�IOError�logging�	getLoggerr/r�io�StringIO)Zpath_or_file�moder.r3r3r4rns


r#�
���(cCsdt|�}||krd||S||kr0d||S||krDd||S||krXd||Sd|SdS)zCConverts a number of bytes to a shorter, more human friendly formatz%.1fTz%.1fGz%.1fMz%.1fKz%dN)�float)Zbytes_�K�M�G�T�fnr3r3r4�
convert_bytes{srTcs�trNy4tj|��ddg}�jdko8t�fdd�|D��Stk
rLYnXt|d��*}y|jd�dStk
r|d	SXWd
QRXd
S)azHelper to determine if a given file contains binary content or not.

    This is especially helpful for `sos clean`, which cannot obfuscate binary
    data and instead, by default, will remove binary files.

    :param fname:   The full path of the file to check binaryness of
    :type fname:    ``str``

    :returns:   True if binary, else False
    :rtype:     ``bool``
    ztext/zinode/�binaryc3s|]}�jj|�VqdS)N)Z	mime_type�
startswith)�.0Z_mt)�_ftupr3r4�	<genexpr>�sz!file_is_binary.<locals>.<genexpr>Ztrr#FTN)	�	magic_mod�magic�detect_from_filename�encoding�anyr-r9r>�UnicodeDecodeError)�fnameZ_mimesZtfiler3)rXr4r�s


c	cs�|r"tjj|�jtjj�}||7}xrtj|�D]d\}}}|rX|jtjj�|krX|dd�=|rltj||�rlq.x$tj||�D]}tjj||�VqzWq.WdS)z�Generator function to find files recursively.
    Usage::

        for filename in find("*.properties", "/var/log/foobar"):
            print filename
    N)	r:�path�dirname�count�sep�walk�fnmatch�filter�join)	Zfile_patternZtop_dirZ	max_depthZpath_patternZ
base_depthraZdirlistZfilelist�namer3r3r4r�s
csBg}x8|D]0}t|��}|j�fdd�|D��WdQRXq
W|S)z�Returns lines matched in fnames, where fnames can either be pathnames to
    files to grep through or open file objects to grep through line by linec3s|]}tj�|�r|VqdS)N)r(�match)rW�line)�patternr3r4rY�szgrep.<locals>.<genexpr>N)r�extend)rlZfiles_or_pathsZmatchesZfopZfor3)rlr4r�s


&cs\tjjdd�jtjj�}�g�fdd�|D�}�rJ|�fdd�|D�7}tdd�|D��S)z6Returns if a command matches an executable on the PATH�PATH�csg|]}tjj|���qSr3)r:rarh)rW�p)�commandr3r4�
<listcomp>�sz!is_executable.<locals>.<listcomp>cs g|]}tjj�|jd���qS)�/)r:rarh�lstrip)rW�c)�sysrootr3r4rr�scss|]}tj|tj�VqdS)N)r:�access�X_OK)rWrar3r3r4rY�sz is_executable.<locals>.<genexpr>)r:�environ�getr*ra�pathsepr^)rqrv�pathsZ
candidatesr3)rqrvr4r�scsb��fdd�}�fdd�}tjj�}
d|
d<|r`x.|j�D]"\}}|rP||
|<q:|
j|d�q:W|r�td�r�d	|rvd
nd||f}tj|�}g}xN|D]F}|jd�r�d
|kr�t	j	|�}|r�|j
|�q�|j|�q�|j|�q�W|
r�t|
d�}nt
}y�t|d||�rtnt
d|
d|d�}|
�s.t|j||�}n
t||�}��rXxr|j�rT||��q@WnZy|j|�rh|nd�Wn@tk
�r�|j�|
�r�|j�d|_d|j�|jd�SX|
�r�|j�x|j�dk�rԐq�W|j�}|j}WnPtk
�r6}z2|
�r|j�|jtjk�r"dddd�S|�WYdd}~XnX|jdk�sP|jdk�rTd}|j||d�S)z�Execute a command and return a dictionary of status and output,
    optionally changing root or current working directory before
    executing command.
    cs(�r�dkrtj���r$tj��dS)Nrs)r:�chroot�chdirr3)r~r}r3r4�_child_prep_fn�s
z.sos_get_command_output.<locals>._child_prep_fncs,��s|j�dkr|j�t�tjd�dS)N�|g{�G�z�?)�poll�	terminater�time�sleep)�proc)�pollerr3r4�
_check_poller�sz-sos_get_command_output.<locals>._check_pollerzC.UTF-8�LC_ALLN�timeoutztimeout %s %ds %sz--foregroundrors�*�wFr#T)�shell�stdout�stderr�bufsize�envZ	close_fdsZ
preexec_fnr�)Zstatus�output�	truncated��~����)r:ry�copy�items�popr�shlexr*rV�globrm�appendr9rrr�AsyncReaderr��
FakeReader�running�waitr-r��close�get_contents�is_fullr��OSError�errno�ENOENT�
returncode)rqr�r�r}r~r�Z
foregroundrU�	sizelimitr�Zto_filerr�Zcmd_env�key�value�argsZ
expanded_args�argZexpanded_argZ_outputrp�readerr�r��er3)r~r}r�r4r!�s~








cs��jd�d	}yt�t�t�|g�}Wn>tk
rd}z"td��d|jj���|�WYdd}~XnX�fdd�tj	|tj
�D�}�r��fdd�|D�}|S)
aImports the module module_fqname and returns a list of defined classes
    from that module. If superclasses is defined then the classes returned will
    be subclasses of the specified superclass or superclasses. If superclasses
    is plural it must be a tuple of classes.r%r#z"Error while trying to load module z:  Ncsg|]\}}|j�kr|�qSr3)�
__module__)rWZcnameZclass_)�
module_fqnamer3r4rrWsz!import_module.<locals>.<listcomp>csg|]}t|��r|�qSr3)�
issubclass)rW�m)�superclassesr3r4rr[sr�)�
rpartition�
__import__�globals�locals�ImportError�print�	__class__�__name__�inspectZ
getmembersZisclass)r�r�Zmodule_name�moduler��modulesr3)r�r�r4rKs
cCst||||d�dS)zeShell out to an external command and return the output or the empty
    string in case of error.
    )r�r}r~r�)r!)�cmdr�r}Zrunatr3r3r4r `sr8cCsJdddddg}d}x$|dkr6|dkr6|d	7}|d
}qWd||||fS)N�BZKiBZMiBZGiBZTiBri�r#g�@z%.*f%sr3)�sizeZ	precision�suffixesZsuffixindexr3r3r4rhscCs>|r,|tjkr,|j|�s,tjj||jd��}t||�}||�S)Nrs)r:rdrVrarhrt�getattr)rarv�methodr�Z_methr3r3r4�_os_wrapperrs


r�cCs$d|krt||dtd�St||d�S)Nr�r�)r��exists)r�r�)rarvr3r3r4rzscCst||d�S)N�isdir)r�)rarvr3r3r4r�scCst||d�S)N�isfile)r�)rarvr3r3r4r�scCst||d�S)N�islink)r�)rarvr3r3r4r�scCst||dt�S)Nr)r�r:)rarvr3r3r4r�s)rvcGs8|r&|j|�r&tjj||jtj��}tjj|f|��S)N)rVr:rarhrtrd)rarvrpr3r3r4r�scCsd|dS)a"Helper to make text bold in console output, without pulling in
    dependencies to the project unneccessarily.

    :param text:    The text to make bold
    :type text:     ``str``

    :returns:       The text wrapped in the ASCII codes to display as bold
    :rtype:         ``str``
    zzr3)�textr3r3r4r�s
cs�g}g�|j|�t|t�r�x�|j�D]�\}��j|�|sF||krV|jt���q&t�t�r&y$|jt�fdd�|D��d�Wntk
r�YnX�j�j��q&Wn
|j|��fdd�|D�S)a	Recursively compile all elements of a potentially nested dict by a set
    of keys. If a given key is a dict within ``dobj``, then _all_ elements
    within that dict, regardless of child keys, will be returned.

    For example, if a Plugin searches the devices dict for the 'storage' key,
    then all storage devices under the that dict (e.g. block, fibre, etc...)
    will be returned. However, if the Plugin specifies 'block' via ``keys``,
    then only the block devices within the devices['storage'] dict will be
    returned.

    Any elements passed here that are _not_ keys within the dict or any nested
    dicts will also be returned.

    :param dobj:    The 'top-level' dict to intially search by
    :type dobj:     ``dict``

    :param keys:    Which keys to compile elements from within ``dobj``. If no
                    keys are given, all nested elements are returned
    :param keys:    ``list`` of ``str``

    :returns:       All elements within the dict and any nested dicts
    :rtype:         ``list``
    c3s|]}|�kr�|VqdS)Nr3)rWr�)�vr3r4rY�sz/recursive_dict_values_by_key.<locals>.<genexpr>rcsg|]}|�kr|�qSr3r3)rW�d)�_filtr3r4rr�sz0recursive_dict_values_by_key.<locals>.<listcomp>)rmrB�dictr�r�r�
IndexError�keys)Zdobjr�Z_items�kr3)r�r�r4r�s&




c@s8eZdZdZdd�Zedd��Zdd�Zedd	��Zd
S)r�z�Used as a replacement AsyncReader for when we are writing directly to
    disk, and allows us to keep more simplified flows for executing,
    monitoring, and collecting command output.
    cCs||_||_dS)N)�processrU)�selfr�rUr3r3r4�__init__�szFakeReader.__init__cCsdS)NFr3)r�r3r3r4r��szFakeReader.is_fullcCs|js
dSdS)Nror�)rU)r�r3r3r4r��szFakeReader.get_contentscCs|jj�dkS)N)r�r�)r�r3r3r4r��szFakeReader.runningN)	r�r��__qualname__�__doc__r��propertyr�r�r�r3r3r3r4r��s
r�cs<eZdZdZ�fdd�Zdd�Zdd�Zedd	��Z�Z	S)
r�z�Used to limit command output to a given size without deadlocking
    sos.

    Takes a sizelimit value in MB, and will compile stdout from Popen into a
    string that is limited to the given sizelimit.
    csbtt|�j�||_||_d|_d|_|rB|d}t||j�|_t|jd�|_d|_	|j
�dS)Nii)�maxlenT)�superr�r��chanrU�	chunksize�slots�intrr��start)r�Zchannelr�rU)r�r3r4r��szAsyncReader.__init__cCsNy*x$|jj|j�}|sP|jj|�qWWnttfk
rBYnXd|_dS)alReads from the channel (pipe) that is the output pipe for a
        called Popen. As we are reading from the pipe, the output is added
        to a deque. After the size of the deque exceeds the sizelimit
        earlier (older) entries are removed.

        This means the returned output is chunksize-sensitive, but is not
        really byte-sensitive.
        FN)r�r>r�rr��
ValueErrorrDr�)r�rkr3r3r4�runs	zAsyncReader.runcCsLx|jrtjd�qW|js2djdd�|jD��Sdjdd�|jD��SdS)z-Returns the contents of the deque as a stringg{�G�z�?rocss|]}|jdd�VqdS)zutf-8�ignoreN)�decode)rW�lnr3r3r4rY sz+AsyncReader.get_contents.<locals>.<genexpr>r�css|]
}|VqdS)Nr3)rWr�r3r3r4rY"sN)r�r�r�rUrhr)r�r3r3r4r�s
zAsyncReader.get_contentscCs|js
dSt|j�|jkS)z?Checks if the deque is full, implying that output was truncatedF)r��lenr)r�r3r3r4r�$szAsyncReader.is_full)
r�r�r�r�r�r�r�r�r��
__classcell__r3r3)r�r4r��s

r�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
rz�Provides a list of modules that can be imported in a package.
    Importable modules are located along the module __path__ list and modules
    are files that end in .py.
    cCs
||_dS)zopackage is a package module
        import my.package.module
        helper = ImporterHelper(my.package.module)N)�package)r�r�r3r3r4r�2szImporterHelper.__init__cCs tjj|�}tjj|�\}}|S)z-Returns the plugin module name given the path)r:ra�basename�splitext)r�ra�baseriZextr3r3r4�_plugin_name8szImporterHelper._plugin_namecs�fdd�|D�}|j�|S)Ncs(g|] }d|kr|jd�r�j|��qS)r�z.py)�endswithr�)rWZplugin)r�r3r4rr?sz9ImporterHelper._get_plugins_from_list.<locals>.<listcomp>)�sort)r�Zlist_�pluginsr3)r�r4�_get_plugins_from_list>s
z%ImporterHelper._get_plugins_from_listcCs0tjj|�r,ttd|��}|j|�}|r,|SgS)Nz*.py)r:rar��listrr�)r�raZpy_filesZpnamesr3r3r4�_find_plugins_in_dirEs
z#ImporterHelper._find_plugins_in_dircCs6g}x,|jjD] }tjj|�r|j|j|��qW|S)zQReturns the list of importable modules in the configured python
        package. )r��__path__r:rar�rmr�)r�r�rar3r3r4�get_modulesMs
zImporterHelper.get_modulesN)	r�r�r�r�r�r�r�r�r�r3r3r3r4r,sc@s$eZdZdd�Zdd�Zdd�ZdS)rcCs||_g|_dS)N)�tmp_dir�files)r�r�r3r3r4r�ZszTempFileUtil.__init__cCs2tj|jd�\}}tj|d�}|jj||f�|S)N)�dirzw+)�tempfileZmkstempr�r:�fdopenr�r�)r��fdr`Zfobjr3r3r4�new^szTempFileUtil.newcCslx`|jD]V\}}y|j�|j�Wntk
r8YnXytj|�Wqtk
r\YqXqWg|_dS)N)r��flushr�r-r:�unlink)r�r`r@r3r3r4�cleanes
zTempFileUtil.cleanN)r�r�r�r�r�r�r3r3r3r4rXsc@seZdZdS)rN)r�r�r�r3r3r3r4rss)T)rA���@�)r�r�rr)NN)N)N)rLNN)r8)Fr:r(r��
subprocessrrrrErfr�r�r�r�Z	threadingr�rG�
contextlibr�collectionsrZpackaging.versionrrr�Z
pkg_resourcesrZr[r\�__file__�AttributeErrorrFr.�textwrapr
�msgZwarningr
�__all__r5r6r"rrTrrrrr!rr rrar�rrrrrrdrrrr�ZThreadr��objectrrr�rr3r3r3r4�<module>	s�

"
	

"

n




6=,

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 5.04 KB 0644
__init__.cpython-36.pyc File 5.04 KB 0644
archive.cpython-36.opt-1.pyc File 22.42 KB 0644
archive.cpython-36.pyc File 22.42 KB 0644
component.cpython-36.opt-1.pyc File 14.84 KB 0644
component.cpython-36.pyc File 14.84 KB 0644
missing.cpython-36.opt-1.pyc File 2.68 KB 0644
missing.cpython-36.pyc File 2.68 KB 0644
options.cpython-36.opt-1.pyc File 11.79 KB 0644
options.cpython-36.pyc File 11.79 KB 0644
utilities.cpython-36.opt-1.pyc File 18.3 KB 0644
utilities.cpython-36.pyc File 18.3 KB 0644