コード例 #1
0
ファイル: mg9.py プロジェクト: charlievieth/GoSubl
def _complete_opts(fn, src, pos, builtins):
    nv = sh.env()
    return {
        "Dir": gs.basedir_or_cwd(fn),
        "Builtins": builtins,
        "Fn": fn or "",
        "Src": src or "",
        "Pos": pos or 0,
        "Home": sh.vdir(),
        "Autoinst": gs.setting("autoinst"),
        "InstallSuffix": gs.setting("installsuffix", ""),
        "Env": {"GOROOT": nv.get("GOROOT", ""), "GOPATH": nv.get("GOPATH", "")},
    }
コード例 #2
0
ファイル: mg9.py プロジェクト: campoy/GoSublime-next
def _cleanup():
	try:
		vdir, vnm = os.path.split(sh.vdir())
		for nm in os.listdir(vdir):
			fn = os.path.join(vdir, nm)
			if nm != vnm and os.path.isdir(fn):
				try:
					gs.println("GoSublime: removing old directory: `%s'" % fn)
					shutil.rmtree(fn)
				except Exception:
					pass

	except Exception:
		pass
コード例 #3
0
ファイル: mg9.py プロジェクト: campoy/GoSublime-next
def _complete_opts(fn, src, pos, builtins):
	nv = sh.env()
	return {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': sh.vdir(),
		'Autoinst': gs.setting('autoinst'),
		'Env': {
			'GOROOT': nv.get('GOROOT', ''),
			'GOPATH': nv.get('GOPATH', ''),
		},
	}
コード例 #4
0
def _complete_opts(fn, src, pos, builtins):
    nv = sh.env()
    return {
        'Dir': gs.basedir_or_cwd(fn),
        'Builtins': builtins,
        'Fn': fn or '',
        'Src': src or '',
        'Pos': pos or 0,
        'Home': sh.vdir(),
        'Autoinst': gs.setting('autoinst'),
        'InstallSuffix': gs.setting('installsuffix', ''),
        'Env': {
            'GOROOT': nv.get('GOROOT', ''),
            'GOPATH': nv.get('GOPATH', ''),
        },
    }
コード例 #5
0
ファイル: mg9.py プロジェクト: allanw1/Arianrhod
def _complete_opts(fn, src, pos, builtins, *, forceInstall = False):
	nv = sh.env()
	return {
		'Dir': gs.basedir_or_cwd(fn),
		'Builtins': builtins,
		'Fn':  fn or '',
		'Src': src or '',
		'Pos': pos or 0,
		'Home': sh.vdir(),
		'Autoinst': gs.setting('autoinst'),
		'InstallSuffix': gs.setting('installsuffix', ''),
		'Env': {
			'GOROOT': nv.get('GOROOT', ''),
			'GOPATH': nv.get('GOPATH', ''),
			'TEMP': nv.get('TEMP', ''),
			'TMP': nv.get('TMP', ''),
			'FORCE_INSTALL': str(int(forceInstall)),
		},
	}
コード例 #6
0
ファイル: mg9.py プロジェクト: RazoRTR/Arianrhod
def _complete_opts(fn, src, pos, builtins, *, forceInstall=False):
    nv = sh.env()
    return {
        'Dir': gs.basedir_or_cwd(fn),
        'Builtins': builtins,
        'Fn': fn or '',
        'Src': src or '',
        'Pos': pos or 0,
        'Home': sh.vdir(),
        'Autoinst': gs.setting('autoinst'),
        'InstallSuffix': gs.setting('installsuffix', ''),
        'Env': {
            'GOROOT': nv.get('GOROOT', ''),
            'GOPATH': nv.get('GOPATH', ''),
            'TEMP': nv.get('TEMP', ''),
            'TMP': nv.get('TMP', ''),
            'FORCE_INSTALL': str(int(forceInstall)),
        },
    }
コード例 #7
0
ファイル: mg9.py プロジェクト: campoy/GoSublime-next
def _send():
	while True:
		try:
			try:
				method, arg, cb = gs.mg9_send_q.get()

				proc = gs.attr(PROC_ATTR_NAME)
				if not proc or proc.poll() is not None:
					killSrv()

					_install(True)

					while _inst_state() == "busy":
						time.sleep(0.100)

					cmd = [
						'margo',
						'-oom', gs.setting('margo_oom', 0),
						'-poll', 30,
						'-tag', TAG,
					]

					c = sh.Command(cmd)
					c.stderr = gs.LOGFILE
					c.env = {
						'GOGC': 10,
						'XDG_CONFIG_HOME': sh.vdir(),
					}

					pr = c.proc()
					if pr.ok:
						proc = pr.p
						err = ''
					else:
						proc = None
						err = 'Exception: %s' % pr.exc

					if err or not proc or proc.poll() is not None:
						killSrv()
						_call(cb, {}, 'Abort. Cannot start MarGo: %s' % err)

						continue

					gs.set_attr(PROC_ATTR_NAME, proc)
					gsq.launch(DOMAIN, lambda: _read_stdout(proc))

				req = Request(f=cb, method=method)
				gs.set_attr(REQUEST_PREFIX+req.token, req)

				header, err = gs.json_encode(req.header())
				if err:
					_cb_err(cb, 'Failed to construct ipc header: %s' % err)
					continue

				body, err = gs.json_encode(arg)
				if err:
					_cb_err(cb, 'Failed to construct ipc body: %s' % err)
					continue

				ev.debug(DOMAIN, {
					'_mode': 'request',
					'header': req.header(),
					'body': arg,
				})

				ln = '%s %s\n' % (header, body)

				try:
					if gs.PY3K:
						proc.stdin.write(bytes(ln, 'UTF-8'))
					else:
						proc.stdin.write(ln)

				except Exception as ex:
					_cb_err(cb, 'Cannot talk to MarGo: %s' % err)
					killSrv()
					gs.print_traceback()

			except Exception:
				killSrv()
				gs.print_traceback()
		except Exception:
			gs.print_traceback()
			break