def __init__(self, package: str, name_in_distros: t.Dict[str, str] = None): """ Creates an instance. :param package: name of the package :param name_in_distros: name in each supported linux distribution if it differs from the already given name """ super().__init__() self.package = package # type: str """ Name of the package """ self.name_in_distros = name_in_distros or {} # type: t.Dict[str, str] """ Name in each supported linux distribution if it differs from the package name """ pkg = {} for distro in self.name_in_distros: if distro not in self.supported_distributions: logging.warning( "Ignore unsupported distribution {}".format(distro)) else: pkg[distro] = self.name_in_distros[distro] for distro in self.supported_distributions: if distro not in pkg: pkg[distro] = package self.name_in_distros = pkg self.typecheck() self._current_distro = get_distribution_name() self._current_package_name = self.name_in_distros[self._current_distro] self._current_install_cmd = self.install_cmds[ self._current_distro].format(self._current_package_name) self._current_check_cmd = self.check_cmds[self._current_distro].format( self._current_package_name) self._current_uninstall_cmd = self.uninstall_cmds[ self._current_distro].format(self._current_package_name)
def __init__(self, package: str, name_in_distros: t.Dict[str, str] = None): """ Creates an instance. :param package: name of the package :param name_in_distros: name in each supported linux distribution if it differs from the already given name """ super().__init__() self.package = package # type: str """ Name of the package """ self.name_in_distros = name_in_distros or {} # type: t.Dict[str, str] """ Name in each supported linux distribution if it differs from the package name """ pkg = {} for distro in self.name_in_distros: if distro not in self.supported_distributions: logging.warning("Ignore unsupported distribution {}".format(distro)) else: pkg[distro] = self.name_in_distros[distro] for distro in self.supported_distributions: if distro not in pkg: pkg[distro] = package self.name_in_distros = pkg self.typecheck() self._current_distro = get_distribution_name() self._current_package_name = self.name_in_distros[self._current_distro] self._current_install_cmd = self.install_cmds[self._current_distro].format(self._current_package_name) self._current_check_cmd = self.check_cmds[self._current_distro].format(self._current_package_name) self._current_uninstall_cmd = self.uninstall_cmds[self._current_distro].format(self._current_package_name)
def _unsupported_distribution(self) -> bool: current_distro = get_distribution_name() current_release = get_distribution_release() for (distro, release) in self.possible_distributions: if distro == current_distro and release == current_release: return False return True
def _execute(self, db: Database): if self._unsupported_distribution(): expected = join_strs( ["{} {} ".format(*l) for l in self.possible_distributions], "or") self._fail( "Unsupported distribution {} and release {}, expected {}". format(get_distribution_name(), get_distribution_release(), expected))
def __init__(self, possible_distributions: t.List[str] = [get_distribution_name()]): """ Creates an instance. :param possible_distributions: names of the allowed linux distributions """ super().__init__() self.possible_distributions = possible_distributions # type: t.List[str] """ Names of the allowed linux distributions """ self.typecheck()
def __init__(self, possible_distributions: t.List[t.Tuple[str, str]] = [(get_distribution_name(), get_distribution_release())]): """ Creates an instance. :param possible_distributions: allowed (distribution, release) tuples """ super().__init__() self.possible_distributions = possible_distributions # type: t.List[t.Tuple[str, str]] """ Allowed (distribution, release) tuples """ self.typecheck()
def __init__(self, possible_distributions: t.List[t.Tuple[str, str]] = [ (get_distribution_name(), get_distribution_release()) ]): """ Creates an instance. :param possible_distributions: allowed (distribution, release) tuples """ super().__init__() self.possible_distributions = possible_distributions # type: t.List[t.Tuple[str, str]] """ Allowed (distribution, release) tuples """ self.typecheck()
def __init__(self, possible_distributions: t.List[str] = [ get_distribution_name() ]): """ Creates an instance. :param possible_distributions: names of the allowed linux distributions """ super().__init__() self.possible_distributions = possible_distributions # type: t.List[str] """ Names of the allowed linux distributions """ self.typecheck()
def _fail_on_unsupported_distro(self): if get_distribution_name() not in self.name_in_distros: self._fail("Unsupported distribution {} for package {}".format(get_distribution_name(), self.package))
def _execute(self, db: Database): if self._unsupported_distribution(): expected = join_strs(["{} {} ".format(*l) for l in self.possible_distributions], "or") self._fail("Unsupported distribution {} and release {}, expected {}".format(get_distribution_name(), get_distribution_release(), expected))
def _execute(self, db: Database): if self._unsupported_distribution(): self._fail("Unsupported distribution {}, expected {}".format(get_distribution_name(), join_strs(self.possible_distributions, "or")))
def _unsupported_distribution(self) -> bool: return get_distribution_name() not in self.possible_distributions
def _execute(self, db: Database): if self._unsupported_distribution(): self._fail("Unsupported distribution {}, expected {}".format( get_distribution_name(), join_strs(self.possible_distributions, "or")))
def _fail_on_unsupported_distro(self): if get_distribution_name() not in self.name_in_distros: self._fail("Unsupported distribution {} for package {}".format( get_distribution_name(), self.package))