PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  4h^c@sddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZdd lmZddlmZmZmZddlmZddlmZddlmZddlmZddlmZmZdZ dfdYZ!dZ"dZ#dZ$dZ%dZ&dS(iN(t signal_number(treadFile(ttailFile(t NotExecutable(tNotFound(t NoPermission(t make_namespec(tsplit_namespec(tVERSION(tnotify(tRemoteCommunicationEvent(t NOT_DONE_YET(t capped_inttFaultstRPCError(tSupervisorStates(tgetSupervisorStateDescription(t ProcessStates(tgetProcessStateDescription(tRUNNING_STATEStSTOPPED_STATESs3.0tSupervisorNamespaceRPCInterfacecBseZdZdZdZeZdZdZdZdZ dZ e Z dZ d Z d Zd Zd Zd ZedZdZedZedZedZedZedZedZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%e%Z&d Z'd!Z(d"Z)e)Z*d#Z+d$Z,e,Z-d%Z.d&Z/d'Z0RS((cCs ||_dS(N(t supervisord(tselfR((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt__init__(scCsO||_t|jjjtrK|jjjtjkrKtt j ndS(N( t update_textt isinstanceRtoptionstmoodtintRtRUNNINGRR tSHUTDOWN_STATE(Rttext((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_update+s cCs|jdtS(sj Return the version of the RPC API used by supervisord @return string version version id t getAPIVersion(R!t API_VERSION(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR"3s cCs|jdtS(sw Return the version of the supervisor package in use by supervisord @return string version version id tgetSupervisorVersion(R!R(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR$=s cCs|jd|jjjS(sh Return identifying string of supervisord @return string identifier identifying string tgetIdentification(R!RRt identifier(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR%Es cCs@|jd|jjj}t|}i|d6|d6}|S(s Return current state of supervisord as a struct @return struct A struct with keys int statecode, string statename tgetStatet statecodet statename(R!RRRR(RtstateR)tdata((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR'Ms   cCs|jd|jjjS(s@ Return the PID of supervisord @return int PID tgetPID(R!RRtget_pid(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR,\s cCs|jd|jjj}|dks;tjj| rPtt j |ny t |t |t |SWn5t k r}|jd}ttt |nXdS(s Read length bytes from the main log starting at offset @param int offset offset to start reading from. @param int length number of bytes to read from the log. @return string result Bytes of log treadLogiN(R!RRtlogfiletNonetostpathtexistsRR tNO_FILERRt ValueErrortargstgetattr(RtoffsettlengthR/tinsttwhy((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR.ds   cCs|jd|jjj}|dks>|jjj| rPttjny|jjj |Wn&t t fk rttj nXxL|jjj jD]8}t|dr|jjj jd|jqqWtS(s^ Clear the main log. @return boolean result always returns True unless error tclearLogtreopensreopening log fileN(R!RRR/R0R3RR R4tremovetOSErrortIOErrortFAILEDtloggerthandlersthasattrtinfoR=tTrue(RR/thandler((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR<zs "cCs#|jdtj|jj_tS(sk Shut down the supervisor process @return boolean result always returns True unless error tshutdown(R!RtSHUTDOWNRRRRF(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRHs cCs#|jdtj|jj_tS(si Restart the supervisor process @return boolean result always return True unless error trestart(R!Rt RESTARTINGRRRRF(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRJs cCs|jdy|jjjdtWn%tk rN}ttj|nX|jj \}}}g|D]}|j ^qn}g|D]}|j ^q}g|D]}|j ^q}|||ggS(s Reload the configuration. The result contains three arrays containing names of process groups: * `added` gives the process groups that have been added * `changed` gives the process groups whose contents have changed * `removed` gives the process groups that are no longer in the configuration @return array result [[added, changed, removed]] t reloadConfigtdo_usage( R!RRtprocess_configtFalseR5RR t CANT_REREADtdiff_to_activetname(Rtmsgtaddedtchangedtremovedtgroup((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRLs cCs}|jdxW|jjjD]F}|j|kr|jj|}|s_ttj|nt SqWttj |dS(s Update the config for a running process from config file. @param string name name of process group to add @return boolean result true if successful taddProcessGroupN( R!RRtprocess_group_configsRRtadd_process_groupRR t ALREADY_ADDEDRFtBAD_NAME(RRRtconfigtresult((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRXs cCse|jd||jjkr4ttj|n|jj|}|sattj|ntS(s Remove a stopped process from the active configuration. @param string name name of process group to remove @return boolean result Indicates whether the removal was successful tremoveProcessGroup( R!Rtprocess_groupsRR R\tremove_process_groupt STILL_RUNNINGRF(RRRR^((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR_s c Csg}|r|jjj}|jx|D]`}|jj|}|jj}|jx.|D]&}|j|}|j||fqeWq/Wnj|jjj} | jxK| D]C}|jj} | jx!| D]}|j||fqWqW|S(N(RR`tkeystsortt processestappendtvalues( Rtlexicalt all_processest group_namest group_nameRWt process_namest process_nametprocesstgroupsRe((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_getAllProcessess&         cCst|\}}|jjj|}|dkrHttj|n|dkr^|dfS|jj|}|dkrttj|n||fS(N( RRR`tgetR0RR R\Re(RRRRkRmRWRn((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_getGroupAndProcesss    c ss|jd|j\}dkrPt\}}|j||Syj\}}Wn]tk r}ttj |j dn2t t fk r}ttj |j dnXjtkrttjnj|jjjr"ttjnj|rojtjkrofd} d| _|| _| StS(s Start a process @param string name Process name (or ``group:name``, or ``group:*``) @param boolean wait Wait for process to be fully started @return boolean result Always true unless error t startProcessicsnjrttjnj}|tjtjfkrWttjn|tjkrjt St S(N( tspawnerrRR t SPAWN_ERRORt get_stateRtSTARTINGRtABNORMAL_TERMINATIONRFR (R*(RRRn(s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pytonwaitBs  g?N(R!RrR0RtstartProcessGrouptget_execv_argsRRR R4R6RRtNOT_EXECUTABLERvRtALREADY_STARTEDtspawnRtreapRtRut transitionRRtdelayt rpcinterfaceRF( RRRtwaitRWRkRmtfilenametargvR;Ry((RRRns;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs s0       cCs|jd|jjj|}|dkrCttj|n|jj }|j g|D]}||f^qc}t |t |j d|}d|_||_|S(s Start all processes in the group named 'name' @param string name The group name @param boolean wait Wait for each process to be fully started @return array result An array of process status info structs RzRg?N(R!RR`RqR0RR R\ReRgRdt make_allfunct isNotRunningRsRR(RRRRRWReRntstartall((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRzVs      cCsJ|jd|j}t|t|jd|}d|_||_|S(s Start all processes listed in the configuration file @param boolean wait Wait for each process to be fully started @return array result An array of process status info structs tstartAllProcessesRg?(R!RpRRRsRR(RRReR((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRos     cs|jd|j|\}dkrPt|\}}|j||Sjtkrwttj |nj }|dk rttj |n|j j |rjtkrfd}d|_||_|StS(s Stop a process named by name @param string name The name of the process to stop (or 'group:name') @param boolean wait Wait for the process to be fully stopped @return boolean result Always return True unless error t stopProcesscs$jjtkr tStS(N(t stop_reportRvRR RF((Rn(s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRys iN(R!RrR0RtstopProcessGroupRvRRR t NOT_RUNNINGtstopRARRRRRRF(RRRRRWRkRmRSRy((Rns;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs"       cCs|jd|jjj|}|dkrCttj|n|jj }|j g|D]}||f^qc}t |t |j d|}d|_||_|S(s Stop all processes in the process group named 'name' @param string name The group name @param boolean wait Wait for each process to be fully stopped @return array result An array of process status info structs RRg?N(R!RR`RqR0RR R\ReRgRdRt isRunningRRR(RRRRRWReRntkillall((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs      cCsJ|jd|j}t|t|jd|}d|_||_|S(s Stop all processes in the process list @param boolean wait Wait for each process to be fully stopped @return array result An array of process status info structs tstopAllProcessesRg?(R!RpRRRRR(RRReR((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs     c Cs|jd|j|\}}|dkrSt|\}}|j|d|Syt|}Wn#tk rttj |nX|j t krttj |n|j |}|dk rttj|ntS(s Send an arbitrary UNIX signal to the process named by name @param string name Name of the process to signal (or 'group:name') @param string signal Signal to send, as name ('HUP') or number ('1') @return boolean t signalProcesstsignalN(R!RrR0RtsignalProcessGroupRR5RR t BAD_SIGNALRvRRRRARF( RRRRRWRnRkRmtsigRS((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs    cCs|jd|jjj|}|dkrCttj|n|jj }|j g|D]}||f^qc}t |t |j d|}|}|jd|S(s Send a signal to all processes in the group named 'name' @param string name The group name @param string signal Signal to send, as name ('HUP') or number ('1') @return array RRN(R!RR`RqR0RR R\ReRgRdRRR(RRRRRWReRntsendallR^((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs      cCsA|j}t|t|jd|}|}|jd|S(s Send a signal to all processes in the process list @param string signal Signal to send, as name ('HUP') or number ('1') @return array An array of process status info structs RtsignalAllProcesses(RpRRRR!(RRRet signalallR^((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs     cCs|jdg}x|jjjD]u}|j|jjk}xW|jD]L}|ji|jd6|jd6|d6|jd6|j d6|j d6qHWq#W|j |S(s Get info about all available process configurations. Each struct represents a single process (i.e. groups get flattened). @return array result An array of process config info structs tgetAllConfigInfoRRRWtinuset autostartt group_priot process_prio( R!RRRYRRR`tprocess_configsRfRtpriorityRd(Rt configinfotgconfigRtpconfig((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR s      c CsS|d}|tjkr|d}|d}tjtj|d }tjtj|d }||}t|dkrtjd}nd|d|f}n|tjtjfkr|d}|sOd |d }qOni|tj tj fkrI|dr@|d } tjtj | d } | j d }qOd}nd}|S(NR*tstarttnowiispid %s, uptime %stpidRtsunknown error (try "tail %s")RRRis%b %d %I:%M %ps Not startedt( RRtdatetimettimetgmtimet_total_secondst timedeltatFATALtBACKOFFtSTOPPEDtEXITEDt localtimetstrftime( RRER*RRtstart_dttnow_dttuptimetdescRtstop_dt((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_interpretProcessInfo7s,        cCsT|jd|j|\}}|dkrCttj|nt|j}t|j}t|j }|j }|j pd}|j pd} |j jpd} |j jpd} i |j jd6|j jd6|d6|d6|d6|d 6t|d 6|d 6| d 6| d 6| d6| d6|jd6} |j| } | | d<| S(s Get info about a process named name @param string name The name of the process (or 'group:name') @return struct result A structure containing data about the process tgetProcessInfoRiRRRWRRRR*R)Rtt exitstatusR/tstdout_logfiletstderr_logfileRt descriptionN(R!RrR0RR R\R t laststarttlaststopt_nowRvRtRR]RRRRRRR(RRRRWRnRRRR*RtRRRRER((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRVs:        cCs tjS(N(R(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRscCsq|jd|jdt}g}xE|D]=\}}t|jj|jj}|j|j|q,W|S(sh Get info about all processes @return array result An array of process status results tgetAllProcessInfoRh(R!RpRFRR]RRRfR(RRitoutputRWRnRR((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs c Cs|j|\}}|dkr6ttj|nt|jd|}|dksktjj | rttj |ny t |t |t |SWn5t k r}|jd} ttt| nXdS(Ns %s_logfilei(RrR0RR R\R7R]R1R2R3R4RRR5R6( RRRR8R9tchannelRWRnR/R:R;((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_readProcessLogs   cCs#|jd|j|||dS(sI Read length bytes from name's stdout log starting at offset @param string name the name of the process (or 'group:name') @param int offset offset to start reading from. @param int length number of bytes to read from the log. @return string result Bytes of log treadProcessStdoutLogtstdout(R!R(RRRR8R9((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs cCs#|jd|j|||dS(sI Read length bytes from name's stderr log starting at offset @param string name the name of the process (or 'group:name') @param int offset offset to start reading from. @param int length number of bytes to read from the log. @return string result Bytes of log treadProcessStderrLogtstderr(R!R(RRRR8R9((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs cCs|j|\}}|dkr6ttj|nt|jd|}|dksktjj | rxddt gSt |t |t |S(Ns %s_logfileRi( RrR0RR R\R7R]R1R2R3RORR(RRRR8R9RRWRnR/((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyt_tailProcessLogs  cCs#|jd|j|||dS(s Provides a more efficient way to tail the (stdout) log than readProcessStdoutLog(). Use readProcessStdoutLog() to read chunks and tailProcessStdoutLog() to tail. Requests (length) bytes from the (name)'s log, starting at (offset). If the total log size is greater than (offset + length), the overflow flag is set and the (offset) is automatically increased to position the buffer at the end of the log. If less than (length) bytes are available, the maximum number of available bytes will be returned. (offset) returned is always the last offset in the log +1. @param string name the name of the process (or 'group:name') @param int offset offset to start reading from @param int length maximum number of bytes to return @return array result [string bytes, int offset, bool overflow] ttailProcessStdoutLogR(R!R(RRRR8R9((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs cCs#|jd|j|||dS(s Provides a more efficient way to tail the (stderr) log than readProcessStderrLog(). Use readProcessStderrLog() to read chunks and tailProcessStderrLog() to tail. Requests (length) bytes from the (name)'s log, starting at (offset). If the total log size is greater than (offset + length), the overflow flag is set and the (offset) is automatically increased to position the buffer at the end of the log. If less than (length) bytes are available, the maximum number of available bytes will be returned. (offset) returned is always the last offset in the log +1. @param string name the name of the process (or 'group:name') @param int offset offset to start reading from @param int length maximum number of bytes to return @return array result [string bytes, int offset, bool overflow] ttailProcessStderrLogR(R!R(RRRR8R9((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs cCs|jd|j|\}}|dkrCttj|ny|jWn)ttfk r|ttj |nXt S(s Clear the stdout and stderr logs for the named process and reopen them. @param string name The name of the process (or 'group:name') @return boolean result Always True unless error tclearProcessLogsN( R!RrR0RR R\t removelogsR@R?RARF(RRRRWRn((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs  cs}|jdgg|j}x-|D]%\}}j|||jfq,Wfd}d|_||_|S(sm Clear all process log files @return array result An array of process status info structs tclearAllProcessLogscss Sjd\}}}t|jj|jj}y||WnNtk r}ji|jjd6|jjd6|jd6|jd6n9Xji|jjd6|jjd6tj d6dd6rt SS(NiRRRWtstatusRtOK( tpopRR]RRRRftcodeR R tSUCCESSR (RWRntcallbackRRte(t callbackstresults(s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pytclearall!s(     g?(R!RpRftclearProcessLogRR(RRiRWRnR((RRs;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRs    cCs |jdt|tr.|jd}nt|tsRttj|n|j|\}}|dkrttj |n|j s|j rttj |ny|j|WnAtk r}|jdtjkrttj|qnXtS(s Send a string of chars to the stdin of the process name. If non-7-bit data is sent (unicode), it is encoded to utf-8 before being sent to the process' stdin. If chars is not a string or is not unicode, raise INCORRECT_PARAMETERS. If the process is not running, raise NOT_RUNNING. If the process' stdin cannot accept input (e.g. it was closed by the child process), raise NO_FILE. @param string name The process name to send to (or 'group:name') @param string chars The character data to send to the process @return boolean result Always return True unless error tsendProcessStdinsutf-8iN(R!Rtunicodetencodet basestringRR tINCORRECT_PARAMETERSRrR0R\RtkillingRtwriteR?R6terrnotEPIPER4RF(RRRtcharsRWRnR;((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR@s"  cCsYt|tr!|jd}nt|trB|jd}ntt||tS(sB Send an event that will be received by event listener subprocesses subscribing to the RemoteCommunicationEvent. @param string type String for the "type" key in the event header @param string data Data for the event body @return boolean Always return True unless error sutf-8(RRRR R RF(RttypeR+((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pytsendRemoteCommEventgs(1t__name__t __module__RR!R"t getVersionR$R%R'R,R.t readMainLogR<RHRJRLRXR_RORpRrRFRsRzRRRRRRRRRRRRRRtreadProcessLogRRRttailProcessLogRRRRRR(((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR'sZ               J   3       .        - 'cCs!|jd|jd|jdS(NiQi ii@Bi@B(tdaystsecondst microseconds(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRzscKs+g}g}||||||d}|S(sl Return a closure representing a function that calls a function for every process, and returns a result cSs |sx |D]\}}t|jj|jj}||r y|||} WnQtk r} |ji|jjd6|jjd6| jd6| jd6q nXt| tj r|j||| fq |ji|jjd6|jjd6t j d6dd6q q Wn|s|Sx|D]} | \}}} y | } Wn[tk r} |ji|jjd6|jjd6| jd6| jd6|j | q&X| t k r&|ji|jjd6|jjd6t j d6dd6|j | q&q&W|rt S|S(NRRRWRRR(RR]RRRRfRR Rttypest FunctionTypeR RR>R (Ret predicatetfunct extra_kwargsRRRWRnRRRRtstructtcbtvalue((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pytallfuncsT             ((ReRRRRRR((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyR~s KcCs|jtkS(N(RvR(Rn((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRscCs t| S(N(R(Rn((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyRscCs t|S(N(R(R((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pytmake_main_rpcinterfaces('R1RRRRtsupervisor.datatypesRtsupervisor.optionsRRRRRRRRtsupervisor.eventsR R tsupervisor.httpR tsupervisor.xmlrpcR R Rtsupervisor.statesRRRRRRR#RRRRRR(((s;/usr/lib/python2.7/site-packages/supervisor/rpcinterface.pyts@     V  Z