Permalink
Browse files

Fix `avail` on Python 3 when program has auto logfile. Closes #1141

  • Loading branch information...
mnaberez committed Sep 7, 2018
1 parent 3bbd65e commit abef0a2be35f4aae4a4edeceadb7a213b729ef8d
Showing with 20 additions and 9 deletions.
  1. +7 −3 supervisor/rpcinterface.py
  2. +13 −6 supervisor/tests/test_rpcinterfaces.py
View
@@ -8,7 +8,10 @@
from supervisor.compat import as_bytes
from supervisor.compat import unicode
from supervisor.datatypes import signal_number
from supervisor.datatypes import (
Automatic,
signal_number,
)
from supervisor.options import readFile
from supervisor.options import tailFile
@@ -585,8 +588,9 @@ def getAllConfigInfo(self):
'stderr_logfile_maxbytes': pconfig.stderr_logfile_maxbytes,
'stderr_syslog': pconfig.stderr_syslog,
}
# no support for None in xml-rpc
d.update((k, '') for k, v in d.items() if v is None)
# 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'])
@@ -17,6 +17,7 @@
from supervisor.tests.base import _TIMEFORMAT
from supervisor.compat import as_string, PY2
from supervisor.datatypes import Automatic
class TestBase(unittest.TestCase):
def setUp(self):
@@ -1101,8 +1102,14 @@ def test_getAllConfigInfo(self):
options = DummyOptions()
supervisord = DummySupervisor(options, 'foo')
pconfig1 = DummyPConfig(options, 'process1', __file__)
pconfig2 = DummyPConfig(options, 'process2', __file__)
pconfig1 = DummyPConfig(options, 'process1', __file__,
stdout_logfile=Automatic,
stderr_logfile=Automatic,
)
pconfig2 = DummyPConfig(options, 'process2', __file__,
stdout_logfile=None,
stderr_logfile=None,
)
gconfig = DummyPGroupConfig(options, 'group1', pconfigs=[pconfig1, pconfig2])
supervisord.process_groups = {'group1': DummyProcessGroup(gconfig)}
supervisord.options.process_group_configs = [gconfig]
@@ -1126,13 +1133,13 @@ def test_getAllConfigInfo(self):
self.assertEqual(configs[0]['stderr_logfile_maxbytes'], 0)
self.assertEqual(configs[0]['startsecs'], 10)
self.assertEqual(configs[0]['redirect_stderr'], False)
self.assertEqual(configs[0]['stdout_logfile'], '')
self.assertEqual(configs[0]['stdout_logfile'], 'auto')
self.assertEqual(configs[0]['exitcodes'], (0, 2))
self.assertEqual(configs[0]['stderr_capture_maxbytes'], 0)
self.assertEqual(configs[0]['startretries'], 999)
self.assertEqual(configs[0]['stderr_logfile_maxbytes'], 0)
self.assertEqual(configs[0]['inuse'], True)
self.assertEqual(configs[0]['stderr_logfile'], '')
self.assertEqual(configs[0]['stderr_logfile'], 'auto')
self.assertEqual(configs[0]['stdout_logfile_backups'], 0)
assert 'test_rpcinterfaces.py' in configs[0]['command']
@@ -1153,13 +1160,13 @@ def test_getAllConfigInfo(self):
self.assertEqual(configs[1]['stderr_logfile_maxbytes'], 0)
self.assertEqual(configs[1]['startsecs'], 10)
self.assertEqual(configs[1]['redirect_stderr'], False)
self.assertEqual(configs[1]['stdout_logfile'], '')
self.assertEqual(configs[1]['stdout_logfile'], 'none')
self.assertEqual(configs[1]['exitcodes'], (0, 2))
self.assertEqual(configs[1]['stderr_capture_maxbytes'], 0)
self.assertEqual(configs[1]['startretries'], 999)
self.assertEqual(configs[1]['stderr_logfile_maxbytes'], 0)
self.assertEqual(configs[1]['inuse'], True)
self.assertEqual(configs[1]['stderr_logfile'], '')
self.assertEqual(configs[1]['stderr_logfile'], 'none')
self.assertEqual(configs[1]['stdout_logfile_backups'], 0)
assert 'test_rpcinterfaces.py' in configs[0]['command']

0 comments on commit abef0a2

Please sign in to comment.