Example #1
0
 def purge(self, cmd):
     days = cmd.args.head | 30
     self.log.info('Deleting releases older than {} days'.format(days))
     data = Map(self.client.put('release/purge', dict(days=days)))
     return IO.pure(
         purge_msg.format(data['monitors'], data['links'], data['releases'])
     )
Example #2
0
def build_venv(global_interpreter: Maybe[str], dir: Path, rplugin_interpreter: Maybe[str], name: str) -> Do:
    interpreter = yield python_interpreter(global_interpreter, rplugin_interpreter)
    retval, out, err = yield Subprocess.popen(str(interpreter), '-m', 'venv', str(dir), '--upgrade', timeout=30)
    success = retval == 0
    yield (
        IO.pure(cons_venv(dir, name))
        if success else
        IO.failed(f'creating venv for `{name}`: {err.join_lines}')
    )
Example #3
0
def find_interpreter(spec: str) -> Do:
    path = Path(spec)
    exists = yield IO.delay(path.exists)
    venv = env.get('VIRTUAL_ENV').get_or_strict('[no venv]')
    yield (
        IO.pure(path)
        if exists else
        virtualenv_interpreter(venv, spec)
    )
Example #4
0
 def check_error(response):
     if isinstance(response, dict) and 'error' in response:
         return IO.failed(response['error'])
     else:
         return IO.pure(response)
Example #5
0
 def data(self):
     return (self.spec // __.lmap(lambda a: IO.pure(
         (a, self.args.tail | List()))).left_or_map(self._lookup))
Example #6
0
 def check(resp):
     return (IO.failed('no release found') if resp == -1 else IO.pure(
         (resp, self.rest)))
Example #7
0
 def venv_absent(self, status: VenvAbsent) -> IO[Boolean]:
     return IO.pure(false)
Example #8
0
def venv_package_status(venv: Venv, req: str) -> Do:
    site_e = yield venv_site(venv)
    yield site_e.cata(lambda a: IO.pure(VenvPackageAbsent(venv)),
                      lambda a: venv_package_status_site(venv, a, req))
Example #9
0
def bootstrap_hs_rplugin(rplugin: InstallableRplugin,
                         meta: HsInstallableRplugin) -> None:
    yield NS.pure(IO.pure(rplugin.rplugin.name))
Example #10
0
 def _data_path(self):
     tpl = 'show/{name}'
     form = lambda a: IO.pure(tpl.format(**a))
     return self._data_spec // __.cata(IO.failed(self._arg_error), form)
Example #11
0
 def _data_path(self):
     tpl = 'release/{show}/{season}/{episode}'
     form = lambda a: IO.pure(tpl.format(**a))
     return self._data_spec // __.cata(IO.failed(self._arg_error), form)
Example #12
0
 def status(self, cmd):
     return IO.pure(format_status_lines(self._status))
Example #13
0
 def list(self, cmd):
     regex = cmd.args.head | ''
     return IO.pure(list(self._format_list(self._list(regex))))
Example #14
0
 def hackage(
         self, a: HsHackageRplugin
 ) -> NS[CrmRibosome, GatherItem[Tuple[str, bool]]]:
     exe = cabal_rplugin_executable(self.rplugin)
     return NS.pure(GatherIO(IO.pure((self.rplugin.name, exe.is_file()))))
Example #15
0
def remove_dir(dir: Path) -> Do:
    exists = yield IO.delay(dir.exists)
    yield IO.delay(shutil.rmtree, dir) if exists else IO.pure(None)
Example #16
0
 def dir(self, a: HsStackDirRplugin
         ) -> NS[CrmRibosome, GatherItem[Tuple[str, bool]]]:
     return NS.pure(GatherIO(IO.pure((self.rplugin.name, False))))
Example #17
0
 def present(self, status: VenvPresent) -> IO[str]:
     return IO.pure(status.venv.name)