§ sÃjoãó—ddlZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z ddlmZmZdd lmZe e¦«Zd Zd efd „ZGd „d¦«ZGd„de¦«ZGd„de¦«ZGd„de¦«Zd„Zd„ZdS)éN)ÚPath)ÚDict)Ú WposError)Ú USER_WPOS_DIR)Ú setup_logging)ÚALL_OPTIMIZATION_FEATURES)Úhome_dirÚis_run_under_user)Úwrite_file_via_tempfilez.progress-statusÚreturncóP—tt¦«tt¦«S)N)rr rÚPROGRESS_STATUS_FILE_NAME©óú py/clwpos/user/progress_check.pyÚget_progress_file_pathrs€Ý •‘ ” �MÕ+DÑ EÔ EÐErc󜇗eZdZUdZeed<ˆfd„Zd„Zdee effd„Z d d„Z d d „Z d d „Z d d „Zedee effd „¦«ZˆxZS)ÚCommandProgresszK Class to represent user's AccelerateWP utility commands progress. Ú total_stagesc ó•—d„| ¦«D¦«}||vr4td|›dt| ¦«¦«›�¦«‚||}t t |¦« |¦«}|S)Ncó—i|] }|j|“Œ Sr)Úcommand)Ú.0Úsubclasss rú z+CommandProgress.__new__..$s*€ð ð ð Ø+3ˆHÔ ˜hð ð ð rzInternal Error: command "z&" is not allowed, available commands: )Ú__subclasses__rÚlistÚkeysÚsuperrÚ__new__)ÚclsrÚcommand_subclass_maprÚinstanceÚ __class__s €rr zCommandProgress.__new__#sµø€ð ð Ø7:×7IÒ7IÑ7KÔ7Kð ñ ô Ðð Ð.Ð .Ð .ÝðW¸ðWðWÝ37Ð8L×8QÒ8QÑ8SÔ8SÑ3TÔ3TðWðWñXôXð Xà'¨Ô0ˆÝ�¨(Ñ3Ô3×;Ò;¸HÑEÔEˆØˆrcó‚—t¦«std¦«‚t¦«|_d|_d|_dS)Nz;Internal Error: trying to use CommandProgress class as rootFr)r rrÚ progress_fileÚ in_progressÚcompleted_stages)ÚselfÚargss rÚ__init__zCommandProgress.__init__.sD€Ý Ñ"Ô"ð [ÝÐYÑZÔZÐ ZÝ3Ñ5Ô5ˆÔØ ˆÔØ !ˆÔÐÐrr có —|j|jdœS)zF Return number of total and completed stages as dict. ©rr(r-©r)s rÚas_dictzCommandProgress.as_dict5s€ð !Ô-Ø $Ô 5ð ð ð rNcóŽ—d|_d|_|jj ddd¬¦«| ¦«dS)z= Start tracking the progress of the command. TriÀ)ÚmodeÚparentsÚexist_okN)r'r(r&ÚparentÚmkdirÚ_update_progress_filer.s rÚstartzCommandProgress.start>sM€ð ˆÔØ !ˆÔØ ÔÔ!×'Ò'¨U¸DÈ4Ð'ÑPÔPÐPØ ×"Ò"Ñ$Ô$Ð$Ð$Ð$rcóž—|jsdS|xjdz c_|j|jkrtd¦«‚| ¦«dS)zg Update progress status by incrementing the number of completed stages by one. NézYInternal Error: the number of completed stages is greater than the total number of stages)r'r(rrr6r.s rÚupdatezCommandProgress.updateGsj€ð Ôð Ø ˆFØ ÐÔ Ñ"ÐÔØ Ô  4Ô#4Ò 4Ð 4Ýð=ñôð ð ×"Ò"Ñ$Ô$Ð$Ð$Ð$rcó¦—|jsdSd|_|j|_|j ¦«r|j ¦«dSdS)zF Complete progress, delete file with progress status. NF)r'rr(r&ÚexistsÚunlinkr.s rÚcompletezCommandProgress.completeVsc€ðÔð Ø ˆFØ ˆÔØ $Ô 1ˆÔØ Ô × $Ò $Ñ &Ô &ð (Ø Ô × %Ò %Ñ 'Ô 'Ð 'Ð 'Ð 'ð (ð (rcóz—ttj| ¦«¦«|jd¦«dS)Ni¤)r ÚjsonÚdumpsr/r&r.s rr6z%CommandProgress._update_progress_filebsA€õ Ý ŒJ�t—|’|‘~”~Ñ &Ô &¨Ô(:¸Eñ Cô Cð Cð Cð Crcó°—t¦«}dddœ}| ¦«s|S t|d¦«5}tj| ¦«¦«}ddd¦«n #1swxYwYt |d¦«t |d¦«dœS#t$r'}t  d|¦«|cYd}~Sd}~wwxYw) zu Return current progress status of the command execution, getting it from from special file. r9rr-ÚrNrr(z$Can't parse progress status json: %s) rr<Úopenr@ÚloadsÚreadÚintÚ ExceptionÚloggerÚerror)r&ÚdefaultsÚfÚstatus_from_fileÚes rÚ get_statuszCommandProgress.get_statusis-€õ /Ñ0Ô0ˆ Ø$%¸1Ð=Ð=ˆà×#Ò#Ñ%Ô%ð ØˆOð Ý�m SÑ)Ô)ð 8¨QÝ#'¤:¨a¯fªf©h¬hÑ#7Ô#7Ð ð 8ð 8ð 8ñ 8ô 8ð 8ð 8ð 8ð 8ð 8ð 8øøøð 8ð 8ð 8ð 8õ!$Ð$4°^Ô$DÑ EÔ EÝ$'Ð(8Ð9KÔ(LÑ$MÔ$Mððð øõð ð ð Ý �LŠLÐ@À!Ñ DÔ DÐ D؈OˆOˆOˆOˆOˆOøøøøð øøøs@«B$»'A.Á" B$Á.A2Á2B$Á5A2Á6-B$Â$ CÂ.Cà CÃC)r N)Ú__name__Ú __module__Ú __qualname__Ú__doc__rGÚ__annotations__r r+rÚstrr/r7r:r>r6Ú staticmethodrOÚ __classcell__)r$s@rrrsø€€€€€€ðððÐÐÑð ð ð ð ð ð"ð"ð"𠘘c 3˜hœð ð ð ð ð%ð%ð%ð%ð %ð %ð %ð %ð (ð (ð (ð (ðCðCðCðCðð˜˜S #˜Xœðððñ„\ðððððrrcó0—eZdZUdZdZeed<dZeed<dS)ÚEnableCommandProgresszS Class to represent user's AccelerateWP utility "enable" command progress. Úenableré rN© rPrQrRrSrrUrTrrGrrrrYrY�s>€€€€€€ððð€GˆSÐÐÑØ€L�#ÐÐÑÐÐrrYcó0—eZdZUdZdZeed<dZeed<dS)ÚDisableCommandProgresszL Class to represent user's WPOS utility "disable" command progress. ÚdisablerérNr\rrrr^r^‰s>€€€€€€ððð€GˆSÐÐÑØ€L�#ÐÐÑÐÐrr^có<—eZdZUdZdZeed<dZeed<de fd„Z dS) ÚGetCommandProgresszH Class to represent user's WPOS utility "get" command progress. Úgetré rÚ user_infocóÆ—d}t|¦«}td„| ¦«D¦«¦«}||z}||tt¦«zz|_dS)a" Recalculate and change total number of progress stages depending on the number of user's docroots and wordpresses. so we could update progress after checking every docroot and wordpress. Example of user_info structure: { 'docroot1': {'wps': [{'path': '', 'version': '5.9'}, {'path': 'wp2', 'version': '5.9'}], ... }, 'docroot2': {'wps': [{'path': '', 'version': '5.9'}], ... }, } éc3ó@K—|]}t|d¦«V—ŒdS)ÚwpsN)Úlen)rÚ doc_root_infos rú zHGetCommandProgress.recalculate_number_of_total_stages..¨s@èè€ð" ð" Ø*7�C� ˜eÔ$Ñ %Ô %ð" ð" ð" ð" ð" ð" rN)rjÚsumÚvaluesrr)r)reÚnumber_of_initial_stagesÚnumber_of_docrootsÚnumber_of_wordpressÚtotal_checks_per_modules rÚ"recalculate_number_of_total_stagesz5GetCommandProgress.recalculate_number_of_total_stages˜s�€ð$%Ð Ý  ™^œ^ÐÝ!ð" ð" Ø;D×;KÒ;KÑ;MÔ;Mð" ñ" ô" ñ ô Ðð#5Ð7JÑ"JÐØ4Ø%­Õ,EÑ(FÔ(FÑFñGˆÔÐÐrN) rPrQrRrSrrUrTrrGÚdictrsrrrrbrb‘sd€€€€€€ððð€GˆSÐÐÑØ€L�#ÐÐÑðG¸DðGðGðGðGðGðGrrbcóF‡—tj‰¦«ˆfd„¦«}|S)zX Decorator for the WPOS utility commands we want to track the progress for. có•—t‰j d¦«¦«|_|j ¦« ‰|g|¢Ri|¤Ž|j ¦«S#|j ¦«wxYw)NÚ_)rrPÚstripÚcommand_progressr7r>)r)r*ÚkwargsÚfuncs €rÚwrapperz'track_command_progress..wrapperµs�ø€å /°´ ×0CÒ0CÀCÑ0HÔ0HÑ IÔ IˆÔØ Ô×#Ò#Ñ%Ô%Ð%ð -Ø�4˜Ð.˜tÐ.Ð.Ð. vÐ.Ð.à Ô !× *Ò *Ñ ,Ô ,Ð ,Ð ,øˆDÔ !× *Ò *Ñ ,Ô ,Ð ,Ð ,øøøs Á A-Á-B©Ú functoolsÚwraps©r{r|s` rÚtrack_command_progressr�°s:ø€õ „_�TÑÔð-ð-ð-ð-ñÔð-ð €NrcóF‡—tj‰¦«ˆfd„¦«}|S)zu Decorator for the WPOS utility methods after which the counter of completed operations must be updated. cór•—‰|g|¢Ri|¤Ž}t|d¦«�|j ¦«|S)Nry)Úgetattrryr:)r)r*rzÚresultr{s €rr|z(update_command_progress..wrapperÅsMø€à��dÐ,˜TÐ,Ð,Ð, VÐ,Ð,ˆÝ �4Ð+Ñ ,Ô ,Ð 8Ø Ô !× (Ò (Ñ *Ô *Ð *؈ rr}r€s` rÚupdate_command_progressr†Às:ø€õ „_�TÑÔððððñÔðð €Nr)r~r@ÚpathlibrÚtypingrÚclwpos.cl_wpos_exceptionsrÚclwpos.constantsrÚclwpos.logsetuprÚclwpos.optimization_featuresrÚ clwpos.utilsr r Úsecureior rPrIrrrrYr^rbr�r†rrrúr�sÆððÐÐÐØ € € € ØÐÐÐÐÐØÐÐÐÐÐà/Ð/Ð/Ð/Ð/Ð/Ø*Ð*Ð*Ð*Ð*Ð*Ø)Ð)Ð)Ð)Ð)Ð)ØBÐBÐBÐBÐBÐBØ4Ð4Ð4Ð4Ð4Ð4Ð4Ð4Ø,Ð,Ð,Ð,Ð,Ð,à ˆ�xÑ Ô €à.ÐðF ðFðFðFðFðaðaðaðaðañaôaðaðHðððð˜Oñôðððððð˜_ñôððGðGðGðGðG˜ñGôGðGð> ð ð ð ð ð ð ð r