403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.6/site-packages/tuned/utils/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/tuned/utils/__pycache__/commands.cpython-36.opt-1.pyc
3

��c3=�@srddlZddlZddlZddlZddlZddlZddljZddl	Z	ddl
TddlmZej
j�ZGdd�d�ZdS)�N)�*)�TunedExceptionc@s�eZdZd^dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zd_dd�Z	d`dd�Z
dd�Zdd�Zdd�Z
dadd�Zdbdd�Zdcd d!�Zddd#d$�Zded%d&�Zdfd'd(�Zdgd)d*�Zdhd+d,�Zd-d.�Zd/d0�Zdid1d2�Zd3d4�Zd5d6�Zdjd7d8�Zddigdfd9d:�Zdkd;d<�Zd=d>�Zd?d@�ZdAdB�Z dldDdE�Z!dFdG�Z"dHdI�Z#dJdK�Z$dLdM�Z%dmdNdO�Z&dPdQ�Z'dRdS�Z(dTdU�Z)dVdW�Z*dXdY�Z+dZd[�Z,d\d]�Z-dS)n�commandsTcCs
||_dS)N)�_logging)�selfZlogging�r�/usr/lib/python3.6/commands.py�__init__szcommands.__init__cCs|jrtj|�dS)N)r�log�error)r�msgrrr�_errorszcommands._errorcCs|jrtj|�dS)N)rr
�debug)rrrrr�_debugszcommands._debugc	Cs.t|�j�j�}ddddddddd�j||�S)N�1�0)�YZYES�TZTRUE�NZNO�FZFALSE)�str�upper�strip�get)r�value�vrrr�get_boolszcommands.get_boolcCstjddt|��j�S)Nz\s+� )�re�subrr)r�srrr�	remove_wsszcommands.remove_wscCstjdd|�S)Nz^"(.*)"$z\1)rr)rrrrr�unquote"szcommands.unquote�\cCs|j|d||f�S)Nz%s%s)�replace)rr Zwhat_escapeZ	escape_byrrr�escape&szcommands.escapecCs|j|d�S)N�)r$)rr Zescape_charrrr�unescape*szcommands.unescapecCs|d|t|�|S)Nr)�len)r�s1�pos�s2rrr�	align_str.szcommands.align_strcCs2g}|dk	r.x t|j��D]}|t|�7}qW|S)N)�sorted�items�list)r�d�l�irrr�	dict2list4s
zcommands.dict2listcCs(|dkrdStjddjt|j����S)Nz(%s)z)|()r�compile�joinr/�keys)rr0rrr�re_lookup_compile<szcommands.re_lookup_compileNrcsV�dkr|dkr.|Snt��dks*|dkr.|S|dkr@|j��}|j�fdd�||�S)Nrcst�j��|jdS)N�)r/�values�	lastindex)�mo)r0rr�<lambda>Msz.commands.multiple_re_replace.<locals>.<lambda>)r(r7r)rr0r �r�flagsr)r0r�multiple_re_replaceDs
zcommands.multiple_re_replacecCsRt|�dks|dkrdS|dkr*|j|�}|j|�}|rNt|j��|jdSdS)Nrr8)r(r7�searchr/r9r:)rr0r r=r;rrr�	re_lookupSs

zcommands.re_lookupFc	Cs�|jd||f�|r2tjj|�}tjj|�r2d}y6|rBtj|�t|d�}|jt|��|j	�d}Wn@t
tfk
r�}z d}|s�|jd||f�WYdd}~XnX|S)NzWriting to file: '%s' < '%s'F�wTz Writing to file '%s' error: '%s')
r�os�path�dirname�isdir�makedirs�open�writer�close�OSError�IOErrorr
)	r�f�dataZmakedir�no_errorr0�fdZrc�errr�
write_to_file]s"

$zcommands.write_to_filer&cCsv|}yt|d�}|j�}|j�Wn<ttfk
r^}z|sN|jd||f�WYdd}~XnX|jd||f�|S)Nr=z"Error when reading file '%s': '%s'z Read data from file: '%s' > '%s')rH�readrJrKrLr
r)rrMZerr_retrOZ	old_valuerQrrr�	read_fileps
$zcommands.read_filecCsj|jd|�tjj|�rfytj||�Wn:tk
rd}z|sVtjd|t	|�f�dSd}~XnXdS)NzRemoving tree: '%s'zcannot remove tree '%s': '%s'FT)
rrCrD�exists�shutil�rmtreerKr
rr)rrMrOrrrrrW|szcommands.rmtreecCsh|jd|�tjj|�rdytj|�Wn:tk
rb}z|sTtjd|t|�f�dSd}~XnXdS)NzRemoving file: '%s'zcannot remove file '%s': '%s'FT)	rrCrDrU�unlinkrKr
rr)rrMrOrrrrrX�szcommands.unlinkcCsd|jd||f�ytj||�Wn<tk
r^}z |sPtjd||t|�f�dSd}~XnXdS)NzRenaming file '%s' to '%s'z%cannot rename file '%s' to '%s': '%s'FT)rrC�renamerKr
rr)r�src�dstrOrrrrrY�szcommands.renamecCs`y"tjd||f�tj||�dStk
rZ}z|sLtjd|||f�dSd}~XnXdS)Nzcopying file '%s' to '%s'Tz!cannot copy file '%s' to '%s': %sF)r
rrV�copyrLr)rrZr[rOrQrrrr\�sz
commands.copycCs6|j|�}t|�dkrdS|j|tj|||tjd��S)NrF)r>)rTr(rRrr�	MULTILINE)rrM�pattern�replrNrrr�replace_in_file�s
zcommands.replace_in_filecCs4|j|�}t|�dkrdS|j||j||tjd��S)NrF)r>)rTr(rRr?rr])rrMr0rNrrr�multiple_replace_in_file�s
z!commands.multiple_replace_in_filecCs�|j|�}x�|D]�}t|�}t||�}tjd|d|tjd�dkr||r�t|�dkrj|ddkrj|d7}|d||f7}qtjd|d	d
|j|�d|tjd�}qW|j||�S)Nz\bz\s*=.*$)r>rr8�
z%s="%s"
z\b(z\s*=).*$z\1�"���z\1")	rTrrr@r]r(rr%rR)rrMr0�addrN�opt�orrrr�add_modify_option_in_file�s

