• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python find.find_package函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中slpkg.pkg.find.find_package函数的典型用法代码示例。如果您正苦于以下问题:Python find_package函数的具体用法?Python find_package怎么用?Python find_package使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _get_removed

 def _get_removed(self):
     """Manage removed packages by extra options
     """
     removed, packages = [], []
     if "--tag" in self.extra:
         for pkg in find_package("", self.meta.pkg_path):
             for tag in self.binary:
                 if pkg.endswith(tag):
                     removed.append(split_package(pkg)[0])
                     packages.append(pkg)
         if not removed:
             self.msg.pkg_not_found("", "'tag'", "Can't remove", "\n")
             raise SystemExit(1)
     else:
         for pkg in self.binary:
             name = GetFromInstalled(pkg).name()
             ver = GetFromInstalled(pkg).version()
             package = find_package("{0}{1}{2}".format(
                 name, ver, self.meta.sp), self.meta.pkg_path)
             if pkg and name == pkg:
                 removed.append(pkg)
                 packages.append(package[0])
             else:
                 self.msg.pkg_not_found("", pkg, "Can't remove", "\n")
                 raise SystemExit(1)
     return removed, packages
开发者ID:dslackw,项目名称:slpkg,代码行数:26,代码来源:manager.py


示例2: views

 def views(self, install, comp_sum):
     """
     Views packages
     """
     pkg_sum = uni_sum = upg_sum = 0
     # fix repositories align
     repo = self.repo + (" " * (6 - (len(self.repo))))
     for pkg, comp in zip(install, comp_sum):
         pkg_split = split_package(pkg[:-4])
         if find_package(pkg[:-4], self.meta.pkg_path):
             pkg_sum += 1
             COLOR = self.meta.color["GREEN"]
         elif find_package(pkg_split[0] + self.meta.sp, self.meta.pkg_path):
             COLOR = self.meta.color["YELLOW"]
             upg_sum += 1
         else:
             COLOR = self.meta.color["RED"]
             uni_sum += 1
         ver = get_installed_version(pkg_split[0])
         print("  {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
             COLOR, pkg_split[0] + ver, self.meta.color["ENDC"],
             " " * (23-len(pkg_split[0] + ver)), pkg_split[1],
             " " * (18-len(pkg_split[1])), pkg_split[2],
             " " * (8-len(pkg_split[2])), pkg_split[3],
             " " * (7-len(pkg_split[3])), repo,
             comp, " K")).rstrip()
     return [pkg_sum, upg_sum, uni_sum]
开发者ID:fatman2021,项目名称:slpkg,代码行数:27,代码来源:install.py


示例3: build_install

 def build_install(self):
     """Searches the package name and version in /tmp to
     install. If find two or more packages e.g. to build
     tag 2 or 3 will fit most.
     """
     slackbuilds = self.dependencies + self.master_packages
     installs, upgraded, = [], []
     if not os.path.exists(self.build_folder):
         os.makedirs(self.build_folder)
     os.chdir(self.build_folder)
     for sbo in slackbuilds:
         pkg = "-".join(sbo.split("-")[:-1])
         ver = sbo.split("-")[-1]
         prgnam = ("{0}-{1}".format(pkg, ver))
         sbo_file = "".join(find_package(prgnam, self.meta.pkg_path))
         src_link = SBoGrep(pkg).source().split()
         if sbo_file:
             Msg().template(78)
             Msg().pkg_found(pkg, split_package(sbo_file)[1])
             Msg().template(78)
         elif self.unst[0] in src_link or self.unst[1] in src_link:
             Msg().template(78)
             print("| Package {0} {1}{2}{3}".format(
                 sbo, self.meta.color["RED"], "".join(src_link),
                 self.meta.color["ENDC"]))
             Msg().template(78)
         else:
             sbo_url = sbo_search_pkg(pkg)
             sbo_link = SBoLink(sbo_url).tar_gz()
             script = sbo_link.split("/")[-1]
             dwn_srcs = sbo_link.split() + src_link
             Download(self.build_folder, dwn_srcs, repo="sbo").start()
             sources = self.filenames(src_link)
             BuildPackage(script, sources, self.build_folder).build()
             binary_list = self.search_in_tmp(prgnam)
             try:
                 binary = (self.meta.output + max(binary_list)).split()
             except ValueError:
                 Msg().build_FAILED(sbo_url, prgnam)
                 sys.exit(0)
             if find_package(pkg + "-", self.meta.pkg_path):
                 print("{0}[ Upgrading ] --> {1}{2}".format(
                     self.meta.color["YELLOW"],
                     self.meta.color["ENDC"], pkg))
                 upgraded.append(prgnam)
             else:
                 print("{0}[ Installing ] --> {1}{2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"], pkg))
                 installs.append(prgnam)
             PackageManager(binary).upgrade(flag="--install-new")
     return installs, upgraded
