mò
LQ¯Lc        
   @   s  d  k  Z  d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d  k Z d k Td d d d d d d d	 d
 d g
 Z	 h  d d <d d <d d <d d <d d <d d <d d <Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d  S(   N(   t   *t   runt   newt   cleant   testt   autotests	   auto-testt   ids   new,runs	   clean,runt   moduless   Define the framework IDs   Create a new applications5   Delete temporary files (including the bytecode cache)s(   Run the application in the current shells5   Run the application in test mode in the current shells'   Automatically run all application testss!   Display the computed modules listc          K   sP  |  i d ƒ } |  i d ƒ } |  i d ƒ } |  i d ƒ } | d j o t | ƒ n | d j p | d j o t | | | ƒ n | d j p | d	 j o t | ƒ n | d j p | d	 j p | d
 j o t	 | | ƒ n | d j o t
 | | ƒ n | d j p | d j o t | | ƒ n | d j o t | | ƒ n d  S(   Nt   commandt   appt   argst   envR   R   s   new,runR   s	   clean,runR   R   s	   auto-testR   R   (   t   kargst   getR   R	   R
   R   R   R   R   R   R   R   t   show_modules(   R   R	   R
   R   R   (    (    t^   /afs/cs.wisc.edu/p/zhu/public/html/space2/dualist/play-1.1/framework/pym/play/commands/base.pyt   execute   s$    'c         C   sæ  g  }	 d  } ys t i | d d d g ƒ \ } } xK | D]C \ } } | d j o | i d ƒ }	 n | d j o
 | } q7 q7 WWn> t i	 j
 o/ } d t | ƒ GHd GHd	 GHt i d
 ƒ n Xt i i |  i ƒ o" d |  i GHd GHt i d
 ƒ n g  } x*|	 D]"} d  } t i i t i i | d d | ƒ ƒ o4 t i i t i i | d d | ƒ ƒ o
 | } n} xy t i t i i | d d ƒ ƒ D]U } t i i t i i | d d | ƒ ƒ o% | i d | ƒ d j o | } Pq’q’W| p( d | GHd | GHd GHt i d
 ƒ n | i | ƒ qWd t i i |  i ƒ GH| d  j o# t d t i i |  i ƒ ƒ } n | d j o t i i |  i ƒ } n t i  t i i | d d ƒ |  i ƒ t i! t i i |  i d ƒ ƒ t i! t i i |  i d ƒ ƒ |  i" ƒ  t# t i i |  i d ƒ d | ƒ t# t i i |  i d ƒ d t$ ƒ  ƒ d GHxm | D]e } | }
 |
 i d ƒ d j o |
 |
 i d ƒ  }
 n t# t i i |  i d ƒ d d |
 | f ƒ qZWd GHd  t i& d! GHd" GHd GHd  S(#   Nt    s   with=s   name=s   --witht   ,s   --names   ~ %ss   ~ Sorry, unrecognized options   ~ iÿÿÿÿs   ~ Oops. %s already existst   ~t   basedirs
   modules/%sR   s   %s-i    s   ~ Oops. No module %s founds+   ~ Try to install it using 'play install %s's+   ~ The new application will be created in %ss%   ~ What is the application name? [%s] s   resources/application-skels
   app/modelst   libs   conf/application.confs   %APPLICATION_NAME%s   %SECRET_KEY%t   -s   # ---- MODULES ----s5   # ---- MODULES ----
