def f(): out, err, _ = gs.runcmd(['go', 'get', '-u', '-v', GOCODE_REPO, MARGO_REPO]) margo.bye_ni() call_cmd(['gocode', 'close']) gs.notice(DOMAIN, '%s done' % msg) gs.println(DOMAIN, '%s done\n%s%s' % (msg, out, err)) do_hello()
def install(aso_tokens, force_install): init_start = time.time() try: os.makedirs(gs.home_path('bin')) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = 'no' m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo0') start = time.time() m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(MARGO0_BIN): margo.bye_ni() gs.notify('GoSublime', 'Installing MarGo9') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_ok and m0_ok: def f(): gs.aso().set('mg9_install_tokens', _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) gs.notify('GoSublime', 'Syncing environment variables') out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True) # notify this early so we don't mask any notices below gs.notify('GoSublime', 'Ready') if err: gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out)) else: gs.environ9.update(env) e = gs.env() a = ( 'GoSublime init (%0.3fs)' % (time.time() - init_start), '| install margo0: %s' % m0_out, '| install margo9: %s' % m_out, '| ~bin: %s' % gs.home_path('bin'), '| margo0: %s (%s)' % _tp(MARGO0_BIN), '| margo9: %s (%s)' % _tp(MARGO9_BIN), '| GOROOT: %s' % e.get('GOROOT', '(not set)'), '| GOPATH: %s' % e.get('GOPATH', '(not set)'), '| GOBIN: %s (should usually be (not set))' % e.get('GOBIN', '(not set)'), ) gs.println(*a) missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing)) killSrv() start = time.time() acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start)))
def f(): out, err, _ = gs.runcmd(['go', 'get', '-u', '-v', GOCODE_REPO, MARGO_REPO]) margo.bye_ni() call_cmd(['gocode', 'close']) gs.notice(DOMAIN, '%s done\n%s%s' % (msg, out, err)) gsq.dispatch(hello, 'Starting MarGo and gocode...', view)
def install(aso_tokens, force_install): init_start = time.time() try: os.makedirs(gs.home_path('bin')) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = 'no' m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo0') start = time.time() m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(MARGO0_BIN): margo.bye_ni() gs.notify('GoSublime', 'Installing MarGo9') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_ok and m0_ok: def f(): gs.aso().set('mg9_install_tokens', _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) gs.notify('GoSublime', 'Syncing environment variables') out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True) # notify this early so we don't mask any notices below gs.notify('GoSublime', 'Ready') if err: gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out)) else: gs.environ9.update(env) e = gs.env() a = ( 'GoSublime init (%0.3fs)' % (time.time() - init_start), '| install margo0: %s' % m0_out, '| install margo9: %s' % m_out, '| ~bin: %s' % gs.home_path('bin'), '| margo0: %s (%s)' % _tp(MARGO0_BIN), '| margo9: %s (%s)' % _tp(MARGO9_BIN), '| GOROOT: %s' % e.get('GOROOT', '(not set)'), '| GOPATH: %s' % e.get('GOPATH', '(not set)'), '| GOBIN: %s (should usually be (not set))' % e.get('GOBIN', '(not set)'), ) gs.println(*a) missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing)) killSrv() start = time.time()
def install(aso_tokens, force_install): k = 'mg9.install.%s' % REV if gs.attr(k, False): gs.error(DOMAIN, 'Installation aborted. Install command already called for GoSublime %s.' % REV) return gs.set_attr(k, True) init_start = time.time() try: os.makedirs(gs.home_path('bin')) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = 'no' m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo0') start = time.time() m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(MARGO0_BIN): margo.bye_ni() gs.notify('GoSublime', 'Installing MarGo9') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_ok and m0_ok: def f(): gs.aso().set('mg9_install_tokens', _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) gs.notify('GoSublime', 'Syncing environment variables') out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True) # notify this early so we don't mask any notices below gs.notify('GoSublime', 'Ready') _check_changes() if err: gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out)) else: gs.environ9.update(env) e = gs.env() a = [ 'GoSublime init (%0.3fs)' % (time.time() - init_start), '| install margo0: %s' % m0_out, '| install margo9: %s' % m_out, ] a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)]) gs.println(*a) missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing)) killSrv() start = time.time()
def install(aso_tokens, force_install): k = 'mg9.install.%s' % REV if gs.attr(k, False): gs.error( DOMAIN, 'Installation aborted. Install command already called for GoSublime %s.' % REV) return gs.set_attr(k, True) init_start = time.time() try: os.makedirs(gs.home_path('bin')) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = 'no' m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo0') start = time.time() m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(MARGO0_BIN): margo.bye_ni() gs.notify('GoSublime', 'Installing MarGo9') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_ok and m0_ok: def f(): gs.aso().set('mg9_install_tokens', _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) gs.notify('GoSublime', 'Syncing environment variables') out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True) # notify this early so we don't mask any notices below gs.notify('GoSublime', 'Ready') _check_changes() if err: gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out)) else: gs.environ9.update(env) e = gs.env() a = [ 'GoSublime init (%0.3fs)' % (time.time() - init_start), '| install margo0: %s' % m0_out, '| install margo9: %s' % m_out, ] a.extend(['| %14s: %s' % ln for ln in _sanity_check(e)]) gs.println(*a) missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing)) killSrv() start = time.time()
def install(aso_tokens, force_install): init_start = time.time() try: os.makedirs(gs.home_path('bin')) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = 'no' m_out = 'no' g_out = 'no' else: start = time.time() m0_out, err, _ = _run(['go', 'build', '-o', MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(GOCODE_BIN): margo.bye_ni() start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) # on windows the file cannot be replaced if it's running so close gocode first. # in theory, mg9 has the same issue but since it's attached to a st2 instance, # the only way to close it is to close st2 (which we're presumably already doing) start = time.time() if os.path.exists(GOCODE_BIN): _run([GOCODE_BIN, 'close']) g_out, err, _ = _run(['go', 'build', '-o', GOCODE_BIN], cwd=GOCODE_SRC) g_out, g_ok = _so(g_out, err, start, time.time()) if m_ok and m0_ok and g_ok: def f(): gs.aso().set('mg9_install_tokens', _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) out, err, _ = gsshell.run([MARGO9_EXE, '-env'], cwd=gs.home_path(), shell=True) if err: gs.notice(DOMAIN, 'Cannot run get env vars: %s' % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, 'Cannot load env vars: %s\nenv output: %s' % (err, out)) else: gs.environ9.update(env) e = gs.env() a = ( 'GoSublime init (%0.3fs)' % (time.time() - init_start), '| install margo0: %s' % m0_out, '| install margo9: %s' % m_out, '| install gocode: %s' % g_out, '| ~bin: %s' % gs.home_path('bin'), '| margo0: %s (%s)' % _tp(MARGO0_BIN), '| margo9: %s (%s)' % _tp(MARGO9_BIN), '| gocode: %s (%s)' % _tp(GOCODE_BIN), '| GOROOT: %s' % e.get('GOROOT', '(not set)'), '| GOPATH: %s' % e.get('GOPATH', '(not set)'), '| GOBIN: %s (should usually be (not set))' % e.get('GOBIN', '(not set)'), ) gs.println(*a) missing = [k for k in ('GOROOT', 'GOPATH') if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ', '.join(missing))
def install(aso_tokens, force_install): k = "mg9.install.%s" % REV if gs.attr(k, False): gs.error(DOMAIN, "Installation aborted. Install command already called for GoSublime %s." % REV) return gs.set_attr(k, True) init_start = time.time() try: os.makedirs(gs.home_path("bin")) except: pass if not force_install and _bins_exist() and aso_tokens == _gen_tokens(): m0_out = "no" m_out = "no" else: gs.notify("GoSublime", "Installing MarGo0") start = time.time() m0_out, err, _ = _run(["go", "build", "-o", MARGO0_BIN], cwd=MARGO0_SRC) m0_out, m0_ok = _so(m0_out, err, start, time.time()) if os.path.exists(MARGO0_BIN): margo.bye_ni() gs.notify("GoSublime", "Installing MarGo9") start = time.time() m_out, err, _ = _run(["go", "build", "-o", MARGO9_BIN], cwd=MARGO9_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_ok and m0_ok: def f(): gs.aso().set("mg9_install_tokens", _gen_tokens()) gs.save_aso() sublime.set_timeout(f, 0) gs.notify("GoSublime", "Syncing environment variables") out, err, _ = gsshell.run([MARGO9_EXE, "-env"], cwd=gs.home_path(), shell=True) # notify this early so we don't mask any notices below gs.notify("GoSublime", "Ready") _check_changes() if err: gs.notice(DOMAIN, "Cannot run get env vars: %s" % (MARGO9_EXE, err)) else: env, err = gs.json_decode(out, {}) if err: gs.notice(DOMAIN, "Cannot load env vars: %s\nenv output: %s" % (err, out)) else: gs.environ9.update(env) e = gs.env() a = [ "GoSublime init (%0.3fs)" % (time.time() - init_start), "| install margo0: %s" % m0_out, "| install margo9: %s" % m_out, ] a.extend(["| %14s: %s" % ln for ln in _sanity_check(e)]) gs.println(*a) missing = [k for k in ("GOROOT", "GOPATH") if not e.get(k)] if missing: gs.notice(DOMAIN, "Missing environment variable(s): %s" % ", ".join(missing)) killSrv() start = time.time() # acall('ping', {}, lambda res, err: gs.println('MarGo Ready %0.3fs' % (time.time() - start))) report_x = lambda: gs.println("GoSublime: Exception while cleaning up old binaries", gs.traceback()) try: d = gs.home_path("bin") for fn in os.listdir(d): try: if fn not in (MARGO9_EXE, MARGO0_EXE) and fn.startswith(("gosublime", "gocode", "margo")): fn = os.path.join(d, fn) gs.println("GoSublime: removing old binary: %s" % fn) os.remove(fn) except Exception: report_x() except Exception: report_x()