<s> """<STR_LIT>""" <EOL> import sys , os <EOL> __version__ = "<STR_LIT>" <EOL> __all__ = [ "<STR_LIT>" ] <EOL> FASTCGI_HELP = r"""<STR_LIT>""" <EOL> FASTCGI_OPTIONS = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:host>' : None , <EOL> '<STR_LIT:port>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : '<STR_LIT:/>' , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:2> , <EOL> '<STR_LIT>' : <NUM_LIT:50> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> def fastcgi_help ( message = None ) : <EOL> print FASTCGI_HELP <EOL> if message : <EOL> print message <EOL> return False <EOL> def runfastcgi ( argset = [ ] , ** kwargs ) : <EOL> options = FASTCGI_OPTIONS . copy ( ) <EOL> options . update ( kwargs ) <EOL> for x in argset : <EOL> if "<STR_LIT:=>" in x : <EOL> k , v = x . split ( '<STR_LIT:=>' , <NUM_LIT:1> ) <EOL> else : <EOL> k , v = x , True <EOL> options [ k . lower ( ) ] = v <EOL> if "<STR_LIT>" in options : <EOL> return fastcgi_help ( ) <EOL> try : <EOL> import flup <EOL> except ImportError , e : <EOL> print >> sys . stderr , "<STR_LIT>" % e <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> return False <EOL> flup_module = '<STR_LIT>' + options [ '<STR_LIT>' ] <EOL> if options [ '<STR_LIT>' ] in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> wsgi_opts = { <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> } <EOL> flup_module += '<STR_LIT>' <EOL> elif options [ '<STR_LIT>' ] in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> wsgi_opts = { <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> '<STR_LIT>' : int ( options [ "<STR_LIT>" ] ) , <EOL> } <EOL> else : <EOL> return fastcgi_help ( "<STR_LIT>" ) <EOL> wsgi_opts [ '<STR_LIT>' ] = False <EOL> try : <EOL> WSGIServer = getattr ( __import__ ( '<STR_LIT>' + flup_module , '<STR_LIT>' , '<STR_LIT>' , flup_module ) , '<STR_LIT>' ) <EOL> except : <EOL> print "<STR_LIT>" + flup_module <EOL> return False <EOL> from django . core . handlers . wsgi import WSGIHandler <EOL> if options [ "<STR_LIT:host>" ] and options [ "<STR_LIT:port>" ] and not options [ "<STR_LIT>" ] : <EOL> wsgi_opts [ '<STR_LIT>' ] = ( options [ "<STR_LIT:host>" ] , int ( options [ "<STR_LIT:port>" ] ) ) <EOL> elif options [ "<STR_LIT>" ] and not options [ "<STR_LIT:host>" ] and not options [ "<STR_LIT:port>" ] : <EOL> wsgi_opts [ '<STR_LIT>' ] = options [ "<STR_LIT>" ] <EOL> elif not options [ "<STR_LIT>" ] and not options [ "<STR_LIT:host>" ] and not options [ "<STR_LIT:port>" ] : <EOL> wsgi_opts [ '<STR_LIT>' ] = None <EOL> else : <EOL> return fastcgi_help ( "<STR_LIT>" ) <EOL> if options [ "<STR_LIT>" ] is None : <EOL> daemonize = ( wsgi_opts [ '<STR_LIT>' ] is not None ) <EOL> else : <EOL> if options [ "<STR_LIT>" ] . lower ( ) in ( '<STR_LIT:true>' , '<STR_LIT:yes>' , '<STR_LIT:t>' ) : <EOL> daemonize = True <EOL> elif options [ "<STR_LIT>" ] . lower ( ) in ( '<STR_LIT:false>' , '<STR_LIT>' , '<STR_LIT:f>' ) : <EOL> daemonize = False <EOL> else : <EOL> return fastcgi_help ( "<STR_LIT>" ) <EOL> daemon_kwargs = { } <EOL> if options [ '<STR_LIT>' ] : <EOL> daemon_kwargs [ '<STR_LIT>' ] = options [ '<STR_LIT>' ] <EOL> if options [ '<STR_LIT>' ] : <EOL> daemon_kwargs [ '<STR_LIT>' ] = options [ '<STR_LIT>' ] <EOL> if options [ '<STR_LIT>' ] : <EOL> daemon_kwargs [ '<STR_LIT>' ] = int ( options [ '<STR_LIT>' ] ) <EOL> if daemonize : <EOL> from django . utils . daemonize import become_daemon <EOL> become_daemon ( our_home_dir = options [ "<STR_LIT>" ] , ** daemon_kwargs ) <EOL> if options [ "<STR_LIT>" ] : <EOL> fp = open ( options [ "<STR_LIT>" ] , "<STR_LIT:w>" ) <EOL> fp . write ( "<STR_LIT>" % os . getpid ( ) ) <EOL> fp . close ( ) <EOL> WSGIServer ( WSGIHandler ( ) , ** wsgi_opts ) . run ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> runfastcgi ( sys . argv [ <NUM_LIT:1> : ] ) </s>
