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(): m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO_BIN], cwd=MARGO_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_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([MARGO_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' % (MARGO_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 margo: %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 != MARGO_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() gsq.launch(DOMAIN, margo.bye_ni)
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(): m_out = 'no' else: gs.notify('GoSublime', 'Installing MarGo') start = time.time() m_out, err, _ = _run(['go', 'build', '-o', MARGO_BIN], cwd=MARGO_SRC) m_out, m_ok = _so(m_out, err, start, time.time()) if m_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([MARGO_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' % (MARGO_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 margo: %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 != MARGO_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() gsq.launch(DOMAIN, margo.bye_ni)
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() # 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()