Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
	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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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)
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
	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())
Ejemplo n.º 16
0
			def f():
				gs.end(tid)
				view.insert(edit, r.end(), '\n%s' % out)
				view.run_command('gs_commander_init')
Ejemplo n.º 17
0
 def f():
     gs.end(tid)
     push_output(view,
                 rkey,
                 out,
                 hourglass_repl='| done: %s' % res.get('dur', ''))
Ejemplo n.º 18
0
		def f():
			gs.end(tid)
			push_output(view, rkey, out, hourglass_repl='| done: %s' % res.get('dur', ''))
Ejemplo n.º 19
0
Archivo: mg9.py Proyecto: ski/GoSublime
	def cb(res, err):
		gs.end(tid)
		f(res, err)
Ejemplo n.º 20
0
 def cb(res, err):
     gs.end(tid)
     f(res, err)