5/9e: ddlmZddlZddlZddlZddlmZddlmZddl m Z ddl m Z ddl Z edd Zd Zd Zd Zd ZdZdS))absolute_importN)contextmanager)Iterable)CRASH_LOG_PATH)PackageMissingErrorTc#K|dz} t|d5}|V|r:|tj|dddn #1swxYwYtj|| tj|dS#ttf$rYdSwxYw# tj|w#ttf$rYwwxYwxYw)z Writeable file object that atomically updates a file (using a temporary file). :param filepath: the file path to be opened :param fsync: whether to force write the file to disk z.tmpwN) openflushosfsyncfilenorenameremoveIOErrorOSError)filepathrtmppathfs py/clwizard/utils.py atomic_writersFG  '3   %1GGG % $$$  % % % % % % % % % % % % % % % '8$$$  Ig     !    DD   Ig    !    D seB5AA& B5&A**B5-A*.B5BB21B25C#7C  C# C C#C  C#cd}tjD]H} t|}n#tj$rY6wxYw||rdSIdS)zQ Detects if the process installing modules is running in the background. cVhdt|kphdt|kS)N>/usr/sbin/cloudlinux-wizardinstall --no-async>/sbin/cloudlinux-wizardrr)set)cmdlines r_is_wizard_cmdlinez9is_background_process_running.._is_wizard_cmdline2s8 E D DG T TCCCs7||S TF)psutil process_iterlistr NoSuchProcess)r!procr s ris_background_process_runningr(-s    #%%    4<<>>**GG#    H   g & & 44  5s!<A Acttjd}ttd}t j||||S)Nr )stdinstdoutstderr)r r devnullr subprocessPopen)cmdfnull log_crashs rrun_backgroundr3GsH S ! !E^S))I       r"cb ddlm}n#t$rtdwxYw||S)Nr)"interpreter_versions_short_summary lvemanager)clselect.clselectctlr5 ImportErrorr) interpreterr5s rinstalled_interpreters_listr:RsV0KKKKKKK 000!,///0 - -k : ::s #cbd|dd|S)z Format version string e.g: 3.6.0 -> 3.6 if version size = 2 9.11.3 -> 9 if version size = 1 :param version given version to convert :param version_size expected size of result version string .N)joinsplit)version version_sizes rconvert_package_versionrAZs+ 88GMM#&&} }5 6 66r"ctj|}|tj tj|}tjd|_||n#t$rYnwxYw|S)z3 Logger setup for all modules :return: z*[%(levelname)s | %(asctime)s]: %(message)s) logging getLoggersetLevelINFO FileHandler Formatter formatter addHandlerr) logger_namelog_file app_loggerfhs r setup_loggerrOfs ";//J %%%"   * *( 8:: b!!!!      sA88 BB)T) __future__rr r.rC contextlibrtypingr constantsr exceptionsrr#rr(r3r:rArOr"rrVs'&&&&& %%%%%%%%%%%%++++++ ,4;;; 7 7 7r"