开发者ID:fatman2021,项目名称:slpkg,代码行数:51,代码来源:slackbuild.py


示例4: __init__

 def __init__(self, image):
     self.image = image
     self.meta = _meta_
     self.msg = Msg()
     self.grey = self.meta.color["GREY"]
     self.green = self.meta.color["GREEN"]
     self.endc = self.meta.color["ENDC"]
     self.dmap = {}
     self.count_pkg = 0
     self.count_dep = 0
     self.dep_path = self.meta.log_path + "dep/"
     self.logs = find_package("", self.dep_path)
     if not self.logs:
         self.no_logs()
     self.installed = find_package("", self.meta.pkg_path)
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:15,代码来源:status_deps.py


示例5: _check_if_used

 def _check_if_used(self, removes):
     """Check package if dependencies for another package
     before removed"""
     if self.extra == "--check-deps":
         print("")
         view = False
         package, dependency = [], []
         for pkg in find_package("", self.dep_path):
             deps = Utils().read_file(self.dep_path + pkg)
             for rmv in removes:
                 if rmv in deps.split():
                     view = True
                     package.append(pkg)
                     dependency.append(rmv)
         if view:
             Msg().template(78)
             print("| {0}{1}{2}".format(
                 self.meta.color["RED"], " " * 30 + "!!! WARNING !!!",
                 self.meta.color["ENDC"]))
             Msg().template(78)
             for p, d in zip(package, dependency):
                 print("| {0}{1}{2} is dependency of the package --> "
                       "{3}{4}{5}".format(self.meta.color["YELLOW"], d,
                                          self.meta.color["ENDC"],
                                          self.meta.color["GREEN"], p,
                                          self.meta.color["ENDC"]))
             Msg().template(78)
             self._skip_remove()
开发者ID:fatman2021,项目名称:slpkg,代码行数:28,代码来源:manager.py


示例6: find

 def find(self, flag):
     """Find installed Slackware packages
     """
     matching, pkg_cache, match_cache = 0, "", ""
     print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
         self.meta.color["CYAN"], ", ".join(self.binary),
         self.meta.color["ENDC"]))
     for pkg in self.binary:
         for match in find_package("", self.meta.pkg_path):
             if "--case-ins" in flag:
                 pkg_cache = pkg.lower()
                 match_cache = match.lower()
             else:
                 pkg_cache = pkg
                 match_cache = match
             if pkg_cache in match_cache:
                 matching += 1
                 print("[ {0}installed{1} ] - {2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"],
                     match))
                 self._sizes(match)
     if matching == 0:
         message = "Can't find"
         self.msg.pkg_not_found("", ", ".join(self.binary), message, "\n")
     else:
         self._calc_sizes()
         print("\nFound summary")
         print("=" * 79)
         print("{0}Total found {1} matching packages.{2}".format(
             self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
         print("{0}Size of installed packages {1} {2}.{3}\n".format(
             self.meta.color["GREY"], round(self.size, 2), self.unit,
             self.meta.color["ENDC"]))
开发者ID:websafe,项目名称:slpkg,代码行数:33,代码来源:manager.py


示例7: find

 def find(self):
     """Find installed Slackware packages
     """
     matching = size = 0
     print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
         self.meta.color["CYAN"], ", ".join(self.binary),
         self.meta.color["ENDC"]))
     for pkg in self.binary:
         for match in find_package("", self.meta.pkg_path):
             if pkg in match:
                 matching += 1
                 print("[ {0}installed{1} ] - {2}".format(
                     self.meta.color["GREEN"], self.meta.color["ENDC"],
                     match))
                 data = Utils().read_file(self.meta.pkg_path + match)
                 for line in data.splitlines():
                     if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
                         if "M" in line[26:]:
                             size += float(line[26:-1]) * 1024
                         else:
                             size += float(line[26:-1])
                         break
     if matching == 0:
         message = "Can't find"
         Msg().pkg_not_found("", ", ".join(self.binary), message, "\n")
     else:
         print("\n{0}Total found {1} matching packages.{2}".format(
             self.meta.color["GREY"], matching, self.meta.color["ENDC"]))
         unit = "Kb"
         if size > 1024:
             unit = "Mb"
             size = (size / 1024)
         print("{0}Size of installed packages {1} {2}.{3}\n".format(
             self.meta.color["GREY"], round(size, 2), unit,
             self.meta.color["ENDC"]))
