示例#1
0
文件: mg9.py 项目: allanw1/Arianrhod
def sanity_check(env={}, error_log=False):
	if not env:
		env = sh.env()

	ns = '(not set)'

	sl = [
		('install state', _inst_state()),
		('sublime.version', sublime.version()),
		('sublime.channel', sublime.channel()),
		('about.ann', gs.attr('about.ann', '')),
		('about.version', gs.attr('about.version', '')),
		('version', about.VERSION),
		('platform', about.PLATFORM),
		('~bin', '%s' % gs.home_dir_path('bin')),
		('margo.exe', '%s (%s)' % _tp(_margo_bin())),
		('go.exe', '%s (%s)' % _tp(sh.which('go') or 'go')),
		('go.version', sh.GO_VERSION),
		('GOROOT', '%s' % env.get('GOROOT', ns)),
		('GOPATH', '%s' % env.get('GOPATH', ns)),
		('GOBIN', '%s (should usually be `%s`)' % (env.get('GOBIN', ns), ns)),
		('set.shell', str(gs.lst(gs.setting('shell')))),
		('env.shell', env.get('SHELL', '')),
		('shell.cmd', str(sh.cmd('${CMD}'))),
	]

	if error_log:
		try:
			with open(gs.home_path('log.txt'), 'r') as f:
				s = f.read().strip()
				sl.append(('error log', s))
		except Exception:
			pass

	return sl
示例#2
0
def sanity_check(env={}, error_log=False):
	if not env:
		env = sh.env()

	ns = '(not set)'

	sl = [
		('install state', _inst_state()),
		('sublime.version', sublime.version()),
		('sublime.channel', sublime.channel()),
		('about.ann', gs.attr('about.ann', '')),
		('about.version', gs.attr('about.version', '')),
		('version', about.VERSION),
		('platform', about.PLATFORM),
		('~bin', '%s' % gs.home_dir_path('bin')),
		('margo.exe', '%s (%s)' % _tp(_margo_bin())),
		('go.exe', '%s (%s)' % _tp(sh.which('go') or 'go')),
		('go.version', sh.GO_VERSION),
		('GOROOT', '%s' % env.get('GOROOT', ns)),
		('GOPATH', '%s' % env.get('GOPATH', ns)),
		('GOBIN', '%s (should usually be `%s`)' % (env.get('GOBIN', ns), ns)),
		('set.shell', str(gs.lst(gs.setting('shell')))),
		('env.shell', env.get('SHELL', '')),
		('shell.cmd', str(sh.cmd('${CMD}'))),
	]

	if error_log:
		try:
			with open(gs.home_path('log.txt'), 'r') as f:
				s = f.read().strip()
				sl.append(('error log', s))
		except Exception:
			pass

	return sl
示例#3
0
    def oracle(self, end_offset, begin_offset=None, mode="plain", scope=""):
        """ Builds the oracle shell command and calls it, returning it's output as a string.
        """
        file_path = self.view.file_name()
        output_format = "plain"
        pos = "#" + str(end_offset)
        if begin_offset is not None:
            pos = "#%i,#%i" % (begin_offset, end_offset)

        oracle = sh.which("oracle")
        if oracle:
            args = [
                "-pos=" + file_path + ":" + pos, "-format=" + output_format,
                mode
            ]
            if scope:
                args.append(scope)
            shcmd = gs.lst(oracle, args)
            print(" ".join(shcmd))
            cmd = sh.Command(shcmd)
            cr = cmd.run()
            if cr.exc:
                _print('error loading env vars: %s' % cr.exc)
            return cr.out, cr.err
        return
