/usr/lib/python3.9/site-packages/tuned/utils/__pycache__
NameSizeModeActions
class_loader.cpython-39.opt-1.pyc21350644editdlrm
class_loader.cpython-39.pyc22530644editdlrm
commands.cpython-39.opt-1.pyc171000644editdlrm
commands.cpython-39.pyc171000644editdlrm
config_parser.cpython-39.opt-1.pyc20090644editdlrm
config_parser.cpython-39.pyc20090644editdlrm
global_config.cpython-39.opt-1.pyc46680644editdlrm
global_config.cpython-39.pyc46680644editdlrm
nettool.cpython-39.opt-1.pyc48250644editdlrm
nettool.cpython-39.pyc48250644editdlrm
polkit.cpython-39.opt-1.pyc17470644editdlrm
polkit.cpython-39.pyc17470644editdlrm
profile_recommender.cpython-39.opt-1.pyc53090644editdlrm
profile_recommender.cpython-39.pyc53090644editdlrm
__init__.cpython-39.opt-1.pyc1470644editdlrm
__init__.cpython-39.pyc1470644editdlrm
Edit: /usr/lib/python3.9/site-packages/tuned/utils/__pycache__/commands.cpython-39.pyc (17100B)
a Á]›i`Cã@stddlZddlZddlZddlZddlZddlZddlmZddl Z ddl Tddl m Z ej  ¡ZGdd„dƒZdS)éN)Ú*)ÚTunedExceptionc@s°eZdZdfdd„Zdd„Zdd„Zdd „Zd d „Zd d „Zdgdd„Z dhdd„Z dd„Z dd„Z dd„Z didd„Zdjdd„Zdkd d!„Zdld#d$„Zdmd%d&„Zdnd'd(„Zdod)d*„Zdpd+d,„Zd-d.„Zd/d0„Zdqd1d2„Zd3d4„Zd5d6„Zdrd7d8„Zddigdfd9d:„Zdsd;d<„Zd=d>„Zd?d@„ZdAdB„Z dtdDdE„Z!dFdG„Z"dHdI„Z#dJdK„Z$dLdM„Z%dudNdO„Z&dPdQ„Z'dRdS„Z(dTdU„Z)dVdW„Z*dXdY„Z+dZd[„Z,d\d]„Z-d^d_„Z.d`da„Z/dbdc„Z0ddde„Z1dS)vÚcommandsTcCs ||_dS©N)Ú_logging)ÚselfZlogging©rú8/usr/lib/python3.9/site-packages/tuned/utils/commands.pyÚ__init__szcommands.__init__cCs|jrt |¡dSr)rÚlogÚerror©rÚmsgrrr Ú_errorszcommands._errorcCs|jrt |¡dSr)rr Údebugr rrr Ú_debugszcommands._debugc Cs.t|ƒ ¡ ¡}dddddddddœ ||¡S)NÚ1Ú0)ÚYZYESÚTZTRUEÚNZNOÚFZFALSE)ÚstrÚupperÚstripÚget)rÚvalueÚvrrr Úget_boolszcommands.get_boolcCst ddt|ƒ¡ ¡S)Nz\s+ú )ÚreÚsubrr)rÚsrrr Ú remove_wsszcommands.remove_wscCst dd|¡S)Nz^"(.*)"$z\1)r r!)rrrrr Úunquote"szcommands.unquoteú\cCs| |d||f¡S)Nz%s%s©Úreplace)rr"Z what_escapeZ escape_byrrr Úescape&szcommands.escapecCs | |d¡S)NÚr&)rr"Z escape_charrrr Úunescape*szcommands.unescapecCs|d|t|ƒ|S)Nr)Úlen)rÚs1ÚposÚs2rrr Ú align_str.szcommands.align_strcCs.g}|dur*t| ¡ƒD]}|t|ƒ7}q|Sr)ÚsortedÚitemsÚlist)rÚdÚlÚirrr Ú dict2list4s zcommands.dict2listcCs(|dur dSt dd t| ¡ƒ¡¡S)Nz(%s)z)|()r ÚcompileÚjoinr2Úkeys)rr3rrr Úre_lookup_compile<szcommands.re_lookup_compileNrcsVˆdur|dur.|Sntˆƒdks*|dur.|S|dur@| ˆ¡}| ‡fdd„||¡S)Nrcstˆ ¡ƒ|jdS)Né)r2ÚvaluesÚ lastindex)Úmo©r3rr ÚMóz.commands.multiple_re_replace..)r+r:r!)rr3r"ÚrÚflagsrr?r Úmultiple_re_replaceDs zcommands.multiple_re_replacecCsRt|ƒdks|durdS|dur*| |¡}| |¡}|rNt| ¡ƒ|jdSdS©Nrr;)r+r:Úsearchr2r<r=)rr3r"rBr>rrr Ú re_lookupSs  zcommands.re_lookupFc Cs| d||f¡|r2tj |¡}tj |¡r2d}zh|rBt |¡|rt|j|dd� ¡t|ƒkrt| d|¡WdSt |dƒ}|  t|ƒ¡|  ¡d}Wn`t t fyú} zDd}t|tƒrÀ|rÔt|tƒræ| j|vræ| d|| f¡WYd} ~ n d} ~ 00|S) ahWrite data to a file. Parameters: f -- filename where to write data -- data to write makedir -- if True and the path doesn't exist, it will be created no_error -- if True errors are silenced, it can be also list of ignored errnos ignore_same -- if True and the write would not change the file, it is skipped Return: bool -- True on success zWriting to file: '%s' < '%s'FT)Úno_errorz=Skipping the write to file '%s', the content would not changeÚwz Writing to file '%s' error: '%s'N)rÚosÚpathÚdirnameÚisdirÚmakedirsÚ read_filerrÚopenÚwriteÚcloseÚOSErrorÚIOErrorÚ isinstanceÚboolr2Úerrnor) rÚfÚdataZmakedirrHZ ignore_samer3ÚfdÚrcÚerrr Ú write_to_file]s0     ÿÿ(zcommands.write_to_filer)c Csx|}zt|dƒ}| ¡}| ¡Wn>ttfy`}z"|sL| d||f¡WYd}~n d}~00| d||f¡|S)NrBz"Error when reading file '%s': '%s'z Read data from file: '%s' > '%s')rPÚreadrRrSrTrr)rrXÚerr_retrHÚ old_valuerZr\rrr rO€s  (zcommands.read_filec Csp| d|¡tj |¡rlzt ||¡Wn@tyj}z(|sTt d|t |ƒf¡WYd}~dSd}~00dS)NzRemoving tree: '%s'zcannot remove tree '%s': '%s'FT) rrJrKÚexistsÚshutilÚrmtreerSr r r©rrXrHr rrr rcŒs zcommands.rmtreec Csn| d|¡tj |¡rjzt |¡Wn@tyh}z(|sRt d|t|ƒf¡WYd}~dSd}~00dS)NzRemoving file: '%s'zcannot remove file '%s': '%s'FT) rrJrKraÚunlinkrSr r rrdrrr re—s zcommands.unlinkc Csj| d||f¡zt ||¡WnBtyd}z*|sNt d||t|ƒf¡WYd}~dSd}~00dS)NzRenaming file '%s' to '%s'z%cannot rename file '%s' to '%s': '%s'FT)rrJÚrenamerSr r r)rÚsrcÚdstrHr rrr rf¢szcommands.renamec Cshz$t d||f¡t ||¡WdStyb}z&|sLt d|||f¡WYd}~dSd}~00dS)Nzcopying file '%s' to '%s'Tz!cannot copy file '%s' to '%s': %sF)r rrbÚcopyrTr )rrgrhrHr\rrr ri¬s z commands.copyc Cs6| |¡}t|ƒdkrdS| |tj|||tjd�¡S©NrF©rC)rOr+r]r r!Ú MULTILINE)rrXÚpatternÚreplrYrrr Úreplace_in_file¶s  zcommands.replace_in_filecCs4| |¡}t|ƒdkrdS| ||j||tjd�¡Srj)rOr+r]rDr rl)rrXr3rYrrr Úmultiple_replace_in_file¾s  z!commands.multiple_replace_in_filecCs²| |¡}|D]–}t|ƒ}t||ƒ}tjd|d|tjd�durz|r¤t|ƒdkrh|ddkrh|d7}|d||f7}qtjd|d d | |¡d |tjd�}q| ||¡S) Nz\bz\s*=.*$rkréÿÿÿÿÚ z%s="%s" z\b(z\s*=).*$z\1"ú") rOrr rFrlr+r!r(r])rrXr3ÚaddrYÚoptÚorrrr Úadd_modify_option_in_fileÈs  ,z"commands.add_modify_option_in_filecCs"| |¡}t t|ƒ d¡¡ ¡S©Nzutf-8)rOÚhashlibZmd5rÚencodeÚ hexdigest©rrXrYrrr Úmd5sumØs zcommands.md5sumcCs"| |¡}t t|ƒ d¡¡ ¡Srx)rOryZsha256rrzr{r|rrr Ú sha256sumÝs zcommands.sha256sumcCs| tj|¡ ¡Sr)rOÚconstsZMACHINE_ID_FILEr)rrHrrr Úget_machine_idâszcommands.get_machine_idc CsXd}tj ¡}d|d<| |¡| dt|ƒ¡d} d} z†t|tt|||ddd�} |  ¡\} } | j }|r¾||vr¾d|vr¾| dd…} t | ƒdkrž| dd…} d d   |¡| f} |s¾|  | ¡Wnzt tf�y:}z\|jdurè|j nd}t|ƒ|v�r&d|v�r&d d   |¡|f} |�s&|  | ¡WYd}~n d}~00|�rL|| | fS|| fSdS) NrÚCÚLC_ALLz Executing %s.r)T)ÚstdoutÚstderrÚenvÚshellÚcwdZ close_fdsZuniversal_newlinesrqzExecuting '%s' error: %sr)rJÚenvironriÚupdaterrÚPopenÚPIPEZ communicateÚ returncoder+r8rrSrTrWÚabs)rÚargsr†r‡r…Z no_errorsZ return_errZretcodeZ _environmentÚoutÚerr_msgÚprocÚerrZerr_outr\rrr Úexecuteès@  ü      zcommands.executecCs.t d|¡}|r| d¡S|r*| ¡dS|S)Nz.*\[([^\]]+)\].*r;r)r ÚmatchÚgroupÚsplit)rÚoptionsZdosplitÚmrrr Úget_active_options    zcommands.get_active_optioncCs,t|ƒ}|dkp*|jd|ddd� ¡dkS)Nrz$/sys/devices/system/cpu/cpu%s/onlinerT)r_rH)rrOr)rÚcpuZscpurrr Ú is_cpu_onlineszcommands.is_cpu_onlinecCs^|dur dSt|ƒ dd¡}zt|dƒ}Wn(tyRt dt|ƒ¡gYS0| |¡S)Nú,r)ézinvalid hexadecimal mask '%s')rr'ÚintÚ ValueErrorr r Úbitmask2cpulist)rÚmaskr˜rrr Ú hex2cpulists  zcommands.hex2cpulistcCs8d}g}|dkr4|d@r"| |¡|dL}|d7}q|SrE)Úappend)rr¡ršÚcpusrrr r *s  zcommands.bitmask2cpulistú'"c Cs^g}|dur|S|}t|ƒturD|dur6t|ƒ |¡}t|ƒ d¡}g}g}d}d}|D�]} t| ƒ} |r”t| ƒdkrŠd}| |¡d}n|| 7}qX| dd… ¡dkr²d}| }qX| �rT| ddksÒ| dd k�rT| d d… d ¡} zPt| ƒd k�r|ttt | dƒt | d ƒd ƒƒ7}n| t | d d…ƒ¡Wnt �yPgYS0qXt| ƒdkrX| | ¡qXt|ƒdk�r„| |¡|D] } |  d ¡} | dd… ¡dk�r¼||  | ¡7}njzLt| ƒd k�rô|ttt | dƒt | d ƒd ƒƒ7}n| t | dƒ¡Wnt �y$gYS0�qˆt tt |ƒƒƒ} |D]}|| v�r>|  |¡�q>| S) NrœFr)réÚ0xTú^ú!r;ú-)Útyper2rrr–r+r£ÚlowerÚrangeržrŸr¢r0ÚsetÚremove)rr4Z strip_charsÚrlZllZll2Z negation_listZhexmaskZhvrÚsvÚnlZvlZcpu_listršrrr Úcpulist_unpack=sj       þ     ( zcommands.cpulist_unpackcCsð| |¡}|dust|ƒdkr"|Sd}|}g}|dt|ƒkr¦||d||dkrœ||kr‚| t||ƒdt||ƒ¡n| t||ƒ¡|d}|d7}q.|dt|ƒkrÚ| t||ƒdt|dƒ¡n| t|dƒ¡|S)Nrr;rªrq)r³r+r£r)rr4r5Újr°rrr Ú cpulist_pack�s" $ $zcommands.cpulist_packcCs.| |¡}| | d¡¡}tt|ƒt|ƒƒS)Nz/sys/devices/system/cpu/online)r³rOr2r®)rr4r¤Zonlinerrr Úcpulist_invert—s zcommands.cpulist_invertcs†|dur dS| |¡}|dur"dS| |¡}d|‰tˆƒ}|ddkrX|d|d7}ˆ |¡‰d ‡fdd„tdtˆƒdƒDƒ¡S)Nz%xérrœc3s|]}ˆ||d…VqdS)r·Nr)Ú.0r5©r"rr Ú ©rAz'commands.cpulist2hex..)r³Úcpulist2bitmaskr+Úzfillr8r­)rr4Zulr˜Zlsrr¹r Ú cpulist2hex�s    zcommands.cpulist2hexcCs d}|D]}|td|ƒO}q|S)Nrr¦)Úpow)rr4r˜rrrr r»«szcommands.cpulist2bitmaskcsd ‡fdd„|Dƒ¡S)Nrœc3s|]}ˆt|ƒVqdSr©r©r¸r©Úprefixrr rº²rAz*commands.cpulist2string..)r8)rr4rÂrrÁr Úcpulist2string±szcommands.cpulist2stringcCsb|dd… ¡dkrH|dd…}|dd… ¡dkrHdd„| |¡DƒSt d|¡}dd„|DƒS)Nrr·zcpulist:cSsg|]}dt|ƒ‘qS)ršr¿rÀrrr Ú ¼rAz(commands.devstr2devs..z\s*(?td|ƒ‚WYd}~n>d}~0t t f�y†}ztd|ƒ‚WYd}~n d}~00|dk�r˜d}n |tj k}|dk�r°d}||fS)Nr)rBz!Failed to read active profile: %szInvalid value in file %s.zFailed to read profile mode: %s)rPrÚACTIVE_PROFILE_FILEr^rrTrWÚENOENTrrSÚEOFErrorÚPROFILE_MODE_FILEÚACTIVE_PROFILE_AUTOÚACTIVE_PROFILE_MANUAL)rÚ profile_nameÚmoderXr\Úmanualrrr Úget_active_profileÞs4.  " 2 "   zcommands.get_active_profilec Cs zFttjdƒ�&}|dur&| |d¡Wdƒn1s:0YWn6ttfy|}ztd|jƒ‚WYd}~n d}~00zNttjdƒ�.}|r˜tj ntj }| |d¡Wdƒn1sÀ0YWn8ttf�y}ztd|jƒ‚WYd}~n d}~00dS)NrIrrz!Failed to save active profile: %szFailed to save profile mode: %s) rPrrÐrQrSrTrÚstrerrorrÓrÕrÔ)rrÖrØrXr\r×rrr Úsave_active_profileûs0$0zcommands.save_active_profilec CsÀd}z.)Úallr+rZNAMES_MAX_LENGTH)rÚnamerrr Ú is_valid_name)szcommands.is_valid_namecCstd|gƒ ¡ ¡S)NÚgetconf)Z check_outputÚdecoder)rÚvariablerrr rë,szcommands.getconfcCs | tj¡}|r| |¡SdgSrà)rOrZSYSFS_CPUS_PRESENT_PATHr³)rr¤rrr Úget_cpus0s zcommands.get_cpus)T)r%r%)r%)Nr)N)FFF)r)F)F)F)F)F)T)T)T)r¥)r))2Ú__name__Ú __module__Ú __qualname__r rrrr#r$r(r*r/r6r:rDrGr]rOrcrerfrirorprwr}r~r€r“r™r›r¢r r³rµr¶r½r»rÃrÅrÆrÏrÙrÛrÞrßrærêrërîrrrr rs^     #   '   D    r)rWryZ tuned.logsZtunedrirJrbZ tuned.constsrr Ú subprocessZtuned.exceptionsrZlogsrr rrrrr Ús