当前位置: 首页>>代码示例>>Python>>正文


Python Msg.pkg_not_found方法代码示例

本文整理汇总了Python中slpkg.messages.Msg.pkg_not_found方法的典型用法代码示例。如果您正苦于以下问题:Python Msg.pkg_not_found方法的具体用法?Python Msg.pkg_not_found怎么用?Python Msg.pkg_not_found使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在slpkg.messages.Msg的用法示例。


在下文中一共展示了Msg.pkg_not_found方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PkgDesc

# 需要导入模块: from slpkg.messages import Msg [as 别名]
# 或者: from slpkg.messages.Msg import pkg_not_found [as 别名]
class PkgDesc(object):
    """Print package description from the repository
    """
    def __init__(self, name, repo, paint):
        self.name = name
        self.repo = repo
        self.paint = paint
        self.meta = _meta_
        self.msg = Msg()
        self.COLOR = ""
        self.lib = ""
        color_text = {
            "red": self.meta.color["RED"],
            "green": self.meta.color["GREEN"],
            "yellow": self.meta.color["YELLOW"],
            "cyan": self.meta.color["CYAN"],
            "grey": self.meta.color["GREY"],
            "": ""
        }
        self.COLOR = color_text[self.paint]
        if self.repo in self.meta.repositories and self.repo != "sbo":
            self.lib = self.meta.lib_path + "{0}_repo/PACKAGES.TXT".format(
                self.repo)

    def view(self):
        """Print package description by repository
        """
        print("")   # new line at start
        description, count = "", 0
        if self.repo == "sbo":
            description = SBoGrep(self.name).description()
        else:
            PACKAGES_TXT = Utils().read_file(self.lib)
            for line in PACKAGES_TXT.splitlines():
                if line.startswith(self.name + ":"):
                    description += line[len(self.name) + 2:] + "\n"
                    count += 1
                    if count == 11:
                        break
        if description:
            print("{0}{1}{2}".format(self.COLOR, description,
                                     self.meta.color["ENDC"]))
        else:
            self.msg.pkg_not_found("", self.name, "No matching", "\n")
            raise SystemExit(1)
        if description and self.repo == "sbo":
            print("")
开发者ID:dslackw,项目名称:slpkg,代码行数:49,代码来源:desc.py

示例2: SBoNetwork