示例#4
0
def sanity_check(env={}, error_log=False):
    if not env:
        env = sh.env()

    ns = "(not set)"

    sl = [
        ("install state", _inst_state()),
        ("sublime.version", sublime.version()),
        ("sublime.channel", sublime.channel()),
        ("about.ann", gs.attr("about.ann", "")),
        ("about.version", gs.attr("about.version", "")),
        ("version", about.VERSION),
        ("platform", about.PLATFORM),
        ("~bin", "%s" % gs.home_dir_path("bin")),
        ("margo.exe", "%s (%s)" % _tp(_margo_bin())),
        ("go.exe", "%s (%s)" % _tp(sh.which("go") or "go")),
        ("go.version", sh.GO_VERSION),
        ("GOROOT", "%s" % env.get("GOROOT", ns)),
        ("GOPATH", "%s" % env.get("GOPATH", ns)),
        ("GOBIN", "%s (should usually be `%s`)" % (env.get("GOBIN", ns), ns)),
        ("set.shell", str(gs.lst(gs.setting("shell")))),
        ("env.shell", env.get("SHELL", "")),
        ("shell.cmd", str(sh.cmd("${CMD}"))),
    ]

    if error_log:
        try:
            with open(gs.home_path("log.txt"), "r") as f:
                s = f.read().strip()
                sl.append(("error log", s))
        except Exception:
            pass

    return sl
示例#5
0
def cmd_build(view, edit, args, wd, rkey):
	cmd_9(view, edit, gs.lst('build', args), wd, rkey)
示例#6
0
def cmd_replay(view, edit, args, wd, rkey):
	cmd_9(view, edit, gs.lst('replay', args), wd, rkey)
示例#7
0
def cmd_run(view, edit, args, wd, rkey):
	cmd_9(view, edit, gs.lst('run', args), wd, rkey)
示例#8
0
			def cb(i, win):
				if i >= 0:
					a = args.get(ents[i], [])
					win.active_view().run_command('gs9o_open', {'run': gs.lst('go', 'test', a)})
示例#9
0
def cmd_build(view, edit, args, wd, rkey):
    cmd_9(view, edit, gs.lst('build', args), wd, rkey)
示例#10
0
def cmd_replay(view, edit, args, wd, rkey):
    cmd_9(view, edit, gs.lst('replay', args), wd, rkey)
示例#11
0
def cmd_run(view, edit, args, wd, rkey):
    cmd_9(view, edit, gs.lst('run', args), wd, rkey)
示例#12
0
 def cb(i, win):
     if i >= 0:
         a = args.get(ents[i], [])
         win.active_view().run_command(
             "gs9o_open", {"run": gs.lst("go", "test", a)}
         )
示例#13
0
			def cb(i, win):
				if i >= 0:
					a = args.get(ents[i], [])
					win.active_view().run_command('gs9o_open', {'run': gs.lst('go', 'test', a)})
示例#14
0
def build_mg(force=False):
	if force:
		pass
	elif gs.setting('_rebuild'):
		print('GoSublime: `_rebuild` is set')
	elif _mg_exists():
		return 'ok'

	gs.notify('GoSublime', 'Installing MarGo')

	gobin = sh.bin_dir()
	gopath = gs.dist_path()
	wd = gobin
	env = {
		'CGO_ENABLED': '0',
		'GOBIN': gobin,
		'GOPATH': gopath,
	}

	# do a cleanup just-in-case there are old packages lying around... we don't really care if it fails
	clean = sh.Command(['go', 'clean', '-i', 'gosubli.me/...'])
	clean.wd = wd
	clean.env = env
	clean.run()

	f = gs.setting('_build_flags') or ['-v', '-x']
	args = gs.lst('go', 'build', f, '-o', sh.exe('margo'), 'gosubli.me/margo')

	build = sh.Command(args)
	build.wd = wd
	build.env = env

	ev.debug('%s.build' % DOMAIN, {
		'cmd': build.cmd_lst,
		'cwd': build.wd,
	})

	cr = build.run()

	if cr.ok and _mg_exists():
		return 'ok'

	m_out = 'cmd: `%s`\nstdout: `%s`\nstderr: `%s`\nexception: `%s`' % (
		cr.cmd_lst,
		cr.out.strip(),
		cr.err.strip(),
		cr.exc,
	)

	err_prefix = 'MarGo build failed'
	gs.error(DOMAIN, '%s\n%s' % (err_prefix, m_out))

	sl = [
		('GoSublime error', '\n'.join((
			err_prefix,
			'This is possibly a bug or miss-configuration of your environment.',
			'For more help, please file an issue with the following build output',
			'at: https://github.com/DisposaBoy/GoSublime/issues/new',
			'or alternatively, you may send an email to: [email protected]',
			'\n',
			m_out,
		)))
	]
	sl.extend(sanity_check({}, False))
	gs.show_output('GoSublime', '\n'.join(sanity_check_sl(sl)))

	return m_out