开发者ID:fatman2021,项目名称:slpkg,代码行数:35,代码来源:manager.py


示例8: build_install

 def build_install(self):
     """Build and install packages if not already installed
     """
     slackbuilds = self.dependencies + self.master_packages
     installs, upgraded, = [], []
     if not os.path.exists(self.build_folder):
         os.makedirs(self.build_folder)
     if not os.path.exists(self._SOURCES):
         os.makedirs(self._SOURCES)
     os.chdir(self.build_folder)
     for prgnam in slackbuilds:
         if (self.meta.not_downgrade == "on" and
                 self.not_downgrade(prgnam) is True):
             continue
         pkg = "-".join(prgnam.split("-")[:-1])
         installed = "".join(find_package(prgnam, self.meta.pkg_path))
         src_link = SBoGrep(pkg).source().split()
         if (installed and "--download-only" not in self.flag and
                 "--rebuild" not in self.flag):
             self.msg.template(78)
             self.msg.pkg_found(prgnam)
             self.msg.template(78)
         elif self.unst[0] in src_link or self.unst[1] in src_link:
             self.msg.template(78)
             print("| Package {0} {1}{2}{3}".format(
                 prgnam, self.meta.color["RED"], "".join(src_link),
                 self.meta.color["ENDC"]))
             self.msg.template(78)
         else:
             sbo_url = sbo_search_pkg(pkg)
             sbo_link = SBoLink(sbo_url).tar_gz()
             script = sbo_link.split("/")[-1]
             if self.meta.sbosrcarch in ["on", "ON"]:
                 src_link = self.sbosrcarsh(prgnam, sbo_link, src_link)
             Download(self.build_folder, sbo_link.split(),
                      repo="sbo").start()
             Download(self._SOURCES, src_link, repo="sbo").start()
             if "--download-only" in self.flag:
                 continue
             sources = self.filenames(src_link)
             BuildPackage(script, sources, self.build_folder,
                          auto=False).build()
             binary = slack_package(prgnam)
             if os.path.isfile("".join(binary)):
                 if GetFromInstalled(pkg).name() == pkg:
                     print("[ {0}Upgrading{1} ] --> {2}".format(
                         self.meta.color["YELLOW"],
                         self.meta.color["ENDC"], prgnam))
                     upgraded.append(prgnam)
                 else:
                     print("[ {0}Installing{1} ] --> {2}".format(
                         self.meta.color["GREEN"],
                         self.meta.color["ENDC"], prgnam))
                     installs.append(prgnam)
                 if ("--rebuild" in self.flag and
                         GetFromInstalled(pkg).name() == pkg):
                     PackageManager(binary).upgrade(flag="--reinstall")
                 else:
                     PackageManager(binary).upgrade(flag="--install-new")
     return installs, upgraded
开发者ID:dslackw,项目名称:slpkg,代码行数:60,代码来源:slackbuild.py


示例9: choose_upg

def choose_upg(packages):
    """Create checklist to choose packages for upgrade
    """
    selected_packages, data = [], []
    if packages:
        for pkg in packages:
            name = GetFromInstalled(pkg).name()
            ver = GetFromInstalled(pkg).version()
            binary = "{0}{1}".format(name, ver)
            installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
            data.append(installed)
        text = "Press 'spacebar' to unchoose packages from upgrade"
        title = " Upgrade "
        backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
        status = True
        pkgs = DialogUtil(data, text, title, backtitle,
                          status).checklist()
        pkgs = [] if pkgs is None else pkgs
        for pkg in pkgs:
            name = split_package(pkg)[0]
            if name in packages:
                selected_packages.append(name)
        if not selected_packages:
            raise SystemExit()
        print("")
    return selected_packages