# 需要导入模块: from slpkg.messages import Msg [as 别名]
# 或者: from slpkg.messages.Msg import pkg_not_found [as 别名]
class SBoNetwork(object):
    """View SBo site in terminal and also read, build or
    install packages
    """
    def __init__(self, name, flag):
        self.name = name
        self.flag = flag
        self.meta = _meta_
        self.msg = Msg()
        self.arch = SBoArch().get()
        self.comp_tar = ".tar.gz"
        self.choice = ""
        self.FAULT = ""
        self.green = self.meta.color["GREEN"]
        self.red = self.meta.color["RED"]
        self.yellow = self.meta.color["YELLOW"]
        self.cyan = self.meta.color["CYAN"]
        self.grey = self.meta.color["GREY"]
        self.endc = self.meta.color["ENDC"]
        self.build_folder = self.meta.build_path
        self._SOURCES = self.meta._SBo_SOURCES
        self.msg.reading()
        self.data = SBoGrep(name="").names()
        self.case_insensitive()
        if "--checklist" in self.flag:
            self.with_checklist()
        grep = SBoGrep(self.name)
        self.sbo_files = grep.files()
        self.blacklist = BlackList().packages(pkgs=self.data, repo="sbo")
        self.sbo_url = sbo_search_pkg(self.name)
        if self.sbo_url:
            self.sbo_desc = grep.description()[len(self.name) + 2:-1]
            self.source_dwn = grep.source().split()
            self.sbo_req = grep.requires()
            self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
            self.sbo_version = grep.version()
            self.dwn_srcs = self.sbo_dwn.split() + self.source_dwn
        if "--checklist" not in self.flag or not self.sbo_url and self.name:
            self.msg.done()

    def view(self):
        """View SlackBuild package, read or install them
        from slackbuilds.org
        """
        if self.sbo_url and self.name not in self.blacklist:
            self.prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
            self.view_sbo()
            while True:
                self.read_choice()
                choice = {
                    "r": self.choice_README,
                    "R": self.choice_README,
                    "s": self.choice_SlackBuild,
                    "S": self.choice_SlackBuild,
                    "f": self.choice_info,
                    "F": self.choice_info,
                    "o": self.choice_doinst,
                    "O": self.choice_doinst,
                    "d": self.choice_download,
                    "D": self.choice_download,
                    "download": self.choice_download,
                    "b": self.choice_build,
                    "B": self.choice_build,
                    "build": self.choice_build,
                    "i": self.choice_install,
                    "I": self.choice_install,
                    "install": self.choice_install,
                    "c": self.choice_clear_screen,
                    "C": self.choice_clear_screen,
                    "clear": self.choice_clear_screen,
                    "q": self.choice_quit,
                    "quit": self.choice_quit,
                    "Q": self.choice_quit
                }
                try:
                    choice[self.choice]()
                except KeyError:
                    pass
        else:
            self.msg.pkg_not_found("\n", self.name, "Can't view", "\n")

    def case_insensitive(self):
        """Matching packages distinguish between uppercase and
        lowercase
        """
        if "--case-ins" in self.flag:
            data_dict = Utils().case_sensitive(self.data)
            for key, value in data_dict.iteritems():
                if key == self.name.lower():
                    self.name = value

    def read_choice(self):
        """Return choice
        """
        commands = {
            "r": "README",
            "R": "README",
            "s": "{0}.SlackBuild".format(self.name),
            "S": "{0}.SlackBuild".format(self.name),
            "f": "{0}.info".format(self.name),
#.........这里部分代码省略.........
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:103,代码来源:network.py

示例3: ArgParse

# 需要导入模块: from slpkg.messages import Msg [as 别名]
# 或者: from slpkg.messages.Msg import pkg_not_found [as 别名]

#.........这里部分代码省略.........
            "yellow",
            "cyan",
            "grey"
        ]
        if (len(self.args) == 3 and self.args[0] in options and
                self.args[1] in self.meta.repositories):
            PkgDesc(self.args[2], self.args[1], paint="").view()
        elif (len(self.args) == 4 and self.args[0] in options and
                self.args[3].startswith(flag[0])):
            tag = self.args[3][len(flag[0]):]
            if self.args[1] in self.meta.repositories and tag in colors:
                PkgDesc(self.args[2], self.args[1], tag).view()
            else:
                usage(self.args[1])
        elif (len(self.args) > 1 and self.args[0] in options and
                self.args[1] not in self.meta.repositories):
            usage(self.args[1])
        else:
            usage("")

    def pkg_find(self):
        """Find packages from all enabled repositories
        """
        flag = []
        options = [
            "-F",
            "--FIND"
        ]
        additional_options = ["--case-ins"]
        for arg in self.args:
            if arg in additional_options:
                flag.append(arg)
                self.args.remove(arg)
        packages = self.args[1:]
        if len(self.args) > 1 and self.args[0] in options:
            find_from_repos(packages, flag)
        else:
            usage("")

    def pkg_contents(self):
        """Print packages contents
        """
        packages = self.args[1:]
        options = [
            "-d",
            "--display"
        ]
        if len(self.args) > 1 and self.args[0] in options:
            PackageManager(packages).display()
        else:
            usage("")

    def congiguration(self):
        """Manage slpkg configuration file
        """
        options = [
            "-g",
            "--config"
        ]
        command = [
            "print",
            "edit",
            "reset"
        ]
        if (len(self.args) == 2 and self.args[0] in options and
                self.args[1] == command[1]):
            Config().edit()
        elif (len(self.args) == 2 and self.args[0] in options and
                self.args[1] == (command[0])):
            Config().view()
        elif (len(self.args) == 2 and self.args[0] in options and
                self.args[1] == (command[2])):
            Config().reset()
        else:
            usage("")

    def auto_detect(self, args):
        """Check for already Slackware binary packages exist
        """
        suffixes = [
            ".tgz",
            ".txz",
            ".tbz",
            ".tlz"
        ]
        if (not args[0].startswith("-") and args[0] not in self.commands and
                args[0].endswith(tuple(suffixes))):
            packages, not_found = [], []
            for pkg in args:
                if pkg.endswith(tuple(suffixes)):
                    if os.path.isfile(pkg):
                        packages.append(pkg)
                    else:
                        not_found.append(pkg)
            if packages:
                Auto(packages).select()
            if not_found:
                for ntf in not_found:
                    self.msg.pkg_not_found("", ntf, "Not installed", "")
            raise SystemExit()