module.%s=${play.path}/modules/%ss!   ~ OK, the application is created.s   ~ Start it with : play run %si   s   ~ Have fun!('   t   withModulest   Nonet   application_namet   getoptR
   t   optlistt   ot   at   splitt   GetoptErrort   errt   strt   syst   exitt   ost   patht   existsR	   t   mdt   mt   dirnamet   joinR   t   isdirt   listdirt   ft   findt   appendt   normpatht	   raw_inputt   basenamet   shutilt   copytreet   mkdirt   checkt
   replaceAllt	   secretKeyt   mnt   argv(   R	   R
   R   R   R)   R   R'   R    R-   R   R9   R(   R   R   (    (    R   R   /   st    !  T
# D			#&
"% 0c         C   s  |  i ƒ  t } | i d ƒ d j o t } | i d ƒ n d GHd GH|  i | ƒ } |  i	 d ƒ d j oP | p |  i
 ƒ  n | i d d ƒ | i d d	 |  i ƒ | i d d
 ƒ n y t i | d t i ƒWn% t j
 o d GHt i d ƒ n XHd  S(   Ns   -fi   s   ~ Ctrl+C to stops   ~ s   application.modet   devi   s   -Xdebugs;   -Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=ns   -Dplay.debug=yesR   s¦   Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). iÿÿÿÿ(   R	   R6   t   Falset   disable_check_jpdaR
   t   countt   Truet   removet   java_cmdt   readConft
   check_jpdat   insertt	   jpda_portt
   subprocesst   callR$   t   environt   OSErrorR"   R#   (   R	   R
   RA   R=   (    (    R   R   n   s(    
 c         C   s‚   |  i ƒ  d t i i t i i |  i d ƒ ƒ GHt i i t i i |  i d ƒ ƒ o# t i t i i |  i d ƒ ƒ n d GHd  S(   Ns   ~ Deleting %st   tmpR   (	   R	   R6   R$   R%   R0   R*   R&   R3   t   rmtree(   R	   (    (    R   R   „   s
    
'%#c         C   sf   |  i ƒ  |  i ƒ  } t | ƒ o( d GHd GHx  | D] } d | GHq4 Wn d GHd GHt i d ƒ d  S(   Ns   ~ Application modules are:s   ~ s   ~ %ss*   ~ No modules installed in this applicationi    (   R	   R6   R   t   lent   moduleR"   R#   (   R	   R
   R   RM   (    (    R   R   ‹   s    
 c         C   sÖ   |  i ƒ  t } | i d ƒ d j o
 t } n |  i | ƒ } d GHd GHd GH|  i ƒ  | i	 d d ƒ | i	 d d |  i
 ƒ | i	 d d	 ƒ y t i | d
 t i ƒWn% t j
 o d GHt i d ƒ n XHd  S(   Ns   -fi   s   ~ Running in test modes   ~ Ctrl+C to stops   ~ i   s   -Xdebugs;   -Xrunjdwp:transport=dt_socket,address=%s,server=y,suspend=ns   -Dplay.debug=yesR   s¦   Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). iÿÿÿÿ(   R	   R6   R<   R=   R
   R>   R?   RA   RC   RD   RE   RF   RG   R$   RH   RI   R"   R#   (   R	   R
   RA   R=   (    (    R   R   ˜   s$    


c         C   sý  |  i ƒ  d GHd GHd GHd t i i t i i |  i d ƒ ƒ GHt i i t i i |  i d ƒ ƒ o# t i t i i |  i d ƒ ƒ n d GH|  i	 d ƒ } y3 t i h  ƒ } t i | ƒ } | i d | ƒ Wn t j
 o	 }
 n Xt i i |  i d	 ƒ }	 t i i |	 ƒ o t i |	 ƒ n t t i i |  i ƒ  d
 ƒ d ƒ } |  i | ƒ } y" t i | d t i d | ƒ} Wn% t j
 o d GHt i d ƒ n Xt t i i |  i ƒ  d
 ƒ d ƒ } x€ t  ox | i! ƒ  o  d GHd GHd GHt i d ƒ n | i" ƒ  i# ƒ  } | o. | GH| i% d ƒ d j o | i& ƒ  PqBqÇqÇWd GHt i i |  i' d d ƒ g } t i i |  i' d d ƒ } xS t i* | ƒ D]B } | i, d ƒ o, | i- t i i t i i | | ƒ ƒ ƒ q—q—Wd i | ƒ } t i/ d j o d i | ƒ } n |  i0 ƒ  d | d | d g } y t i1 | d t i ƒWn% t j
 o d GHt i d ƒ n Xd GHt2 i3 d ƒ t i i t i i |  i d ƒ ƒ o d  GHd GHn t i i t i i |  i d! ƒ ƒ o d" |	 GHd GHn t4 | i5 ƒ d  S(#   Ns   ~ Running in test modes   ~ Ctrl+C to stops   ~ s   ~ Deleting %sRJ   R   s	   http.ports   http://localhost:%s/@kills   test-results
   system.outt   wR   t   stdouts¦   Could not execute the java executable, please make sure the JAVA_HOME environment variable is set properly (the java executable should reside at JAVA_HOME/bin/java). iÿÿÿÿt   rs$   ~ Oops, application has not started?s   /@tests to run the testsR   s*   modules/testrunner/lib/play-testrunner.jars   modules/testrunner/firephoques   .jart   :t   ntt   ;s
   -classpaths%   -Dapplication.url=http://localhost:%ss"   play.modules.testrunner.FirePhoques(   Could not execute the headless browser. i   s   test-result/result.passeds   ~ All tests passeds   test-result/result.faileds3   ~ Some tests have failed. See file://%s for results(6   R	   R6   R$   R%   R0   R*   R&   R3   RK   RB   t	   http_portt   urllib2t   ProxyHandlert   proxy_handlert   build_openert   openert   opent	   Exceptiont   et   test_resultt   log_patht   soutRA   R
   RF   t   PopenRH   t   play_processRI   R"   R#   t   soutintR?   t   pollt   readlinet   stript   lineR.   t   closet   play_envt   fpcpt	   fpcp_libsR,   t   jart   endswithR/   t   cp_argst   namet	   java_pathRG   t   timet   sleept   killt   pid(   R	   R
   RA   RT   Rk   Ri   RY   Rj   Rf   R]   R\   Rm   Ra   Rb   RW   R_   (    (    R   R   ¬   s€    
'%#$"$ 
 0%	%		c         C   s—   |  d p	 d GHn t d ƒ } | o1 d GHd | GHd GHt |  d d ƒ i | ƒ n< d GHd GHd GHt i i |  d ƒ o t i |  d ƒ n d  S(	   NR   s   ~ framework ID is not sets4   ~ What is the new framework ID (or blank to unset)? R   s    ~ OK, the framework ID is now %st   id_fileRN   s   ~ OK, the framework ID is unset(	   Rh   R1   t   new_idRZ   t   writeR$   R%   R&   R@   (   Rh   Ru   (    (    R   R   ö   s    		c         C   s×   t  i d j ox d  k } | i i i d t t |  ƒ ƒ } | i i i
 | d ƒ p1 d |  | i i i ƒ  f GHd GHt i d ƒ qÓ nL y t  i t |  ƒ d ƒ Wn. t j
 o" d |  GHd	 GHt i d ƒ n Xd  S(
   NRR   i   i    s0   ~ Cannot kill the process with pid %s (ERROR %s)s   ~ iÿÿÿÿi   s0   ~ Play was not running (Process id %s not found)R   (   R$   Rn   t   ctypest   windllt   kernel32t   OpenProcessR<   t   intRs   t   handlet   TerminateProcesst   GetLastErrorR"   R#   Rr   RI   (   Rs   R|   Rw   (    (    R   Rr     s    	!	(   R"   R$   RF   R3   R   RU   t
   webbrowserRp   t
   play.utilst   COMMANDSt   HELPR   R   R   R   R   R   R   R   Rr   (   R   R   R‚   Rr   R   RU   R   RF   R"   R   R   R   R   Rp   R   R   R3   R$   R   (    (    R   t   ?   s&   								$E
		?					J	