Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, py3_wrapper):
"""
We need to poll stdin to receive i3bar messages.
"""
Thread.__init__(self)
self.config = py3_wrapper.config
self.error = None
self.py3_config = py3_wrapper.config["py3_config"]
self.modules = py3_wrapper.modules
self.on_click = self.py3_config["on_click"]
self.output_modules = py3_wrapper.output_modules
self.poller_inp = IOPoller(sys.stdin)
self.py3_wrapper = py3_wrapper
self.write_tmp_i3status_config(tmpfile)
i3status_pipe = Popen(
[self.i3status_path, "-c", tmpfile.name],
stdout=PIPE,
stderr=PIPE,
# Ignore the SIGTSTP signal for this subprocess
preexec_fn=lambda: signal(SIGTSTP, SIG_IGN),
)
self.py3_wrapper.log(
"i3status spawned using config file {}".format(tmpfile.name)
)
self.poller_inp = IOPoller(i3status_pipe.stdout)
self.poller_err = IOPoller(i3status_pipe.stderr)
self.tmpfile_path = tmpfile.name
# Store the pipe so we can signal it
self.i3status_pipe = i3status_pipe
try:
# loop on i3status output
while self.py3_wrapper.running:
line = self.poller_inp.readline()
if line:
# remove leading comma if present
if line[0] == ",":
line = line[1:]
if line.startswith("[{"):
json_list = loads(line)
self.last_output = json_list
with NamedTemporaryFile(prefix="py3status_") as tmpfile:
self.write_tmp_i3status_config(tmpfile)
i3status_pipe = Popen(
[self.i3status_path, "-c", tmpfile.name],
stdout=PIPE,
stderr=PIPE,
# Ignore the SIGTSTP signal for this subprocess
preexec_fn=lambda: signal(SIGTSTP, SIG_IGN),
)
self.py3_wrapper.log(
"i3status spawned using config file {}".format(tmpfile.name)
)
self.poller_inp = IOPoller(i3status_pipe.stdout)
self.poller_err = IOPoller(i3status_pipe.stderr)
self.tmpfile_path = tmpfile.name
# Store the pipe so we can signal it
self.i3status_pipe = i3status_pipe
try:
# loop on i3status output
while self.py3_wrapper.running:
line = self.poller_inp.readline()
if line:
# remove leading comma if present
if line[0] == ",":
line = line[1:]
if line.startswith("[{"):
json_list = loads(line)