开发者ID:websafe,项目名称:slpkg,代码行数:104,代码来源:main.py

示例4: PackageManager

# 需要导入模块: from slpkg.messages import Msg [as 别名]
# 或者: from slpkg.messages.Msg import pkg_not_found [as 别名]
class PackageManager(object):
    """Package manager class for install, upgrade,
    reinstall, remove, find and display packages"""
    def __init__(self, binary):
        self.binary = binary
        self.meta = _meta_
        self.msg = Msg()
        self.skip = []
        self.size = 0
        self.unit = "Kb"

    def install(self, flag):
        """Install Slackware binary packages
        """
        for pkg in self.binary:
            try:
                subprocess.call("installpkg {0} {1}".format(flag, pkg),
                                shell=True)
                check = pkg[:-4].split("/")[-1]
                if os.path.isfile(self.meta.pkg_path + check):
                    print("Completed!\n")
                else:
                    raise SystemExit()
            except subprocess.CalledProcessError:
                self._not_found("Can't install", self.binary, pkg)

    def upgrade(self, flag):
        """Upgrade Slackware binary packages with new
        """
        for pkg in self.binary:
            try:
                subprocess.call("upgradepkg {0} {1}".format(flag, pkg),
                                shell=True)
                check = pkg[:-4].split("/")[-1]
                if os.path.isfile(self.meta.pkg_path + check):
                    print("Completed!\n")
                else:
                    raise SystemExit()
            except subprocess.CalledProcessError:
                self._not_found("Can't upgrade", self.binary, pkg)

    def _not_found(self, message, binary, pkg):
        if len(binary) > 1:
            bol = eol = ""
        else:
            bol = eol = "\n"
        self.msg.pkg_not_found(bol, pkg, message, eol)

    def remove(self, flag, extra):
        """Remove Slackware binary packages
        """
        self.flag = flag
        self.extra = extra
        self.dep_path = self.meta.log_path + "dep/"
        dependencies, rmv_list = [], []
        self.removed = self._view_removed()
        if not self.removed:
            print("")   # new line at end
        else:
            msg = "package"
            if len(self.removed) > 1:
                msg = msg + "s"
            try:
                if self.meta.default_answer in ["y", "Y"]:
                    remove_pkg = self.meta.default_answer
                else:
                    remove_pkg = raw_input(
                        "\nAre you sure to remove {0} {1} [y/N]? ".format(
                            str(len(self.removed)), msg))
            except EOFError:
                print("")   # new line at exit
                raise SystemExit()
            if remove_pkg in ["y", "Y"]:
                self._check_if_used(self.binary)
                for rmv in self.removed:
                    # If package build and install with "slpkg -s sbo <package>"
                    # then look log file for dependencies in /var/log/slpkg/dep,
                    # read and remove all else remove only the package.
                    if (os.path.isfile(self.dep_path + rmv) and
                            self.meta.del_deps in ["on", "ON"] or
                            "--deps" in self.extra):
                        dependencies = self._view_deps(self.dep_path, rmv)
                        if dependencies and self._rmv_deps_answer() in ["y",
                                                                        "Y"]:
                            rmv_list += self._rmv_deps(dependencies, rmv)
                        else:
                            rmv_list += self._rmv_pkg(rmv)
                    else:
                        rmv_list += self._rmv_pkg(rmv)
                # Prints all removed packages
                self._reference_rmvs(rmv_list)

    def _rmv_deps_answer(self):
        """Remove dependencies answer
        """
        if self.meta.remove_deps_answer in ["y", "Y"]:
            remove_dep = self.meta.remove_deps_answer
        else:
            try:
                remove_dep = raw_input(
#.........这里部分代码省略.........
开发者ID:websafe,项目名称:slpkg,代码行数:103,代码来源:manager.py

示例5: BuildPackage

# 需要导入模块: from slpkg.messages import Msg [as 别名]
# 或者: from slpkg.messages.Msg import pkg_not_found [as 别名]
class BuildPackage(object):
    """Build SBo packages from source
    """
    def __init__(self, script, sources, path, auto):
        self.script = script
        self.sources = sources
        self.path = path
        self.auto = auto
        self.meta = _meta_
        self.msg = Msg()
        self._SOURCES = self.meta._SBo_SOURCES
        self.prgnam = self.script[:-7]
        self.log_file = "build_{0}_log".format(self.prgnam)
        self.sbo_logs = self.meta.log_path + "sbo/"
        self.build_logs = self.sbo_logs + "build_logs/"
        self.start_log_time = time.strftime("%H:%M:%S")
        self.start_time = time.time()
        if not os.path.exists(self.meta.log_path):
            os.mkdir(self.meta.log_path)
        if not os.path.exists(self.sbo_logs):
            os.mkdir(self.sbo_logs)
        if not os.path.exists(self.build_logs):
            os.mkdir(self.build_logs)

    def build(self):
        """
        Build package from source and create log
        file in path /var/log/slpkg/sbo/build_logs/.
        Also check md5sum calculates.
        """
        try:
            self._delete_dir()
            tar = tarfile.open(self.script)
            tar.extractall()
            tar.close()
            self._makeflags()
            self._delete_sbo_tar_gz()
            self._create_md5_dict()
            if not self.auto:
                os.chdir(self._SOURCES)
            for src in self.sources:
                # fix build sources with spaces
                src = src.replace("%20", " ")
                check_md5(self.sbo_md5[src], src)
                shutil.copy2(src, self.path + self.prgnam)
            os.chdir(self.path + self.prgnam)
            # change permissions
            subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
                            shell=True)
            pass_var = self._pass_variable()
            if self.meta.sbo_build_log in ["on", "ON"]:
                if os.path.isfile(self.build_logs + self.log_file):
                    os.remove(self.build_logs + self.log_file)
                # start log write
                log_head(self.build_logs, self.log_file, self.start_log_time)
                subprocess.Popen("{0} ./{1}.SlackBuild 2>&1 | tee -a "
                                 "{2}{3}".format(" ".join(pass_var),
                                                 self.prgnam, self.build_logs,
                                                 self.log_file), shell=True,
                                 stdout=sys.stdout).communicate()
                sum_time = build_time(self.start_time)
                # write end in log file
                log_end(self.build_logs, self.log_file, sum_time)
                print("Total build time for package {0} : {1}\n".format(
                    self.prgnam, sum_time))
            else:
                subprocess.call("{0} ./{1}.SlackBuild".format(
                    " ".join(pass_var), self.prgnam), shell=True)
            os.chdir(self.path)
        except KeyboardInterrupt:   # (OSError, IOError):
            self.msg.pkg_not_found("\n", self.prgnam, "Wrong file", "\n")

    def _create_md5_dict(self):
        """Create md5 dictionary per source
        """
        self.sbo_md5 = {}
        md5_lists = SBoGrep(self.prgnam).checksum()
        for src, md5 in zip(self.sources, md5_lists):
            self.sbo_md5[src] = md5

    def _makeflags(self):
        """Set variable MAKEFLAGS with the numbers of
        processors
        """
        if self.meta.makeflags in ["on", "ON"]:
            cpus = multiprocessing.cpu_count()
            os.environ["MAKEFLAGS"] = "-j{0}".format(cpus)

    def _pass_variable(self):
        """Return enviroment variables
        """
        pass_var = []
        for var in os.environ.keys():
            expVAR = var.split("_")
            if expVAR[0] == self.prgnam.upper() and expVAR[1] != "PATH":
                pass_var.append("{0}={1}".format(expVAR[1], os.environ[var]))
        return pass_var

    def _delete_sbo_tar_gz(self):
        """Delete slackbuild tar.gz file after untar
#.........这里部分代码省略.........
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:103,代码来源:build.py


注:本文中的slpkg.messages.Msg.pkg_not_found方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。