fjddlZddlZddlZddlmZddlmZmZddlmZddl m Z ddl m Z ddlmZddlmZGd d eZd Zd Zd ZdZdZdZdS)N)Enum)datetime timedelta)docroot)wp_get_constant)gettext) user_context) disable_quotaceZdZdZdZdZdZdS)PluginStatusesa INSTALLED = plugin exists in MU directory ERROR = plugin should have been installed: there are advices w/o incompatibility and created_at > 2days (wordpress-install cron expected to trigger install) NOT_INSTALLED = plugin does not exist in MU directory: in ideal world it means whether there are no compatible advices or wordpress-plugin install cron has not worked yet INSTALLEDERROR NOT_INSTALLEDN)__name__ __module__ __qualname____doc__r rrW/opt/cloudlinux/venv/lib64/python3.11/site-packages/xray/smart_advice_plugin_helpers.pyr r s)  I E#MMMrr c tj|rdStj|}t |j|j5t5 tj |nQ#t$rD}tj d|t|ttdd}~wwxYw dddn #1swxYwYddddS#1swxYwYdS)z5 Creates MU plugin dir if does not exist yet Nztj|r!tj|r|Sd}t j|}t|j|j 5 t|dd}n9#t$r,}tj d t|Yd}~nd}~wwxYw|so t|d d}|r tj|d}n9#t$r,}tj d t|Yd}~nd}~wwxYwdddn #1swxYwY|S) z Resolve path to MU plugins directory for given site. Fast path: /wp-content/mu-plugins (and presence of our plugin there). Fallback: read WPMU_PLUGIN_DIR or WP_CONTENT_DIR via wp_get_constant (wp-cli), under user context. z wp-contentz mu-pluginscl-smart-advice.phpzcl-smart-adviceNWPMU_PLUGIN_DIRT)raise_exceptionz3Unable to read WPMU_PLUGIN_DIR constant, "error=%s"WP_CONTENT_DIRz2Unable to read WP_CONTENT_DIR constant, "error=%s")rrjoinrisfilerrr rrr Exceptionr!r"r#) r& full_wp_pathfast_mu fast_mu_filefast_mu_folder mu_directoryr(r) content_dirs rget_mu_directoryr95s)gll<|DDG7<<)>??LW\\'+<==N w}}W"'..">">27==Q_C`C`L T""I i& (8 9 9 \ \ Y*<9J\`aaaLL Y Y Y MOQTUVQWQW X X X X X X X X Y \ \-l>. / //rc@g|r d|Dfd|DS)z 1. At least 1 advice has no incompatibilities 2. The newest advice w/o incompatibilities was created > 2 days ago cg|] }|d S) advice_typer).0issues r z.should_have_been_installed..hs@@@u]+@@@rc4g|]}t||Sr)is_advice_should_been_synced)rEadvice issue_typess rrGz.should_have_been_installed..js9     ' < <    rr)advices_for_websiteissuesrKs @rshould_have_been_installedrNasQ K A@@@@@     )   rctj|d}|dd|vo-|tj|jt dz kS)z If advice does not have incompatibility and older than cron time (once a day) -> it should have been synced, which triggers plugin installation created_atrJtype)days)r fromisoformatnowtzinfor)rJwebsite_issue_typesrPs rrIrIps] '|(<==J ( F #+> > M j&7889!;L;L;LL LMrct|||rtjjSt ||rtjjStjjS)aJ If smart-advice.php in MU plugin dir -> INSTALLED If there is at least 1 advice w/o issues and the newest advice is > 2 days -> cron should've work and install plugin, most likely error happened -> ERROR otherwise: NOT_INSTALLED: all advices are incompatible or wordpress-plugin install cron did not work yet )rAr r valuerNrr)usernamer=r>rMcurrent_advicess rget_plugin_statusr\ysN8VW55*'-- #OV < <*#))  ' --r)rrr!enumrrrclcommon.cpapir!xray.internal.clwpos_safe_importsrxrayrr%xray.internal.utilsr secureior r r*r9rArNrIr\rrrrcs; ((((((((""""""======,,,,,,""""""$$$$$T$$$ III"@ 0 0 0   MMM . . . . .r