nwo
stringlengths 10
28
| sha
stringlengths 40
40
| path
stringlengths 11
97
| identifier
stringlengths 1
64
| parameters
stringlengths 2
2.24k
| return_statement
stringlengths 0
2.17k
| docstring
stringlengths 0
5.45k
| docstring_summary
stringlengths 0
3.83k
| func_begin
int64 1
13.4k
| func_end
int64 2
13.4k
| function
stringlengths 28
56.4k
| url
stringlengths 106
209
| project
int64 1
48
| executed_lines
list | executed_lines_pc
float64 0
153
| missing_lines
list | missing_lines_pc
float64 0
100
| covered
bool 2
classes | filecoverage
float64 2.53
100
| function_lines
int64 2
1.46k
| mccabe
int64 1
253
| coverage
float64 0
100
| docstring_lines
int64 0
112
| function_nodoc
stringlengths 9
56.4k
| id
int64 0
29.8k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SystemNamespaceRPCInterface.listMethods
|
(self)
|
return keys
|
Return an array listing the available method names
@return array result An array of method names available (strings).
|
Return an array listing the available method names
| 175 | 183 |
def listMethods(self):
""" Return an array listing the available method names
@return array result An array of method names available (strings).
"""
methods = self._listMethods()
keys = list(methods.keys())
keys.sort()
return keys
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L175-L183
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 99.741602 | 9 | 1 | 100 | 3 |
def listMethods(self):
methods = self._listMethods()
keys = list(methods.keys())
keys.sort()
return keys
| 4,108 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SystemNamespaceRPCInterface.methodHelp
|
(self, name)
|
Return a string showing the method's documentation
@param string name The name of the method.
@return string result The documentation for the method name.
|
Return a string showing the method's documentation
| 185 | 195 |
def methodHelp(self, name):
""" Return a string showing the method's documentation
@param string name The name of the method.
@return string result The documentation for the method name.
"""
methods = self._listMethods()
for methodname in methods.keys():
if methodname == name:
return methods[methodname]
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L185-L195
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 100 |
[] | 0 | true | 99.741602 | 11 | 3 | 100 | 4 |
def methodHelp(self, name):
methods = self._listMethods()
for methodname in methods.keys():
if methodname == name:
return methods[methodname]
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
| 4,109 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SystemNamespaceRPCInterface.methodSignature
|
(self, name)
|
Return an array describing the method signature in the
form [rtype, ptype, ptype...] where rtype is the return data type
of the method, and ptypes are the parameter data types that the
method accepts in method argument order.
@param string name The name of the method.
@return array result The result.
|
Return an array describing the method signature in the
form [rtype, ptype, ptype...] where rtype is the return data type
of the method, and ptypes are the parameter data types that the
method accepts in method argument order.
| 197 | 220 |
def methodSignature(self, name):
""" Return an array describing the method signature in the
form [rtype, ptype, ptype...] where rtype is the return data type
of the method, and ptypes are the parameter data types that the
method accepts in method argument order.
@param string name The name of the method.
@return array result The result.
"""
methods = self._listMethods()
for method in methods:
if method == name:
rtype = None
ptypes = []
parsed = gettags(methods[method])
for thing in parsed:
if thing[1] == 'return': # tag name
rtype = thing[2] # datatype
elif thing[1] == 'param': # tag name
ptypes.append(thing[2]) # datatype
if rtype is None:
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
return [rtype] + ptypes
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L197-L220
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 100 |
[] | 0 | true | 99.741602 | 24 | 7 | 100 | 7 |
def methodSignature(self, name):
methods = self._listMethods()
for method in methods:
if method == name:
rtype = None
ptypes = []
parsed = gettags(methods[method])
for thing in parsed:
if thing[1] == 'return': # tag name
rtype = thing[2] # datatype
elif thing[1] == 'param': # tag name
ptypes.append(thing[2]) # datatype
if rtype is None:
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
return [rtype] + ptypes
raise RPCError(Faults.SIGNATURE_UNSUPPORTED)
| 4,110 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SystemNamespaceRPCInterface.multicall
|
(self, calls)
|
Process an array of calls, and return an array of
results. Calls should be structs of the form {'methodName':
string, 'params': array}. Each result will either be a
single-item array containing the result value, or a struct of
the form {'faultCode': int, 'faultString': string}. This is
useful when you need to make lots of small calls without lots
of round trips.
@param array calls An array of call requests
@return array result An array of results
|
Process an array of calls, and return an array of
results. Calls should be structs of the form {'methodName':
string, 'params': array}. Each result will either be a
single-item array containing the result value, or a struct of
the form {'faultCode': int, 'faultString': string}. This is
useful when you need to make lots of small calls without lots
of round trips.
| 222 | 303 |
def multicall(self, calls):
"""Process an array of calls, and return an array of
results. Calls should be structs of the form {'methodName':
string, 'params': array}. Each result will either be a
single-item array containing the result value, or a struct of
the form {'faultCode': int, 'faultString': string}. This is
useful when you need to make lots of small calls without lots
of round trips.
@param array calls An array of call requests
@return array result An array of results
"""
remaining_calls = calls[:] # [{'methodName':x, 'params':x}, ...]
callbacks = [] # always empty or 1 callback function only
results = [] # results of completed calls
# args are only to fool scoping and are never passed by caller
def multi(remaining_calls=remaining_calls,
callbacks=callbacks,
results=results):
# if waiting on a callback, call it, then remove it if it's done
if callbacks:
try:
value = callbacks[0]()
except RPCError as exc:
value = {'faultCode': exc.code,
'faultString': exc.text}
except:
info = sys.exc_info()
errmsg = "%s:%s" % (info[0], info[1])
value = {'faultCode': Faults.FAILED,
'faultString': 'FAILED: ' + errmsg}
if value is not NOT_DONE_YET:
callbacks.pop(0)
results.append(value)
# if we don't have a callback now, pop calls and call them in
# order until one returns a callback.
while (not callbacks) and remaining_calls:
call = remaining_calls.pop(0)
name = call.get('methodName', None)
params = call.get('params', [])
try:
if name is None:
raise RPCError(Faults.INCORRECT_PARAMETERS,
'No methodName')
if name == 'system.multicall':
raise RPCError(Faults.INCORRECT_PARAMETERS,
'Recursive system.multicall forbidden')
# make the call, may return a callback or not
root = AttrDict(self.namespaces)
value = traverse(root, name, params)
except RPCError as exc:
value = {'faultCode': exc.code,
'faultString': exc.text}
except:
info = sys.exc_info()
errmsg = "%s:%s" % (info[0], info[1])
value = {'faultCode': Faults.FAILED,
'faultString': 'FAILED: ' + errmsg}
if isinstance(value, types.FunctionType):
callbacks.append(value)
else:
results.append(value)
# we are done when there's no callback and no more calls queued
if callbacks or remaining_calls:
return NOT_DONE_YET
else:
return results
multi.delay = 0.05
# optimization: multi() is called here instead of just returning
# multi in case all calls complete and we can return with no delay.
value = multi()
if value is NOT_DONE_YET:
return multi
else:
return value
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L222-L303
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81
] | 100 |
[] | 0 | true | 99.741602 | 82 | 16 | 100 | 10 |
def multicall(self, calls):
remaining_calls = calls[:] # [{'methodName':x, 'params':x}, ...]
callbacks = [] # always empty or 1 callback function only
results = [] # results of completed calls
# args are only to fool scoping and are never passed by caller
def multi(remaining_calls=remaining_calls,
callbacks=callbacks,
results=results):
# if waiting on a callback, call it, then remove it if it's done
if callbacks:
try:
value = callbacks[0]()
except RPCError as exc:
value = {'faultCode': exc.code,
'faultString': exc.text}
except:
info = sys.exc_info()
errmsg = "%s:%s" % (info[0], info[1])
value = {'faultCode': Faults.FAILED,
'faultString': 'FAILED: ' + errmsg}
if value is not NOT_DONE_YET:
callbacks.pop(0)
results.append(value)
# if we don't have a callback now, pop calls and call them in
# order until one returns a callback.
while (not callbacks) and remaining_calls:
call = remaining_calls.pop(0)
name = call.get('methodName', None)
params = call.get('params', [])
try:
if name is None:
raise RPCError(Faults.INCORRECT_PARAMETERS,
'No methodName')
if name == 'system.multicall':
raise RPCError(Faults.INCORRECT_PARAMETERS,
'Recursive system.multicall forbidden')
# make the call, may return a callback or not
root = AttrDict(self.namespaces)
value = traverse(root, name, params)
except RPCError as exc:
value = {'faultCode': exc.code,
'faultString': exc.text}
except:
info = sys.exc_info()
errmsg = "%s:%s" % (info[0], info[1])
value = {'faultCode': Faults.FAILED,
'faultString': 'FAILED: ' + errmsg}
if isinstance(value, types.FunctionType):
callbacks.append(value)
else:
results.append(value)
# we are done when there's no callback and no more calls queued
if callbacks or remaining_calls:
return NOT_DONE_YET
else:
return results
multi.delay = 0.05
# optimization: multi() is called here instead of just returning
# multi in case all calls complete and we can return with no delay.
value = multi()
if value is NOT_DONE_YET:
return multi
else:
return value
| 4,111 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
AttrDict.__getattr__
|
(self, name)
|
return self.get(name)
| 307 | 308 |
def __getattr__(self, name):
return self.get(name)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L307-L308
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.741602 | 2 | 1 | 100 | 0 |
def __getattr__(self, name):
return self.get(name)
| 4,112 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
RootRPCInterface.__init__
|
(self, subinterfaces)
| 311 | 313 |
def __init__(self, subinterfaces):
for name, rpcinterface in subinterfaces:
setattr(self, name, rpcinterface)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L311-L313
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 99.741602 | 3 | 2 | 100 | 0 |
def __init__(self, subinterfaces):
for name, rpcinterface in subinterfaces:
setattr(self, name, rpcinterface)
| 4,113 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
supervisor_xmlrpc_handler.__init__
|
(self, supervisord, subinterfaces)
| 346 | 348 |
def __init__(self, supervisord, subinterfaces):
self.rpcinterface = RootRPCInterface(subinterfaces)
self.supervisord = supervisord
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L346-L348
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 99.741602 | 3 | 1 | 100 | 0 |
def __init__(self, supervisord, subinterfaces):
self.rpcinterface = RootRPCInterface(subinterfaces)
self.supervisord = supervisord
| 4,114 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
supervisor_xmlrpc_handler.loads
|
(self, data)
|
return params, method
| 350 | 369 |
def loads(self, data):
params = method = None
for action, elem in iterparse(StringIO(data)):
unmarshall = self.unmarshallers.get(elem.tag)
if unmarshall:
data = unmarshall(elem)
elem.clear()
elem.text = data
elif elem.tag == "value":
try:
data = elem[0].text
except IndexError:
data = elem.text or ""
elem.clear()
elem.text = data
elif elem.tag == "methodName":
method = elem.text
elif elem.tag == "params":
params = tuple([v.text for v in elem])
return params, method
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L350-L369
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19
] | 100 |
[] | 0 | true | 99.741602 | 20 | 9 | 100 | 0 |
def loads(self, data):
params = method = None
for action, elem in iterparse(StringIO(data)):
unmarshall = self.unmarshallers.get(elem.tag)
if unmarshall:
data = unmarshall(elem)
elem.clear()
elem.text = data
elif elem.tag == "value":
try:
data = elem[0].text
except IndexError:
data = elem.text or ""
elem.clear()
elem.text = data
elif elem.tag == "methodName":
method = elem.text
elif elem.tag == "params":
params = tuple([v.text for v in elem])
return params, method
| 4,115 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
supervisor_xmlrpc_handler.match
|
(self, request)
|
return request.uri.startswith(self.path)
| 371 | 372 |
def match(self, request):
return request.uri.startswith(self.path)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L371-L372
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.741602 | 2 | 1 | 100 | 0 |
def match(self, request):
return request.uri.startswith(self.path)
| 4,116 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
supervisor_xmlrpc_handler.continue_request
|
(self, data, request)
| 374 | 443 |
def continue_request(self, data, request):
logger = self.supervisord.options.logger
try:
try:
# on 2.x, the Expat parser doesn't like Unicode which actually
# contains non-ASCII characters. It's a bit of a kludge to
# do it conditionally here, but it's down to how underlying
# libs behave
if PY2:
data = data.encode('ascii', 'xmlcharrefreplace')
params, method = self.loads(data)
except:
logger.error(
'XML-RPC request data %r is invalid: unmarshallable' %
(data,)
)
request.error(400)
return
# no <methodName> in the request or name is an empty string
if not method:
logger.error(
'XML-RPC request data %r is invalid: no method name' %
(data,)
)
request.error(400)
return
# we allow xml-rpc clients that do not send empty <params>
# when there are no parameters for the method call
if params is None:
params = ()
try:
logger.trace('XML-RPC method called: %s()' % method)
value = self.call(method, params)
logger.trace('XML-RPC method %s() returned successfully' %
method)
except RPCError as err:
# turn RPCError reported by method into a Fault instance
value = xmlrpclib.Fault(err.code, err.text)
logger.trace('XML-RPC method %s() returned fault: [%d] %s' % (
method,
err.code, err.text))
if isinstance(value, types.FunctionType):
# returning a function from an RPC method implies that
# this needs to be a deferred response (it needs to block).
pushproducer = request.channel.push_with_producer
pushproducer(DeferredXMLRPCResponse(request, value))
else:
# if we get anything but a function, it implies that this
# response doesn't need to be deferred, we can service it
# right away.
body = as_bytes(xmlrpc_marshal(value))
request['Content-Type'] = 'text/xml'
request['Content-Length'] = len(body)
request.push(body)
request.done()
except:
tb = traceback.format_exc()
logger.critical(
"Handling XML-RPC request with data %r raised an unexpected "
"exception: %s" % (data, tb)
)
# internal error, report as HTTP server error
request.error(500)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L374-L443
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
11,
12,
13,
17,
18,
19,
20,
21,
22,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
39,
40,
41,
42,
45,
46,
47,
48,
49,
50,
51,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
68,
69
] | 77.142857 |
[
10
] | 1.428571 | false | 99.741602 | 70 | 8 | 98.571429 | 0 |
def continue_request(self, data, request):
logger = self.supervisord.options.logger
try:
try:
# on 2.x, the Expat parser doesn't like Unicode which actually
# contains non-ASCII characters. It's a bit of a kludge to
# do it conditionally here, but it's down to how underlying
# libs behave
if PY2:
data = data.encode('ascii', 'xmlcharrefreplace')
params, method = self.loads(data)
except:
logger.error(
'XML-RPC request data %r is invalid: unmarshallable' %
(data,)
)
request.error(400)
return
# no <methodName> in the request or name is an empty string
if not method:
logger.error(
'XML-RPC request data %r is invalid: no method name' %
(data,)
)
request.error(400)
return
# we allow xml-rpc clients that do not send empty <params>
# when there are no parameters for the method call
if params is None:
params = ()
try:
logger.trace('XML-RPC method called: %s()' % method)
value = self.call(method, params)
logger.trace('XML-RPC method %s() returned successfully' %
method)
except RPCError as err:
# turn RPCError reported by method into a Fault instance
value = xmlrpclib.Fault(err.code, err.text)
logger.trace('XML-RPC method %s() returned fault: [%d] %s' % (
method,
err.code, err.text))
if isinstance(value, types.FunctionType):
# returning a function from an RPC method implies that
# this needs to be a deferred response (it needs to block).
pushproducer = request.channel.push_with_producer
pushproducer(DeferredXMLRPCResponse(request, value))
else:
# if we get anything but a function, it implies that this
# response doesn't need to be deferred, we can service it
# right away.
body = as_bytes(xmlrpc_marshal(value))
request['Content-Type'] = 'text/xml'
request['Content-Length'] = len(body)
request.push(body)
request.done()
except:
tb = traceback.format_exc()
logger.critical(
"Handling XML-RPC request with data %r raised an unexpected "
"exception: %s" % (data, tb)
)
# internal error, report as HTTP server error
request.error(500)
| 4,117 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
supervisor_xmlrpc_handler.call
|
(self, method, params)
|
return traverse(self.rpcinterface, method, params)
| 445 | 446 |
def call(self, method, params):
return traverse(self.rpcinterface, method, params)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L445-L446
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.741602 | 2 | 1 | 100 | 0 |
def call(self, method, params):
return traverse(self.rpcinterface, method, params)
| 4,118 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SupervisorTransport.__init__
|
(self, username=None, password=None, serverurl=None)
| 482 | 505 |
def __init__(self, username=None, password=None, serverurl=None):
xmlrpclib.Transport.__init__(self)
self.username = username
self.password = password
self.verbose = False
self.serverurl = serverurl
if serverurl.startswith('http://'):
parsed = urlparse.urlparse(serverurl)
host, port = parsed.hostname, parsed.port
if port is None:
port = 80
def get_connection(host=host, port=port):
return httplib.HTTPConnection(host, port)
self._get_connection = get_connection
elif serverurl.startswith('unix://'):
def get_connection(serverurl=serverurl):
# we use 'localhost' here because domain names must be
# < 64 chars (or we'd use the serverurl filename)
conn = UnixStreamHTTPConnection('localhost')
conn.socketfile = serverurl[7:]
return conn
self._get_connection = get_connection
else:
raise ValueError('Unknown protocol for serverurl %s' % serverurl)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L482-L505
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
23
] | 95.833333 |
[] | 0 | false | 99.741602 | 24 | 6 | 100 | 0 |
def __init__(self, username=None, password=None, serverurl=None):
xmlrpclib.Transport.__init__(self)
self.username = username
self.password = password
self.verbose = False
self.serverurl = serverurl
if serverurl.startswith('http://'):
parsed = urlparse.urlparse(serverurl)
host, port = parsed.hostname, parsed.port
if port is None:
port = 80
def get_connection(host=host, port=port):
return httplib.HTTPConnection(host, port)
self._get_connection = get_connection
elif serverurl.startswith('unix://'):
def get_connection(serverurl=serverurl):
# we use 'localhost' here because domain names must be
# < 64 chars (or we'd use the serverurl filename)
conn = UnixStreamHTTPConnection('localhost')
conn.socketfile = serverurl[7:]
return conn
self._get_connection = get_connection
else:
raise ValueError('Unknown protocol for serverurl %s' % serverurl)
| 4,119 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SupervisorTransport.close
|
(self)
| 507 | 510 |
def close(self):
if self.connection:
self.connection.close()
self.connection = None
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L507-L510
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 99.741602 | 4 | 2 | 100 | 0 |
def close(self):
if self.connection:
self.connection.close()
self.connection = None
| 4,120 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
SupervisorTransport.request
|
(self, host, handler, request_body, verbose=0)
|
return u.close()
| 512 | 551 |
def request(self, host, handler, request_body, verbose=0):
request_body = as_bytes(request_body)
if not self.connection:
self.connection = self._get_connection()
self.headers = {
"User-Agent" : self.user_agent,
"Content-Type" : "text/xml",
"Accept": "text/xml"
}
# basic auth
if self.username is not None and self.password is not None:
unencoded = "%s:%s" % (self.username, self.password)
encoded = as_string(encodestring(as_bytes(unencoded)))
encoded = encoded.replace('\n', '')
encoded = encoded.replace('\012', '')
self.headers["Authorization"] = "Basic %s" % encoded
self.headers["Content-Length"] = str(len(request_body))
self.connection.request('POST', handler, request_body, self.headers)
r = self.connection.getresponse()
if r.status != 200:
self.connection.close()
self.connection = None
raise xmlrpclib.ProtocolError(host + handler,
r.status,
r.reason,
'' )
data = r.read()
data = as_string(data)
# on 2.x, the Expat parser doesn't like Unicode which actually
# contains non-ASCII characters
data = data.encode('ascii', 'xmlcharrefreplace')
p, u = self.getparser()
p.feed(data)
p.close()
return u.close()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L512-L551
| 6 |
[
0,
1,
2,
3,
4,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
31,
32,
33,
34,
35,
36,
37,
38,
39
] | 80 |
[] | 0 | false | 99.741602 | 40 | 5 | 100 | 0 |
def request(self, host, handler, request_body, verbose=0):
request_body = as_bytes(request_body)
if not self.connection:
self.connection = self._get_connection()
self.headers = {
"User-Agent" : self.user_agent,
"Content-Type" : "text/xml",
"Accept": "text/xml"
}
# basic auth
if self.username is not None and self.password is not None:
unencoded = "%s:%s" % (self.username, self.password)
encoded = as_string(encodestring(as_bytes(unencoded)))
encoded = encoded.replace('\n', '')
encoded = encoded.replace('\012', '')
self.headers["Authorization"] = "Basic %s" % encoded
self.headers["Content-Length"] = str(len(request_body))
self.connection.request('POST', handler, request_body, self.headers)
r = self.connection.getresponse()
if r.status != 200:
self.connection.close()
self.connection = None
raise xmlrpclib.ProtocolError(host + handler,
r.status,
r.reason,
'' )
data = r.read()
data = as_string(data)
# on 2.x, the Expat parser doesn't like Unicode which actually
# contains non-ASCII characters
data = data.encode('ascii', 'xmlcharrefreplace')
p, u = self.getparser()
p.feed(data)
p.close()
return u.close()
| 4,121 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/xmlrpc.py
|
UnixStreamHTTPConnection.connect
|
(self)
| 554 | 557 |
def connect(self): # pragma: no cover
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# we abuse the host parameter as the socketname
self.sock.connect(self.socketfile)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/xmlrpc.py#L554-L557
| 6 |
[] | 0 |
[] | 0 | false | 99.741602 | 4 | 1 | 100 | 0 |
def connect(self): # pragma: no cover
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# we abuse the host parameter as the socketname
self.sock.connect(self.socketfile)
| 4,122 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
_total_seconds
|
(timedelta)
|
return ((timedelta.days * 86400 + timedelta.seconds) * 10**6 +
timedelta.microseconds) / 10**6
| 930 | 932 |
def _total_seconds(timedelta):
return ((timedelta.days * 86400 + timedelta.seconds) * 10**6 +
timedelta.microseconds) / 10**6
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L930-L932
| 6 |
[
0,
1
] | 66.666667 |
[] | 0 | false | 99.574468 | 3 | 1 | 100 | 0 |
def _total_seconds(timedelta):
return ((timedelta.days * 86400 + timedelta.seconds) * 10**6 +
timedelta.microseconds) / 10**6
| 4,123 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
make_allfunc
|
(processes, predicate, func, **extra_kwargs)
|
return allfunc
|
Return a closure representing a function that calls a
function for every process, and returns a result
|
Return a closure representing a function that calls a
function for every process, and returns a result
| 934 | 1,022 |
def make_allfunc(processes, predicate, func, **extra_kwargs):
""" Return a closure representing a function that calls a
function for every process, and returns a result """
callbacks = []
results = []
def allfunc(
processes=processes,
predicate=predicate,
func=func,
extra_kwargs=extra_kwargs,
callbacks=callbacks, # used only to fool scoping, never passed by caller
results=results, # used only to fool scoping, never passed by caller
):
if not callbacks:
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
if predicate(process):
try:
callback = func(name, **extra_kwargs)
except RPCError as e:
results.append({'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
continue
if isinstance(callback, types.FunctionType):
callbacks.append((group, process, callback))
else:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
if not callbacks:
return results
for struct in callbacks[:]:
group, process, cb = struct
try:
value = cb()
except RPCError as e:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
callbacks.remove(struct)
else:
if value is not NOT_DONE_YET:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
callbacks.remove(struct)
if callbacks:
return NOT_DONE_YET
return results
# XXX the above implementation has a weakness inasmuch as the
# first call into each individual process callback will always
# return NOT_DONE_YET, so they need to be called twice. The
# symptom of this is that calling this method causes the
# client to block for much longer than it actually requires to
# kill all of the running processes. After the first call to
# the killit callback, the process is actually dead, but the
# above killall method processes the callbacks one at a time
# during the select loop, which, because there is no output
# from child processes after e.g. stopAllProcesses is called,
# is not busy, so hits the timeout for each callback. I
# attempted to make this better, but the only way to make it
# better assumes totally synchronous reaping of child
# processes, which requires infrastructure changes to
# supervisord that are scary at the moment as it could take a
# while to pin down all of the platform differences and might
# require a C extension to the Python signal module to allow
# the setting of ignore flags to signals.
return allfunc
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L934-L1022
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
28,
29,
30,
32,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
54,
56,
57,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88
] | 70.786517 |
[] | 0 | false | 99.574468 | 89 | 12 | 100 | 2 |
def make_allfunc(processes, predicate, func, **extra_kwargs):
callbacks = []
results = []
def allfunc(
processes=processes,
predicate=predicate,
func=func,
extra_kwargs=extra_kwargs,
callbacks=callbacks, # used only to fool scoping, never passed by caller
results=results, # used only to fool scoping, never passed by caller
):
if not callbacks:
for group, process in processes:
name = make_namespec(group.config.name, process.config.name)
if predicate(process):
try:
callback = func(name, **extra_kwargs)
except RPCError as e:
results.append({'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
continue
if isinstance(callback, types.FunctionType):
callbacks.append((group, process, callback))
else:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
if not callbacks:
return results
for struct in callbacks[:]:
group, process, cb = struct
try:
value = cb()
except RPCError as e:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
callbacks.remove(struct)
else:
if value is not NOT_DONE_YET:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
callbacks.remove(struct)
if callbacks:
return NOT_DONE_YET
return results
# XXX the above implementation has a weakness inasmuch as the
# first call into each individual process callback will always
# return NOT_DONE_YET, so they need to be called twice. The
# symptom of this is that calling this method causes the
# client to block for much longer than it actually requires to
# kill all of the running processes. After the first call to
# the killit callback, the process is actually dead, but the
# above killall method processes the callbacks one at a time
# during the select loop, which, because there is no output
# from child processes after e.g. stopAllProcesses is called,
# is not busy, so hits the timeout for each callback. I
# attempted to make this better, but the only way to make it
# better assumes totally synchronous reaping of child
# processes, which requires infrastructure changes to
# supervisord that are scary at the moment as it could take a
# while to pin down all of the platform differences and might
# require a C extension to the Python signal module to allow
# the setting of ignore flags to signals.
return allfunc
| 4,124 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
isRunning
|
(process)
|
return process.get_state() in RUNNING_STATES
| 1,024 | 1,025 |
def isRunning(process):
return process.get_state() in RUNNING_STATES
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L1024-L1025
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.574468 | 2 | 1 | 100 | 0 |
def isRunning(process):
return process.get_state() in RUNNING_STATES
| 4,125 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
isNotRunning
|
(process)
|
return not isRunning(process)
| 1,027 | 1,028 |
def isNotRunning(process):
return not isRunning(process)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L1027-L1028
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.574468 | 2 | 1 | 100 | 0 |
def isNotRunning(process):
return not isRunning(process)
| 4,126 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
isSignallable
|
(process)
| 1,030 | 1,032 |
def isSignallable(process):
if process.get_state() in SIGNALLABLE_STATES:
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L1030-L1032
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 99.574468 | 3 | 2 | 100 | 0 |
def isSignallable(process):
if process.get_state() in SIGNALLABLE_STATES:
return True
| 4,127 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
make_main_rpcinterface
|
(supervisord)
|
return SupervisorNamespaceRPCInterface(supervisord)
| 1,035 | 1,036 |
def make_main_rpcinterface(supervisord):
return SupervisorNamespaceRPCInterface(supervisord)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L1035-L1036
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.574468 | 2 | 1 | 100 | 0 |
def make_main_rpcinterface(supervisord):
return SupervisorNamespaceRPCInterface(supervisord)
| 4,128 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.__init__
|
(self, supervisord)
| 49 | 50 |
def __init__(self, supervisord):
self.supervisord = supervisord
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L49-L50
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 99.574468 | 2 | 1 | 100 | 0 |
def __init__(self, supervisord):
self.supervisord = supervisord
| 4,129 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._update
|
(self, text)
| 52 | 56 |
def _update(self, text):
self.update_text = text # for unit tests, mainly
if ( isinstance(self.supervisord.options.mood, int) and
self.supervisord.options.mood < SupervisorStates.RUNNING ):
raise RPCError(Faults.SHUTDOWN_STATE)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L52-L56
| 6 |
[
0,
1,
2,
4
] | 80 |
[] | 0 | false | 99.574468 | 5 | 3 | 100 | 0 |
def _update(self, text):
self.update_text = text # for unit tests, mainly
if ( isinstance(self.supervisord.options.mood, int) and
self.supervisord.options.mood < SupervisorStates.RUNNING ):
raise RPCError(Faults.SHUTDOWN_STATE)
| 4,130 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getAPIVersion
|
(self)
|
return API_VERSION
|
Return the version of the RPC API used by supervisord
@return string version id
|
Return the version of the RPC API used by supervisord
| 60 | 66 |
def getAPIVersion(self):
""" Return the version of the RPC API used by supervisord
@return string version id
"""
self._update('getAPIVersion')
return API_VERSION
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L60-L66
| 6 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 99.574468 | 7 | 1 | 100 | 3 |
def getAPIVersion(self):
self._update('getAPIVersion')
return API_VERSION
| 4,131 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getSupervisorVersion
|
(self)
|
return VERSION
|
Return the version of the supervisor package in use by supervisord
@return string version id
|
Return the version of the supervisor package in use by supervisord
| 70 | 76 |
def getSupervisorVersion(self):
""" Return the version of the supervisor package in use by supervisord
@return string version id
"""
self._update('getSupervisorVersion')
return VERSION
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L70-L76
| 6 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 99.574468 | 7 | 1 | 100 | 3 |
def getSupervisorVersion(self):
self._update('getSupervisorVersion')
return VERSION
| 4,132 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getIdentification
|
(self)
|
return self.supervisord.options.identifier
|
Return identifying string of supervisord
@return string identifier identifying string
|
Return identifying string of supervisord
| 78 | 84 |
def getIdentification(self):
""" Return identifying string of supervisord
@return string identifier identifying string
"""
self._update('getIdentification')
return self.supervisord.options.identifier
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L78-L84
| 6 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 99.574468 | 7 | 1 | 100 | 3 |
def getIdentification(self):
self._update('getIdentification')
return self.supervisord.options.identifier
| 4,133 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getState
|
(self)
|
return data
|
Return current state of supervisord as a struct
@return struct A struct with keys int statecode, string statename
|
Return current state of supervisord as a struct
| 86 | 99 |
def getState(self):
""" Return current state of supervisord as a struct
@return struct A struct with keys int statecode, string statename
"""
self._update('getState')
state = self.supervisord.options.mood
statename = getSupervisorStateDescription(state)
data = {
'statecode':state,
'statename':statename,
}
return data
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L86-L99
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 99.574468 | 14 | 1 | 100 | 3 |
def getState(self):
self._update('getState')
state = self.supervisord.options.mood
statename = getSupervisorStateDescription(state)
data = {
'statecode':state,
'statename':statename,
}
return data
| 4,134 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getPID
|
(self)
|
return self.supervisord.options.get_pid()
|
Return the PID of supervisord
@return int PID
|
Return the PID of supervisord
| 101 | 107 |
def getPID(self):
""" Return the PID of supervisord
@return int PID
"""
self._update('getPID')
return self.supervisord.options.get_pid()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L101-L107
| 6 |
[
0,
1,
2,
3,
4,
5,
6
] | 100 |
[] | 0 | true | 99.574468 | 7 | 1 | 100 | 3 |
def getPID(self):
self._update('getPID')
return self.supervisord.options.get_pid()
| 4,135 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.readLog
|
(self, offset, length)
|
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
|
Read length bytes from the main log starting at offset
| 109 | 127 |
def readLog(self, offset, length):
""" 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
"""
self._update('readLog')
logfile = self.supervisord.options.logfile
if logfile is None or not os.path.exists(logfile):
raise RPCError(Faults.NO_FILE, logfile)
try:
return as_string(readFile(logfile, int(offset), int(length)))
except ValueError as inst:
why = inst.args[0]
raise RPCError(getattr(Faults, why))
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L109-L127
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18
] | 100 |
[] | 0 | true | 99.574468 | 19 | 4 | 100 | 5 |
def readLog(self, offset, length):
self._update('readLog')
logfile = self.supervisord.options.logfile
if logfile is None or not os.path.exists(logfile):
raise RPCError(Faults.NO_FILE, logfile)
try:
return as_string(readFile(logfile, int(offset), int(length)))
except ValueError as inst:
why = inst.args[0]
raise RPCError(getattr(Faults, why))
| 4,136 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.clearLog
|
(self)
|
return True
|
Clear the main log.
@return boolean result always returns True unless error
|
Clear the main log.
| 131 | 152 |
def clearLog(self):
""" Clear the main log.
@return boolean result always returns True unless error
"""
self._update('clearLog')
logfile = self.supervisord.options.logfile
if logfile is None or not self.supervisord.options.exists(logfile):
raise RPCError(Faults.NO_FILE)
# there is a race condition here, but ignore it.
try:
self.supervisord.options.remove(logfile)
except (OSError, IOError):
raise RPCError(Faults.FAILED)
for handler in self.supervisord.options.logger.handlers:
if hasattr(handler, 'reopen'):
self.supervisord.options.logger.info('reopening log file')
handler.reopen()
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L131-L152
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21
] | 100 |
[] | 0 | true | 99.574468 | 22 | 6 | 100 | 3 |
def clearLog(self):
self._update('clearLog')
logfile = self.supervisord.options.logfile
if logfile is None or not self.supervisord.options.exists(logfile):
raise RPCError(Faults.NO_FILE)
# there is a race condition here, but ignore it.
try:
self.supervisord.options.remove(logfile)
except (OSError, IOError):
raise RPCError(Faults.FAILED)
for handler in self.supervisord.options.logger.handlers:
if hasattr(handler, 'reopen'):
self.supervisord.options.logger.info('reopening log file')
handler.reopen()
return True
| 4,137 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.shutdown
|
(self)
|
return True
|
Shut down the supervisor process
@return boolean result always returns True unless error
|
Shut down the supervisor process
| 154 | 161 |
def shutdown(self):
""" Shut down the supervisor process
@return boolean result always returns True unless error
"""
self._update('shutdown')
self.supervisord.options.mood = SupervisorStates.SHUTDOWN
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L154-L161
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 100 |
[] | 0 | true | 99.574468 | 8 | 1 | 100 | 3 |
def shutdown(self):
self._update('shutdown')
self.supervisord.options.mood = SupervisorStates.SHUTDOWN
return True
| 4,138 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.restart
|
(self)
|
return True
|
Restart the supervisor process
@return boolean result always return True unless error
|
Restart the supervisor process
| 163 | 171 |
def restart(self):
""" Restart the supervisor process
@return boolean result always return True unless error
"""
self._update('restart')
self.supervisord.options.mood = SupervisorStates.RESTARTING
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L163-L171
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 99.574468 | 9 | 1 | 100 | 3 |
def restart(self):
self._update('restart')
self.supervisord.options.mood = SupervisorStates.RESTARTING
return True
| 4,139 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.reloadConfig
|
(self)
|
return [[added, changed, removed]]
|
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]]
|
Reload the configuration.
| 173 | 200 |
def reloadConfig(self):
"""
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]]
"""
self._update('reloadConfig')
try:
self.supervisord.options.process_config(do_usage=False)
except ValueError as msg:
raise RPCError(Faults.CANT_REREAD, msg)
added, changed, removed = self.supervisord.diff_to_active()
added = [group.name for group in added]
changed = [group.name for group in changed]
removed = [group.name for group in removed]
return [[added, changed, removed]]
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L173-L200
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27
] | 100 |
[] | 0 | true | 99.574468 | 28 | 5 | 100 | 12 |
def reloadConfig(self):
self._update('reloadConfig')
try:
self.supervisord.options.process_config(do_usage=False)
except ValueError as msg:
raise RPCError(Faults.CANT_REREAD, msg)
added, changed, removed = self.supervisord.diff_to_active()
added = [group.name for group in added]
changed = [group.name for group in changed]
removed = [group.name for group in removed]
return [[added, changed, removed]]
| 4,140 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.addProcessGroup
|
(self, name)
|
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
|
Update the config for a running process from config file.
| 202 | 216 |
def addProcessGroup(self, name):
""" 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
"""
self._update('addProcessGroup')
for config in self.supervisord.options.process_group_configs:
if config.name == name:
result = self.supervisord.add_process_group(config)
if not result:
raise RPCError(Faults.ALREADY_ADDED, name)
return True
raise RPCError(Faults.BAD_NAME, name)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L202-L216
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 99.574468 | 15 | 4 | 100 | 4 |
def addProcessGroup(self, name):
self._update('addProcessGroup')
for config in self.supervisord.options.process_group_configs:
if config.name == name:
result = self.supervisord.add_process_group(config)
if not result:
raise RPCError(Faults.ALREADY_ADDED, name)
return True
raise RPCError(Faults.BAD_NAME, name)
| 4,141 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.removeProcessGroup
|
(self, name)
|
return True
|
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
|
Remove a stopped process from the active configuration.
| 218 | 231 |
def removeProcessGroup(self, name):
""" 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
"""
self._update('removeProcessGroup')
if name not in self.supervisord.process_groups:
raise RPCError(Faults.BAD_NAME, name)
result = self.supervisord.remove_process_group(name)
if not result:
raise RPCError(Faults.STILL_RUNNING, name)
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L218-L231
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 99.574468 | 14 | 3 | 100 | 4 |
def removeProcessGroup(self, name):
self._update('removeProcessGroup')
if name not in self.supervisord.process_groups:
raise RPCError(Faults.BAD_NAME, name)
result = self.supervisord.remove_process_group(name)
if not result:
raise RPCError(Faults.STILL_RUNNING, name)
return True
| 4,142 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._getAllProcesses
|
(self, lexical=False)
|
return all_processes
| 233 | 258 |
def _getAllProcesses(self, lexical=False):
# if lexical is true, return processes sorted in lexical order,
# otherwise, sort in priority order
all_processes = []
if lexical:
group_names = list(self.supervisord.process_groups.keys())
group_names.sort()
for group_name in group_names:
group = self.supervisord.process_groups[group_name]
process_names = list(group.processes.keys())
process_names.sort()
for process_name in process_names:
process = group.processes[process_name]
all_processes.append((group, process))
else:
groups = list(self.supervisord.process_groups.values())
groups.sort() # asc by priority
for group in groups:
processes = list(group.processes.values())
processes.sort() # asc by priority
for process in processes:
all_processes.append((group, process))
return all_processes
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L233-L258
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25
] | 96.153846 |
[] | 0 | false | 99.574468 | 26 | 6 | 100 | 0 |
def _getAllProcesses(self, lexical=False):
# if lexical is true, return processes sorted in lexical order,
# otherwise, sort in priority order
all_processes = []
if lexical:
group_names = list(self.supervisord.process_groups.keys())
group_names.sort()
for group_name in group_names:
group = self.supervisord.process_groups[group_name]
process_names = list(group.processes.keys())
process_names.sort()
for process_name in process_names:
process = group.processes[process_name]
all_processes.append((group, process))
else:
groups = list(self.supervisord.process_groups.values())
groups.sort() # asc by priority
for group in groups:
processes = list(group.processes.values())
processes.sort() # asc by priority
for process in processes:
all_processes.append((group, process))
return all_processes
| 4,143 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._getGroupAndProcess
|
(self, name)
|
return group, process
| 260 | 275 |
def _getGroupAndProcess(self, name):
# get process to start from name
group_name, process_name = split_namespec(name)
group = self.supervisord.process_groups.get(group_name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
if process_name is None:
return group, None
process = group.processes.get(process_name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
return group, process
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L260-L275
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 99.574468 | 16 | 4 | 100 | 0 |
def _getGroupAndProcess(self, name):
# get process to start from name
group_name, process_name = split_namespec(name)
group = self.supervisord.process_groups.get(group_name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
if process_name is None:
return group, None
process = group.processes.get(process_name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
return group, process
| 4,144 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.startProcess
|
(self, name, wait=True)
|
return True
|
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
|
Start a process
| 277 | 353 |
def startProcess(self, name, wait=True):
""" 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
"""
self._update('startProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.startProcessGroup(group_name, wait)
# test filespec, don't bother trying to spawn if we know it will
# eventually fail
try:
filename, argv = process.get_execv_args()
except NotFound as why:
raise RPCError(Faults.NO_FILE, why.args[0])
except (BadCommand, NotExecutable, NoPermission) as why:
raise RPCError(Faults.NOT_EXECUTABLE, why.args[0])
if process.get_state() in RUNNING_STATES:
raise RPCError(Faults.ALREADY_STARTED, name)
if process.get_state() == ProcessStates.UNKNOWN:
raise RPCError(Faults.FAILED,
"%s is in an unknown process state" % name)
process.spawn()
# We call reap() in order to more quickly obtain the side effects of
# process.finish(), which reap() eventually ends up calling. This
# might be the case if the spawn() was successful but then the process
# died before its startsecs elapsed or it exited with an unexpected
# exit code. In particular, finish() may set spawnerr, which we can
# check and immediately raise an RPCError, avoiding the need to
# defer by returning a callback.
self.supervisord.reap()
if process.spawnerr:
raise RPCError(Faults.SPAWN_ERROR, name)
# We call process.transition() in order to more quickly obtain its
# side effects. In particular, it might set the process' state from
# STARTING->RUNNING if the process has a startsecs==0.
process.transition()
if wait and process.get_state() != ProcessStates.RUNNING:
# by default, this branch will almost always be hit for processes
# with default startsecs configurations, because the default number
# of startsecs for a process is "1", and the process will not have
# entered the RUNNING state yet even though we've called
# transition() on it. This is because a process is not considered
# RUNNING until it has stayed up > startsecs.
def onwait():
if process.spawnerr:
raise RPCError(Faults.SPAWN_ERROR, name)
state = process.get_state()
if state not in (ProcessStates.STARTING, ProcessStates.RUNNING):
raise RPCError(Faults.ABNORMAL_TERMINATION, name)
if state == ProcessStates.RUNNING:
return True
return NOT_DONE_YET
onwait.delay = 0.05
onwait.rpcinterface = self
return onwait # deferred
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L277-L353
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76
] | 100 |
[] | 0 | true | 99.574468 | 77 | 13 | 100 | 5 |
def startProcess(self, name, wait=True):
self._update('startProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.startProcessGroup(group_name, wait)
# test filespec, don't bother trying to spawn if we know it will
# eventually fail
try:
filename, argv = process.get_execv_args()
except NotFound as why:
raise RPCError(Faults.NO_FILE, why.args[0])
except (BadCommand, NotExecutable, NoPermission) as why:
raise RPCError(Faults.NOT_EXECUTABLE, why.args[0])
if process.get_state() in RUNNING_STATES:
raise RPCError(Faults.ALREADY_STARTED, name)
if process.get_state() == ProcessStates.UNKNOWN:
raise RPCError(Faults.FAILED,
"%s is in an unknown process state" % name)
process.spawn()
# We call reap() in order to more quickly obtain the side effects of
# process.finish(), which reap() eventually ends up calling. This
# might be the case if the spawn() was successful but then the process
# died before its startsecs elapsed or it exited with an unexpected
# exit code. In particular, finish() may set spawnerr, which we can
# check and immediately raise an RPCError, avoiding the need to
# defer by returning a callback.
self.supervisord.reap()
if process.spawnerr:
raise RPCError(Faults.SPAWN_ERROR, name)
# We call process.transition() in order to more quickly obtain its
# side effects. In particular, it might set the process' state from
# STARTING->RUNNING if the process has a startsecs==0.
process.transition()
if wait and process.get_state() != ProcessStates.RUNNING:
# by default, this branch will almost always be hit for processes
# with default startsecs configurations, because the default number
# of startsecs for a process is "1", and the process will not have
# entered the RUNNING state yet even though we've called
# transition() on it. This is because a process is not considered
# RUNNING until it has stayed up > startsecs.
def onwait():
if process.spawnerr:
raise RPCError(Faults.SPAWN_ERROR, name)
state = process.get_state()
if state not in (ProcessStates.STARTING, ProcessStates.RUNNING):
raise RPCError(Faults.ABNORMAL_TERMINATION, name)
if state == ProcessStates.RUNNING:
return True
return NOT_DONE_YET
onwait.delay = 0.05
onwait.rpcinterface = self
return onwait # deferred
return True
| 4,145 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.startProcessGroup
|
(self, name, wait=True)
|
return startall
|
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
|
Start all processes in the group named 'name'
| 355 | 378 |
def startProcessGroup(self, name, wait=True):
""" 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
"""
self._update('startProcessGroup')
group = self.supervisord.process_groups.get(name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [ (group, process) for process in processes ]
startall = make_allfunc(processes, isNotRunning, self.startProcess,
wait=wait)
startall.delay = 0.05
startall.rpcinterface = self
return startall
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L355-L378
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 100 |
[] | 0 | true | 99.574468 | 24 | 3 | 100 | 5 |
def startProcessGroup(self, name, wait=True):
self._update('startProcessGroup')
group = self.supervisord.process_groups.get(name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [ (group, process) for process in processes ]
startall = make_allfunc(processes, isNotRunning, self.startProcess,
wait=wait)
startall.delay = 0.05
startall.rpcinterface = self
return startall
| 4,146 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.startAllProcesses
|
(self, wait=True)
|
return startall
|
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
|
Start all processes listed in the configuration file
| 380 | 394 |
def startAllProcesses(self, wait=True):
""" 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
"""
self._update('startAllProcesses')
processes = self._getAllProcesses()
startall = make_allfunc(processes, isNotRunning, self.startProcess,
wait=wait)
startall.delay = 0.05
startall.rpcinterface = self
return startall
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L380-L394
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 99.574468 | 15 | 1 | 100 | 4 |
def startAllProcesses(self, wait=True):
self._update('startAllProcesses')
processes = self._getAllProcesses()
startall = make_allfunc(processes, isNotRunning, self.startProcess,
wait=wait)
startall.delay = 0.05
startall.rpcinterface = self
return startall
| 4,147 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.stopProcess
|
(self, name, wait=True)
|
return True
|
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
|
Stop a process named by name
| 396 | 445 |
def stopProcess(self, name, wait=True):
""" 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
"""
self._update('stopProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.stopProcessGroup(group_name, wait)
if process.get_state() not in RUNNING_STATES:
raise RPCError(Faults.NOT_RUNNING, name)
msg = process.stop()
if msg is not None:
raise RPCError(Faults.FAILED, msg)
# We'll try to reap any killed child. FWIW, reap calls waitpid, and
# then, if waitpid returns a pid, calls finish() on the process with
# that pid, which drains any I/O from the process' dispatchers and
# changes the process' state. I chose to call reap without once=True
# because we don't really care if we reap more than one child. Even if
# we only reap one child. we may not even be reaping the child that we
# just stopped (this is all async, and process.stop() may not work, and
# we'll need to wait for SIGKILL during process.transition() as the
# result of normal select looping).
self.supervisord.reap()
if wait and process.get_state() not in STOPPED_STATES:
def onwait():
# process will eventually enter a stopped state by
# virtue of the supervisord.reap() method being called
# during normal operations
process.stop_report()
if process.get_state() not in STOPPED_STATES:
return NOT_DONE_YET
return True
onwait.delay = 0
onwait.rpcinterface = self
return onwait # deferred
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L396-L445
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49
] | 100 |
[] | 0 | true | 99.574468 | 50 | 8 | 100 | 5 |
def stopProcess(self, name, wait=True):
self._update('stopProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.stopProcessGroup(group_name, wait)
if process.get_state() not in RUNNING_STATES:
raise RPCError(Faults.NOT_RUNNING, name)
msg = process.stop()
if msg is not None:
raise RPCError(Faults.FAILED, msg)
# We'll try to reap any killed child. FWIW, reap calls waitpid, and
# then, if waitpid returns a pid, calls finish() on the process with
# that pid, which drains any I/O from the process' dispatchers and
# changes the process' state. I chose to call reap without once=True
# because we don't really care if we reap more than one child. Even if
# we only reap one child. we may not even be reaping the child that we
# just stopped (this is all async, and process.stop() may not work, and
# we'll need to wait for SIGKILL during process.transition() as the
# result of normal select looping).
self.supervisord.reap()
if wait and process.get_state() not in STOPPED_STATES:
def onwait():
# process will eventually enter a stopped state by
# virtue of the supervisord.reap() method being called
# during normal operations
process.stop_report()
if process.get_state() not in STOPPED_STATES:
return NOT_DONE_YET
return True
onwait.delay = 0
onwait.rpcinterface = self
return onwait # deferred
return True
| 4,148 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.stopProcessGroup
|
(self, name, wait=True)
|
return killall
|
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
|
Stop all processes in the process group named 'name'
| 447 | 470 |
def stopProcessGroup(self, name, wait=True):
""" 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
"""
self._update('stopProcessGroup')
group = self.supervisord.process_groups.get(name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [ (group, process) for process in processes ]
killall = make_allfunc(processes, isRunning, self.stopProcess,
wait=wait)
killall.delay = 0.05
killall.rpcinterface = self
return killall
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L447-L470
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 100 |
[] | 0 | true | 99.574468 | 24 | 3 | 100 | 5 |
def stopProcessGroup(self, name, wait=True):
self._update('stopProcessGroup')
group = self.supervisord.process_groups.get(name)
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [ (group, process) for process in processes ]
killall = make_allfunc(processes, isRunning, self.stopProcess,
wait=wait)
killall.delay = 0.05
killall.rpcinterface = self
return killall
| 4,149 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.stopAllProcesses
|
(self, wait=True)
|
return killall
|
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
|
Stop all processes in the process list
| 472 | 487 |
def stopAllProcesses(self, wait=True):
""" 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
"""
self._update('stopAllProcesses')
processes = self._getAllProcesses()
killall = make_allfunc(processes, isRunning, self.stopProcess,
wait=wait)
killall.delay = 0.05
killall.rpcinterface = self
return killall
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L472-L487
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 99.574468 | 16 | 1 | 100 | 4 |
def stopAllProcesses(self, wait=True):
self._update('stopAllProcesses')
processes = self._getAllProcesses()
killall = make_allfunc(processes, isRunning, self.stopProcess,
wait=wait)
killall.delay = 0.05
killall.rpcinterface = self
return killall
| 4,150 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.signalProcess
|
(self, name, signal)
|
return True
|
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
|
Send an arbitrary UNIX signal to the process named by name
| 489 | 518 |
def signalProcess(self, name, signal):
""" 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
"""
self._update('signalProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.signalProcessGroup(group_name, signal=signal)
try:
sig = signal_number(signal)
except ValueError:
raise RPCError(Faults.BAD_SIGNAL, signal)
if process.get_state() not in SIGNALLABLE_STATES:
raise RPCError(Faults.NOT_RUNNING, name)
msg = process.signal(sig)
if not msg is None:
raise RPCError(Faults.FAILED, msg)
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L489-L518
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29
] | 100 |
[] | 0 | true | 99.574468 | 30 | 5 | 100 | 5 |
def signalProcess(self, name, signal):
self._update('signalProcess')
group, process = self._getGroupAndProcess(name)
if process is None:
group_name, process_name = split_namespec(name)
return self.signalProcessGroup(group_name, signal=signal)
try:
sig = signal_number(signal)
except ValueError:
raise RPCError(Faults.BAD_SIGNAL, signal)
if process.get_state() not in SIGNALLABLE_STATES:
raise RPCError(Faults.NOT_RUNNING, name)
msg = process.signal(sig)
if not msg is None:
raise RPCError(Faults.FAILED, msg)
return True
| 4,151 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.signalProcessGroup
|
(self, name, signal)
|
return result
|
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
|
Send a signal to all processes in the group named 'name'
| 520 | 543 |
def signalProcessGroup(self, name, signal):
""" 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
"""
group = self.supervisord.process_groups.get(name)
self._update('signalProcessGroup')
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [(group, process) for process in processes]
sendall = make_allfunc(processes, isSignallable, self.signalProcess,
signal=signal)
result = sendall()
self._update('signalProcessGroup')
return result
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L520-L543
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 100 |
[] | 0 | true | 99.574468 | 24 | 3 | 100 | 5 |
def signalProcessGroup(self, name, signal):
group = self.supervisord.process_groups.get(name)
self._update('signalProcessGroup')
if group is None:
raise RPCError(Faults.BAD_NAME, name)
processes = list(group.processes.values())
processes.sort()
processes = [(group, process) for process in processes]
sendall = make_allfunc(processes, isSignallable, self.signalProcess,
signal=signal)
result = sendall()
self._update('signalProcessGroup')
return result
| 4,152 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.signalAllProcesses
|
(self, signal)
|
return result
|
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
|
Send a signal to all processes in the process list
| 545 | 556 |
def signalAllProcesses(self, signal):
""" 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
"""
processes = self._getAllProcesses()
signalall = make_allfunc(processes, isSignallable, self.signalProcess,
signal=signal)
result = signalall()
self._update('signalAllProcesses')
return result
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L545-L556
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 99.574468 | 12 | 1 | 100 | 4 |
def signalAllProcesses(self, signal):
processes = self._getAllProcesses()
signalall = make_allfunc(processes, isSignallable, self.signalProcess,
signal=signal)
result = signalall()
self._update('signalAllProcesses')
return result
| 4,153 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getAllConfigInfo
|
(self)
|
return configinfo
|
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
|
Get info about all available process configurations. Each struct
represents a single process (i.e. groups get flattened).
| 558 | 606 |
def getAllConfigInfo(self):
""" 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
"""
self._update('getAllConfigInfo')
configinfo = []
for gconfig in self.supervisord.options.process_group_configs:
inuse = gconfig.name in self.supervisord.process_groups
for pconfig in gconfig.process_configs:
d = {'autostart': pconfig.autostart,
'directory': pconfig.directory,
'uid': pconfig.uid,
'command': pconfig.command,
'exitcodes': pconfig.exitcodes,
'group': gconfig.name,
'group_prio': gconfig.priority,
'inuse': inuse,
'killasgroup': pconfig.killasgroup,
'name': pconfig.name,
'process_prio': pconfig.priority,
'redirect_stderr': pconfig.redirect_stderr,
'startretries': pconfig.startretries,
'startsecs': pconfig.startsecs,
'stdout_capture_maxbytes': pconfig.stdout_capture_maxbytes,
'stdout_events_enabled': pconfig.stdout_events_enabled,
'stdout_logfile': pconfig.stdout_logfile,
'stdout_logfile_backups': pconfig.stdout_logfile_backups,
'stdout_logfile_maxbytes': pconfig.stdout_logfile_maxbytes,
'stdout_syslog': pconfig.stdout_syslog,
'stopsignal': int(pconfig.stopsignal), # enum on py3
'stopwaitsecs': pconfig.stopwaitsecs,
'stderr_capture_maxbytes': pconfig.stderr_capture_maxbytes,
'stderr_events_enabled': pconfig.stderr_events_enabled,
'stderr_logfile': pconfig.stderr_logfile,
'stderr_logfile_backups': pconfig.stderr_logfile_backups,
'stderr_logfile_maxbytes': pconfig.stderr_logfile_maxbytes,
'stderr_syslog': pconfig.stderr_syslog,
'serverurl': pconfig.serverurl,
}
# no support for these types in xml-rpc
d.update((k, 'auto') for k, v in d.items() if v is Automatic)
d.update((k, 'none') for k, v in d.items() if v is None)
configinfo.append(d)
configinfo.sort(key=lambda r: r['name'])
return configinfo
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L558-L606
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48
] | 100 |
[] | 0 | true | 99.574468 | 49 | 3 | 100 | 4 |
def getAllConfigInfo(self):
self._update('getAllConfigInfo')
configinfo = []
for gconfig in self.supervisord.options.process_group_configs:
inuse = gconfig.name in self.supervisord.process_groups
for pconfig in gconfig.process_configs:
d = {'autostart': pconfig.autostart,
'directory': pconfig.directory,
'uid': pconfig.uid,
'command': pconfig.command,
'exitcodes': pconfig.exitcodes,
'group': gconfig.name,
'group_prio': gconfig.priority,
'inuse': inuse,
'killasgroup': pconfig.killasgroup,
'name': pconfig.name,
'process_prio': pconfig.priority,
'redirect_stderr': pconfig.redirect_stderr,
'startretries': pconfig.startretries,
'startsecs': pconfig.startsecs,
'stdout_capture_maxbytes': pconfig.stdout_capture_maxbytes,
'stdout_events_enabled': pconfig.stdout_events_enabled,
'stdout_logfile': pconfig.stdout_logfile,
'stdout_logfile_backups': pconfig.stdout_logfile_backups,
'stdout_logfile_maxbytes': pconfig.stdout_logfile_maxbytes,
'stdout_syslog': pconfig.stdout_syslog,
'stopsignal': int(pconfig.stopsignal), # enum on py3
'stopwaitsecs': pconfig.stopwaitsecs,
'stderr_capture_maxbytes': pconfig.stderr_capture_maxbytes,
'stderr_events_enabled': pconfig.stderr_events_enabled,
'stderr_logfile': pconfig.stderr_logfile,
'stderr_logfile_backups': pconfig.stderr_logfile_backups,
'stderr_logfile_maxbytes': pconfig.stderr_logfile_maxbytes,
'stderr_syslog': pconfig.stderr_syslog,
'serverurl': pconfig.serverurl,
}
# no support for these types in xml-rpc
d.update((k, 'auto') for k, v in d.items() if v is Automatic)
d.update((k, 'none') for k, v in d.items() if v is None)
configinfo.append(d)
configinfo.sort(key=lambda r: r['name'])
return configinfo
| 4,154 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._interpretProcessInfo
|
(self, info)
|
return desc
| 608 | 637 |
def _interpretProcessInfo(self, info):
state = info['state']
if state == ProcessStates.RUNNING:
start = info['start']
now = info['now']
start_dt = datetime.datetime(*time.gmtime(start)[:6])
now_dt = datetime.datetime(*time.gmtime(now)[:6])
uptime = now_dt - start_dt
if _total_seconds(uptime) < 0: # system time set back
uptime = datetime.timedelta(0)
desc = 'pid %s, uptime %s' % (info['pid'], uptime)
elif state in (ProcessStates.FATAL, ProcessStates.BACKOFF):
desc = info['spawnerr']
if not desc:
desc = 'unknown error (try "tail %s")' % info['name']
elif state in (ProcessStates.STOPPED, ProcessStates.EXITED):
if info['start']:
stop = info['stop']
stop_dt = datetime.datetime(*time.localtime(stop)[:7])
desc = stop_dt.strftime('%b %d %I:%M %p')
else:
desc = 'Not started'
else:
desc = ''
return desc
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L608-L637
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
24,
25,
27,
28,
29
] | 93.333333 |
[] | 0 | false | 99.574468 | 30 | 7 | 100 | 0 |
def _interpretProcessInfo(self, info):
state = info['state']
if state == ProcessStates.RUNNING:
start = info['start']
now = info['now']
start_dt = datetime.datetime(*time.gmtime(start)[:6])
now_dt = datetime.datetime(*time.gmtime(now)[:6])
uptime = now_dt - start_dt
if _total_seconds(uptime) < 0: # system time set back
uptime = datetime.timedelta(0)
desc = 'pid %s, uptime %s' % (info['pid'], uptime)
elif state in (ProcessStates.FATAL, ProcessStates.BACKOFF):
desc = info['spawnerr']
if not desc:
desc = 'unknown error (try "tail %s")' % info['name']
elif state in (ProcessStates.STOPPED, ProcessStates.EXITED):
if info['start']:
stop = info['stop']
stop_dt = datetime.datetime(*time.localtime(stop)[:7])
desc = stop_dt.strftime('%b %d %I:%M %p')
else:
desc = 'Not started'
else:
desc = ''
return desc
| 4,155 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getProcessInfo
|
(self, name)
|
return info
|
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
|
Get info about a process named name
| 639 | 683 |
def getProcessInfo(self, name):
""" 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
"""
self._update('getProcessInfo')
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
# TODO timestamps are returned as xml-rpc integers for b/c but will
# saturate the xml-rpc integer type in jan 2038 ("year 2038 problem").
# future api versions should return timestamps as a different type.
start = capped_int(process.laststart)
stop = capped_int(process.laststop)
now = capped_int(self._now())
state = process.get_state()
spawnerr = process.spawnerr or ''
exitstatus = process.exitstatus or 0
stdout_logfile = process.config.stdout_logfile or ''
stderr_logfile = process.config.stderr_logfile or ''
info = {
'name':process.config.name,
'group':group.config.name,
'start':start,
'stop':stop,
'now':now,
'state':state,
'statename':getProcessStateDescription(state),
'spawnerr':spawnerr,
'exitstatus':exitstatus,
'logfile':stdout_logfile, # b/c alias
'stdout_logfile':stdout_logfile,
'stderr_logfile':stderr_logfile,
'pid':process.pid,
}
description = self._interpretProcessInfo(info)
info['description'] = description
return info
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L639-L683
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44
] | 100 |
[] | 0 | true | 99.574468 | 45 | 6 | 100 | 4 |
def getProcessInfo(self, name):
self._update('getProcessInfo')
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
# TODO timestamps are returned as xml-rpc integers for b/c but will
# saturate the xml-rpc integer type in jan 2038 ("year 2038 problem").
# future api versions should return timestamps as a different type.
start = capped_int(process.laststart)
stop = capped_int(process.laststop)
now = capped_int(self._now())
state = process.get_state()
spawnerr = process.spawnerr or ''
exitstatus = process.exitstatus or 0
stdout_logfile = process.config.stdout_logfile or ''
stderr_logfile = process.config.stderr_logfile or ''
info = {
'name':process.config.name,
'group':group.config.name,
'start':start,
'stop':stop,
'now':now,
'state':state,
'statename':getProcessStateDescription(state),
'spawnerr':spawnerr,
'exitstatus':exitstatus,
'logfile':stdout_logfile, # b/c alias
'stdout_logfile':stdout_logfile,
'stderr_logfile':stderr_logfile,
'pid':process.pid,
}
description = self._interpretProcessInfo(info)
info['description'] = description
return info
| 4,156 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._now
|
(self)
|
return time.time()
| 685 | 687 |
def _now(self): # pragma: no cover
# this is here to service stubbing in unit tests
return time.time()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L685-L687
| 6 |
[] | 0 |
[] | 0 | false | 99.574468 | 3 | 1 | 100 | 0 |
def _now(self): # pragma: no cover
# this is here to service stubbing in unit tests
return time.time()
| 4,157 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.getAllProcessInfo
|
(self)
|
return output
|
Get info about all processes
@return array result An array of process status results
|
Get info about all processes
| 689 | 702 |
def getAllProcessInfo(self):
""" Get info about all processes
@return array result An array of process status results
"""
self._update('getAllProcessInfo')
all_processes = self._getAllProcesses(lexical=True)
output = []
for group, process in all_processes:
name = make_namespec(group.config.name, process.config.name)
output.append(self.getProcessInfo(name))
return output
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L689-L702
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
] | 100 |
[] | 0 | true | 99.574468 | 14 | 2 | 100 | 3 |
def getAllProcessInfo(self):
self._update('getAllProcessInfo')
all_processes = self._getAllProcesses(lexical=True)
output = []
for group, process in all_processes:
name = make_namespec(group.config.name, process.config.name)
output.append(self.getProcessInfo(name))
return output
| 4,158 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._readProcessLog
|
(self, name, offset, length, channel)
| 704 | 719 |
def _readProcessLog(self, name, offset, length, channel):
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile is None or not os.path.exists(logfile):
raise RPCError(Faults.NO_FILE, logfile)
try:
return as_string(readFile(logfile, int(offset), int(length)))
except ValueError as inst:
why = inst.args[0]
raise RPCError(getattr(Faults, why))
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L704-L719
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 100 |
[] | 0 | true | 99.574468 | 16 | 5 | 100 | 0 |
def _readProcessLog(self, name, offset, length, channel):
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile is None or not os.path.exists(logfile):
raise RPCError(Faults.NO_FILE, logfile)
try:
return as_string(readFile(logfile, int(offset), int(length)))
except ValueError as inst:
why = inst.args[0]
raise RPCError(getattr(Faults, why))
| 4,159 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.readProcessStdoutLog
|
(self, name, offset, length)
|
return self._readProcessLog(name, offset, length, 'stdout')
|
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
|
Read length bytes from name's stdout log starting at offset
| 721 | 730 |
def readProcessStdoutLog(self, name, offset, length):
""" 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
"""
self._update('readProcessStdoutLog')
return self._readProcessLog(name, offset, length, 'stdout')
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L721-L730
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 99.574468 | 10 | 1 | 100 | 6 |
def readProcessStdoutLog(self, name, offset, length):
self._update('readProcessStdoutLog')
return self._readProcessLog(name, offset, length, 'stdout')
| 4,160 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.readProcessStderrLog
|
(self, name, offset, length)
|
return self._readProcessLog(name, offset, length, 'stderr')
|
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
|
Read length bytes from name's stderr log starting at offset
| 734 | 743 |
def readProcessStderrLog(self, name, offset, length):
""" 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
"""
self._update('readProcessStderrLog')
return self._readProcessLog(name, offset, length, 'stderr')
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L734-L743
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9
] | 100 |
[] | 0 | true | 99.574468 | 10 | 1 | 100 | 6 |
def readProcessStderrLog(self, name, offset, length):
self._update('readProcessStderrLog')
return self._readProcessLog(name, offset, length, 'stderr')
| 4,161 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface._tailProcessLog
|
(self, name, offset, length, channel)
|
return tailFile(logfile, int(offset), int(length))
| 745 | 756 |
def _tailProcessLog(self, name, offset, length, channel):
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile is None or not os.path.exists(logfile):
return ['', 0, False]
return tailFile(logfile, int(offset), int(length))
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L745-L756
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11
] | 100 |
[] | 0 | true | 99.574468 | 12 | 4 | 100 | 0 |
def _tailProcessLog(self, name, offset, length, channel):
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile is None or not os.path.exists(logfile):
return ['', 0, False]
return tailFile(logfile, int(offset), int(length))
| 4,162 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.tailProcessStdoutLog
|
(self, name, offset, length)
|
return self._tailProcessLog(name, offset, length, 'stdout')
|
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]
|
Provides a more efficient way to tail the (stdout) log than
readProcessStdoutLog(). Use readProcessStdoutLog() to read
chunks and tailProcessStdoutLog() to tail.
| 758 | 778 |
def tailProcessStdoutLog(self, name, offset, length):
"""
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]
"""
self._update('tailProcessStdoutLog')
return self._tailProcessLog(name, offset, length, 'stdout')
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L758-L778
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 |
[] | 0 | true | 99.574468 | 21 | 1 | 100 | 16 |
def tailProcessStdoutLog(self, name, offset, length):
self._update('tailProcessStdoutLog')
return self._tailProcessLog(name, offset, length, 'stdout')
| 4,163 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.tailProcessStderrLog
|
(self, name, offset, length)
|
return self._tailProcessLog(name, offset, length, 'stderr')
|
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]
|
Provides a more efficient way to tail the (stderr) log than
readProcessStderrLog(). Use readProcessStderrLog() to read
chunks and tailProcessStderrLog() to tail.
| 782 | 802 |
def tailProcessStderrLog(self, name, offset, length):
"""
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]
"""
self._update('tailProcessStderrLog')
return self._tailProcessLog(name, offset, length, 'stderr')
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L782-L802
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 |
[] | 0 | true | 99.574468 | 21 | 1 | 100 | 16 |
def tailProcessStderrLog(self, name, offset, length):
self._update('tailProcessStderrLog')
return self._tailProcessLog(name, offset, length, 'stderr')
| 4,164 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.clearProcessLogs
|
(self, name)
|
return True
|
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
|
Clear the stdout and stderr logs for the named process and
reopen them.
| 804 | 824 |
def clearProcessLogs(self, name):
""" 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
"""
self._update('clearProcessLogs')
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
try:
# implies a reopen
process.removelogs()
except (IOError, OSError):
raise RPCError(Faults.FAILED, name)
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L804-L824
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 |
[] | 0 | true | 99.574468 | 21 | 3 | 100 | 5 |
def clearProcessLogs(self, name):
self._update('clearProcessLogs')
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
try:
# implies a reopen
process.removelogs()
except (IOError, OSError):
raise RPCError(Faults.FAILED, name)
return True
| 4,165 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.clearAllProcessLogs
|
(self)
|
return clearall
|
Clear all process log files
@return array result An array of process status info structs
|
Clear all process log files
| 828 | 871 |
def clearAllProcessLogs(self):
""" Clear all process log files
@return array result An array of process status info structs
"""
self._update('clearAllProcessLogs')
results = []
callbacks = []
all_processes = self._getAllProcesses()
for group, process in all_processes:
callbacks.append((group, process, self.clearProcessLog))
def clearall():
if not callbacks:
return results
group, process, callback = callbacks.pop(0)
name = make_namespec(group.config.name, process.config.name)
try:
callback(name)
except RPCError as e:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
else:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
if callbacks:
return NOT_DONE_YET
return results
clearall.delay = 0.05
clearall.rpcinterface = self
return clearall
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L828-L871
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43
] | 100 |
[] | 0 | true | 99.574468 | 44 | 6 | 100 | 3 |
def clearAllProcessLogs(self):
self._update('clearAllProcessLogs')
results = []
callbacks = []
all_processes = self._getAllProcesses()
for group, process in all_processes:
callbacks.append((group, process, self.clearProcessLog))
def clearall():
if not callbacks:
return results
group, process, callback = callbacks.pop(0)
name = make_namespec(group.config.name, process.config.name)
try:
callback(name)
except RPCError as e:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':e.code,
'description':e.text})
else:
results.append(
{'name':process.config.name,
'group':group.config.name,
'status':Faults.SUCCESS,
'description':'OK'}
)
if callbacks:
return NOT_DONE_YET
return results
clearall.delay = 0.05
clearall.rpcinterface = self
return clearall
| 4,166 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.sendProcessStdin
|
(self, name, chars)
|
return True
|
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
|
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.
| 873 | 909 |
def sendProcessStdin(self, name, chars):
""" 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
"""
self._update('sendProcessStdin')
if not isinstance(chars, (str, bytes, unicode)):
raise RPCError(Faults.INCORRECT_PARAMETERS, chars)
chars = as_bytes(chars)
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
if not process.pid or process.killing:
raise RPCError(Faults.NOT_RUNNING, name)
try:
process.write(chars)
except OSError as why:
if why.args[0] == errno.EPIPE:
raise RPCError(Faults.NO_FILE, name)
else:
raise
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L873-L909
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36
] | 100 |
[] | 0 | true | 99.574468 | 37 | 7 | 100 | 11 |
def sendProcessStdin(self, name, chars):
self._update('sendProcessStdin')
if not isinstance(chars, (str, bytes, unicode)):
raise RPCError(Faults.INCORRECT_PARAMETERS, chars)
chars = as_bytes(chars)
group, process = self._getGroupAndProcess(name)
if process is None:
raise RPCError(Faults.BAD_NAME, name)
if not process.pid or process.killing:
raise RPCError(Faults.NOT_RUNNING, name)
try:
process.write(chars)
except OSError as why:
if why.args[0] == errno.EPIPE:
raise RPCError(Faults.NO_FILE, name)
else:
raise
return True
| 4,167 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/rpcinterface.py
|
SupervisorNamespaceRPCInterface.sendRemoteCommEvent
|
(self, type, data)
|
return True
|
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
|
Send an event that will be received by event listener
subprocesses subscribing to the RemoteCommunicationEvent.
| 911 | 928 |
def sendRemoteCommEvent(self, type, data):
""" 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
"""
if isinstance(type, unicode):
type = type.encode('utf-8')
if isinstance(data, unicode):
data = data.encode('utf-8')
notify(
RemoteCommunicationEvent(type, data)
)
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/rpcinterface.py#L911-L928
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
10,
12,
13,
14,
15,
16,
17
] | 88.888889 |
[
9,
11
] | 11.111111 | false | 99.574468 | 18 | 3 | 88.888889 | 6 |
def sendRemoteCommEvent(self, type, data):
if isinstance(type, unicode):
type = type.encode('utf-8')
if isinstance(data, unicode):
data = data.encode('utf-8')
notify(
RemoteCommunicationEvent(type, data)
)
return True
| 4,168 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
stripEscapes
|
(s)
|
return result
|
Remove all ANSI color escapes from the given string.
|
Remove all ANSI color escapes from the given string.
| 518 | 538 |
def stripEscapes(s):
"""
Remove all ANSI color escapes from the given string.
"""
result = b''
show = 1
i = 0
L = len(s)
while i < L:
if show == 0 and s[i:i + 1] in ANSI_TERMINATORS:
show = 1
elif show:
n = s.find(ANSI_ESCAPE_BEGIN, i)
if n == -1:
return result + s[i:]
else:
result = result + s[i:n]
i = n
show = 0
i += 1
return result
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L518-L538
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20
] | 100 |
[] | 0 | true | 98.850575 | 21 | 6 | 100 | 1 |
def stripEscapes(s):
result = b''
show = 1
i = 0
L = len(s)
while i < L:
if show == 0 and s[i:i + 1] in ANSI_TERMINATORS:
show = 1
elif show:
n = s.find(ANSI_ESCAPE_BEGIN, i)
if n == -1:
return result + s[i:]
else:
result = result + s[i:n]
i = n
show = 0
i += 1
return result
| 4,169 |
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
default_handler
|
(event, response)
| 544 | 546 |
def default_handler(event, response):
if response != b'OK':
raise RejectEvent(response)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L544-L546
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 98.850575 | 3 | 2 | 100 | 0 |
def default_handler(event, response):
if response != b'OK':
raise RejectEvent(response)
| 4,170 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PDispatcher.__init__
|
(self, process, channel, fd)
| 20 | 24 |
def __init__(self, process, channel, fd):
self.process = process # process which "owns" this dispatcher
self.channel = channel # 'stderr' or 'stdout'
self.fd = fd
self.closed = False
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L20-L24
| 6 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 98.850575 | 5 | 1 | 100 | 0 |
def __init__(self, process, channel, fd):
self.process = process # process which "owns" this dispatcher
self.channel = channel # 'stderr' or 'stdout'
self.fd = fd
self.closed = False
| 4,171 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PDispatcher.__repr__
|
(self)
|
return '<%s at %s for %s (%s)>' % (self.__class__.__name__,
id(self),
self.process,
self.channel)
| 26 | 30 |
def __repr__(self):
return '<%s at %s for %s (%s)>' % (self.__class__.__name__,
id(self),
self.process,
self.channel)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L26-L30
| 6 |
[
0,
1
] | 40 |
[] | 0 | false | 98.850575 | 5 | 1 | 100 | 0 |
def __repr__(self):
return '<%s at %s for %s (%s)>' % (self.__class__.__name__,
id(self),
self.process,
self.channel)
| 4,172 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PDispatcher.handle_error
|
(self)
| 44 | 55 |
def handle_error(self):
nil, t, v, tbinfo = compact_traceback()
self.process.config.options.logger.critical(
'uncaptured python exception, closing channel %s (%s:%s %s)' % (
repr(self),
t,
v,
tbinfo
)
)
self.close()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L44-L55
| 6 |
[
0,
1,
2,
3,
11
] | 41.666667 |
[] | 0 | false | 98.850575 | 12 | 1 | 100 | 0 |
def handle_error(self):
nil, t, v, tbinfo = compact_traceback()
self.process.config.options.logger.critical(
'uncaptured python exception, closing channel %s (%s:%s %s)' % (
repr(self),
t,
v,
tbinfo
)
)
self.close()
| 4,173 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PDispatcher.close
|
(self)
| 57 | 61 |
def close(self):
if not self.closed:
self.process.config.options.logger.debug(
'fd %s closed, stopped monitoring %s' % (self.fd, self))
self.closed = True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L57-L61
| 6 |
[
0,
1,
2,
4
] | 80 |
[] | 0 | false | 98.850575 | 5 | 2 | 100 | 0 |
def close(self):
if not self.closed:
self.process.config.options.logger.debug(
'fd %s closed, stopped monitoring %s' % (self.fd, self))
self.closed = True
| 4,174 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.__init__
|
(self, process, event_type, fd)
|
Initialize the dispatcher.
`event_type` should be one of ProcessLogStdoutEvent or
ProcessLogStderrEvent
|
Initialize the dispatcher.
| 84 | 110 |
def __init__(self, process, event_type, fd):
"""
Initialize the dispatcher.
`event_type` should be one of ProcessLogStdoutEvent or
ProcessLogStderrEvent
"""
self.process = process
self.event_type = event_type
self.fd = fd
self.channel = self.event_type.channel
self._init_normallog()
self._init_capturelog()
self.childlog = self.normallog
# all code below is purely for minor speedups
begintoken = self.event_type.BEGIN_TOKEN
endtoken = self.event_type.END_TOKEN
self.begintoken_data = (begintoken, len(begintoken))
self.endtoken_data = (endtoken, len(endtoken))
self.mainlog_level = loggers.LevelsByName.DEBG
config = self.process.config
self.log_to_mainlog = config.options.loglevel <= self.mainlog_level
self.stdout_events_enabled = config.stdout_events_enabled
self.stderr_events_enabled = config.stderr_events_enabled
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L84-L110
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26
] | 100 |
[] | 0 | true | 98.850575 | 27 | 1 | 100 | 4 |
def __init__(self, process, event_type, fd):
self.process = process
self.event_type = event_type
self.fd = fd
self.channel = self.event_type.channel
self._init_normallog()
self._init_capturelog()
self.childlog = self.normallog
# all code below is purely for minor speedups
begintoken = self.event_type.BEGIN_TOKEN
endtoken = self.event_type.END_TOKEN
self.begintoken_data = (begintoken, len(begintoken))
self.endtoken_data = (endtoken, len(endtoken))
self.mainlog_level = loggers.LevelsByName.DEBG
config = self.process.config
self.log_to_mainlog = config.options.loglevel <= self.mainlog_level
self.stdout_events_enabled = config.stdout_events_enabled
self.stderr_events_enabled = config.stderr_events_enabled
| 4,175 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher._init_normallog
|
(self)
|
Configure the "normal" (non-capture) log for this channel of this
process. Sets self.normallog if logging is enabled.
|
Configure the "normal" (non-capture) log for this channel of this
process. Sets self.normallog if logging is enabled.
| 112 | 142 |
def _init_normallog(self):
"""
Configure the "normal" (non-capture) log for this channel of this
process. Sets self.normallog if logging is enabled.
"""
config = self.process.config
channel = self.channel
logfile = getattr(config, '%s_logfile' % channel)
maxbytes = getattr(config, '%s_logfile_maxbytes' % channel)
backups = getattr(config, '%s_logfile_backups' % channel)
to_syslog = getattr(config, '%s_syslog' % channel)
if logfile or to_syslog:
self.normallog = config.options.getLogger()
if logfile:
loggers.handle_file(
self.normallog,
filename=logfile,
fmt='%(message)s',
rotating=not not maxbytes, # optimization
maxbytes=maxbytes,
backups=backups
)
if to_syslog:
loggers.handle_syslog(
self.normallog,
fmt=config.name + ' %(message)s'
)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L112-L142
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30
] | 100 |
[] | 0 | true | 98.850575 | 31 | 5 | 100 | 2 |
def _init_normallog(self):
config = self.process.config
channel = self.channel
logfile = getattr(config, '%s_logfile' % channel)
maxbytes = getattr(config, '%s_logfile_maxbytes' % channel)
backups = getattr(config, '%s_logfile_backups' % channel)
to_syslog = getattr(config, '%s_syslog' % channel)
if logfile or to_syslog:
self.normallog = config.options.getLogger()
if logfile:
loggers.handle_file(
self.normallog,
filename=logfile,
fmt='%(message)s',
rotating=not not maxbytes, # optimization
maxbytes=maxbytes,
backups=backups
)
if to_syslog:
loggers.handle_syslog(
self.normallog,
fmt=config.name + ' %(message)s'
)
| 4,176 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher._init_capturelog
|
(self)
|
Configure the capture log for this process. This log is used to
temporarily capture output when special output is detected.
Sets self.capturelog if capturing is enabled.
|
Configure the capture log for this process. This log is used to
temporarily capture output when special output is detected.
Sets self.capturelog if capturing is enabled.
| 144 | 158 |
def _init_capturelog(self):
"""
Configure the capture log for this process. This log is used to
temporarily capture output when special output is detected.
Sets self.capturelog if capturing is enabled.
"""
capture_maxbytes = getattr(self.process.config,
'%s_capture_maxbytes' % self.channel)
if capture_maxbytes:
self.capturelog = self.process.config.options.getLogger()
loggers.handle_boundIO(
self.capturelog,
fmt='%(message)s',
maxbytes=capture_maxbytes,
)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L144-L158
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14
] | 100 |
[] | 0 | true | 98.850575 | 15 | 2 | 100 | 3 |
def _init_capturelog(self):
capture_maxbytes = getattr(self.process.config,
'%s_capture_maxbytes' % self.channel)
if capture_maxbytes:
self.capturelog = self.process.config.options.getLogger()
loggers.handle_boundIO(
self.capturelog,
fmt='%(message)s',
maxbytes=capture_maxbytes,
)
| 4,177 |
|
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.removelogs
|
(self)
| 160 | 165 |
def removelogs(self):
for log in (self.normallog, self.capturelog):
if log is not None:
for handler in log.handlers:
handler.remove()
handler.reopen()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L160-L165
| 6 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 98.850575 | 6 | 4 | 100 | 0 |
def removelogs(self):
for log in (self.normallog, self.capturelog):
if log is not None:
for handler in log.handlers:
handler.remove()
handler.reopen()
| 4,178 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.reopenlogs
|
(self)
| 167 | 171 |
def reopenlogs(self):
for log in (self.normallog, self.capturelog):
if log is not None:
for handler in log.handlers:
handler.reopen()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L167-L171
| 6 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 98.850575 | 5 | 4 | 100 | 0 |
def reopenlogs(self):
for log in (self.normallog, self.capturelog):
if log is not None:
for handler in log.handlers:
handler.reopen()
| 4,179 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher._log
|
(self, data)
| 173 | 203 |
def _log(self, data):
if data:
config = self.process.config
if config.options.strip_ansi:
data = stripEscapes(data)
if self.childlog:
self.childlog.info(data)
if self.log_to_mainlog:
if not isinstance(data, bytes):
text = data
else:
try:
text = data.decode('utf-8')
except UnicodeDecodeError:
text = 'Undecodable: %r' % data
msg = '%(name)r %(channel)s output:\n%(data)s'
config.options.logger.log(
self.mainlog_level, msg, name=config.name,
channel=self.channel, data=text)
if self.channel == 'stdout':
if self.stdout_events_enabled:
notify(
ProcessLogStdoutEvent(self.process,
self.process.pid, data)
)
else: # channel == stderr
if self.stderr_events_enabled:
notify(
ProcessLogStderrEvent(self.process,
self.process.pid, data)
)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L173-L203
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
11,
12,
15,
16,
19,
20,
21,
26,
27
] | 61.290323 |
[
13,
14
] | 6.451613 | false | 98.850575 | 31 | 10 | 93.548387 | 0 |
def _log(self, data):
if data:
config = self.process.config
if config.options.strip_ansi:
data = stripEscapes(data)
if self.childlog:
self.childlog.info(data)
if self.log_to_mainlog:
if not isinstance(data, bytes):
text = data
else:
try:
text = data.decode('utf-8')
except UnicodeDecodeError:
text = 'Undecodable: %r' % data
msg = '%(name)r %(channel)s output:\n%(data)s'
config.options.logger.log(
self.mainlog_level, msg, name=config.name,
channel=self.channel, data=text)
if self.channel == 'stdout':
if self.stdout_events_enabled:
notify(
ProcessLogStdoutEvent(self.process,
self.process.pid, data)
)
else: # channel == stderr
if self.stderr_events_enabled:
notify(
ProcessLogStderrEvent(self.process,
self.process.pid, data)
)
| 4,180 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.record_output
|
(self)
| 205 | 239 |
def record_output(self):
if self.capturelog is None:
# shortcut trying to find capture data
data = self.output_buffer
self.output_buffer = b''
self._log(data)
return
if self.capturemode:
token, tokenlen = self.endtoken_data
else:
token, tokenlen = self.begintoken_data
if len(self.output_buffer) <= tokenlen:
return # not enough data
data = self.output_buffer
self.output_buffer = b''
try:
before, after = data.split(token, 1)
except ValueError:
after = None
index = find_prefix_at_end(data, token)
if index:
self.output_buffer = self.output_buffer + data[-index:]
data = data[:-index]
self._log(data)
else:
self._log(before)
self.toggle_capturemode()
self.output_buffer = after
if after:
self.record_output()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L205-L239
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
29,
30,
31,
32,
33,
34
] | 94.285714 |
[] | 0 | false | 98.850575 | 35 | 7 | 100 | 0 |
def record_output(self):
if self.capturelog is None:
# shortcut trying to find capture data
data = self.output_buffer
self.output_buffer = b''
self._log(data)
return
if self.capturemode:
token, tokenlen = self.endtoken_data
else:
token, tokenlen = self.begintoken_data
if len(self.output_buffer) <= tokenlen:
return # not enough data
data = self.output_buffer
self.output_buffer = b''
try:
before, after = data.split(token, 1)
except ValueError:
after = None
index = find_prefix_at_end(data, token)
if index:
self.output_buffer = self.output_buffer + data[-index:]
data = data[:-index]
self._log(data)
else:
self._log(before)
self.toggle_capturemode()
self.output_buffer = after
if after:
self.record_output()
| 4,181 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.toggle_capturemode
|
(self)
| 241 | 263 |
def toggle_capturemode(self):
self.capturemode = not self.capturemode
if self.capturelog is not None:
if self.capturemode:
self.childlog = self.capturelog
else:
for handler in self.capturelog.handlers:
handler.flush()
data = self.capturelog.getvalue()
channel = self.channel
procname = self.process.config.name
event = self.event_type(self.process, self.process.pid, data)
notify(event)
msg = "%(procname)r %(channel)s emitted a comm event"
self.process.config.options.logger.debug(msg,
procname=procname,
channel=channel)
for handler in self.capturelog.handlers:
handler.remove()
handler.reopen()
self.childlog = self.normallog
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L241-L263
| 6 |
[
0,
1,
2,
3,
4,
5,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
19,
20,
21,
22
] | 86.956522 |
[] | 0 | false | 98.850575 | 23 | 5 | 100 | 0 |
def toggle_capturemode(self):
self.capturemode = not self.capturemode
if self.capturelog is not None:
if self.capturemode:
self.childlog = self.capturelog
else:
for handler in self.capturelog.handlers:
handler.flush()
data = self.capturelog.getvalue()
channel = self.channel
procname = self.process.config.name
event = self.event_type(self.process, self.process.pid, data)
notify(event)
msg = "%(procname)r %(channel)s emitted a comm event"
self.process.config.options.logger.debug(msg,
procname=procname,
channel=channel)
for handler in self.capturelog.handlers:
handler.remove()
handler.reopen()
self.childlog = self.normallog
| 4,182 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.writable
|
(self)
|
return False
| 265 | 266 |
def writable(self):
return False
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L265-L266
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 98.850575 | 2 | 1 | 100 | 0 |
def writable(self):
return False
| 4,183 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.readable
|
(self)
|
return True
| 268 | 271 |
def readable(self):
if self.closed:
return False
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L268-L271
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.850575 | 4 | 2 | 100 | 0 |
def readable(self):
if self.closed:
return False
return True
| 4,184 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
POutputDispatcher.handle_read_event
|
(self)
| 273 | 281 |
def handle_read_event(self):
data = self.process.config.options.readfd(self.fd)
self.output_buffer += data
self.record_output()
if not data:
# if we get no data back from the pipe, it means that the
# child process has ended. See
# mail.python.org/pipermail/python-dev/2004-August/046850.html
self.close()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L273-L281
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 100 |
[] | 0 | true | 98.850575 | 9 | 2 | 100 | 0 |
def handle_read_event(self):
data = self.process.config.options.readfd(self.fd)
self.output_buffer += data
self.record_output()
if not data:
# if we get no data back from the pipe, it means that the
# child process has ended. See
# mail.python.org/pipermail/python-dev/2004-August/046850.html
self.close()
| 4,185 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.__init__
|
(self, process, channel, fd)
| 294 | 316 |
def __init__(self, process, channel, fd):
PDispatcher.__init__(self, process, channel, fd)
# the initial state of our listener is ACKNOWLEDGED; this is a
# "busy" state that implies we're awaiting a READY_FOR_EVENTS_TOKEN
self.process.listener_state = EventListenerStates.ACKNOWLEDGED
self.process.event = None
self.result = b''
self.resultlen = None
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile:
maxbytes = getattr(process.config, '%s_logfile_maxbytes' % channel)
backups = getattr(process.config, '%s_logfile_backups' % channel)
self.childlog = process.config.options.getLogger()
loggers.handle_file(
self.childlog,
logfile,
'%(message)s',
rotating=not not maxbytes, # optimization
maxbytes=maxbytes,
backups=backups,
)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L294-L316
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15
] | 69.565217 |
[] | 0 | false | 98.850575 | 23 | 2 | 100 | 0 |
def __init__(self, process, channel, fd):
PDispatcher.__init__(self, process, channel, fd)
# the initial state of our listener is ACKNOWLEDGED; this is a
# "busy" state that implies we're awaiting a READY_FOR_EVENTS_TOKEN
self.process.listener_state = EventListenerStates.ACKNOWLEDGED
self.process.event = None
self.result = b''
self.resultlen = None
logfile = getattr(process.config, '%s_logfile' % channel)
if logfile:
maxbytes = getattr(process.config, '%s_logfile_maxbytes' % channel)
backups = getattr(process.config, '%s_logfile_backups' % channel)
self.childlog = process.config.options.getLogger()
loggers.handle_file(
self.childlog,
logfile,
'%(message)s',
rotating=not not maxbytes, # optimization
maxbytes=maxbytes,
backups=backups,
)
| 4,186 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.removelogs
|
(self)
| 318 | 322 |
def removelogs(self):
if self.childlog is not None:
for handler in self.childlog.handlers:
handler.remove()
handler.reopen()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L318-L322
| 6 |
[
0,
1,
2,
3,
4
] | 100 |
[] | 0 | true | 98.850575 | 5 | 3 | 100 | 0 |
def removelogs(self):
if self.childlog is not None:
for handler in self.childlog.handlers:
handler.remove()
handler.reopen()
| 4,187 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.reopenlogs
|
(self)
| 324 | 327 |
def reopenlogs(self):
if self.childlog is not None:
for handler in self.childlog.handlers:
handler.reopen()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L324-L327
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.850575 | 4 | 3 | 100 | 0 |
def reopenlogs(self):
if self.childlog is not None:
for handler in self.childlog.handlers:
handler.reopen()
| 4,188 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.writable
|
(self)
|
return False
| 330 | 331 |
def writable(self):
return False
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L330-L331
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 98.850575 | 2 | 1 | 100 | 0 |
def writable(self):
return False
| 4,189 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.readable
|
(self)
|
return True
| 333 | 336 |
def readable(self):
if self.closed:
return False
return True
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L333-L336
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.850575 | 4 | 2 | 100 | 0 |
def readable(self):
if self.closed:
return False
return True
| 4,190 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.handle_read_event
|
(self)
| 338 | 356 |
def handle_read_event(self):
data = self.process.config.options.readfd(self.fd)
if data:
self.state_buffer += data
procname = self.process.config.name
msg = '%r %s output:\n%s' % (procname, self.channel, data)
self.process.config.options.logger.debug(msg)
if self.childlog:
if self.process.config.options.strip_ansi:
data = stripEscapes(data)
self.childlog.info(data)
else:
# if we get no data back from the pipe, it means that the
# child process has ended. See
# mail.python.org/pipermail/python-dev/2004-August/046850.html
self.close()
self.handle_listener_state_change()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L338-L356
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
15,
16,
17,
18
] | 84.210526 |
[] | 0 | false | 98.850575 | 19 | 4 | 100 | 0 |
def handle_read_event(self):
data = self.process.config.options.readfd(self.fd)
if data:
self.state_buffer += data
procname = self.process.config.name
msg = '%r %s output:\n%s' % (procname, self.channel, data)
self.process.config.options.logger.debug(msg)
if self.childlog:
if self.process.config.options.strip_ansi:
data = stripEscapes(data)
self.childlog.info(data)
else:
# if we get no data back from the pipe, it means that the
# child process has ended. See
# mail.python.org/pipermail/python-dev/2004-August/046850.html
self.close()
self.handle_listener_state_change()
| 4,191 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.handle_listener_state_change
|
(self)
| 358 | 443 |
def handle_listener_state_change(self):
data = self.state_buffer
if not data:
return
process = self.process
procname = process.config.name
state = process.listener_state
if state == EventListenerStates.UNKNOWN:
# this is a fatal state
self.state_buffer = b''
return
if state == EventListenerStates.ACKNOWLEDGED:
if len(data) < self.READY_FOR_EVENTS_LEN:
# not enough info to make a decision
return
elif data.startswith(self.READY_FOR_EVENTS_TOKEN):
self._change_listener_state(EventListenerStates.READY)
tokenlen = self.READY_FOR_EVENTS_LEN
self.state_buffer = self.state_buffer[tokenlen:]
process.event = None
else:
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
process.event = None
if self.state_buffer:
# keep going til its too short
self.handle_listener_state_change()
else:
return
elif state == EventListenerStates.READY:
# the process sent some spurious data, be strict about it
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
process.event = None
return
elif state == EventListenerStates.BUSY:
if self.resultlen is None:
# we haven't begun gathering result data yet
pos = data.find(b'\n')
if pos == -1:
# we can't make a determination yet, we dont have a full
# results line
return
result_line = self.state_buffer[:pos]
self.state_buffer = self.state_buffer[pos+1:] # rid LF
resultlen = result_line[self.RESULT_TOKEN_START_LEN:]
try:
self.resultlen = int(resultlen)
except ValueError:
try:
result_line = as_string(result_line)
except UnicodeDecodeError:
result_line = 'Undecodable: %r' % result_line
process.config.options.logger.warn(
'%s: bad result line: \'%s\'' % (procname, result_line)
)
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
notify(EventRejectedEvent(process, process.event))
process.event = None
return
else:
needed = self.resultlen - len(self.result)
if needed:
self.result += self.state_buffer[:needed]
self.state_buffer = self.state_buffer[needed:]
needed = self.resultlen - len(self.result)
if not needed:
self.handle_result(self.result)
self.process.event = None
self.result = b''
self.resultlen = None
if self.state_buffer:
# keep going til its too short
self.handle_listener_state_change()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L358-L443
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
25,
26,
27,
28,
29,
30,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
60,
63,
64,
65,
66,
67,
68,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85
] | 91.860465 |
[
58,
59
] | 2.325581 | false | 98.850575 | 86 | 16 | 97.674419 | 0 |
def handle_listener_state_change(self):
data = self.state_buffer
if not data:
return
process = self.process
procname = process.config.name
state = process.listener_state
if state == EventListenerStates.UNKNOWN:
# this is a fatal state
self.state_buffer = b''
return
if state == EventListenerStates.ACKNOWLEDGED:
if len(data) < self.READY_FOR_EVENTS_LEN:
# not enough info to make a decision
return
elif data.startswith(self.READY_FOR_EVENTS_TOKEN):
self._change_listener_state(EventListenerStates.READY)
tokenlen = self.READY_FOR_EVENTS_LEN
self.state_buffer = self.state_buffer[tokenlen:]
process.event = None
else:
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
process.event = None
if self.state_buffer:
# keep going til its too short
self.handle_listener_state_change()
else:
return
elif state == EventListenerStates.READY:
# the process sent some spurious data, be strict about it
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
process.event = None
return
elif state == EventListenerStates.BUSY:
if self.resultlen is None:
# we haven't begun gathering result data yet
pos = data.find(b'\n')
if pos == -1:
# we can't make a determination yet, we dont have a full
# results line
return
result_line = self.state_buffer[:pos]
self.state_buffer = self.state_buffer[pos+1:] # rid LF
resultlen = result_line[self.RESULT_TOKEN_START_LEN:]
try:
self.resultlen = int(resultlen)
except ValueError:
try:
result_line = as_string(result_line)
except UnicodeDecodeError:
result_line = 'Undecodable: %r' % result_line
process.config.options.logger.warn(
'%s: bad result line: \'%s\'' % (procname, result_line)
)
self._change_listener_state(EventListenerStates.UNKNOWN)
self.state_buffer = b''
notify(EventRejectedEvent(process, process.event))
process.event = None
return
else:
needed = self.resultlen - len(self.result)
if needed:
self.result += self.state_buffer[:needed]
self.state_buffer = self.state_buffer[needed:]
needed = self.resultlen - len(self.result)
if not needed:
self.handle_result(self.result)
self.process.event = None
self.result = b''
self.resultlen = None
if self.state_buffer:
# keep going til its too short
self.handle_listener_state_change()
| 4,192 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher.handle_result
|
(self, result)
| 445 | 461 |
def handle_result(self, result):
process = self.process
procname = process.config.name
logger = process.config.options.logger
try:
self.process.group.config.result_handler(process.event, result)
logger.debug('%s: event was processed' % procname)
self._change_listener_state(EventListenerStates.ACKNOWLEDGED)
except RejectEvent:
logger.warn('%s: event was rejected' % procname)
self._change_listener_state(EventListenerStates.ACKNOWLEDGED)
notify(EventRejectedEvent(process, process.event))
except:
logger.warn('%s: event caused an error' % procname)
self._change_listener_state(EventListenerStates.UNKNOWN)
notify(EventRejectedEvent(process, process.event))
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L445-L461
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
] | 100 |
[] | 0 | true | 98.850575 | 17 | 3 | 100 | 0 |
def handle_result(self, result):
process = self.process
procname = process.config.name
logger = process.config.options.logger
try:
self.process.group.config.result_handler(process.event, result)
logger.debug('%s: event was processed' % procname)
self._change_listener_state(EventListenerStates.ACKNOWLEDGED)
except RejectEvent:
logger.warn('%s: event was rejected' % procname)
self._change_listener_state(EventListenerStates.ACKNOWLEDGED)
notify(EventRejectedEvent(process, process.event))
except:
logger.warn('%s: event caused an error' % procname)
self._change_listener_state(EventListenerStates.UNKNOWN)
notify(EventRejectedEvent(process, process.event))
| 4,193 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PEventListenerDispatcher._change_listener_state
|
(self, new_state)
| 463 | 480 |
def _change_listener_state(self, new_state):
process = self.process
procname = process.config.name
old_state = process.listener_state
msg = '%s: %s -> %s' % (
procname,
getEventListenerStateDescription(old_state),
getEventListenerStateDescription(new_state)
)
process.config.options.logger.debug(msg)
process.listener_state = new_state
if new_state == EventListenerStates.UNKNOWN:
msg = ('%s: has entered the UNKNOWN state and will no longer '
'receive events, this usually indicates the process '
'violated the eventlistener protocol' % procname)
process.config.options.logger.warn(msg)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L463-L480
| 6 |
[
0,
1,
2,
3,
4,
5,
10,
11,
12,
13,
14,
17
] | 66.666667 |
[] | 0 | false | 98.850575 | 18 | 2 | 100 | 0 |
def _change_listener_state(self, new_state):
process = self.process
procname = process.config.name
old_state = process.listener_state
msg = '%s: %s -> %s' % (
procname,
getEventListenerStateDescription(old_state),
getEventListenerStateDescription(new_state)
)
process.config.options.logger.debug(msg)
process.listener_state = new_state
if new_state == EventListenerStates.UNKNOWN:
msg = ('%s: has entered the UNKNOWN state and will no longer '
'receive events, this usually indicates the process '
'violated the eventlistener protocol' % procname)
process.config.options.logger.warn(msg)
| 4,194 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PInputDispatcher.__init__
|
(self, process, channel, fd)
| 485 | 487 |
def __init__(self, process, channel, fd):
PDispatcher.__init__(self, process, channel, fd)
self.input_buffer = b''
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L485-L487
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 98.850575 | 3 | 1 | 100 | 0 |
def __init__(self, process, channel, fd):
PDispatcher.__init__(self, process, channel, fd)
self.input_buffer = b''
| 4,195 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PInputDispatcher.writable
|
(self)
|
return False
| 489 | 492 |
def writable(self):
if self.input_buffer and not self.closed:
return True
return False
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L489-L492
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 98.850575 | 4 | 3 | 100 | 0 |
def writable(self):
if self.input_buffer and not self.closed:
return True
return False
| 4,196 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PInputDispatcher.readable
|
(self)
|
return False
| 494 | 495 |
def readable(self):
return False
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L494-L495
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 98.850575 | 2 | 1 | 100 | 0 |
def readable(self):
return False
| 4,197 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PInputDispatcher.flush
|
(self)
| 497 | 501 |
def flush(self):
# other code depends on this raising EPIPE if the pipe is closed
sent = self.process.config.options.write(self.fd,
self.input_buffer)
self.input_buffer = self.input_buffer[sent:]
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L497-L501
| 6 |
[
0,
1,
2,
4
] | 80 |
[] | 0 | false | 98.850575 | 5 | 1 | 100 | 0 |
def flush(self):
# other code depends on this raising EPIPE if the pipe is closed
sent = self.process.config.options.write(self.fd,
self.input_buffer)
self.input_buffer = self.input_buffer[sent:]
| 4,198 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/dispatchers.py
|
PInputDispatcher.handle_write_event
|
(self)
| 503 | 512 |
def handle_write_event(self):
if self.input_buffer:
try:
self.flush()
except OSError as why:
if why.args[0] == errno.EPIPE:
self.input_buffer = b''
self.close()
else:
raise
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/dispatchers.py#L503-L512
| 6 |
[
0,
1,
2,
3,
4,
5,
6,
7,
9
] | 90 |
[] | 0 | false | 98.850575 | 10 | 4 | 100 | 0 |
def handle_write_event(self):
if self.input_buffer:
try:
self.flush()
except OSError as why:
if why.args[0] == errno.EPIPE:
self.input_buffer = b''
self.close()
else:
raise
| 4,199 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
Proxy.__init__
|
(self, object, **kwargs)
| 8 | 10 |
def __init__(self, object, **kwargs):
self.object = object
self.on_delete = kwargs.get('on_delete', None)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L8-L10
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 100 | 3 | 1 | 100 | 0 |
def __init__(self, object, **kwargs):
self.object = object
self.on_delete = kwargs.get('on_delete', None)
| 4,200 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
Proxy.__del__
|
(self)
| 12 | 14 |
def __del__(self):
if self.on_delete:
self.on_delete()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L12-L14
| 6 |
[
0,
1,
2
] | 100 |
[] | 0 | true | 100 | 3 | 2 | 100 | 0 |
def __del__(self):
if self.on_delete:
self.on_delete()
| 4,201 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
Proxy.__getattr__
|
(self, name)
|
return getattr(self.object, name)
| 16 | 17 |
def __getattr__(self, name):
return getattr(self.object, name)
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L16-L17
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 100 | 2 | 1 | 100 | 0 |
def __getattr__(self, name):
return getattr(self.object, name)
| 4,202 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
Proxy._get
|
(self)
|
return self.object
| 19 | 20 |
def _get(self):
return self.object
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L19-L20
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 100 | 2 | 1 | 100 | 0 |
def _get(self):
return self.object
| 4,203 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
ReferenceCounter.__init__
|
(self, **kwargs)
| 26 | 29 |
def __init__(self, **kwargs):
self.on_non_zero = kwargs['on_non_zero']
self.on_zero = kwargs['on_zero']
self.ref_count = 0
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L26-L29
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 100 | 4 | 1 | 100 | 0 |
def __init__(self, **kwargs):
self.on_non_zero = kwargs['on_non_zero']
self.on_zero = kwargs['on_zero']
self.ref_count = 0
| 4,204 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
ReferenceCounter.get_count
|
(self)
|
return self.ref_count
| 31 | 32 |
def get_count(self):
return self.ref_count
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L31-L32
| 6 |
[
0,
1
] | 100 |
[] | 0 | true | 100 | 2 | 1 | 100 | 0 |
def get_count(self):
return self.ref_count
| 4,205 |
||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
ReferenceCounter.increment
|
(self)
| 34 | 37 |
def increment(self):
if self.ref_count == 0:
self.on_non_zero()
self.ref_count += 1
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L34-L37
| 6 |
[
0,
1,
2,
3
] | 100 |
[] | 0 | true | 100 | 4 | 2 | 100 | 0 |
def increment(self):
if self.ref_count == 0:
self.on_non_zero()
self.ref_count += 1
| 4,206 |
|||
Supervisor/supervisor
|
a7cb60d58b5eb610feb76c675208f87501d4bc4b
|
supervisor/socket_manager.py
|
ReferenceCounter.decrement
|
(self)
| 39 | 44 |
def decrement(self):
if self.ref_count <= 0:
raise Exception('Illegal operation: cannot decrement below zero')
self.ref_count -= 1
if self.ref_count == 0:
self.on_zero()
|
https://github.com/Supervisor/supervisor/blob/a7cb60d58b5eb610feb76c675208f87501d4bc4b/project6/supervisor/socket_manager.py#L39-L44
| 6 |
[
0,
1,
2,
3,
4,
5
] | 100 |
[] | 0 | true | 100 | 6 | 3 | 100 | 0 |
def decrement(self):
if self.ref_count <= 0:
raise Exception('Illegal operation: cannot decrement below zero')
self.ref_count -= 1
if self.ref_count == 0:
self.on_zero()
| 4,207 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.