ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ iB^c@`srddlmZddlmZddlmZddlZddlZddlZddlZddlm Z m Z ddl m Z ddl Z ddlmZmZddlmZdd lmZmZmZdd lmZdd lmZmZmZdd lmZdd lm Z de!fdYZ"de!fdYZ#defdYZ$e%dZ&dS(i(tprint_function(tdivision(tabsolute_importN(tAnyStrtOptional(t iteritems(t get_abs_reltrun_process_in_cagefs(tdrop_privileges(tBaseSelectorErrortMissingVirtualenvErrortMissingAppRootError(t WSGI_PATH(tClSelectExceptt clpassengert clselectctl(tBaseApplicationsManager(t PythonManagertPythonAppFormatVersioncB`seZdZdZdZRS(s@ Class represents possible python application versions. ii(t__name__t __module__t__doc__tLEGACYtSTABLE(((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyR#stPythonVenvFormatVersioncB`seZdZdZdZRS(sJ Class represents possible python application venv path versions. ii(RRRRR(((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyR.stApplicationsManagercB`seZdZdZdZdZdZdZdZdZ dZ ddZ e d Z d Zd Zdd Zdd ZdZdZdZdZddZdZddZdZeedZddZRS(s!.cl.selector/python-selector.jsons/var/lve/.py.migration.statuss!.cl.selector/.py.migration.statuss//var/log/cloudlinux/py-selector/app_imports.logsimported_pip_requirements.txttpythont virtualenvcC`stt|jtdS(N(tsuperRt__init__R(tself((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyRDscC`stt|j||d|S(Ntpatterns(RRt_find_config_files(Rt user_namet app_directoryR((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyR HscC`sdj|g}|S(s Return lines for htaccess that are specific to the python interpreter :param binary_path: path to the environment's python binary :param app_config: application's config dictionary sPassengerPython "{}" (tformat(t binary_patht app_configtspecific_lines((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyt(get_interpreter_specific_passenger_linesLscC`s-ddlm}i}i}|j|}xttj|D]\}}|d|jkrfqAnyutjj |dtj } tjj | s|j d|wAnt | } | j} WdQX|j| } | r| j} | d}| d}n d }}tjjtjjtjj|d }|d d}y||d }Wntk rztj}nXi |d 6|d 6|d6|dd6dd6|pt d6gd6id6|pdd6}|||tj+t|d}|j| |jWdQXWdQXdS(s Generates requirements file from python apps :param user: username :param app_root: app root :param app_logger: app logger Ni(RRtHOMER-tfreezes-lRit returncodes/Error during generation pip requirements file. toutputtfailedtw(RR7R8R9RzRR3RRtpipRRRqRR;tstrR tExternalProgramFailedRtRuR<twritetclose(RRGRRdtapp_patht_treq_pathRRtpip_patht user_homeRitmodulesRRN((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyRyys.      c C`s|jj|j}t||\}}tjj||}|rgtjj| rgt|ntjj||}|rtjj| rt |n||fS(s Calculate, check exists and return application folders This method does not check that application exists in config. :raises: NoSuchUserException, MissingVirtualenvError, MissingAppRootError :return: tuple(app_root, app_venv) with absolute paths ( t_pwdtget_pw_by_nameRqtget_venv_rel_pathR7R8R9RR R ( RRRtchk_envt chk_app_rootRRtrel_pathtapp_venv((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pytget_app_foldersscC`s[|j||}|dkr*|j}nt||\}}tjj|||d|S(s Return a path to the environment's interpreter binary Get interpreter path for application :param user: owner of the application :param app_root: app path relative to user home (app-root) :param user_dir: User's home directory :param binary_name: name of binary in virtual environemnt (python, npm, node) :return: path to interpreter binary in virtual environment tbinN(tget_interpreter_version_for_appRpt BINARY_NAMERR7R8R9(RRGRtuser_dirt binary_nametversionRR((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pytget_binary_paths   (N(RRt _USER_CONFIGRRR^RzR6tVENV_DIRRRR t staticmethodR'RWRgRpRRR~RRRRRRRyRRR(((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyR:s2   F  L         &cC`st|tjjtj|\}}t|tjjtjtj|\}}|dkrtjj |r|tj|krt j |fSt j |fS|t j krt j |fS|t j krt j |fSt d|dS(s6 Get path to users VENV relative to home dir. Old python selector transforms app_root using get_prefix() method before creating venv directory. We should handle both cases: - when app is from old selector - when app is from new selector and return right env directory. If both old and new vevns exist we use old one. Return tuple with two values: - detected version of venv path (LEGACY for path with replacements "/" -> "_" & "_" => "__" and STABLE in other case) - path to venv relative to user's home dir sunknown version `%s`N(RR7R8R9RRRt get_prefixRpRRRRt ValueError(RGR*RRt new_rel_dirt old_abs_dirt old_rel_dir((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyRs'- '    ('t __future__RRRRYR7RRttypingRRt future.utilsRRttclselect.utilsRRtclcommon.clpwdRtclselect.baseclselectR R R tclselect.clpassengerR tclselectR RRt"clselect.baseclselect.apps_managerRt&clselect.clselectpython.python_managerRtobjectRRRRpR(((sU/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectpython/apps_manager.pyts*