.z"commands.add_modify_option_in_filecCs"|j|�}tjt|�jd��j�S)Nzutf-8)rT�hashlibZmd5r�encode�	hexdigest)rrMrNrrr�md5sum�s
zcommands.md5sumcCs"|j|�}tjt|�jd��j�S)Nzutf-8)rTriZsha256rrjrk)rrMrNrrr�	sha256sum�s
zcommands.sha256sumcCs|jtj|�j�S)N)rT�constsZMACHINE_ID_FILEr)rrOrrr�get_machine_id�szcommands.get_machine_idcCsRd}tjj�}d|d<|j|�|jdt|��d}	d}
y�t|tt|||ddd�}|j�\}	}|j	}|r�||kr�d|kr�|dd
�}
t
|
�dkr�|	dd�}
d	|d|
f}
|s�|j|
�Wnvtt
fk
�r4}zT|jdk	r�|jnd}t|�|k�r$d|k�r$d	|d|f}
|�s$|j|
�WYdd}~XnX|�rF||	|
fS||	fSdS)
Nr�C�LC_ALLz
Executing %s.r&T)�stdout�stderr�env�shell�cwdZ	close_fdsZuniversal_newlinesr8zExecuting %s error: %srdrdrd)rC�environr\�updaterr�Popen�PIPEZcommunicate�
returncoder(r
rKrL�errno�abs)r�argsrurvrtZ	no_errorsZ
return_errZretcodeZ_environment�outZerr_msg�proc�errZerr_outrQrrr�execute�s>