开发者ID:dslackw,项目名称:slpkg,代码行数:26,代码来源:upgrade_checklist.py


示例10: tag

 def tag(self, sbo, count_ins, count_upg, count_uni):
     """Tag with color green if package already installed,
     color yellow for packages to upgrade and color red
     if not installed.
     """
     if find_package(sbo, self.meta.pkg_path):
         paint = self.meta.color["GREEN"]
         count_ins += 1
     elif find_package("-".join(sbo.split("-")[:-1]) + "-",
                       self.meta.pkg_path):
         paint = self.meta.color["YELLOW"]
         count_upg += 1
     else:
         paint = self.meta.color["RED"]
         count_uni += 1
     return paint, count_ins, count_upg, count_uni
开发者ID:fatman2021,项目名称:slpkg,代码行数:16,代码来源:slackbuild.py


示例11: store

def store(dependencies_list):
    '''
    In the end lest a check of the packages that are on the list
    are already installed.
    '''
    (upgrade_name,
     package_for_upgrade,
     upgrade_version,
     upgrade_arch
     ) = ([] for i in range(4))
    for pkg in dependencies_list:
        ver = SBoGrep(pkg).version()
        prgnam = ("{0}-{1}".format(pkg, ver))
        # if package not installed
        # take version from repository
        pkg_version = ver
        arch = os.uname()[4]
        if arch.startswith("i") and arch.endswith("86"):
            arch = "i486"
        if find_package(prgnam, pkg_path) == []:
            for sbo in os.listdir(pkg_path):
                if (sbo.startswith(pkg + sp) and
                        sbo.endswith("_SBo")):
                    # search if packages installed
                    # if yes grab package name and version
                    pkg_version = split_package(sbo)[1]
            upgrade_name.append(pkg)
            package_for_upgrade.append("{0}-{1}".format(pkg, pkg_version))
            upgrade_version.append(ver)
            upgrade_arch.append(arch)
    return [upgrade_name, package_for_upgrade, upgrade_version, upgrade_arch]
开发者ID:unixbhaskar,项目名称:slpkg,代码行数:31,代码来源:check.py


