<s> import logging <EOL> import optparse <EOL> import daemonize <EOL> from django . apps import apps <EOL> from django . core . management . base import NoArgsCommand <EOL> from ... utils import get_backend , get_middleware , configure_logging <EOL> from ... runner import runner <EOL> class Command ( NoArgsCommand ) : <EOL> option_list = NoArgsCommand . option_list + ( <EOL> optparse . make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = None , <EOL> help = "<STR_LIT>" ) , <EOL> optparse . make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = None , <EOL> help = "<STR_LIT>" ) , <EOL> optparse . make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = None , <EOL> help = "<STR_LIT>" ) , <EOL> optparse . make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = '<STR_LIT:1>' , <EOL> help = "<STR_LIT>" ) , <EOL> optparse . make_option ( '<STR_LIT>' , action = '<STR_LIT:store>' , dest = '<STR_LIT>' , default = '<STR_LIT:1>' , <EOL> help = "<STR_LIT>" ) , <EOL> ) <EOL> def handle_noargs ( self , ** options ) : <EOL> verbosity = int ( options [ '<STR_LIT>' ] ) <EOL> level = { <EOL> <NUM_LIT:0> : logging . WARNING , <EOL> <NUM_LIT:1> : logging . INFO , <EOL> <NUM_LIT:2> : logging . DEBUG , <EOL> } [ verbosity ] <EOL> def log_filename ( name ) : <EOL> try : <EOL> return options [ '<STR_LIT>' ] % name <EOL> except TypeError : <EOL> return options [ '<STR_LIT>' ] <EOL> def touch_filename ( name ) : <EOL> try : <EOL> return options [ '<STR_LIT>' ] % name <EOL> except TypeError : <EOL> return None <EOL> log_fd = configure_logging ( <EOL> level = level , <EOL> format = '<STR_LIT>' , <EOL> filename = log_filename ( '<STR_LIT>' ) , <EOL> ) <EOL> log = logging . getLogger ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> get_backend ( ) <EOL> get_middleware ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> apps . get_models ( ) <EOL> log . info ( "<STR_LIT>" ) <EOL> def run ( ) : <EOL> runner ( <EOL> log , <EOL> log_filename , <EOL> touch_filename , <EOL> machine_number = int ( options [ '<STR_LIT>' ] ) , <EOL> machine_count = int ( options [ '<STR_LIT>' ] ) , <EOL> ) <EOL> if options [ '<STR_LIT>' ] : <EOL> daemon = daemonize . Daemonize ( <EOL> app = '<STR_LIT>' , <EOL> pid = options [ '<STR_LIT>' ] , <EOL> action = run , <EOL> keep_fds = [ log_fd ] , <EOL> ) <EOL> daemon . start ( ) <EOL> else : <EOL> run ( ) </s>
