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']) )
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}') )
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) )
def check_error(response): if isinstance(response, dict) and 'error' in response: return IO.failed(response['error']) else: return IO.pure(response)
def data(self): return (self.spec // __.lmap(lambda a: IO.pure( (a, self.args.tail | List()))).left_or_map(self._lookup))
def check(resp): return (IO.failed('no release found') if resp == -1 else IO.pure( (resp, self.rest)))
def venv_absent(self, status: VenvAbsent) -> IO[Boolean]: return IO.pure(false)
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))
def bootstrap_hs_rplugin(rplugin: InstallableRplugin, meta: HsInstallableRplugin) -> None: yield NS.pure(IO.pure(rplugin.rplugin.name))
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)
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)
def status(self, cmd): return IO.pure(format_status_lines(self._status))
def list(self, cmd): regex = cmd.args.head | '' return IO.pure(list(self._format_list(self._list(regex))))
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()))))
def remove_dir(dir: Path) -> Do: exists = yield IO.delay(dir.exists) yield IO.delay(shutil.rmtree, dir) if exists else IO.pure(None)
def dir(self, a: HsStackDirRplugin ) -> NS[CrmRibosome, GatherItem[Tuple[str, bool]]]: return NS.pure(GatherIO(IO.pure((self.rplugin.name, False))))
def present(self, status: VenvPresent) -> IO[str]: return IO.pure(status.venv.name)