def do_hello(): global hello_sarting if hello_sarting: return hello_sarting = True tid = gs.begin(DOMAIN, 'Starting Gocode', False) call_cmd(['gocode']) gs.end(tid) margo_cmd = list(gs.setting('margo_cmd', [])) if margo_cmd: margo_cmd.extend([ "-d", "-call", "replace", "-addr", gs.setting('margo_addr', '') ]) tid = gs.begin(DOMAIN, 'Starting MarGo', False) out, err, _ = gs.runcmd(margo_cmd) gs.end(tid) out = out.strip() err = err.strip() if err: gs.notice(DOMAIN, err) elif out: gs.notice(DOMAIN, 'MarGo started %s' % out) hello_sarting = False else: err = 'Missing `margo_cmd`' gs.notice("MarGo", err) hello_sarting = False
def run(self): self.started = time.time() tid = gs.begin(DOMAIN, self.message, set_status=False, cancel=self.cancel) try: try: self.p = gs.popen(self.cmd, shell=self.shell, stderr=subprocess.STDOUT, environ=self.env, cwd=self.cwd, bufsize=1) CommandStdoutReader(self, self.p.stdout).start() except Exception as ex: self.x = ex finally: self.rcode = self.p.wait() if self.p else False finally: gs.end(tid) self.ended = time.time() self.on_done(self) for f in self.done: try: f(self) except Exception: gs.notice(DOMAIN, gs.traceback())
def do_hello(): global hello_sarting if hello_sarting: return hello_sarting = True tid = gs.begin(DOMAIN, 'Starting Gocode', False) call_cmd([mg9.GOCODE_BIN]) gs.end(tid) margo_cmd = list(gs.setting('margo_cmd', [])) margo_cmd = [ mg9.MARGO0_BIN, "-d", "-call", "replace", "-addr", gs.setting('margo_addr', '') ] tid = gs.begin(DOMAIN, 'Starting MarGo', False) out, err, _ = gs.runcmd(margo_cmd) gs.end(tid) out = out.strip() err = err.strip() if err: gs.notice(DOMAIN, err) elif out: gs.println(DOMAIN, 'MarGo started %s' % out) hello_sarting = False
def run(self): tid = gs.begin(self.domain, self.msg, self.set_status) try: self.f() except Exception: gs.notice(self.domain, gs.traceback()) finally: gs.end(tid)
def run(self): while True: try: f, msg = self.q.get() tid = gs.begin(self.domain, msg, False) try: f() except Exception: gs.notice(self.domain, traceback.format_exc()) except: pass gs.end(tid)
def run(self): while True: try: f, msg, set_status = self.q.get() tid = gs.begin(self.domain, msg, set_status) try: f() except Exception: gs.notice(self.domain, gs.traceback()) except: pass gs.end(tid)
def do_post_save(view): if not gs.is_pkg_view(view): return for c in gs.setting("on_save", []): cmd = c.get("cmd", "") args = c.get("args", {}) msg = "running on_save command %s" % cmd tid = gs.begin(DOMAIN, msg, set_status=False) try: view.run_command(cmd, args) except Exception as ex: gs.notice(DOMAIN, "Error %s" % ex) finally: gs.end(tid)
def do_post_save(view): if not gs.is_pkg_view(view): return for c in gs.setting('on_save', []): cmd = c.get('cmd', '') args = c.get('args', {}) msg = 'running on_save command %s' % cmd tid = gs.begin(DOMAIN, msg, set_status=False) try: view.run_command(cmd, args) except Exception as ex: gs.notice(DOMAIN, 'Error %s' % ex) finally: gs.end(tid)
def do_post_save(view): if not gs.is_pkg_view(view): return domain = 'GoSublime-On-Save' for c in gs.setting('on_save', []): cmd = c.get('cmd', '') args = c.get('args', {}) msg = 'running on_save command %s' % cmd tid = gs.begin(domain, msg, set_status=False) gs.println(msg) try: view.run_command(cmd, args) except Exception as ex: gs.notice(domain, 'Error %s' % ex) finally: gs.end(tid)
def do_hello(): global hello_sarting if hello_sarting: return hello_sarting = True margo_cmd = [ mg9.MARGO0_BIN, "-d", "-call", "replace", "-addr", gs.setting('margo_addr', '') ] tid = gs.begin(DOMAIN, 'Starting MarGo', False) out, err, _ = gsshell.run(margo_cmd) gs.end(tid) out = out.strip() err = err.strip() if err: gs.notice(DOMAIN, err) elif out: gs.println(DOMAIN, 'MarGo started %s' % out) hello_sarting = False
def f(): gs.end(tid) view.insert(edit, r.end(), '\n%s' % out) view.run_command('gs_commander_init')
def f(): gs.end(tid) push_output(view, rkey, out, hourglass_repl='| done: %s' % res.get('dur', ''))
def cb(res, err): gs.end(tid) f(res, err)