示例12: install_packages

 def install_packages(self):
     """
     Install or upgrade packages
     """
     installs, upgraded = [], []
     for inst in (self.dep_install + self.install):
         package = (self.tmp_path + inst).split()
         pkg_ver = "{0}-{1}".format(split_package(inst)[0],
                                    split_package(inst)[1])
         self.checksums(inst)
         if os.path.isfile(self.meta.pkg_path + inst[:-4]):
             print("[ {0}reinstalling{1} ] --> {2}".format(
                 self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
             installs.append(pkg_ver)
             PackageManager(package).upgrade("--reinstall")
         elif find_package(split_package(inst)[0] + self.meta.sp,
                           self.meta.pkg_path):
             print("[ {0}upgrading{1} ] --> {2}".format(
                 self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
             upgraded.append(pkg_ver)
             PackageManager(package).upgrade("--install-new")
         else:
             print("[ {0}installing{1} ] --> {2}".format(
                 self.meta.color["GREEN"], self.meta.color["ENDC"], inst))
             installs.append(pkg_ver)
             PackageManager(package).upgrade("--install-new")
     return [installs, upgraded]
开发者ID:fatman2021,项目名称:slpkg,代码行数:27,代码来源:install.py


示例13: _rmv_pkg

 def _rmv_pkg(self, package):
     """Remove one signle package
     """
     if (find_package(package + self.meta.sp, self.meta.pkg_path) and
             package not in self.skip):
         self._removepkg(package)
     return package.split()
开发者ID:fatman2021,项目名称:slpkg,代码行数:7,代码来源:manager.py


示例14: search_in_tmp

 def search_in_tmp(self, prgnam):
     """Search for binary packages in /tmp directory
     """
     binary = []
     for search in find_package(prgnam, self.meta.output):
         if "_SBo" in search:
             binary.append(search)
     return binary
开发者ID:fatman2021,项目名称:slpkg,代码行数:8,代码来源:slackbuild.py


示例15: list_of_installed

 def list_of_installed(self, pkg):
     """Return installed packages
     """
     find = pkg + self.meta.sp
     if pkg.endswith(".txz") or pkg.endswith(".tgz"):
         find = pkg[:-4]
     if find_package(find, self.meta.pkg_path):
         return pkg
开发者ID:fatman2021,项目名称:slpkg,代码行数:8,代码来源:manager.py


示例16: deps_used

 def deps_used(self, pkg, used):
     """Create dependencies dictionary
     """
     if find_package(pkg + self.meta.sp, self.meta.pkg_path):
         if pkg not in self.deps_dict.values():
             self.deps_dict[pkg] = used
         else:
             self.deps_dict[pkg] += used
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:8,代码来源:tracking.py


示例17: run

 def run(self):
     """Run tracking dependencies
     """
     self.msg.resolving()
     self.repositories()
     if self.find_pkg:
         self.dependencies_list.reverse()
         self.requires = Utils().dimensional_list(self.dependencies_list)
         self.dependencies = Utils().remove_dbs(self.requires)
         if self.dependencies == []:
             self.dependencies = ["No dependencies"]
         if "--graph=" in self.flag:
             self.deps_tree()
         self.msg.done()
         pkg_len = len(self.name) + 24
         print("")    # new line at start
         self.msg.template(pkg_len)
         print("| Package {0}{1}{2} dependencies :".format(
             self.cyan, self.name, self.endc))
         self.msg.template(pkg_len)
         print("\\")
         print(" +---{0}[ Tree of dependencies ]{1}".format(self.yellow,
                                                            self.endc))
         index = 0
         for pkg in self.dependencies:
             if "--check-deps" in self.flag:
                 used = self.check_used(pkg)
                 self.deps_used(pkg, used)
                 used = "{0} {1}{2}{3}".format(
                     "is dependency -->", self.cyan,
                     ", ".join(used), self.endc)
             else:
                 used = ""
             index += 1
             installed = ""
             if find_package(pkg + self.meta.sp, self.meta.pkg_path):
                 if self.meta.use_colors in ["off", "OFF"]:
                     installed = "* "
                 print(" |")
                 print(" {0}{1}: {2}{3}{4} {5}{6}".format(
                     "+--", index, self.green, pkg,
                     self.endc, installed, used))
             else:
                 print(" |")
                 print(" {0}{1}: {2}{3}{4} {5}".format(
                     "+--", index, self.red, pkg,
                     self.endc, installed))
         if self.meta.use_colors in ["off", "OFF"]:
             print("\n * = Installed\n")
         else:
             print("")    # new line at end
         if "--graph=" in self.flag:
             self.graph()
     else:
         self.msg.done()
         print("\nNo package was found to match\n")
         raise SystemExit(1)
开发者ID:dslackw,项目名称:slpkg,代码行数:57,代码来源:tracking.py


示例18: search_in_tmp

def search_in_tmp(prgnam):
    '''
    Search for binarys packages in /tmp directory
    '''
    binary = []
    for search in find_package(prgnam, tmp):
        if "_SBo" in search:
            binary.append(search)
    return binary
开发者ID:unixbhaskar,项目名称:slpkg,代码行数:9,代码来源:slackbuild.py


示例19: __init__

 def __init__(self, package):
     self.package = package
     self.meta = _meta_
     self.files = find_package(self.package + self.meta.sp,
                               self.meta.pkg_path)
     self.find = ""
     for f in self.files:
         if split_package(f)[0] == self.package:
             self.find = f
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:9,代码来源:installed.py


示例20: list_color_tag

 def list_color_tag(self, pkg):
     """Tag with color installed packages
     """
     find = pkg + self.meta.sp
     if pkg.endswith(".txz") or pkg.endswith(".tgz"):
         find = pkg[:-4]
     if find_package(find, self.meta.pkg_path):
         pkg = "{0}{1}{2}".format(self.meta.color["GREEN"], pkg,
                                  self.meta.color["ENDC"])
     return pkg
开发者ID:fatman2021,项目名称:slpkg,代码行数:10,代码来源:manager.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python slack_version.slack_ver函数代码示例发布时间:2022-05-27
下一篇:
Python messages.Msg类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap