Beispiel #1
0
def plugin_venv(base_dir: Path, rplugin: Rplugin) -> Do:
    yield venv_existent(base_dir)(rplugin)
    venv_status = yield N.from_io(check_venv(base_dir, rplugin))
    yield (
        N.pure(venv_status.venv)
        if isinstance(venv_status, VenvPresent) else
        N.error(f'venv for {rplugin} did not appear')
    )
Beispiel #2
0
 def dist_rplugin(self, rplugin: DistRplugin) -> Do:
     venv = yield venv_from_rplugin(rplugin)
     plugin_path_e = yield N.from_io(venv_plugin_path(venv))
     plugin_path = yield N.e(plugin_path_e)
     python_exe = venv.meta.python_executable
     bin_path = venv.meta.bin_path
     yield start_python_rplugin_host(rplugin, python_exe, bin_path,
                                     plugin_path, Nil)
Beispiel #3
0
def define_handlers(active_rplugin: ActiveRplugin) -> Do:
    channel = active_rplugin.channel
    cname = camelcaseify(active_rplugin.name)
    rpc_handlers_fun = f'{cname}RpcHandlers'
    result = yield N.call_once_defined(rpc_handlers_fun, timeout=3)
    handlers = (Lists.wrap(result).flat_map(RpcHandlerSpec.decode).map(
        lambda spec: ActiveRpcTrigger(spec=spec, channel=channel)))
    yield N.pure(handlers)
Beispiel #4
0
 def hackage(self, a: HsHackageRplugin) -> Do:
     cabal = yield N.from_io(cabal_exe())
     return Subprocess(cabal,
                       List('install', a.dep),
                       self.rplugin.rplugin.name,
                       600,
                       env=None)
Beispiel #5
0
 def stackage(self, a: HsStackageRplugin) -> Do:
     stack = yield N.from_io(stack_exe())
     return Subprocess(stack,
                       List('install', a.dep),
                       self.rplugin.rplugin.name,
                       600,
                       env=None)
Beispiel #6
0
 def check(rplugin: Rplugin) -> NvimIO[None]:
     return wait_until_valid(
         str(rplugin),
         lambda n: N.from_io(rplugin_ready(base_dir, rplugin)),
         timeout=timeout,
         interval=.5,
     )
Beispiel #7
0
 def dir(self, a: HsStackDirRplugin) -> Do:
     stack = yield N.from_io(stack_exe())
     return Subprocess(stack,
                       List('install'),
                       self.rplugin.rplugin.name,
                       600,
                       cwd=a.dir,
                       env=None)
Beispiel #8
0
def setup_venvs(names: List[str]) -> Do:
    venvs = yield setup_venv_dir(Just(venvs_path))
    create = names.exists(lambda a: not venv_path(a).exists())
    if create:
        yield N.from_io(clear_cache())
    plugins = yield names.traverse(setup_venv, NvimIO)
    yield nvim_sync_command('CrmSetupPlugins')
    yield plugins.traverse(venv_existent(venvs, 30), NvimIO)
    yield plugins.traverse(package_installed(venvs), NvimIO)
Beispiel #9
0
def reboot_spec() -> Do:
    before = yield call_once_defined(reboot_test)
    json = yield N.e(dump_json(update_query))
    yield nvim_command(f'CrmUpdateState {json}')
    yield seen_program('update_state')
    updated_path = yield await_k(check_path)
    yield nvim_command('CrmUpdate')
    yield nvim_command('CrmReboot')
    yield wait_for_function_undef(reboot_test)
    after = yield call_once_defined(reboot_test)
    return updated_path & (k(before) == 13) & (k(after) == 17)
Beispiel #10
0
def deactivate_spec() -> Do:
    yield await_k(flag_channel_id_becomes, not_equal(-1))
    channel = yield flag_channel_id()
    yield await_k(flag_jobpid_becomes, greater(0))
    yield nvim_command('CrmDeactivate')
    command_nonexistent = yield await_k(command_must_not_exist, 'FlagTest', timeout=10)
    quit_var = yield var_must_become('flagellum_quit', 1)
    pid = yield N.safe(nvim_call_tpe(int, 'jobpid', channel))
    return (
        command_nonexistent &
        k(pid).must(have_type(NError)) &
        quit_var
    )
Beispiel #11
0
def start_host(
    cmdline: str,
    debug: bool = False,
) -> Do:
    ribo_log.debug(f'starting host: {cmdline}; debug: {debug}')
    stderr_handler_name = yield define_rpc_stderr_handler(
        stderr_handler_prefix)
    channel = yield nvim_call_tpe(
        int, 'jobstart', cmdline, dict(rpc=True,
                                       on_stderr=stderr_handler_name))
    pid = yield nvim_call_tpe(int, 'jobpid', channel)
    ribo_log.debug(f'host running, channel {channel}, pid {pid}')
    yield N.pure((channel, pid))
Beispiel #12
0
def flag_channel_id() -> Do:
    name = yield plugin_name()
    state = yield nvim_call_json(f'{camelcase(name)}State')
    active = yield N.m(state.active.head, 'no active rplugins')
    return active.channel
Beispiel #13
0
def log_matches(matcher: Matcher[List[str]]) -> Do:
    output = yield N.from_io(IO.file(test_config.log_file))
    return k(output).must(matcher)
Beispiel #14
0
def present_venv(name: str) -> NvimIO[Path]:
    return N.simple(temp_dir, 'rplugin', 'venv', 'flagellum', 'lib',
                    'python3.7')
Beispiel #15
0
def global_interpreter() -> Do:
    global_spec = yield interpreter.value
    yield N.from_io(python_interpreter(global_spec.to_maybe, Nothing))
Beispiel #16
0
def setup_one_with_venvs(name: str, venv_dir: Maybe[Path] = Nothing) -> Do:
    base_dir = yield setup_venv_dir(venv_dir)
    rplugin = yield setup_one(name, venv_dir)
    venv_rplugin = yield N.m(cons_installable_rplugin.match(rplugin), f'couldn\'t cons InstallableRplugin')
    return base_dir, venv_rplugin
Beispiel #17
0
 def site_rplugin(self, rplugin: SiteRplugin) -> NvimIO[ActiveRplugin]:
     return N.error('site rplugins not implemented yet')