Ic@s`dZddkZddkZeidjoddklZn ddkZddkZddkl Z ddk l Z l Z l ZddkZddklZddkZdadd klZdd klZdd klZdd klZdd klZde fdYZdefdYZdefdYZde fdYZ!dS(s[ Provides the two commands for preparing an application: ``prepare-app`` and ``setup-app`` iNii(tstring24(tStringIO(tCommandt BadCommandtrun(tcopydir(t ConfigParser(t import_string(t appconfig(tuuid(tsecrettAbstractInstallCommandcBseZdZedfedfedfgZeiido6ei deei i eiddddfneiid o!ei deeid fnd Z d Z ee Z d Zdd ZdZdZdZdZdZdZRS(is/etc/paste/sysconfig.pys!/usr/local/etc/paste/sysconfig.pyspaste.script.default_sysconfigtHOMEis.pastetconfigs sysconfig.pytPASTE_SYSCONFIGcCs*|i|_g}x|o|didog|_|idqn|dido3|iidt|idtdfqn|ddjoJ|id|p tdn|iidt|idfqn|i|idqW|i t t |i |S(Nis--no-default-sysconfigs --sysconfig=s --sysconfigs9You gave --sysconfig as the last argument without a value( tdefault_sysconfigst sysconfigst startswithtpoptinserttTruetlenRtappendtload_sysconfigstsuperR R(tselftargstnew_args((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR,s,    #  " c Kstt|i|}|iddddddd|iddd dd dd |id dddd dddd|iddd dddd|idddddddddd|S(Ns --sysconfigtactionRtdestRthelpsSystem configuration files--no-default-sysconfigt store_truetno_default_sysconfigs&Don't load the default sysconfig filess--easy-installteasy_install_optmetavartOPsOAn option to add if invoking easy_install (like --easy-install=exclude-scripts)s --no-installt no_installs?Don't try to install the package (it must already be installed)s-fs --find-linksteasy_install_find_linkstURLsPassed through to easy_install(RR tstandard_parsert add_option(tclstkwtparser((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR'Gs6   c CsW|i}|ig|_xt|D] \}\}}|idotii|p|otd|q~q*nh}t ||t i d|}x*|i D]\}}t |||qW||_n=yti|}Wn&tj o}|oqq*nX||_|iid|q*W|i} |id| dS(Ns.pys sysconfig file %s does not exists__sysconfig_%i__itadd_custom_options(Rtreversetsysconfig_modulest enumeratetendswithtostpathtexistsRtexecfiletnewtmoduletitemstsetattrt__file__Rt simple_importt ImportErrort paste_commandRR+tcall_sysconfig_functions( RtconfigstindextexplicittnametglobstmodtvalueteR+((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRks:          cCs6x/|iD]$}t||ot||Sq W|S(s Return the value of the given option in the first sysconfig module in which it is found, or ``default`` (None) if not found in any. (R.thasattrtgetattr(RRAtdefaultRC((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pytget_sysconfig_options  cCs?g}|iD]*}t||o|t||qq~S(s Return the option value for the given name in all the sysconfig modules in which is is found (``[]`` if none). (R.RFRG(RRAt_[1]RC((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pytget_sysconfig_optionsscOs:|i|}|djotd|n|||S(s Call the specified function in the first sysconfig module it is defined in. ``NameError`` if no function is found. s+Method %s not found in any sysconfig moduleN(RItNonet NameError(RRARR*tval((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pytcall_sysconfig_functions  cOs1g}|i|D]}||||q~S(sw Call all the named functions in the sysconfig modules, returning a list of the return values. (RK(RRARR*RJtmethod((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR=scCsDh}|id|}|ix|D]}|i|q)W|S(se Return the folded results of calling the ``install_variables()`` functions. tinstall_variables(R=R-tupdate(Rt installertresulttall_varstvardict((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pytsysconfig_install_varss  c Csky>ti|}|iodGHdG|GdG|iGHn|SWn&tij o|iiod|GHnddg}xF|iipgD]1}|idpd|}n|i |qWx,|ii pgD]}|i d |qW|i ot d |nd |GHd d k l}d dkl}|dddg||gti|SXdS(se This gets a distribution object, and installs the distribution if required. sDistribution already installed:t tfromsFBecause --no-install was given, we won't try to install the package %ss-vs-mt-s--s--find-links=%ss'Must install %s, but in simulation modesMust install %si(t easy_install(tsetupt script_argss-qR[N(t pkg_resourcestget_distributiontverbosetlocationtDistributionNotFoundtoptionsR$R!RRR%tsimulateRtsetuptools.commandR[t setuptoolsR\(RtreqtdistRctopR[R\((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR_s8      cCs(|id|}||||}|S(Nspaste.app_install(tload_entry_point(Rtdistrotep_grouptep_nametinstaller_classRS((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyt get_installers  N(t__name__t __module__tdefault_interactivetFalseRRR1tenvirontgetRR2tjoinRR't classmethodRRLRIRKROR=RWR_Ro(((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR s,      &    tMakeConfigCommandc BseZdZd"ZdZdZdZdZe i de de de Z e i ddd d d d d e i dddd dd de i dddd dddd de i ddd d dd de i ddd d dd ddZdZdZd Zd!ZRS(#is:Install a package and create a fresh config file/directorys&PACKAGE_NAME [CONFIG_FILE] [VAR=VALUE]s Note: this is an experimental command, and it will probably change in several ways by the next release. make-config is part of a two-phase installation process (the second phase is setup-app). make-config installs the package (using easy_install) and asks it to create a bare configuration file or directory (possibly filling in defaults from the extra variables you give). Rdtquiettno_interactives--infoRRRt show_infoRsQShow information on the package (after installing it), but do not write a config.s--nametstoreRmsJThe name of the application contained in the distribution (default "main")s --entry-groupRlRHspaste.app_factorysZThe entry point group to install (i.e., the kind of application; default paste.app_factorys--edittedits?Edit the configuration file after generating it (using $EDITOR)s--setupt run_setupsXRun setup-app immediately after generating (and possibly editing) the configuration filec Cs|id|_d|ijoK|iidj otdn|iidd\|_|i_n|iipd|i_n|i|i|_|i |i|ii |ii|_ |ii o1t |idjotdn|i St |idjoFtd|id|i }|ptd n|d|_n|id|_|i|ii|_|i|i |_|ii|i|id|i|id <|i|id <|ii|id <|ii |id <|iid|ii|iidti|iidti|idjoH|ii}|idGHx'|D]\}}d||fGHqWn|i i ||i|it!}|ii"o|i#}n|i i$|i}|d}|ii%oH|p0dGH|i&ddt'o|i%|qWq|i%|n^|i i$|i}| o|dj o dGHn+dGH|ox|D]} d| GHqWndS(Nit#s9You may not give both --name and a requirement with #nameitmains*With --info you can only give one argumentitdefault_config_filenames&You must give a configuration filenamet project_namet requirementRmRltapp_nametapp_instance_uuidtapp_instance_secretsVariables for installation:s %s: %rs'Config-file editing was not successful.sRun setup-app anyway?RHsNo config files need editings$Now you should edit the config filess %s((RRRcRmRLRtsplitR_RkRoRlRSR{RtfilterR=t config_filetcheck_config_fileRRWtvarsRRt parse_varst setdefaulttlowerR tuuid4R t secret_stringR`R7tsortt write_configRR}t run_editorteditable_config_filesR~taskRs( RRct print_varsRARDt edit_successt setup_configst setup_configt filenamestfn((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pytcommands| ( !             cCs|iid}|GHdS(N(RSt descriptionRL(Rttext((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR{cscCs|iidjodS|i}|iio/tii|dotd|qn9|idptii| otd|ndS(NisSThe CONFIG_FILE argument %r looks like a filename, and a directory name is expectedt/sRThe CONFIG_FILE argument %r looks like a directory name and a filename is expected( RStexpect_config_directoryRLRR1R2tsplitextRR0(RR((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRgs  $cCstd|gdS(Ns setup-app(t run_command(Rtfilename((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR~vscCs|ii|i}|djo dGHtS|p dGHtSt|djo dGHtStii dp dGHtS|i odtid|dfGHnti d |d}|od tid|fGHtStS( Ns6Warning: the config file is not known (--edit ignored)s6Warning: no config files need editing (--edit ignored)isEWarning: there is more than one editable config file (--edit ignored)tEDITORs+Error: you must set $EDITOR if using --edits%s %sis $EDITOR %ss.Warning: editor %s returned with error code %i( RSRRRLRsRRR1RtRuR`tsystem(RRtretval((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRys*  N(RpRqtdefault_verbosityRLtmax_argstmin_argstsummarytusageRR R'RR+R(RR{RR~R(((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRxsD        H   t SetupCommandc BsxeZdZdZdZdZdZdZei de de de Z e i ddd d d d dd ddZRS(is)Setup an application, given a config filet CONFIG_FILEs Note: this is an experimental command, and it will probably change in several ways by the next release. Setup an application according to its configuration file. This is the second part of a two-phase web application installation process (the first phase is prepare-app). The setup process may consist of things like creating directories and setting up databases. RdRyt interactives--nameRR|Rt section_nameRHRs5The name of the section to set up (default: app:main)c Cs|id}|ii}|djo3d|jo|idd\}}qYd}nd|jo|}d|}n|iddd}|idpd|}n|djo|d|7}n|tdiddd}tii ti |}|i |t |dti }|i i}|i i}|i i}|djotd |n|i|||} | i||||i| |id | |dS( NiRiRt:sapp:sconfig:t relative_tosThe section %r is not the application (probably a filter). You should add #section_name, where section_name is the section that configures your applicationtpost_setup_hook(RRcRRLRRRR1R2Rvtgetcwdtlogging_file_configRtcontexttentry_point_nametprotocolt distributionRRoRRWR=( Rt config_spectsectiont plain_sectionRtconfRmRlRhRS((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRs:             N(RpRqRRRRRRR R'RR+R(RLR(((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRs   t InstallercBsteZdZeZd ZeZdZ dZ dZ dZ dZ d dZdZdZd ZRS( sV Abstract base class for installers, and also a generic installer that will run off config files in the .egg-info directory of a distribution. Packages that simply refer to this installer can provide a file ``*.egg-info/paste_deploy_config.ini_tmpl`` that will be interpreted by Cheetah. They can also provide ``websetup`` modules with a ``setup_app(command, conf, vars)`` (or the now-deprecated ``setup_config(command, filename, section, vars)``) function, that will be called. In the future other functions or configuration files may be called. cCs||_||_||_dS(N(RhRlRm(RRhRlRm((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyt__init__s  cCsdS(NsAn application((RR ((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRscCs |i||i||dS(s Writes the content to the filename (directory or single file). You should use the ``command`` object, which respects things like simulation and interactive. ``vars`` is a dictionary of user-provided variables. N(t ensure_filetconfig_content(RRRR((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRscCs|ip|gSdSdS(s> Return a list of filenames; this is primarily used when the filename is treated as a directory and several configuration files are created. The default implementation returns the file itself. Return None if you don't know what files should be edited on installation. N(RRL(RR((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRs cCs`d}|ii|p%|io d|GHn|i|S|i|ii||d|S(s Called by ``self.write_config``, this returns the text content for the config file, given the provided variables. The default implementation reads ``Package.egg-info/paste_deploy_config.ini_tmpl`` and fills it with the variables. spaste_deploy_config.ini_tmpls No %s foundR(Rht has_metadataR`t simple_configttemplate_renderert get_metadata(RRRt meta_name((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR s   cCse|io;ddk}|ii|d|g}ti|||Sti|}|i|SdS(s Subclasses may override this to provide different template substitution (e.g., use a different template engine). iNt searchList(t use_cheetahtCheetah.TemplatetTemplateRt careful_subtstringt substitute(RtcontentRRtCheetahttmpl((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRs   cCs;|idjod|i}nd}d|ii|fS(sO Return a very simple configuration file for this application. RRts[app:main] use = egg:%s%s (RmRhR(RRRm((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR,s c Cs8g}|iidD];}|io(|iid o||iqq~}|pdGHdGHnx|D]}|d}ti|} | d joqwn|io d|GHnt| do |i | i ||||qwt| do| i ||||qwd | i | i fGHqwWd S( s Called to setup an application, given its configuration file/directory. The default implementation calls ``package.websetup.setup_config(command, filename, section, vars)`` or ``package.websetup.setup_app(command, config, vars)`` With ``setup_app`` the ``config`` object is a dictionary with the extra attributes ``global_conf``, ``local_conf`` and ``filename`` s top_level.txtRs&No modules are listed in top_level.txts<Try running python setup.py egg_info to regenerate that files .websetupsRunning setup_config() from %st setup_appRs4No setup_app() or setup_config() function in %s (%s)N(Rhtget_metadata_lineststripRRttry_import_moduleRLR`RFt_call_setup_appRRRpR9( RRRRRRJtlinetmodulestmod_nameRC((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR8s*>     cCsrtii|}d|jo|iddd}nd||f}t|}||_||||dS(NRis config:%s#%s(R1R2tabspathRRR(RtfuncRRRRR((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyR]s   N(RpRqt__doc__RsRRLRRRRRRRRRRRR(((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyRs     %(ii("RR1tsyst version_infotpaste.script.utilRRR5t cStringIORtpaste.script.commandRRRRtpaste.script.templatestpastet paste.scriptRR^RLRRt paste.utilRt paste.deployRR R R RxRtobjectR(((s;/usr/lib/python2.6/site-packages/paste/script/appinstall.pyts*      =