0x1949 Team - FAZEMRX - MANAGER
Edit File: utilities.cpython-310.pyc
o i��d~H � @ s\ d dl Z d dlZd dlZd dlmZmZmZ d dlZd dlZd dl Z d dl Z d dlZd dlZd dl Z d dlZd dlZd dlmZ d dlmZ zd dlmZ W n ey] d dlmZ Y nw dZz d dlZe�e� dZW n& eefy� e� d �Z!d d l"m#Z# dZ$e!�%de#e$d dd� d � Y nw dZ&dd� Z'dLdd�Z(dMdd�Z)dd� Z*dNdd�Z+dd � Z,dOd!d"�Z-e&dddddddddf d#d$�Z.dOd%d&�Z/dPd(d)�Z0dQd+d,�Z1e j2fd-d.�Z3d/d0� Z4d1d2� Z5d3d4� Z6d5d6� Z7d7d8� Z8e j9d9�d:d;�Z:d<d=� Z;g fd>d?�Z<d@dA� ZG dBdC� dC�Z=G dDdE� dEe j>�Z?G dFdG� dGe@�ZAG dHdI� dI�ZBG dJdK� dKeC�ZDdS )R� N)�Popen�PIPE�STDOUT)�closing)�deque)� parse_version)�parseFT�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 )�replace_whitespacei, c C sT t | d��}t�| �j|kr|�| d� |�� W d � S 1 s#w Y dS )z,Returns the last number_of_bytes of filename�rb� N)�open�os�stat�st_size�seek�read)�filename�number_of_bytes�f� r �//usr/lib/python3/dist-packages/sos/utilities.py�tail2 s $�r �rc C sV t | t�r'zt| |�W S ty& t�d�}|�d| � tt� � � Y S w t| �S )z@Returns a file-like object that can be used as a context managerr zfileobj: %s could not be opened) � isinstance�strr �IOError�logging� getLogger�debugr �io�StringIO)�path_or_file�mode�logr r r �fileobj: s �r( � � � @� c C s` t | �}| |krd|| S | |krd|| S | |kr"d|| S | |kr,d|| S d| S )zCConverts a number of bytes to a shorter, more human friendly formatz%.1fTz%.1fGz%.1fMz%.1fKz%d)�float)�bytes_�K�M�G�T�fnr r r � convert_bytesG s r4 c s� t r'zt�| �� ddg}� jdkot� fdd�|D �� W S ty& Y nw t| d�� }z|�d� W W d � d S tyK Y W d � d S w 1 sOw Y dS )az Helper 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/�binaryc 3 s � | ] }� j �|�V qd S �N)� mime_type� startswith)�.0�_mt��_ftupr r � <genexpr>h � � z!file_is_binary.<locals>.<genexpr>�tr� NFT) � magic_mod�magic�detect_from_filename�encoding�any� Exceptionr r �UnicodeDecodeError)�fname�_mimes�tfiler r; r �file_is_binaryV s* ��� ���rK c c s� � |rt j�|��t jj�}||7 }t �|�D ]/\}}}|r,|�t jj�|kr,|dd�= |r5t�||�s5qt�|| �D ] }t j�||�V q;qdS )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) �file_pattern�top_dir� max_depth�path_pattern� base_depthrL �dirlist�filelist�namer r r �findx s � ��r\ c sR g }|D ]"}t |��}|�� fdd�|D �� W d � n1 s!w Y q|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 linec 3 s � | ]}t �� |�r|V qd S r6 )�re�match)r9 �line��patternr r r= � s � zgrep.<locals>.<genexpr>N)r( �extend)ra �files_or_paths�matches�fop�for r` r �grep� s ��rg c s\ t j�dd��t jj�}� g� fdd�|D � }�r%|�fdd�|D �7 }tdd� |D ��S )z6Returns if a command matches an executable on the PATH�PATH� c s g | ] }t j�|� ��qS r )r rL rS )r9 �p)�commandr r � <listcomp>� � z!is_executable.<locals>.<listcomp>c s g | ]}t j�� |�d ���qS )�/)r rL rS �lstrip)r9 �c��sysrootr r rl � s �c s s � | ] }t �|t j�V qd S r6 )r �access�X_OK)r9 rL r r r r= � s � z is_executable.<locals>.<genexpr>)r �environ�get�splitrL �pathseprE )rk rr �paths� candidatesr )rk rr r � is_executable� s �r{ c sP � �fdd�}�fdd�}t j�� } d| d<