本文整理汇总了Python中slpkg.utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: view
def view(self):
"""View slpkg config file
"""
print("") # new line at start
conf_args = [
"RELEASE",
"BUILD_PATH",
"PACKAGES",
"PATCHES",
"CHECKMD5",
"DEL_ALL",
"DEL_BUILD",
"SBO_BUILD_LOG",
"MAKEFLAGS",
"DEFAULT_ANSWER",
"REMOVE_DEPS_ANSWER",
"SKIP_UNST",
"RSL_DEPS",
"DEL_DEPS",
"USE_COLORS",
"DOWNDER",
"DOWNDER_OPTIONS",
"SLACKPKG_LOG",
"ONLY_INSTALLED",
"PRG_BAR",
"EDITOR"
]
read_conf = Utils().read_file(self.config_file)
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print("{0}".format(line))
else:
print("{0}{1}{2}".format(self.meta.color["CYAN"], line,
self.meta.color["ENDC"]))
print("") # new line at end
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:35,代码来源:config.py
示例2: 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
示例3: _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
示例4: get_deps
def get_deps(self):
"""Grap package requirements from repositories
"""
if self.repo == "rlw":
# Robby"s repository dependencies as shown in the central page
# http://rlworkman.net/pkgs/
dependencies = {
"abiword": "wv",
"claws-mail": "libetpan",
"inkscape": "gtkmm atkmm pangomm cairomm mm-common libsigc++ "
"libwpg lxml gsl numpy BeautifulSoup",
"texlive": "libsigsegv texi2html",
"xfburn": "libburn libisofs"
}
if self.name in dependencies.keys():
return dependencies[self.name].split()
else:
return ""
else:
PACKAGES_TXT = Utils().read_file("{0}{1}_repo/PACKAGES.TXT".format(
_meta_.lib_path, self.repo))
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"):
pkg_name = split_package(line[14:].strip())[0]
if line.startswith("PACKAGE REQUIRED:"):
if pkg_name == self.name:
if line[18:].strip():
return self._req_fix(line)
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:28,代码来源:greps.py
示例5: __init__
def __init__(self):
self.meta = _meta_
self.DEFAULT_REPOS_NAMES = self.meta.default_repositories
self.custom_repo_file = "/etc/slpkg/custom-repositories"
self.default_repo_file = "/etc/slpkg/default-repositories"
self.custom_repositories_list = Utils().read_file(self.custom_repo_file)
self.default_repositories_list = Utils().read_file(
self.default_repo_file)
self.default_repository()
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:9,代码来源:repositories.py
示例6: case_insensitive
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
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:9,代码来源:network.py
示例7: sbo_case_insensitive
def sbo_case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase for sbo repository
"""
if "--case-ins" in self.flag:
data = SBoGrep(name="").names()
data_dict = Utils().case_sensitive(data)
for key, value in data_dict.iteritems():
if key == self.name.lower():
self.name = value
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:10,代码来源:tracking.py
示例8: case_insensitive
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 name in self.slackbuilds:
for key, value in data_dict.iteritems():
if key == name.lower():
index = self.slackbuilds.index(name)
self.slackbuilds[index] = value
开发者ID:websafe,项目名称:slpkg,代码行数:11,代码来源:slackbuild.py
示例9: _sizes
def _sizes(self, package):
"""Package size summary
"""
data = Utils().read_file(self.meta.pkg_path + package)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
if "M" in line[26:]:
self.size += float(line[26:-1]) * 1024
else:
self.size += float(line[26:-1])
break
开发者ID:websafe,项目名称:slpkg,代码行数:11,代码来源:manager.py
示例10: check_used
def check_used(self, pkg):
"""Check if dependencies used
"""
used = []
dep_path = self.meta.log_path + "dep/"
logs = find_package("", dep_path)
for log in logs:
deps = Utils().read_file(dep_path + log)
for dep in deps.splitlines():
if pkg == dep:
used.append(log)
return used
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:12,代码来源:tracking.py
示例11: view
def view(self, repo):
"""
View repository information
"""
status = "{0}disabled{1}".format(self.meta.color["RED"],
self.meta.color["ENDC"])
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in self.meta.default_repositories:
self.form["Default:"] = "yes"
if (repo in self.meta.repositories and
os.path.isfile(self.meta.lib_path + "{0}_repo/PACKAGES."
"TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
if repo != "sbo":
data = self.repository_data(repo)
size = units(data[1], data[2])
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = "{0} {1}".format(
str(size[1][0]), str(size[0][0]))
self.form["Total uncompressed packages:"] = "{0} {1}".format(
str(size[1][1]), str(size[0][1]))
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(self.meta.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))):
status = "{0}enabled{1}".format(self.meta.color["GREEN"],
self.meta.color["ENDC"])
sum_sbo_pkgs = 0
for line in (Utils().read_file(
self.meta.lib_path + "sbo_repo/SLACKBUILDS."
"TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(
self.meta.log_path + "sbo/ChangeLog.txt")
last_upd = changelog_txt.split("\n", 1)[0]
self.form["Repo id:"] = repo
self.form["Repo url:"] = self.all_repos[repo]
self.form["Total compressed packages:"] = ""
self.form["Total uncompressed packages:"] = ""
self.form["Number of packages:"] = sum_sbo_pkgs
self.form["Status:"] = status
self.form["Last updated:"] = last_upd
print("")
for key, value in sorted(self.form.iteritems()):
print self.meta.color["GREY"] + key + self.meta.color["ENDC"], value
print("")
raise SystemExit()
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:52,代码来源:repoinfo.py
示例12: _view_deps
def _view_deps(self, path, package):
"""View dependencies for before remove
"""
dependencies = Utils().read_file(path + package)
print("") # new line at start
Msg().template(78)
print("| Found dependencies for package {0}:".format(package))
Msg().template(78)
for dep in dependencies.splitlines():
print("| {0}{1}{2}".format(self.meta.color["RED"], dep,
self.meta.color["ENDC"]))
Msg().template(78)
return dependencies
开发者ID:fatman2021,项目名称:slpkg,代码行数:13,代码来源:manager.py
示例13: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data = []
data = Utils().package_name(self.PACKAGES_TXT)
data_dict = Utils().case_sensitive(data)
for pkg in self.packages:
index = self.packages.index(pkg)
for key, value in data_dict.iteritems():
if key == pkg.lower():
self.packages[index] = value
开发者ID:BrentonEarl,项目名称:slpkg,代码行数:13,代码来源:install.py
示例14: _sizes
def _sizes(self, package):
"""Package size summary
"""
data = Utils().read_file(self.meta.pkg_path + package)
for line in data.splitlines():
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
digit = float((''.join(re.findall(
"[-+]?\d+[\.]?\d*[eE]?[-+]?\d*", line[26:]))))
self.file_size = line[26:].strip()
if "M" in line[26:]:
self.size += digit * 1024
else:
self.size += digit
break
开发者ID:dslackw,项目名称:slpkg,代码行数:14,代码来源:manager.py
示例15: case_insensitive
def case_insensitive(self):
"""Matching packages distinguish between uppercase and
lowercase
"""
if "--case-ins" in self.flag:
data = []
for name in self.data[0]:
data.append(split_package(name)[0])
data_dict = Utils().case_sensitive(data)
for pkg in self.packages:
for key, value in data_dict.iteritems():
if key == pkg.lower():
index = self.packages.index(pkg)
self.packages[index] = value
开发者ID:websafe,项目名称:slpkg,代码行数:14,代码来源:install.py
示例16: search_pkg
def search_pkg(name, repo):
"""Search if package exists in PACKAGES.TXT file
and return the name.
"""
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
names = Utils().package_name(PACKAGES_TXT)
blacklist = BlackList().packages(pkgs=names, repo=repo)
for line in PACKAGES_TXT.splitlines():
status(0)
if line.startswith("PACKAGE NAME: ") and len(line) > 16:
pkg_name = split_package(line[15:])[0].strip()
if name == pkg_name and name not in blacklist:
return pkg_name
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:14,代码来源:search.py
示例17: sbo_search_pkg
def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLACKBUILDS_TXT.splitlines():
if line.startswith("SLACKBUILD LOCATION"):
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()
if name == sbo_name:
return (sbo_url + line[23:].strip() + "/")
return ""
开发者ID:dslackw,项目名称:slpkg,代码行数:14,代码来源:search.py
示例18: pkg_security
def pkg_security(pkgs):
"""Check packages before install or upgrade for security
reasons. Configuration file in the /etc/slpkg/pkg_security"""
security_packages = Utils().read_file("/etc/slpkg/pkg_security")
packages = []
for read in security_packages.splitlines():
read = read.lstrip()
if not read.startswith("#"):
packages.append(read.replace("\n", ""))
for p in pkgs:
for pkg in packages:
if p == pkg:
Msg().security_pkg(p)
if not Msg().answer() in ["y", "Y"]:
raise SystemExit()
开发者ID:dslackw,项目名称:slpkg,代码行数:15,代码来源:security.py
示例19: slack
def slack(self):
"""Official slackware repository
"""
default = "http://mirrors.slackware.com/slackware/"
if self.meta.arch.startswith("arm"):
default = "http://ftp.arm.slackware.com/slackwarearm/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file(
self.meta.conf_path + "slackware-mirrors")
for line in mirrors.splitlines():
line = line.rstrip()
if not line.startswith("#") and line:
default = line.split()[-1]
if not default.endswith("/"):
default += "/"
return default
开发者ID:fabioalvaro,项目名称:slpkg,代码行数:16,代码来源:repositories.py
示例20: __init__
def __init__(self):
self.meta = _meta_
self.quit = False
self.blackfile = "/etc/slpkg/blacklist"
self.black_conf = ""
if os.path.isfile(self.blackfile):
self.black_conf = Utils().read_file(self.blackfile)
开发者ID:dslackw,项目名称:slpkg,代码行数:7,代码来源:blacklist.py
注:本文中的slpkg.utils.Utils类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论