def spawn_i3status(self):
try:<EOL><INDENT>with NamedTemporaryFile(prefix="<STR_LIT>") as tmpfile:<EOL><INDENT>self.write_tmp_i3status_config(tmpfile)<EOL>i3status_pipe = Popen(<EOL>[self.i3status_path, "<STR_LIT:-c>", tmpfile.name],<EOL>stdout=PIPE,<EOL>stderr=PIPE,<EOL>preexec_fn=lambda: signal(SIGTSTP, SIG_IGN),<EOL>)<EOL>self.py3_wrapper.log(<EOL>"<STR_LIT>".format(tmpfile.name)<EOL>)<EOL>self.poller_inp = IOPoller(i3status_pipe.stdout)<EOL>self.poller_err = IOPoller(i3status_pipe.stderr)<EOL>self.tmpfile_path = tmpfile.name<EOL>self.i3status_pipe = i3status_pipe<EOL>try:<EOL><INDENT>while self.py3_wrapper.running:<EOL><INDENT>line = self.poller_inp.readline()<EOL>if line:<EOL><INDENT>if line[<NUM_LIT:0>] == "<STR_LIT:U+002C>":<EOL><INDENT>line = line[<NUM_LIT:1>:]<EOL><DEDENT>if line.startswith("<STR_LIT>"):<EOL><INDENT>json_list = loads(line)<EOL>self.last_output = json_list<EOL>self.set_responses(json_list)<EOL>self.ready = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>err = self.poller_err.readline()<EOL>code = i3status_pipe.poll()<EOL>if code is not None:<EOL><INDENT>msg = "<STR_LIT>"<EOL>if err:<EOL><INDENT>msg += "<STR_LIT>".format(err)<EOL><DEDENT>else:<EOL><INDENT>msg += "<STR_LIT>".format(code)<EOL><DEDENT>raise IOError(msg)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>except IOError:<EOL><INDENT>err = sys.exc_info()[<NUM_LIT:1>]<EOL>self.error = err<EOL>self.py3_wrapper.log(err, "<STR_LIT:error>")<EOL><DEDENT><DEDENT><DEDENT>except OSError:<EOL><INDENT>self.error = "<STR_LIT>"<EOL><DEDENT>except Exception:<EOL><INDENT>self.py3_wrapper.report_exception("<STR_LIT>", notify_user=True)<EOL><DEDENT>self.i3status_pipe = None<EOL>
Spawn i3status using a self generated config file and poll its output.