ok

Mini Shell

Direktori : /proc/thread-self/root/lib/python2.7/site-packages/tuned/utils/
Upload File :
Current File : //proc/thread-self/root/lib/python2.7/site-packages/tuned/utils/commands.pyc

�
��\c@s�ddlZddlZddlZddlZddlZddljZddlZddl	Tddl
mZejj
�Zddd��YZdS(i����N(t*(tTunedExceptiontcommandscBs�eZed�Zd�Zd�Zd�Zd�Zd�Zddd�Z	dd�Z
d	�Zd
�Zd�Z
d(dd
�Zd(d�Zeed�Zded�Zed�Zed�Zed�Zed�Zd�Zd�Zed�Zed�Zed(iged�Zed�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d'�Z)RS()cCs
||_dS(N(t_logging(tselftlogging((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt__init__scCs|jrtj|�ndS(N(Rtlogterror(Rtmsg((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt_errors	cCs|jrtj|�ndS(N(RRtdebug(RR	((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt_debugs	cCs`t|�j�j�}idd6dd6dd6dd6dd6dd6dd	6dd
6j||�S(Nt1tYtYEStTtTRUEt0tNtNOtFtFALSE(tstrtuppertstriptget(Rtvaluetv((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytget_boolscCstjddt|��j�S(Ns\s+t (tretsubRR(Rts((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt	remove_wsscCstjdd|�S(Ns^"(.*)"$s\1(RR (RR((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytunquote!ss\cCs|j|d||f�S(Ns%s%s(treplace(RR!twhat_escapet	escape_by((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytescape%scCs|j|d�S(Nt(R$(RR!tescape_char((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytunescape)scCs|d|t|�|S(NR(tlen(Rts1tposts2((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt	align_str-scCsFg}|dk	rBx-t|j��D]}|t|�7}q%Wn|S(N(tNonetsortedtitemstlist(Rtdtlti((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt	dict2list3s
cCs6|dkrdStjddjt|j����S(Ns(%s)s)|((R0RtcompiletjoinR3tkeys(RR4((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytre_lookup_compile;sics{�dkr|dkrA|Sn"t��dks=|dkrA|S|dkr_|j��}n|j�fd�||�S(Nicst�j��|jdS(Ni(R3tvaluest	lastindex(tmo(R4(s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt<lambda>Ls(R0R+R;R (RR4R!trtflags((R4s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytmultiple_re_replaceCscCstt|�dks|dkr"dS|dkr@|j|�}n|j|�}|rpt|j��|jdSdS(Nii(R+R0R;tsearchR3R<R=(RR4R!R@R>((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt	re_lookupRsc	Cs�|jd||f�|rMtjj|�}tjj|�rMt}qMnyL|rftj|�nt|d�}|jt	|��|j
�t}Wn?tt
fk
r�}t}|s�|jd||f�q�nX|S(NsWriting to file: '%s' < '%s'tws Writing to file '%s' error: '%s'(RtostpathtdirnametisdirtFalsetmakedirstopentwriteRtclosetTruetOSErrortIOErrorR
(	Rtftdatatmakedirtno_errorR4tfdtrcte((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt
write_to_file\s"

R(cCs�|}y)t|d�}|j�}|j�Wn9ttfk
rj}|sk|jd||f�qknX|jd||f�|S(NR@s"Error when reading file '%s': '%s's Read data from file: '%s' > '%s'(RLtreadRNRPRQR
R(RRRterr_retRUt	old_valueRX((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt	read_fileoscCs{|jd|�tjj|�rwytj||�Wqwtk
rs}|sotjd|t	|�f�nt
SXntS(NsRemoving tree: '%s'scannot remove tree '%s': '%s'(RRFRGtexiststshutiltrmtreeRPRRRRJRO(RRRRUR((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyR`{s cCsx|jd|�tjj|�rtytj|�Wqttk
rp}|sltjd|t|�f�nt	SXnt
S(NsRemoving file: '%s'scannot remove file '%s': '%s'(RRFRGR^tunlinkRPRRRRJRO(RRRRUR((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyRa�s cCso|jd||f�ytj||�Wn=tk
rj}|sftjd||t|�f�ntSXtS(NsRenaming file '%s' to '%s's%cannot rename file '%s' to '%s': '%s'(	RRFtrenameRPRRRRJRO(RtsrctdstRUR((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyRb�s#cCsmy/tjd||f�tj||�tSWn7tk
rh}|sdtjd|||f�ntSXdS(Nscopying file '%s' to '%s's!cannot copy file '%s' to '%s': %s(RRR_tcopyRORQRRJ(RRcRdRURX((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyRe�scCsM|j|�}t|�dkr%tS|j|tj|||dtj��S(NiRA(R]R+RJRYRR t	MULTILINE(RRRtpatterntreplRS((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytreplace_in_file�scCsJ|j|�}t|�dkr%tS|j||j||dtj��S(NiRA(R]R+RJRYRBRRf(RRRR4RS((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytmultiple_replace_in_file�scCs�|j|�}x�|D]�}t|�}t||�}tjd|d|dtj�dkr�|r�t|�dkr�|ddkr�|d7}n|d||f7}q�qtjd|d	d|d|dtj�}qW|j||�S(
Ns\bs\s*=.*$RAii����s
s%s="%s"
s\b(s\s*=).*$s\1s"s\1"(	R]RRRCRfR0R+R RY(RRRR4taddRStopttoR((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytadd_modify_option_in_file�s
)"
2cCs|jtj|�j�S(N(R]tconststMACHINE_ID_FILER(RRU((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytget_machine_id�scCs�d}tjj�}d|d<|j|�|jdt|��d}	d}
y�t|dtdtd|d	|d
|dt	dt	�}|j
�\}	}|j}|r||krd|kr|d
 }
t|
�dkr�|	d
 }
nd|d|
f}
|s|j
|
�qnWn�ttfk
r�}|jdk	rI|jnd
}t|�|kr�d|kr�d|d|f}
|s�|j
|
�q�q�nX|r�||	|
fS||	fSdS(NitCtLC_ALLs
Executing %s.R(tstdouttstderrtenvtshelltcwdt	close_fdstuniversal_newlinesi����sExecuting %s error: %s(RFtenvironRetupdateRRR0tPopentPIPEROtcommunicatet
returncodeR+R
RPRQterrnotabs(RtargsRwRxRvt	no_errorst
return_errtretcodet_environmenttoutterr_msgtprocterrterr_outRX((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytexecute�s>

		


cCs=tjd|�}|r%|jd�S|r9|j�dS|S(Ns.*\[([^\]]+)\].*ii(Rtmatchtgrouptsplit(Rtoptionstdosplittm((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytget_active_option�s
cCs;t|�}|dkp:|jd|dt�j�dkS(NRs$/sys/devices/system/cpu/cpu%s/onlineRUR
(RR]ROR(Rtcputscpu((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt
is_cpu_online�scCst|dkrdSt|�jdd�}yt|d�}Wn)tk
rftjdt|��gSX|j|�S(Nt,R(isinvalid hexadecimal mask '%s'(R0RR$tintt
ValueErrorRRtbitmask2cpulist(RtmaskR�((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pythex2cpulists
cCsQd}g}x>|dkrL|d@r5|j|�n|dL}|d7}qW|S(Nii(tappend(RR�R�tcpus((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyR�s

c
Cs�g}|dkr|St|�tkr1|}nt|�jd�}g}g}t}d}xW|D]O}t|�}	|r�t|	�dkr�t}|j|�d}q�||	7}qe|	dd!j�dkr�t	}|	}qe|	r�|	ddks|	ddkr�|	djd	�}
yat|
�dkrb|tt
t|
d�t|
d�d��7}n|jt|	d��Wq�tk
r�gSXqet|	�dkre|j|	�qeqeWt|�dkr�|j|�nx�|D]�}|jd	�}|dd!j�dkr%||j
|�7}q�yat|�dkrn|tt
t|d�t|d�d��7}n|jt|d��Wq�tk
r�gSXq�Wttt|���}x*|D]"}
|
|kr�|j|
�q�q�W|S(
NR�R(iit0xt^t!it-(R0ttypeR3RR�RJR+R�tlowerROtrangeR�R�R�R1tsettremove(RR5trltlltll2t
negation_listthexmaskthvRtsvtnltvltcpu_listR�((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytcpulist_unpacksd	

	
	&	


4
	
cCs?|j|�}|dks-t|�dkr1|Sd}|}g}x�|dt|�kr�||d||dkr�||kr�|jt||�dt||��n|jt||��|d}n|d7}qFW|dt|�kr$|jt||�dt|d��n|jt|d��|S(NiiR�i����(R�R0R+R�R(RR5R6tjR�((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytcpulist_packbs",
,cCsA|j|�}|j|jd��}tt|�t|��S(Ns/sys/devices/system/cpu/online(R�R]R3R�(RR5R�tonline((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytcpulist_invertxscs�|dkrdS|j|�}|dkr/dS|j|�}d|�t��}|ddkry|d|d7}n�j|��dj�fd�tdt��d�D��S(Ns%xiiR�c3s |]}�||d!VqdS(iN((t.0R6(R!(s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pys	<genexpr>�s(R0R�tcpulist2bitmaskR+tzfillR9R�(RR5tulR�tls((R!s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytcpulist2hex~s
cCs.d}x!|D]}|td|�O}q
W|S(Nii(tpow(RR5R�R((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyR��s
cCs,y|j|t�SWn|j|�SXdS(N(twaitRJ(Rt	terminatettime((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyR��scCs�t|�j�j�}x�ddddgD]�}|j|�}|dkrRq+ny�t|| �}||}|dkr�|d9}nG|dkr�|d9}n.|dkr�|d	9}n|dkr�d}n|SWq+tk
r�dSXq+WdS(
NtKBtMBtGBR(i����iiii@(RRRtrfindR�R0R�(RR!tunittunit_ixtvaltu((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytget_size�s&



	
c	Cs�d}d}y1ttjd��}|j�j�}WdQXWn`tk
rw}|jtjkr�td|��q�n)t	t
fk
r�}td|��nXybttjd��J}|j�j�}|dtjtj
gkr�tdtj��nWdQXWn`tk
r<}|jtjkretd|��qen)t	t
fk
rd}td|��nX|dkrzd}n|tj
k}|dkr�d}n||fS(NR(R@s!Failed to read active profile: %ssInvalid value in file %s.sFailed to read profile mode: %s(RLRotACTIVE_PROFILE_FILERZRRQR�tENOENTRRPtEOFErrortPROFILE_MODE_FILEtACTIVE_PROFILE_AUTOtACTIVE_PROFILE_MANUALR0(Rtprofile_nametmodeRRRXtmanual((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytget_active_profile�s4 		cCs�y?ttjd��'}|dk	r8|j|d�nWdQXWn,ttfk
rm}td|j��nXyHttj	d��0}|r�tj
ntj}|j|d�WdQXWn,ttfk
r�}td|j��nXdS(NREs
s!Failed to save active profile: %ssFailed to save profile mode: %s(RLRoR�R0RMRPRQRtstrerrorR�R�R�(RR�R�RRRXR�((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pytsave_active_profile�sN(*t__name__t
__module__RORR
RRR"R#R'R*R/R7R;R0RBRDRJRYR]R`RaRbReRiRjRnRqR�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyR
sJ								


		
'					C								((R�t
tuned.logsttunedReRFR_ttuned.constsRoRt
subprocessttuned.exceptionsRtlogsRRR(((s8/usr/lib/python2.7/site-packages/tuned/utils/commands.pyt<module>s


Zerion Mini Shell 1.0