<s> """<STR_LIT>""" <EOL> import os <EOL> curdir = os . path . join ( os . getcwd ( ) , os . path . dirname ( __file__ ) ) <EOL> import re <EOL> import time <EOL> from cherrypy . test import helper <EOL> def read_process ( cmd , args = "<STR_LIT>" ) : <EOL> pipein , pipeout = os . popen4 ( "<STR_LIT>" % ( cmd , args ) ) <EOL> try : <EOL> firstline = pipeout . readline ( ) <EOL> if ( re . search ( r"<STR_LIT>" , firstline , <EOL> re . IGNORECASE ) ) : <EOL> raise IOError ( '<STR_LIT>' % cmd ) <EOL> output = firstline + pipeout . read ( ) <EOL> finally : <EOL> pipeout . close ( ) <EOL> return output <EOL> APACHE_PATH = "<STR_LIT>" <EOL> CONF_PATH = "<STR_LIT>" <EOL> conf_modpython_gateway = """<STR_LIT>""" <EOL> conf_cpmodpy = """<STR_LIT>""" <EOL> class ModPythonSupervisor ( helper . Supervisor ) : <EOL> using_apache = True <EOL> using_wsgi = False <EOL> template = None <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . host , self . port ) <EOL> def start ( self , modulename ) : <EOL> mpconf = CONF_PATH <EOL> if not os . path . isabs ( mpconf ) : <EOL> mpconf = os . path . join ( curdir , mpconf ) <EOL> f = open ( mpconf , '<STR_LIT:wb>' ) <EOL> try : <EOL> f . write ( self . template % <EOL> { '<STR_LIT:port>' : self . port , '<STR_LIT>' : modulename , <EOL> '<STR_LIT:host>' : self . host } ) <EOL> finally : <EOL> f . close ( ) <EOL> result = read_process ( APACHE_PATH , "<STR_LIT>" % mpconf ) <EOL> if result : <EOL> print ( result ) <EOL> def stop ( self ) : <EOL> """<STR_LIT>""" <EOL> read_process ( APACHE_PATH , "<STR_LIT>" ) <EOL> loaded = False <EOL> def wsgisetup ( req ) : <EOL> global loaded <EOL> if not loaded : <EOL> loaded = True <EOL> options = req . get_options ( ) <EOL> import cherrypy <EOL> cherrypy . config . update ( { <EOL> "<STR_LIT>" : os . path . join ( curdir , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : options [ '<STR_LIT>' ] , <EOL> } ) <EOL> modname = options [ '<STR_LIT>' ] <EOL> mod = __import__ ( modname , globals ( ) , locals ( ) , [ '<STR_LIT>' ] ) <EOL> mod . setup_server ( ) <EOL> cherrypy . server . unsubscribe ( ) <EOL> cherrypy . engine . start ( ) <EOL> from mod_python import apache <EOL> return apache . OK <EOL> def cpmodpysetup ( req ) : <EOL> global loaded <EOL> if not loaded : <EOL> loaded = True <EOL> options = req . get_options ( ) <EOL> import cherrypy <EOL> cherrypy . config . update ( { <EOL> "<STR_LIT>" : os . path . join ( curdir , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : options [ '<STR_LIT>' ] , <EOL> } ) <EOL> from mod_python import apache <EOL> return apache . OK </s>
