<s> _NOW = <NUM_LIT> <EOL> _TIMEFORMAT = '<STR_LIT>' <EOL> class DummyOptions : <EOL> make_pipes_error = None <EOL> fork_error = None <EOL> execv_error = None <EOL> kill_error = None <EOL> minfds = <NUM_LIT:5> <EOL> loglevel = <NUM_LIT:20> <EOL> def __init__ ( self ) : <EOL> self . identifier = '<STR_LIT>' <EOL> self . childlogdir = '<STR_LIT>' <EOL> self . uid = <NUM_LIT> <EOL> self . logger = self . getLogger ( ) <EOL> self . backofflimit = <NUM_LIT:10> <EOL> self . logfile = '<STR_LIT>' <EOL> self . nocleanup = False <EOL> self . strip_ansi = False <EOL> self . pidhistory = { } <EOL> self . process_group_configs = [ ] <EOL> self . nodaemon = False <EOL> self . socket_map = { } <EOL> self . mood = <NUM_LIT:1> <EOL> self . mustreopen = False <EOL> self . realizeargs = None <EOL> self . fds_cleaned_up = False <EOL> self . rlimit_set = False <EOL> self . setuid_called = False <EOL> self . httpservers_opened = False <EOL> self . signals_set = False <EOL> self . daemonized = False <EOL> self . make_logger_messages = None <EOL> self . autochildlogdir_cleared = False <EOL> self . cleaned_up = False <EOL> self . pidfile_written = False <EOL> self . directory = None <EOL> self . waitpid_return = None , None <EOL> self . kills = { } <EOL> self . _signal = None <EOL> self . parent_pipes_closed = None <EOL> self . child_pipes_closed = None <EOL> self . forkpid = <NUM_LIT:0> <EOL> self . pgrp_set = None <EOL> self . duped = { } <EOL> self . written = { } <EOL> self . fds_closed = [ ] <EOL> self . _exitcode = None <EOL> self . execv_args = None <EOL> self . setuid_msg = None <EOL> self . privsdropped = None <EOL> self . logs_reopened = False <EOL> self . environment_processed = False <EOL> self . select_result = [ ] , [ ] , [ ] <EOL> self . select_error = None <EOL> self . write_accept = None <EOL> self . write_error = None <EOL> self . tempfile_name = '<STR_LIT>' <EOL> self . remove_error = None <EOL> self . removed = [ ] <EOL> self . existing = [ ] <EOL> self . openreturn = None <EOL> self . readfd_result = '<STR_LIT>' <EOL> self . parse_warnings = [ ] <EOL> self . serverurl = '<STR_LIT>' <EOL> self . changed_directory = False <EOL> self . chdir_error = None <EOL> self . umaskset = None <EOL> def getLogger ( self , * args , ** kw ) : <EOL> logger = DummyLogger ( ) <EOL> logger . handlers = [ DummyLogger ( ) ] <EOL> logger . args = args , kw <EOL> return logger <EOL> def realize ( self , args , ** kw ) : <EOL> self . realizeargs = args <EOL> self . realizekw = kw <EOL> def process_config_file ( self , do_usage = True ) : <EOL> pass <EOL> def cleanup_fds ( self ) : <EOL> self . fds_cleaned_up = True <EOL> def set_rlimits ( self ) : <EOL> self . rlimits_set = True <EOL> return [ '<STR_LIT>' ] <EOL> def set_uid ( self ) : <EOL> self . setuid_called = True <EOL> return '<STR_LIT>' <EOL> def openhttpservers ( self , supervisord ) : <EOL> self . httpservers_opened = True <EOL> def daemonize ( self ) : <EOL> self . daemonized = True <EOL> def setsignals ( self ) : <EOL> self . signals_set = True <EOL> def get_signal ( self ) : <EOL> return self . _signal <EOL> def get_socket_map ( self ) : <EOL> return self . socket_map <EOL> def make_logger ( self , critical_msgs , warn_msgs , info_msgs ) : <EOL> self . make_logger_messages = critical_msgs , warn_msgs , info_msgs <EOL> def clear_autochildlogdir ( self ) : <EOL> self . autochildlogdir_cleared = True <EOL> def get_autochildlog_name ( self , * ignored ) : <EOL> return self . tempfile_name <EOL> def cleanup ( self ) : <EOL> self . cleaned_up = True <EOL> def write_pidfile ( self ) : <EOL> self . pidfile_written = True <EOL> def waitpid ( self ) : <EOL> return self . waitpid_return <EOL> def kill ( self , pid , sig ) : <EOL> if self . kill_error : <EOL> raise OSError ( self . kill_error ) <EOL> self . kills [ pid ] = sig <EOL> def stat ( self , filename ) : <EOL> import os <EOL> return os . stat ( filename ) <EOL> def get_path ( self ) : <EOL> return [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def get_pid ( self ) : <EOL> import os <EOL> return os . getpid ( ) <EOL> def check_execv_args ( self , filename , argv , st ) : <EOL> if filename == '<STR_LIT>' : <EOL> from supervisor . options import NotFound <EOL> raise NotFound ( '<STR_LIT>' ) <EOL> def make_pipes ( self , stderr = True ) : <EOL> if self . make_pipes_error : <EOL> raise OSError ( self . make_pipes_error ) <EOL> pipes = { } <EOL> pipes [ '<STR_LIT>' ] , pipes [ '<STR_LIT>' ] = ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> pipes [ '<STR_LIT>' ] , pipes [ '<STR_LIT>' ] = ( <NUM_LIT:5> , <NUM_LIT:6> ) <EOL> if stderr : <EOL> pipes [ '<STR_LIT>' ] , pipes [ '<STR_LIT>' ] = ( <NUM_LIT:7> , <NUM_LIT:8> ) <EOL> else : <EOL> pipes [ '<STR_LIT>' ] , pipes [ '<STR_LIT>' ] = None , None <EOL> return pipes <EOL> def write ( self , fd , chars ) : <EOL> if self . write_error : <EOL> raise OSError ( self . write_error ) <EOL> if self . write_accept : <EOL> chars = chars [ self . write_accept ] <EOL> data = self . written . setdefault ( fd , '<STR_LIT>' ) <EOL> data += chars <EOL> self . written [ fd ] = data <EOL> return len ( chars ) <EOL> def fork ( self ) : <EOL> if self . fork_error : <EOL> raise OSError ( self . fork_error ) <EOL> return self . forkpid <EOL> def close_fd ( self , fd ) : <EOL> self . fds_closed . append ( fd ) <EOL> def close_parent_pipes ( self , pipes ) : <EOL> self . parent_pipes_closed = pipes <EOL> def close_child_pipes ( self , pipes ) : <EOL> self . child_pipes_closed = pipes <EOL> def setpgrp ( self ) : <EOL> self . pgrp_set = True <EOL> def dup2 ( self , frm , to ) : <EOL> self . duped [ frm ] = to <EOL> def _exit ( self , code ) : <EOL> self . _exitcode = code <EOL> def execve ( self , filename , argv , environment ) : <EOL> if self . execv_error : <EOL> if self . execv_error == <NUM_LIT:1> : <EOL> raise OSError ( self . execv_error ) <EOL> else : <EOL> raise RuntimeError ( self . execv_error ) <EOL> self . execv_args = ( filename , argv ) <EOL> self . execv_environment = environment <EOL> def dropPrivileges ( self , uid ) : <EOL> if self . setuid_msg : <EOL> return self . setuid_msg <EOL> self . privsdropped = uid <EOL> def readfd ( self , fd ) : <EOL> return self . readfd_result <EOL> def reopenlogs ( self ) : <EOL> self . logs_reopened = True <EOL> def process_environment ( self ) : <EOL> self . environment_processed = True <EOL> def mktempfile ( self , prefix , suffix , dir ) : <EOL> return self . tempfile_name <EOL> def select ( self , r , w , x , timeout ) : <EOL> import select <EOL> if self . select_error : <EOL> raise select . error ( self . select_error ) <EOL> return self . select_result <EOL> def remove ( self , path ) : <EOL> import os <EOL> if self . remove_error : <EOL> raise os . error ( self . remove_error ) <EOL> self . removed . append ( path ) <EOL> def exists ( self , path ) : <EOL> if path in self . existing : <EOL> return True <EOL> return False <EOL> def open ( self , name , mode = '<STR_LIT:r>' ) : <EOL> if self . openreturn : <EOL> return self . openreturn <EOL> return open ( name , mode ) <EOL> def chdir ( self , dir ) : <EOL> if self . chdir_error : <EOL> raise OSError ( self . chdir_error ) <EOL> self . changed_directory = True <EOL> def setumask ( self , mask ) : <EOL> self . umaskset = mask <EOL> class DummyLogger : <EOL> def __init__ ( self ) : <EOL> self . reopened = False <EOL> self . removed = False <EOL> self . closed = False <EOL> self . data = [ ] <EOL> def info ( self , msg , ** kw ) : <EOL> if kw : <EOL> msg = msg % kw <EOL> self . data . append ( msg ) <EOL> warn = debug = critical = trace = error = blather = info <EOL> def log ( self , level , msg , ** kw ) : <EOL> if kw : <EOL> msg = msg % kw <EOL> self . data . append ( msg ) <EOL> def reopen ( self ) : <EOL> self . reopened = True <EOL> def close ( self ) : <EOL> self . closed = True <EOL> def remove ( self ) : <EOL> self . removed = True <EOL> def flush ( self ) : <EOL> self . flushed = True <EOL> def getvalue ( self ) : <EOL> return '<STR_LIT>' . join ( self . data ) <EOL> class DummySupervisor : <EOL> def __init__ ( self , options = None , state = None , process_groups = None ) : <EOL> if options is None : <EOL> self . options = DummyOptions ( ) <EOL> else : <EOL> self . options = options <EOL> if state is None : <EOL> from supervisor . supervisord import SupervisorStates <EOL> self . options . mood = SupervisorStates . RUNNING <EOL> else : <EOL> self . options . mood = state <EOL> if process_groups is None : <EOL> self . process_groups = { } <EOL> else : <EOL> self . process_groups = process_groups <EOL> def get_state ( self ) : <EOL> return self . options . mood <EOL> class DummySocket : <EOL> bind_called = False <EOL> bind_addr = None <EOL> listen_called = False <EOL> listen_backlog = None <EOL> close_called = False <EOL> def __init__ ( self , fd ) : <EOL> self . fd = fd <EOL> def fileno ( self ) : <EOL> return self . fd <EOL> def bind ( self , addr ) : <EOL> self . bind_called = True <EOL> self . bind_addr = addr <EOL> def listen ( self , backlog ) : <EOL> self . listen_called = True <EOL> self . listen_backlog = backlog <EOL> def close ( self ) : <EOL> self . close_called = True <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> class DummySocketConfig : <EOL> def __init__ ( self , fd ) : <EOL> self . fd = fd <EOL> def addr ( self ) : <EOL> return '<STR_LIT>' <EOL> def __eq__ ( self , other ) : <EOL> return self . fd == other . fd <EOL> def __ne__ ( self , other ) : <EOL> return not self . __eq__ ( other ) <EOL> def create_and_bind ( self ) : <EOL> return DummySocket ( self . fd ) <EOL> class DummySocketManager : <EOL> def __init__ ( self , config , ** kwargs ) : <EOL> self . _config = config <EOL> def config ( self ) : <EOL> return self . _config <EOL> def get_socket ( self ) : <EOL> return DummySocket ( self . _config . fd ) <EOL> class DummyProcess : <EOL> pid = <NUM_LIT:0> <EOL> laststart = <NUM_LIT:0> <EOL> laststop = <NUM_LIT:0> <EOL> delay = <NUM_LIT:0> <EOL> administrative_stop = <NUM_LIT:0> <EOL> system_stop = <NUM_LIT:0> <EOL> killing = <NUM_LIT:0> <EOL> backoff = <NUM_LIT:0> <EOL> waitstatus = None <EOL> exitstatus = None <EOL> pipes = None <EOL> rpipes = None <EOL> dispatchers = None <EOL> stdout_logged = '<STR_LIT>' <EOL> stderr_logged = '<STR_LIT>' <EOL> spawnerr = None <EOL> stdout_buffer = '<STR_LIT>' <EOL> stderr_buffer = '<STR_LIT>' <EOL> stdin_buffer = '<STR_LIT>' <EOL> listener_state = None <EOL> group = None <EOL> def __init__ ( self , config , state = None ) : <EOL> self . config = config <EOL> self . logsremoved = False <EOL> self . stop_called = False <EOL> self . backoff_secs = None <EOL> self . spawned = False <EOL> if state is None : <EOL> from supervisor . process import ProcessStates <EOL> state = ProcessStates . RUNNING <EOL> self . state = state <EOL> self . error_at_clear = False <EOL> self . killed_with = None <EOL> self . drained = False <EOL> self . stdout_buffer = '<STR_LIT>' <EOL> self . stderr_buffer = '<STR_LIT>' <EOL> self . stdout_logged = '<STR_LIT>' <EOL> self . stderr_logged = '<STR_LIT>' <EOL> self . stdin_buffer = '<STR_LIT>' <EOL> self . pipes = { } <EOL> self . rpipes = { } <EOL> self . dispatchers = { } <EOL> self . finished = None <EOL> self . logs_reopened = False <EOL> self . execv_arg_exception = None <EOL> self . input_fd_drained = None <EOL> self . output_fd_drained = None <EOL> self . transitioned = False <EOL> self . write_error = None <EOL> def reopenlogs ( self ) : <EOL> self . logs_reopened = True <EOL> def removelogs ( self ) : <EOL> if self . error_at_clear : <EOL> raise IOError ( '<STR_LIT>' ) <EOL> self . logsremoved = True <EOL> def get_state ( self ) : <EOL> return self . state <EOL> def stop ( self ) : <EOL> self . stop_called = True <EOL> self . killing = False <EOL> from supervisor . process import ProcessStates <EOL> self . state = ProcessStates . STOPPED <EOL> def kill ( self , signal ) : <EOL> self . killed_with = signal <EOL> def spawn ( self ) : <EOL> self . spawned = True <EOL> from supervisor . process import ProcessStates <EOL> self . state = ProcessStates . RUNNING <EOL> def drain ( self ) : <EOL> self . drained = True <EOL> def __cmp__ ( self , other ) : <EOL> return cmp ( self . config . priority , other . config . priority ) <EOL> def readable_fds ( self ) : <EOL> return [ ] <EOL> def record_output ( self ) : <EOL> self . stdout_logged += self . stdout_buffer <EOL> self . stdout_buffer = '<STR_LIT>' <EOL> self . stderr_logged += self . stderr_buffer <EOL> self . stderr_buffer = '<STR_LIT>' <EOL> def finish ( self , pid , sts ) : <EOL> self . finished = pid , sts <EOL> def give_up ( self ) : <EOL> from supervisor . process import ProcessStates <EOL> self . state = ProcessStates . FATAL <EOL> def get_execv_args ( self ) : <EOL> if self . execv_arg_exception : <EOL> raise self . execv_arg_exception ( '<STR_LIT>' ) <EOL> import shlex <EOL> commandargs = shlex . split ( self . config . command ) <EOL> program = commandargs [ <NUM_LIT:0> ] <EOL> return program , commandargs <EOL> def drain_output_fd ( self , fd ) : <EOL> self . output_fd_drained = fd <EOL> def drain_input_fd ( self , fd ) : <EOL> self . input_fd_drained = fd <EOL> def write ( self , chars ) : <EOL> if self . write_error : <EOL> raise OSError ( self . write_error ) <EOL> self . stdin_buffer += chars <EOL> def transition ( self ) : <EOL> self . transitioned = True <EOL> class DummyPConfig : <EOL> def __init__ ( self , options , name , command , directory = None , umask = None , <EOL> priority = <NUM_LIT> , autostart = True , <EOL> autorestart = True , startsecs = <NUM_LIT:10> , startretries = <NUM_LIT> , <EOL> uid = None , stdout_logfile = None , stdout_capture_maxbytes = <NUM_LIT:0> , <EOL> stdout_events_enabled = False , <EOL> stdout_logfile_backups = <NUM_LIT:0> , stdout_logfile_maxbytes = <NUM_LIT:0> , <EOL> stderr_logfile = None , stderr_capture_maxbytes = <NUM_LIT:0> , <EOL> stderr_events_enabled = False , <EOL> stderr_logfile_backups = <NUM_LIT:0> , stderr_logfile_maxbytes = <NUM_LIT:0> , <EOL> redirect_stderr = False , <EOL> stopsignal = None , stopwaitsecs = <NUM_LIT:10> , stopasgroup = False , killasgroup = False , <EOL> exitcodes = ( <NUM_LIT:0> , <NUM_LIT:2> ) , environment = None , serverurl = None ) : <EOL> self . options = options <EOL> self . name = name <EOL> self . command = command <EOL> self . priority = priority <EOL> self . autostart = autostart <EOL> self . autorestart = autorestart <EOL> self . startsecs = startsecs <EOL> self . startretries = startretries <EOL> self . uid = uid <EOL> self . stdout_logfile = stdout_logfile <EOL> self . stdout_capture_maxbytes = stdout_capture_maxbytes <EOL> self . stdout_events_enabled = stdout_events_enabled <EOL> self . stdout_logfile_backups = stdout_logfile_backups <EOL> self . stdout_logfile_maxbytes = stdout_logfile_maxbytes <EOL> self . stderr_logfile = stderr_logfile <EOL> self . stderr_capture_maxbytes = stderr_capture_maxbytes <EOL> self . stderr_events_enabled = stderr_events_enabled <EOL> self . stderr_logfile_backups = stderr_logfile_backups <EOL> self . stderr_logfile_maxbytes = stderr_logfile_maxbytes <EOL> self . redirect_stderr = redirect_stderr <EOL> if stopsignal is None : <EOL> import signal <EOL> stopsignal = signal . SIGTERM <EOL> self . stopsignal = stopsignal <EOL> self . stopwaitsecs = stopwaitsecs <EOL> self . stopasgroup = stopasgroup <EOL> self . killasgroup = killasgroup <EOL> self . exitcodes = exitcodes <EOL> self . environment = environment <EOL> self . directory = directory <EOL> self . umask = umask <EOL> self . autochildlogs_created = False <EOL> self . serverurl = serverurl <EOL> def create_autochildlogs ( self ) : <EOL> self . autochildlogs_created = True <EOL> def make_process ( self , group = None ) : <EOL> process = DummyProcess ( self ) <EOL> process . group = group <EOL> return process <EOL> def make_dispatchers ( self , proc ) : <EOL> use_stderr = not self . redirect_stderr <EOL> pipes = self . options . make_pipes ( use_stderr ) <EOL> stdout_fd , stderr_fd , stdin_fd = ( pipes [ '<STR_LIT>' ] , pipes [ '<STR_LIT>' ] , <EOL> pipes [ '<STR_LIT>' ] ) <EOL> dispatchers = { } <EOL> if stdout_fd is not None : <EOL> dispatchers [ stdout_fd ] = DummyDispatcher ( readable = True ) <EOL> if stderr_fd is not None : <EOL> dispatchers [ stderr_fd ] = DummyDispatcher ( readable = True ) <EOL> if stdin_fd is not None : <EOL> dispatchers [ stdin_fd ] = DummyDispatcher ( writable = True ) <EOL> return dispatchers , pipes <EOL> def makeExecutable ( file , substitutions = None ) : <EOL> import os <EOL> import sys <EOL> import tempfile <EOL> if substitutions is None : <EOL> substitutions = { } <EOL> data = open ( file ) . read ( ) <EOL> last = os . path . split ( file ) [ <NUM_LIT:1> ] <EOL> substitutions [ '<STR_LIT>' ] = sys . executable <EOL> for key in substitutions . keys ( ) : <EOL> data = data . replace ( '<STR_LIT>' % key . upper ( ) , substitutions [ key ] ) <EOL> tmpnam = tempfile . mktemp ( prefix = last ) <EOL> f = open ( tmpnam , '<STR_LIT:w>' ) <EOL> f . write ( data ) <EOL> f . close ( ) <EOL> os . chmod ( tmpnam , <NUM_LIT:0> <NUM_LIT> ) <EOL> return tmpnam <EOL> def makeSpew ( unkillable = False ) : <EOL> import os <EOL> here = os . path . dirname ( __file__ ) <EOL> if not unkillable : <EOL> return makeExecutable ( os . path . join ( here , '<STR_LIT>' ) ) <EOL> return makeExecutable ( os . path . join ( here , '<STR_LIT>' ) ) <EOL> class DummyMedusaServerLogger : <EOL> def __init__ ( self ) : <EOL> self . logged = [ ] <EOL> def log ( self , category , msg ) : <EOL> self . logged . append ( ( category , msg ) ) <EOL> class DummyMedusaServer : <EOL> def __init__ ( self ) : <EOL> self . logger = DummyMedusaServerLogger ( ) <EOL> class DummyMedusaChannel : <EOL> def __init__ ( self ) : <EOL> self . server = DummyMedusaServer ( ) <EOL> self . producer = None <EOL> def push_with_producer ( self , producer ) : <EOL> self . producer = producer <EOL> def close_when_done ( self ) : <EOL> pass <EOL> class DummyRequest : <EOL> command = '<STR_LIT:GET>' <EOL> _error = None <EOL> _done = False <EOL> version = '<STR_LIT:1.0>' <EOL> def __init__ ( self , path , params , query , fragment , env = None ) : <EOL> self . args = path , params , query , fragment <EOL> self . producers = [ ] <EOL> self . headers = { } <EOL> self . header = [ ] <EOL> self . outgoing = [ ] <EOL> self . channel = DummyMedusaChannel ( ) <EOL> if env is None : <EOL> self . env = { } <EOL> else : <EOL> self . env = env <EOL> def split_uri ( self ) : <EOL> return self . args <EOL> def error ( self , code ) : <EOL> self . _error = code <EOL> def push ( self , producer ) : <EOL> self . producers . append ( producer ) <EOL> def __setitem__ ( self , header , value ) : <EOL> self . headers [ header ] = value <EOL> def has_key ( self , header ) : <EOL> return self . headers . has_key ( header ) <EOL> def done ( self ) : <EOL> self . _done = True <EOL> def build_reply_header ( self ) : <EOL> return '<STR_LIT>' <EOL> def log ( self , * arg , ** kw ) : <EOL> pass <EOL> def cgi_environment ( self ) : <EOL> return self . env <EOL> def get_server_url ( self ) : <EOL> return '<STR_LIT>' <EOL> class DummyRPCInterfaceFactory : <EOL> def __init__ ( self , supervisord , ** config ) : <EOL> self . supervisord = supervisord <EOL> self . config = config <EOL> class DummyRPCServer : <EOL> def __init__ ( self ) : <EOL> self . supervisor = DummySupervisorRPCNamespace ( ) <EOL> self . system = DummySystemRPCNamespace ( ) <EOL> class DummySystemRPCNamespace : <EOL> pass <EOL> class DummySupervisorRPCNamespace : <EOL> _restartable = True <EOL> _restarted = False <EOL> _shutdown = False <EOL> _readlog_error = False <EOL> from supervisor . process import ProcessStates <EOL> all_process_info = [ <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : <NUM_LIT:11> , <EOL> '<STR_LIT:state>' : ProcessStates . RUNNING , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:start>' : _NOW - <NUM_LIT:100> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : _NOW , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : '<STR_LIT:bar>' , <EOL> '<STR_LIT>' : <NUM_LIT:12> , <EOL> '<STR_LIT:state>' : ProcessStates . FATAL , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:start>' : _NOW - <NUM_LIT:100> , <EOL> '<STR_LIT>' : _NOW - <NUM_LIT:50> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : _NOW , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } , <EOL> { <EOL> '<STR_LIT:name>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT:state>' : ProcessStates . STOPPED , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:start>' : _NOW - <NUM_LIT:100> , <EOL> '<STR_LIT>' : _NOW - <NUM_LIT> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : _NOW , <EOL> '<STR_LIT:description>' : '<STR_LIT>' , <EOL> } , <EOL> ] <EOL> def getAPIVersion ( self ) : <EOL> return '<STR_LIT>' <EOL> getVersion = getAPIVersion <EOL> def getPID ( self ) : <EOL> return <NUM_LIT> <EOL> def readProcessStdoutLog ( self , name , offset , length ) : <EOL> from supervisor import xmlrpc <EOL> import xmlrpclib <EOL> if name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> elif name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . FAILED , '<STR_LIT>' ) <EOL> elif name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . NO_FILE , '<STR_LIT>' ) <EOL> a = '<STR_LIT>' * <NUM_LIT:10> <EOL> return a [ offset : ] <EOL> readProcessLog = readProcessStdoutLog <EOL> readProcessStderrLog = readProcessStdoutLog <EOL> def getAllProcessInfo ( self ) : <EOL> return self . all_process_info <EOL> def getProcessInfo ( self , name ) : <EOL> from supervisor import xmlrpc <EOL> import xmlrpclib <EOL> from supervisor . process import ProcessStates <EOL> for i in self . all_process_info : <EOL> if i [ '<STR_LIT:name>' ] == name : <EOL> info = i <EOL> return info <EOL> if name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . FAILED , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise xmlrpclib . Fault ( xmlrpc . Faults . NO_FILE , '<STR_LIT>' ) <EOL> def startProcess ( self , name ) : <EOL> from supervisor import xmlrpc <EOL> from xmlrpclib import Fault <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . NO_FILE , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . NOT_EXECUTABLE , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . ALREADY_STARTED , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . SPAWN_ERROR , '<STR_LIT>' ) <EOL> return True <EOL> def startProcessGroup ( self , name ) : <EOL> from supervisor import xmlrpc <EOL> return [ <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> ] <EOL> def startAllProcesses ( self ) : <EOL> from supervisor import xmlrpc <EOL> return [ <EOL> { '<STR_LIT:name>' : '<STR_LIT:foo>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SPAWN_ERROR , <EOL> '<STR_LIT:description>' : '<STR_LIT>' } <EOL> ] <EOL> def stopProcessGroup ( self , name ) : <EOL> from supervisor import xmlrpc <EOL> return [ <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> ] <EOL> def stopProcess ( self , name ) : <EOL> from supervisor import xmlrpc <EOL> from xmlrpclib import Fault <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . NOT_RUNNING , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . FAILED , '<STR_LIT>' ) <EOL> return True <EOL> def stopAllProcesses ( self ) : <EOL> from supervisor import xmlrpc <EOL> return [ <EOL> { '<STR_LIT:name>' : '<STR_LIT:foo>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . BAD_NAME , <EOL> '<STR_LIT:description>' : '<STR_LIT>' } <EOL> ] <EOL> def restart ( self ) : <EOL> if self . _restartable : <EOL> self . _restarted = True <EOL> return <EOL> from xmlrpclib import Fault <EOL> from supervisor import xmlrpc <EOL> raise Fault ( xmlrpc . Faults . SHUTDOWN_STATE , '<STR_LIT>' ) <EOL> def shutdown ( self ) : <EOL> if self . _restartable : <EOL> self . _shutdown = True <EOL> return <EOL> from xmlrpclib import Fault <EOL> from supervisor import xmlrpc <EOL> raise Fault ( xmlrpc . Faults . SHUTDOWN_STATE , '<STR_LIT>' ) <EOL> def reloadConfig ( self ) : <EOL> return [ [ [ '<STR_LIT>' ] , [ '<STR_LIT>' ] , [ '<STR_LIT>' ] ] ] <EOL> def addProcessGroup ( self , name ) : <EOL> from xmlrpclib import Fault <EOL> from supervisor import xmlrpc <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . ALREADY_ADDED , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> if hasattr ( self , '<STR_LIT>' ) : <EOL> self . processes . append ( name ) <EOL> else : <EOL> self . processes = [ name ] <EOL> def removeProcessGroup ( self , name ) : <EOL> from xmlrpclib import Fault <EOL> from supervisor import xmlrpc <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . STILL_RUNNING , '<STR_LIT>' ) <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> self . processes . remove ( name ) <EOL> def clearProcessStdoutLog ( self , name ) : <EOL> from xmlrpclib import Fault <EOL> from supervisor import xmlrpc <EOL> if name == '<STR_LIT>' : <EOL> raise Fault ( xmlrpc . Faults . BAD_NAME , '<STR_LIT>' ) <EOL> return True <EOL> clearProcessLog = clearProcessStdoutLog <EOL> clearProcessStderrLog = clearProcessStdoutLog <EOL> clearProcessLogs = clearProcessStdoutLog <EOL> def clearAllProcessLogs ( self ) : <EOL> from supervisor import xmlrpc <EOL> return [ <EOL> { '<STR_LIT:name>' : '<STR_LIT:foo>' , '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . SUCCESS , <EOL> '<STR_LIT:description>' : '<STR_LIT:OK>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:status>' : xmlrpc . Faults . FAILED , <EOL> '<STR_LIT:description>' : '<STR_LIT>' } <EOL> ] <EOL> def raiseError ( self ) : <EOL> raise ValueError ( '<STR_LIT:error>' ) <EOL> def getSupervisorVersion ( self ) : <EOL> return '<STR_LIT>' <EOL> def readLog ( self , whence , offset ) : <EOL> if self . _readlog_error : <EOL> from xmlrpclib import Fault <EOL> raise Fault ( self . _readlog_error , '<STR_LIT>' ) <EOL> return '<STR_LIT>' <EOL> class DummyPGroupConfig : <EOL> def __init__ ( self , options , name = '<STR_LIT>' , priority = <NUM_LIT> , pconfigs = None ) : <EOL> self . options = options <EOL> self . name = name <EOL> self . priority = priority <EOL> if pconfigs is None : <EOL> pconfigs = [ ] <EOL> self . process_configs = pconfigs <EOL> self . after_setuid_called = False <EOL> self . pool_events = [ ] <EOL> self . buffer_size = <NUM_LIT:10> <EOL> def after_setuid ( self ) : <EOL> self . after_setuid_called = True <EOL> def make_group ( self ) : <EOL> return DummyProcessGroup ( self ) <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . __class__ , id ( self ) , <EOL> self . name ) <EOL> class DummyFCGIGroupConfig ( DummyPGroupConfig ) : <EOL> def __init__ ( self , options , name = '<STR_LIT>' , priority = <NUM_LIT> , pconfigs = None , socket_config = DummySocketConfig ( <NUM_LIT:1> ) ) : <EOL> DummyPGroupConfig . __init__ ( self , options , name , priority , pconfigs ) <EOL> self . socket_config = socket_config <EOL> class DummyProcessGroup : <EOL> def __init__ ( self , config ) : <EOL> self . config = config <EOL> self . transitioned = False <EOL> self . all_stopped = False <EOL> self . dispatchers = { } <EOL> self . unstopped_processes = [ ] <EOL> def transition ( self ) : <EOL> self . transitioned = True <EOL> def stop_all ( self ) : <EOL> self . all_stopped = True <EOL> def get_unstopped_processes ( self ) : <EOL> return self . unstopped_processes <EOL> def get_dispatchers ( self ) : <EOL> return self . dispatchers <EOL> class DummyFCGIProcessGroup ( DummyProcessGroup ) : <EOL> def __init__ ( self , config ) : <EOL> DummyProcessGroup . __init__ ( self , config ) <EOL> self . socket_manager = DummySocketManager ( config . socket_config ) <EOL> class PopulatedDummySupervisor ( DummySupervisor ) : <EOL> def __init__ ( self , options , group_name , * pconfigs ) : <EOL> DummySupervisor . __init__ ( self , options ) <EOL> self . process_groups = { } <EOL> processes = { } <EOL> self . group_name = group_name <EOL> gconfig = DummyPGroupConfig ( options , group_name , pconfigs = pconfigs ) <EOL> pgroup = DummyProcessGroup ( gconfig ) <EOL> self . process_groups [ group_name ] = pgroup <EOL> for pconfig in pconfigs : <EOL> process = DummyProcess ( pconfig ) <EOL> processes [ pconfig . name ] = process <EOL> pgroup . processes = processes <EOL> def set_procattr ( self , process_name , attr_name , val , group_name = None ) : <EOL> if group_name is None : <EOL> group_name = self . group_name <EOL> process = self . process_groups [ group_name ] . processes [ process_name ] <EOL> setattr ( process , attr_name , val ) <EOL> class DummyDispatcher : <EOL> write_event_handled = False <EOL> read_event_handled = False <EOL> error_handled = False <EOL> logs_reopened = False <EOL> logs_removed = False <EOL> closed = False <EOL> flush_error = None <EOL> flushed = False <EOL> def __init__ ( self , readable = False , writable = False , error = False ) : <EOL> self . _readable = readable <EOL> self . _writable = writable <EOL> self . _error = error <EOL> self . input_buffer = '<STR_LIT>' <EOL> if readable : <EOL> def reopenlogs ( ) : <EOL> self . logs_reopened = True <EOL> self . reopenlogs = reopenlogs <EOL> def removelogs ( ) : <EOL> self . logs_removed = True <EOL> self . removelogs = removelogs <EOL> def readable ( self ) : <EOL> return self . _readable <EOL> def writable ( self ) : <EOL> return self . _writable <EOL> def handle_write_event ( self ) : <EOL> if self . _error : <EOL> raise self . _error <EOL> self . write_event_handled = True <EOL> def handle_read_event ( self ) : <EOL> if self . _error : <EOL> raise self . _error <EOL> self . read_event_handled = True <EOL> def handle_error ( self ) : <EOL> self . error_handled = True <EOL> def close ( self ) : <EOL> self . closed = True <EOL> def flush ( self ) : <EOL> if self . flush_error : <EOL> raise OSError ( self . flush_error ) <EOL> self . flushed = True <EOL> class DummyStream : <EOL> def __init__ ( self , error = None ) : <EOL> self . error = error <EOL> self . closed = False <EOL> self . flushed = False <EOL> self . written = '<STR_LIT>' <EOL> def close ( self ) : <EOL> if self . error : <EOL> raise self . error <EOL> self . closed = True <EOL> def flush ( self ) : <EOL> self . flushed = True <EOL> def write ( self , msg ) : <EOL> if self . error : <EOL> raise self . error <EOL> self . written += msg <EOL> def seek ( self , num , whence = <NUM_LIT:0> ) : <EOL> pass <EOL> def tell ( self ) : <EOL> return len ( self . written ) <EOL> class DummyEvent : <EOL> def __init__ ( self , serial = '<STR_LIT:abc>' ) : <EOL> if serial is not None : <EOL> self . serial = serial <EOL> def __str__ ( self ) : <EOL> return '<STR_LIT>' <EOL> def dummy_handler ( event , result ) : <EOL> pass <EOL> def rejecting_handler ( event , result ) : <EOL> from supervisor . dispatchers import RejectEvent <EOL> raise RejectEvent ( result ) <EOL> def exception_handler ( event , result ) : <EOL> raise ValueError ( result ) <EOL> def lstrip ( s ) : <EOL> strings = [ x . strip ( ) for x in s . split ( '<STR_LIT:\n>' ) ] <EOL> return '<STR_LIT:\n>' . join ( strings ) </s>
