def setup(self):
<EOL>signal(SIGTSTP, self.i3bar_stop)<EOL>signal(SIGCONT, self.i3bar_start)<EOL>self.log("<STR_LIT:=>" * <NUM_LIT:8>)<EOL>msg = "<STR_LIT>"<EOL>self.log(msg.format(**self.config))<EOL>try:<EOL><INDENT>git_path = os.path.join(os.path.dirname(__file__), "<STR_LIT:..>", "<STR_LIT>")<EOL>with open(os.path.join(git_path, "<STR_LIT>"), "<STR_LIT:r>") as f:<EOL><INDENT>out = f.readline()<EOL><DEDENT>branch = "<STR_LIT:/>".join(out.strip().split("<STR_LIT:/>")[<NUM_LIT:2>:])<EOL>self.log("<STR_LIT>".format(branch))<EOL>log_path = os.path.join(git_path, "<STR_LIT>", "<STR_LIT>", "<STR_LIT>", branch)<EOL>with open(log_path, "<STR_LIT:r>") as f:<EOL><INDENT>out = f.readlines()[-<NUM_LIT:1>]<EOL><DEDENT>sha = out.split("<STR_LIT:U+0020>")[<NUM_LIT:1>][:<NUM_LIT:7>]<EOL>msg = "<STR_LIT::>".join(out.strip().split("<STR_LIT:\t>")[-<NUM_LIT:1>].split("<STR_LIT::>")[<NUM_LIT:1>:])<EOL>self.log("<STR_LIT>".format(sha, msg))<EOL><DEDENT>except:  <EOL><INDENT>pass<EOL><DEDENT>self.log("<STR_LIT>".format(self.config["<STR_LIT>"]))<EOL>if self.config["<STR_LIT>"]:<EOL><INDENT>self.log("<STR_LIT>".format(self.config))<EOL><DEDENT>if self.config["<STR_LIT>"]:<EOL><INDENT>self.is_gevent = self.gevent_monkey_patch_report()<EOL><DEDENT>else:<EOL><INDENT>self.is_gevent = False<EOL><DEDENT>config_path = self.config["<STR_LIT>"]<EOL>self.log("<STR_LIT>".format(self.config["<STR_LIT>"]))<EOL>self.config["<STR_LIT>"] = process_config(config_path, self)<EOL>self.i3status_thread = I3status(self)<EOL>i3s_modules = self.config["<STR_LIT>"]["<STR_LIT>"]<EOL>if self.config["<STR_LIT>"] or not i3s_modules:<EOL><INDENT>self.i3status_thread.mock()<EOL>i3s_mode = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>for module in i3s_modules:<EOL><INDENT>self.log("<STR_LIT>".format(module))<EOL><DEDENT>i3s_mode = "<STR_LIT>"<EOL>self.i3status_thread.start()<EOL>while not self.i3status_thread.ready:<EOL><INDENT>if not self.i3status_thread.is_alive():<EOL><INDENT>err = self.i3status_thread.error<EOL>self.notify_user(err)<EOL>self.i3status_thread.mock()<EOL>i3s_mode = "<STR_LIT>"<EOL>break<EOL><DEDENT>time.sleep(<NUM_LIT:0.1>)<EOL><DEDENT><DEDENT>if self.config["<STR_LIT>"]:<EOL><INDENT>self.log(<EOL>"<STR_LIT>".format(<EOL>i3s_mode, self.config["<STR_LIT>"]<EOL>)<EOL>)<EOL><DEDENT>if i3s_mode == "<STR_LIT>":<EOL><INDENT>task = CheckI3StatusThread(self.i3status_thread, self)<EOL>self.timeout_queue_add(task)<EOL><DEDENT>self.events_thread = Events(self)<EOL>self.events_thread.daemon = True<EOL>self.events_thread.start()<EOL>if self.config["<STR_LIT>"]:<EOL><INDENT>self.log("<STR_LIT>")<EOL><DEDENT>self.commands_thread = CommandServer(self)<EOL>self.commands_thread.daemon = True<EOL>self.commands_thread.start()<EOL>if self.config["<STR_LIT>"]:<EOL><INDENT>self.log("<STR_LIT>")<EOL><DEDENT>self.udev_monitor = UdevMonitor(self)<EOL>if not self.config["<STR_LIT>"]:<EOL><INDENT>sys.stdout = open("<STR_LIT>", "<STR_LIT:w>")<EOL>sys.stderr = open("<STR_LIT>", "<STR_LIT:w>")<EOL><DEDENT>self.py3_modules = self.config["<STR_LIT>"]["<STR_LIT>"]<EOL>self.log("<STR_LIT>".format(self.config["<STR_LIT>"]))<EOL>user_modules = self.get_user_configured_modules()<EOL>if self.config["<STR_LIT>"]:<EOL><INDENT>self.log("<STR_LIT>".format(user_modules))<EOL><DEDENT>if self.py3_modules:<EOL><INDENT>self.load_modules(self.py3_modules, user_modules)<EOL><DEDENT>
Setup py3status and spawn i3status/events/modules threads.