%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/clselect/
Upload File :
Create Path :
Current File : //proc/227033/root/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyc

�
i�B^c	@`sddlmZddlmZddlmZddlZddlZddlZddljj	j
ZddlZddl
mZddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZmZddlmZm Z dZ!eZ"de$d�Z%dd�Z&d�Z'd�Z(dd�Z)ddddddddd�Z*d�Z+dd�Z,dd�Z-dd�Z.dd�Z/dd�Z0ddd�Z1de$dd�Z2d �Z3d!�Z4dS("i(tprint_function(tabsolute_import(tdivisionN(tConnectionError(t	iteritemsi(tclpassenger(tclselectctl(tutils(tuserdomains(tClSelectExcept(tApplicationsManager(tenvironmentstinterpreters(tAPP_STARTED_CONSTtAPP_STOPPED_CONSTsapp.jscC`s�t||�}|s|}ntj|||�}|j�sF|r�ytjdd�|}Wn tk
r�tj|��nX|j|d|�n|S(Ntkeytversiont
destroy_first(	t_get_prefixRtEnvironmenttexistsRtKeyErrorR	tNoSuchAlternativeVersiontcreate(tusert	directoryRtenv_nameRtprefixtenvironmenttinterpreter((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_create_environment!s	
cC`s�t||�}|dkrmtj|�}ytj|||�}Wqmtk
ritjd|��qmXn|d}t	j
jt	j
jt	j
j|���}t
j|||�}|S(Ns8No such application (or application not configured) "%s"tbinary(RtNoneRtsummaryRtget_using_realpath_keysRR	tNoSuchApplicationtostpathtbasenametdirnameRR(RRtapp_summaryRtuser_summaryRRR((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_get_environment/s

*cC`s.tj||�\}}tjjtj|�S(N(Rtget_abs_relR$R%tjoinRtDEFAULT_PREFIX(RRt_trel_dir((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyR?scC`sAddlm}|j�j|�s=tj||d��ndS(s�
    Check whether particular interpreter version is enabled and raises
    exception if not
    :param user: user to include in exception
    i(tnode_managersversion is not enabledN(tclselectnodejsR0tNodeManagertis_version_enabledR	tUnableToSetAlternative(RRR0((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_ensure_version_enabledDscC`s�|dkrt�}ntj||�\}}|j|�}xM|j�D]?}tj||�\}}|tjj|tj�rL|SqLWdS(s�
    Return None if new_app_directory is not nested inside an existing
    user application, and the name of conflicting application otherwise
    N(	R R
RR+tget_user_config_datatkeysR$tsept
startswith(tnew_app_directoryRtapps_managertabs_app_pathR.tfull_configtexisting_apptexisting_app_abs_path((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_get_existing_nesting_app_forPscC`s�|	dkrt�}	n|dkr6tjd��nt||�|dkrXt}n|dkrmi}n|dkr�d}nt|||	�}|dk	r�tj|��ntj	|�}t
|||�}|j�j}
t
j||||	j|
d|d|d|
�t
j||�|sWt
j|�}tj|||�}|d}ni|d6|d6|d	6td
6|d6|d6gd
6|d6}|
r�|
|d<n|	j|||�dS(s�
    Create application
    :param user: unix user name
    :param directory: application path in user's home (app-root)
    :param alias: alias (app-uri)
    :param version: version of interpreter
    :param doc_root: doc_root
    :param app_mode: application mode for nodejs
    :param env_vars: dict with enviroment variables
    :param startup_file: main application file
    :param domain_name: domain name
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :param passenger_log_file: Passenger log filename to write to app's .htaccess
    :return: None
    sNot passed version as argumentt
productiontdoc_roottstartup_filetpassenger_log_filetdomainunodejs_versionudomainuapp_uriu
app_statusustartup_fileuapp_modeuconfig_filesuenv_varsupassenger_log_fileN(R R
R	t	WrongDataR5tDEFAULT_STARTUP_FILER@tBusyApplicationRootRt	get_aliasRRRRt	configuretINTERPRETERtrestartR!RR"tDEFAULT_APP_STATEtadd_app_to_config(RRtaliasRRBtapp_modetenv_varsRCtdomain_nameR;RDtconflicting_appRRtsummary_dataR(tapp_data((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyRcsJ
			


cC`sd}tjjtj|�j|d�}tjj|�r~ytj|�Wq�tk
rzt	j
di|d6��q�Xn$tjj|�r�t	j|��ntjj|d�}tjj|�s�tj
|d�nytj||�Wn$tk
rt	jd|��nXdS(	s�
    Creates symlink to app's node_modules in app_root
    :param username: user name
    :param environment_path: Path to app's virtual environment
    :param app_root: Application root
    :return: None
    s�Cloudlinux NodeJS Selector demands to store node modules for application in separate folder (virtual environment) pointed by symlink called "node_modules". That`s why application should not contain folder/file with such name in application roottnode_moduless"Can`t remove symlink %(link_name)st	link_nameslib/node_modulesi�sError creating symlink. N(R$R%R,tpwdtgetpwnamtpw_dirtislinktremovetOSErrorR	tRemoveSymlinkErrorRtSymlinkErrortmakedirstsymlinktCreateSymlinkError(tusernametenvironment_pathtapp_roottmessageRWtlink_to((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_create_symlink_to_node_modules�s$
$

c
C`s�|dkrt�}n|j||�}|jd�tkr�tj|�j}dj|d|g�}yt	j
|�Wntk
r�nX|j|||�}t
j|�|j||�yt
j||�Wntjk
r�nXdSt
j|�}|j||�}	ytj|||�Wn.tk
rW|	rAdStjd|��nXt||�j}
tj||
�\}}yt	j
|�Wntk
r�nXt
j||�yt
j||�Wntjk
r�nXdS(sa
    Destroy web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    t
app_statust/tnodevenvNs8No such application (or application not configured) "%s"(R R
tget_app_configtgetRRXRYRZR,tshutiltrmtreeR]tget_htaccess_by_appdirRt$remove_passenger_lines_from_htaccesstremove_app_from_configRLR	tMissingApprootDirectoryR!RR"RRFR*RR+tunconfigure(
Rt
app_directoryRBR;t
app_configt	user_homet
nodevenv_paththtaccess_filenameR)t
app_in_configRtabs_dirR.((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytdestroy�sL


	
cC`s�|dkrt�}n|j||�}|dkrLtjd|��n|jd�tkredS|j|||�|j||t�t	j
||�dS(s`
    Starts web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    s8No such application (or application not configured) "%s"RiN(R R
RlR	RFRmR
tupdate_htaccess_filetset_app_statusRRL(RRuRBR;Rv((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytstart
s	
cC`s�|dkrt�}n|j||�}|dkrLtjd|��n|jd�tkrtt|||�ntj	||�dS(sb
    Restarts web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    s8No such application (or application not configured) "%s"RiN(
R R
RlR	RFRmRRRRL(RRuRBR;Rv((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyRL's	
cC`s�|dkrt�}n|j||�}|dkrLtjd|��n|jd�tkredS|j||||�}tj	|�|j
||t�tj||�dS(s_
    Stops web app with specified directory for specified user
    :param user: username
    :param app_directory: application directory
    :param doc_root: Document root for selected domain
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    s8No such application (or application not configured) "%s"RiN(R R
RlR	RFRmRRpRRqR~RL(RRuRBR;RvRy((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytstop@s	

c
C`s
d}d}d}tjjjtj�t|�sFtjd��ndj	d|d|�}idd	6}ytj
|d
td|�}Wnitk
r�|j
dd
�}ytj
|d
td|�}Wq�tk
r�tj||��q�XnX|jj
d�}	|jj
d�}
|�ytj
|d
td|�}Wn$tk
rftj||��nX|jj
d�}|jj
d�}|	j�|j�ks�|
|kr�|
dk	r�|
d dks�|dk	r|d dkrtj|||	|f��ndS(s@
    Check response from user's webapp before and after calling action.
    Also compare both responses
    :param domain: domain associated with webapp
    :param alias: URI associated with webapp
    :param action: called action, that make something with webapp: install modules, transit it, etc
    :return: None
    sTWeb application is inaccessible by its address "%s". The operation wasn't performed.s�The operation was performed, but check availability of application has failed. Web application is inaccessible by its address "%s" after the operation.s�The operation was performed, but check availability of application has failed. Web application responds, but its return code "%s" or content type before operation "%s" doesn't equal to contet type after operation "%s".s+Wrong action for calling in checking webappshttps://{domain}/{alias}REROsjMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 CentOS/3.6-2.el5.centos Firefox/3.6.13s
User-Agenttverifytheadersshttps://shttp://sContent-TypetStatusit500N(trequeststpackagesturllib3tdisable_warningsturllib_exceptionstInsecureRequestWarningtcallableR	RFtformatRmtFalseRtreplacetWebAppErrorR�tlowerR (
REROtactiontapp_is_inaccessible_beforetapp_is_inaccessible_aftert
app_is_brokent
webapp_urlR�trequesttbefore_mime_typet
before_statustafter_mime_typetafter_status((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytcheck_response_from_webapp^s@
		



(cC`s�|dkrtjd��n|dkr<tjd��n|d}t|�}g|D]+\}}tj|||d�rY|^qY}t|�dkr�tjd��n|d}||fS(s�
    Get info (alias and domain) about user's web application
    :param app_summary: dict -> summary info about user's web application
    :param user: str -> name of unix user
    :return: tuple -> (alias, domain)
    s3Was passed incorrect summary info about applications!Was passed incorrect name of userROtdocrootis-Can not found suitable domain for applicationN(R R	RFRRtrealpaths_are_equaltlen(R(RROtuser_domainsRERBt
found_domainst
app_domain((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt_get_info_about_webapp�s
%
t-c
`sE|d
krt�}n|j��}ytj��|�}Wn)tk
rktjdj����nX|dt	kr�t
}n|d}|d}|d}	tj���\�}
t��|	�������fd�}|s:yt
d|d|d|�WqAtjk
r6}tjd	|��qAXn|�d
S(s�
    Install nodejs extension to user's webapp
    :param user: name os unix user
    :param directory: directory with webapp (app-root)
    :param extension: name and version of extension
    :param skip_web_check: skip check web application after change it's properties
    :param apps_manager: Application Manager. Class that responsible
           for gathering and writing information about applications
    :return: None
    s%Record about application {} is absentRitapp_uriREtnodejs_versionc`s*�jd�d��tj���dS(Nt	extensiontcwd(textension_installRRL((R�RRR�R(sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyR��sROR�s3An error occured during installation of modules. %sN(R R
R6RR"RR	RFR�R
tTrueR+RR�R�(
RRR�tskip_web_checkR;tuser_configRUROR�R�R.R�terr((R�RRR�RsO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytinstall�s0
	


cC`s�i}x�ttj|��D]�\}}|dtjkrAqnt|||�j�}i|dd6|dd6|dd6|dd6||<d|krt|d�dkr|d||d<qqW|S(NRREROtnameRtdomainsi(RRR!R
RKR*tas_deepdictR�(RtsummRtdataR((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyR!�s""cC`sUt|�tk	rt�nx3|D]+}t||�ttgkr"t�q"q"W|S(N(ttypetdictt	TypeErrortstrtunicode(RQtitem((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pytvalidate_env_vars�s	

(5t
__future__RRRR$RXR�t$requests.packages.urllib3.exceptionsR�R�t
exceptionsR�Rntrequests.exceptionsRtfuture.utilsRtRRRtclcommon.cpapiRtclselectexceptR	tclselectnodejs.apps_managerR
tclselectnodejsuserRRtbaseclselectR
RRGRMR R�RR*RR5R@RRhR|RRLR�R�R�R�R!R�(((sO/opt/alt/python27/lib/python2.7/site-packages/clselect/clselectctlnodejsuser.pyt<module>sH			A	"C9/	

Zerion Mini Shell 1.0