zcommands.executecCs.tjd|�}|r|jd�S|r*|j�dS|S)Nz.*\[([^\]]+)\].*r8r)r�match�group�split)rZoptionsZdosplit�mrrr�get_active_option�s
zcommands.get_active_optioncCs*t|�}|dkp(|jd|dd�j�dkS)Nrz$/sys/devices/system/cpu/cpu%s/onlineT)rOr)rrTr)r�cpuZscpurrr�
is_cpu_onlineszcommands.is_cpu_onlinecCs\|dkrdSt|�jdd�}yt|d�}Wn&tk
rPtjdt|��gSX|j|�S)N�,r&�zinvalid hexadecimal mask '%s')rr$�int�
ValueErrorr
r�bitmask2cpulist)r�maskr�rrr�hex2cpulistszcommands.hex2cpulistcCs<d}g}x.|dkr6|d@r$|j|�|dL}|d7}q
W|S)Nrr8)�append)rr�r��cpusrrrr�s

zcommands.bitmask2cpulist�'"cCs^g}|dkr|S|}t|�tk	rD|dk	r6t|�j|�}t|�jd�}g}g}d}d}�x|D�]}	t|	�}
|r�t|
�dkr�d}|j|�d}n||
7}q\|
dd�j�dkr�d}|
}q\|
o�|
ddks�|
dd	k�rP|
d
d�jd�}yPt|�d
k�r|ttt	|d�t	|d
�d
��7}n|jt	|
d
d���Wnt
k
�rLgSXq\t|
�dkr\|j|
�q\Wt|�dk�r�|j|�x�|D]�}	|	jd�}|	dd�j�dk�r�||j|	�7}ndyLt|�d
k�r�|ttt	|d�t	|d
�d
��7}n|jt	|d��Wnt
k
�rgSX�q�Wttt
|���}
x"|D]}||
k�r<|
j|��q<W|
S)Nr�Fr&r�Z0xT�^�!r8�-)�typer/rrr�r(r��lower�ranger�r�r�r-�set�remove)rr1Zstrip_chars�rlZllZll2Z
negation_listZhexmaskZhvrZsv�nlZvlZcpu_listr�rrr�cpulist_unpack-sh





(

zcommands.cpulist_unpackcCs�|j|�}|dkst|�dkr"|Sd}|}g}xz|dt|�kr�||d||dkr�||kr�|jt||�dt||��n|jt||��|d}|d7}q0W|dt|�kr�|jt||�dt|d��n|jt|d��|S)Nrr8r�rdrd)r�r(r�r)rr1r2�jr�rrr�cpulist_packqs"
$$zcommands.cpulist_packcCs.|j|�}|j|jd��}tt|�t|��S)Nz/sys/devices/system/cpu/online)r�rTr/r�)rr1r�Zonlinerrr�cpulist_invert�s
zcommands.cpulist_invertcs�|dkrdS|j|�}|dkr"dS|j|�}d|�t��}|ddkrX|d|d7}�j|��dj�fdd�tdt��d�D��S)Nz%x�rr�c3s|]}�||d�VqdS)r�Nr)�.0r2)r rr�	<genexpr>�sz'commands.cpulist2hex.<locals>.<genexpr>)r��cpulist2bitmaskr(�zfillr5r�)rr1Zulr�Zlsr)r r�cpulist2hex�s


