prevents start of command_endpoint thread when click_events are disabled

This commit is contained in:
Arvedui 2014-08-15 00:16:50 +02:00
parent de3db6fb19
commit cee58e495c

View File

@ -45,11 +45,13 @@ class Status:
def __init__(self, standalone=False, interval=1, input_stream=sys.stdin, click_events=True):
self.modules = util.ModuleList(self, ClassFinder(Module))
self.standalone = standalone
self.click_events = click_events
if standalone:
self.io = io.StandaloneIO(click_events, interval)
self.command_endpoint = CommandEndpoint(
self.modules,
lambda: io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull, "w")), skiplines=1))
self.io = io.StandaloneIO(self.click_events, interval)
if self.click_events:
self.command_endpoint = CommandEndpoint(
self.modules,
lambda: io.JSONIO(io=io.IOHandler(sys.stdin, open(os.devnull, "w")), skiplines=1))
else:
self.io = io.IOHandler(input_stream)
@ -78,7 +80,8 @@ class Status:
text=configuration_error.message))
def run(self):
self.command_endpoint.start()
if self.click_events:
self.command_endpoint.start()
for j in io.JSONIO(self.io).read():
for module in self.modules:
module.inject(j)