zcommands.cpulist2hexcCs$d}x|D]}|td|�O}q
W|S)Nrr�)�pow)rr1r�rrrrr��s
zcommands.cpulist2bitmaskcsdj�fdd�|D��S)Nr�c3s|]}�t|�VqdS)N)r)r�r)�prefixrrr��sz*commands.cpulist2string.<locals>.<genexpr>)r5)rr1r�r)r�r�cpulist2string�szcommands.cpulist2stringcCsb|dd�j�dkrH|dd�}|dd�j�dkrHdd�|j|�D�Stjd|�}dd�|D�S)Nrr�zcpulist:cSsg|]}dt|��qS)r�)r)r�rrrr�
<listcomp>�sz(commands.devstr2devs.<locals>.<listcomp>z\s*(?<!\\),\s*cSsg|]}t|�jdd��qS)z\,r�)rr$)r�rrrrr��s)r�r�rr�)rr r1rrr�devstr2devs�szcommands.devstr2devsc	Cs"y|j|d�S|j|�SdS)NF)�wait)rZ	terminateZtimerrrr��sz
commands.waitcCs�t|�j�j�}x�dD]�}|j|�}|dkr.qybt|d|��}||d�}|dkr^|d9}n0|dkrp|d	9}n|dkr�|d9}n|dkr�d}|Stk
r�dSXqWdS)N�KB�MB�GBr&r8i)r�r�r�r&rdiii@)rrr�rfindr�r�)rr ZunitZunit_ix�val�urrr�get_size�s&




zcommands.get_sizecCs�d}d}y(ttjd��}|j�j�}WdQRXWnjtk
rj}z|jtjkrZtd|��WYdd}~Xn2t	t
fk
r�}ztd|��WYdd}~XnXyHttjd��2}|j�j�}|dtjtj
gkr�tdtj��WdQRXWnptk
�r"}z |jtjk�rtd|��WYdd}~Xn4t	t
fk
�rT}ztd|��WYdd}~XnX|dk�rfd}n
|tj
k}|dk�r~d}||fS)Nr&r=z!Failed to read active profile: %szInvalid value in file %s.zFailed to read profile mode: %s)rHrn�ACTIVE_PROFILE_FILErSrrLr|�ENOENTrrK�EOFError�PROFILE_MODE_FILE�ACTIVE_PROFILE_AUTO�ACTIVE_PROFILE_MANUAL)r�profile_name�moderMrQ�manualrrr�get_active_profile�s4


zcommands.get_active_profilecCs�y2ttjd��}|dk	r&|j|d�WdQRXWn4ttfk
rf}ztd|j��WYdd}~XnXy:ttjd��$}|r�tj	ntj
}|j|d�WdQRXWn4ttfk
r�}ztd|j��WYdd}~XnXdS)NrBrbz!Failed to save active profile: %szFailed to save profile mode: %s)rHrnr�rIrKrLr�strerrorr�r�r�)rr�r�rMrQr�rrr�save_active_profile�s zcommands.save_active_profilecCs�d}y(ttjd��}|j�j�}WdQRXWnjtk
rf}z|jtjkrVtd|��WYdd}~Xn2t	t
fk
r�}ztd|��WYdd}~XnX|dkr�d}|S)Nr&r=z1Failed to read the active post-loaded profile: %s)rHrn�POST_LOADED_PROFILE_FILErSrrLr|r�rrKr�)rr�rMrQrrr�get_post_loaded_profile�sz commands.get_post_loaded_profilecCsly2ttjd��}|dk	r&|j|d�WdQRXWn4ttfk
rf}ztd|j��WYdd}~XnXdS)NrBrbz1Failed to save the active post-loaded profile: %s)rHrnr�rIrKrLrr�)rr�rMrQrrr�save_post_loaded_profilesz!commands.save_post_loaded_profile)T)r#r#)r#)Nr)N)FF)r&F)F)F)F)F)T)T)T)r�)r&).�__name__�
__module__�__qualname__r	r
rrr!r"r%r'r,r3r7r?rArRrTrWrXrYr\r`rarhrlrmror�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrsV
















'
	
D
r)r|riZ
tuned.logsZtunedr\rCrVZtuned.constsrnr�
subprocessZtuned.exceptionsrZlogsrr
rrrrr�<module>s



Youez - 2016 - github.com/yon3zu
LinuXploit