Update metadata import

This commit is contained in:
Dimitris Zlatanidis 2015-06-07 16:38:52 +03:00
parent 47dc13f593
commit 5538e7b93d
11 changed files with 95 additions and 86 deletions

View file

@ -27,7 +27,7 @@ import sys
from messages import Msg
from sbo.greps import SBoGrep
from pkg.manager import PackageManager
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def find_from_repos(pkg):
@ -37,12 +37,12 @@ def find_from_repos(pkg):
cache = ""
count_pkg = count_repo = 0
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
_m.color["CYAN"], ", ".join(pkg), _m.color["ENDC"]))
_meta_.color["CYAN"], ", ".join(pkg), _meta_.color["ENDC"]))
Msg().template(78)
print("| {0} {1}{2}{3}".format("Repository", "Package", " " * 54, "Size"))
Msg().template(78)
try:
for repo in _m.repositories:
for repo in _meta_.repositories:
PACKAGES_TXT = PackageManager(pkg).list_lib(repo)
packages, sizes = PackageManager(pkg).list_greps(repo, PACKAGES_TXT)
for find, size in zip(packages, sizes):
@ -58,7 +58,7 @@ def find_from_repos(pkg):
find + ver, " " * (53 - len(find + ver)),
size))
print("\n{0}Total found {1} packages in {2} repositories.{3}\n".format(
_m.color["GREY"], count_pkg, count_repo, _m.color["ENDC"]))
_meta_.color["GREY"], count_pkg, count_repo, _meta_.color["ENDC"]))
except KeyboardInterrupt:
print("") # new line at exit
sys.exit(0)

View file

@ -27,7 +27,7 @@ from collections import OrderedDict
from utils import Utils
from downloader import Download
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
from sbo.greps import SBoGrep
from pkg.find import find_package
@ -49,10 +49,10 @@ class QueuePkgs(object):
"#\n"
]
self.quit = False
self.queue = _m.lib_path + "queue/"
self.queue = _meta_.lib_path + "queue/"
self.queue_list = self.queue + "queue_list"
if not os.path.exists(_m.lib_path):
os.mkdir(_m.lib_path)
if not os.path.exists(_meta_.lib_path):
os.mkdir(_meta_.lib_path)
if not os.path.exists(self.queue):
os.mkdir(self.queue)
if not os.path.isfile(self.queue_list):
@ -81,8 +81,8 @@ class QueuePkgs(object):
print("\nPackages in queue:\n")
for pkg in self.packages():
if pkg:
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
self.quit = True
if self.quit:
print("") # new line at exit
@ -98,13 +98,13 @@ class QueuePkgs(object):
for pkg in pkgs:
find = sbo_search_pkg(pkg)
if pkg not in queue_list and find is not None:
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["GREEN"], pkg,
_meta_.color["ENDC"]))
queue.write(pkg + "\n")
self.quit = True
else:
print("{0}{1}{2}".format(_m.color["RED"], pkg,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["RED"], pkg,
_meta_.color["ENDC"]))
self.quit = True
queue.close()
if self.quit:
@ -122,8 +122,8 @@ class QueuePkgs(object):
if line not in pkgs:
queue.write(line + "\n")
else:
print("{0}{1}{2}".format(_m.color["RED"], line,
_m.color["ENDC"]))
print("{0}{1}{2}".format(_meta_.color["RED"], line,
_meta_.color["ENDC"]))
self.quit = True
queue.close()
if self.quit:
@ -136,19 +136,19 @@ class QueuePkgs(object):
packages = self.packages()
if packages:
for pkg in packages:
if not os.path.exists(_m.build_path):
os.mkdir(_m.build_path)
if not os.path.exists(_meta_.build_path):
os.mkdir(_meta_.build_path)
sbo_url = sbo_search_pkg(pkg)
sbo_dwn = SBoLink(sbo_url).tar_gz()
source_dwn = SBoGrep(pkg).source().split()
sources = []
os.chdir(_m.build_path)
os.chdir(_meta_.build_path)
script = sbo_dwn.split("/")[-1]
Download(_m.build_path, sbo_dwn.split()).start()
Download(_meta_.build_path, sbo_dwn.split()).start()
for src in source_dwn:
Download(_m.build_path, src.split()).start()
Download(_meta_.build_path, src.split()).start()
sources.append(src.split("/")[-1])
BuildPackage(script, sources, _m.build_path).build()
BuildPackage(script, sources, _meta_.build_path).build()
else:
print("\nPackages not found in the queue for building\n")
@ -161,13 +161,13 @@ class QueuePkgs(object):
print("") # new line at start
for pkg in packages:
# check if package exist in /tmp
find = find_package(pkg, _m.tmp)
find = find_package(pkg, _meta_.tmp)
try:
find = max(find)
except ValueError:
print("Package '{0}' not found in /tmp\n".format(pkg))
if pkg in find:
binary = "{0}{1}".format(_m.tmp, find)
binary = "{0}{1}".format(_meta_.tmp, find)
PackageManager(binary.split()).install()
else:
print("\nPackages not found in the queue for installation\n")

View file

@ -24,13 +24,13 @@
import os
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def delete(path, packages):
"""
Remove downloaded packages
"""
if _m.del_all in ["on", "ON"]:
if _meta_.del_all in ["on", "ON"]:
for pkg in packages:
os.remove(path + pkg)

View file

@ -29,7 +29,7 @@ from sizes import units
from utils import Utils
from repositories import Repo
from repolist import RepoList
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class RepoInfo(object):
@ -53,15 +53,17 @@ class RepoInfo(object):
"""
View repository information
"""
status = "{0}disabled{1}".format(_m.color["RED"], _m.color["ENDC"])
status = "{0}disabled{1}".format(_meta_.color["RED"],
_meta_.color["ENDC"])
self.form["Status:"] = status
self.form["Default:"] = "no"
if repo in _m.default_repositories:
if repo in _meta_.default_repositories:
self.form["Default:"] = "yes"
if (repo in _m.repositories and
os.path.isfile(_m.lib_path + "{0}_repo/PACKAGES.TXT".format(
if (repo in _meta_.repositories and
os.path.isfile(_meta_.lib_path + "{0}_repo/PACKAGES.TXT".format(
repo))):
status = "{0}enabled{1}".format(_m.color["GREEN"], _m.color["ENDC"])
status = "{0}enabled{1}".format(_meta_.color["GREEN"],
_meta_.color["ENDC"])
if repo != "sbo":
data = self.repository_data(repo)
size = units(data[1], data[2])
@ -74,15 +76,17 @@ class RepoInfo(object):
self.form["Number of packages:"] = data[0]
self.form["Status:"] = status
self.form["Last updated:"] = data[3]
elif (repo == "sbo" and os.path.isfile(_m.lib_path + "{0}_repo/"
elif (repo == "sbo" and os.path.isfile(_meta_.lib_path + "{0}_repo/"
"SLACKBUILDS.TXT".format(repo))):
status = "{0}enabled{1}".format(_m.color["GREEN"], _m.color["ENDC"])
status = "{0}enabled{1}".format(_meta_.color["GREEN"],
_meta_.color["ENDC"])
sum_sbo_pkgs = 0
for line in (Utils().read_file(
_m.lib_path + "sbo_repo/SLACKBUILDS.TXT").splitlines()):
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT").splitlines()):
if line.startswith("SLACKBUILD NAME: "):
sum_sbo_pkgs += 1
changelog_txt = Utils().read_file(_m.log_path + "sbo/ChangeLog.txt")
changelog_txt = Utils().read_file(
_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]
@ -93,7 +97,7 @@ class RepoInfo(object):
self.form["Last updated:"] = last_upd
print("")
for key, value in sorted(self.form.iteritems()):
print _m.color["GREY"] + key + _m.color["ENDC"], value
print _meta_.color["GREY"] + key + _meta_.color["ENDC"], value
print("")
sys.exit(0)
@ -103,7 +107,7 @@ class RepoInfo(object):
"""
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
for line in (Utils().read_file(
_m.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
_meta_.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
if line.startswith("PACKAGES.TXT;"):
last_upd = line[14:].strip()
if line.startswith("PACKAGE NAME:"):
@ -113,7 +117,7 @@ class RepoInfo(object):
if line.startswith("PACKAGE SIZE (uncompressed): "):
unsize.append(line[30:-2].strip())
if repo in ["salix", "slackl"]:
log = Utils().read_file(_m.log_path + "{0}/ChangeLog.txt".format(
repo))
log = Utils().read_file(
_meta_.log_path + "{0}/ChangeLog.txt".format(repo))
last_upd = log.split("\n", 1)[0]
return [sum_pkgs, size, unsize, last_upd]

View file

@ -26,7 +26,7 @@ import sys
from messages import Msg
from repositories import Repo
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class RepoList(object):
@ -66,19 +66,19 @@ class RepoList(object):
"Status"))
Msg().template(78)
for repo_id, repo_URL in sorted(self.all_repos.iteritems()):
status, COLOR = "disabled", _m.color["RED"]
status, COLOR = "disabled", _meta_.color["RED"]
default = "yes"
if len(repo_URL) > 49:
repo_URL = repo_URL[:48] + "~"
if repo_id in _m.repositories:
status, COLOR = "enabled", _m.color["GREEN"]
if repo_id not in _m.default_repositories:
if repo_id in _meta_.repositories:
status, COLOR = "enabled", _meta_.color["GREEN"]
if repo_id not in _meta_.default_repositories:
default = "no"
print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format(
repo_id, " " * (9 - len(repo_id)),
repo_URL, " " * (52 - len(repo_URL)),
default, " " * (8 - len(default)),
COLOR, status, _m.color["ENDC"]))
COLOR, status, _meta_.color["ENDC"]))
print("\nFor enable or disable default repositories edit "
"'/etc/slpkg/slpkg.conf' file\n")
sys.exit(0)

View file

@ -26,7 +26,7 @@ import os
import sys
from utils import Utils
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class Repo(object):
@ -46,8 +46,8 @@ class Repo(object):
line = line.lstrip()
if line and not line.startswith("#"):
repo_name.append(line.split()[0])
if (repo in _m.repositories or repo in repo_name or
repo in _m.default_repositories):
if (repo in _meta_.repositories or repo in repo_name or
repo in _meta_.default_repositories):
print("\nRepository name '{0}' exist, select different name.\n"
"View all repositories with command 'repo-list'.\n".format(
repo))
@ -102,7 +102,7 @@ class Repo(object):
"""
default = "http://mirrors.slackware.com/slackware/"
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
mirrors = Utils().read_file(_m.conf_path + "slackware-mirrors")
mirrors = Utils().read_file(_meta_.conf_path + "slackware-mirrors")
for line in mirrors.splitlines():
line = line.rstrip()
if not line.startswith("#") and line:

View file

@ -32,7 +32,7 @@ from url_read import URL
from checksum import check_md5
from downloader import Download
from grep_md5 import pkg_checksum
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def it_self_update():
@ -44,43 +44,45 @@ def it_self_update():
repository = "github"
branch = "master"
ver_link = ("https://raw.{0}usercontent.com/{1}/{2}/"
"{3}/{4}/__metadata__.py".format(repository, _m.__author__,
_m.__all__, branch,
_m.__all__))
"{3}/{4}/__metadata__.py".format(repository, _meta_.__author__,
_meta_.__all__, branch,
_meta_.__all__))
version_data = URL(ver_link).reading()
for line in version_data.splitlines():
line = line.strip()
if line.startswith("__version_info__"):
__new_version__ = ".".join(re.findall(r"\d+", line))
if __new_version__ > _m.__version__:
if _m.default_answer == "y":
answer = _m.default_answer
if __new_version__ > _meta_.__version__:
if _meta_.default_answer == "y":
answer = _meta_.default_answer
else:
print("\nNew version '{0}-{1}' is available !\n".format(
_m.__all__, __new_version__))
_meta_.__all__, __new_version__))
answer = raw_input("Would you like to upgrade [Y/n]? ")
if answer in ["y", "Y"]:
print("") # new line after answer
else:
sys.exit(0)
dwn_link = ["https://{0}.com/{1}/{2}/archive/"
"v{3}.tar.gz".format(repository, _m.__author__, _m.__all__,
"v{3}.tar.gz".format(repository, _meta_.__author__,
_meta_.__all__,
__new_version__)]
if not os.path.exists(_m.build_path):
os.makedirs(_m.build_path)
Download(_m.build_path, dwn_link).start()
os.chdir(_m.build_path)
if not os.path.exists(_meta_.build_path):
os.makedirs(_meta_.build_path)
Download(_meta_.build_path, dwn_link).start()
os.chdir(_meta_.build_path)
slpkg_tar_file = "v" + __new_version__ + ".tar.gz"
tar = tarfile.open(slpkg_tar_file)
tar.extractall()
tar.close()
file_name = "{0}-{1}".format(_m.__all__, __new_version__)
file_name = "{0}-{1}".format(_meta_.__all__, __new_version__)
os.chdir(file_name)
check_md5(pkg_checksum(_m.__all__ + "-" + slpkg_tar_file[1:],
_m.__all__), _m.build_path + slpkg_tar_file)
check_md5(pkg_checksum(_meta_.__all__ + "-" + slpkg_tar_file[1:],
_meta_.__all__),
_meta_.build_path + slpkg_tar_file)
subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
subprocess.call("sh install.sh", shell=True)
else:
print("\n{0}: There is no new version, already used the last !"
"\n".format(_m.__all__))
"\n".format(_meta_.__all__))
sys.exit(0)

View file

@ -25,7 +25,7 @@
import sys
import time
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def status(index, width, step):
@ -33,7 +33,8 @@ def status(index, width, step):
Print toolbar status
"""
if index == width:
sys.stdout.write("{0}.{1}".format(_m.color["GREY"], _m.color["ENDC"]))
sys.stdout.write("{0}.{1}".format(_meta_.color["GREY"],
_meta_.color["ENDC"]))
sys.stdout.flush()
width += step
time.sleep(0.02)

View file

@ -24,7 +24,7 @@
from utils import Utils
from messages import Msg
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
from pkg.find import find_package
@ -47,7 +47,7 @@ def track_dep(name, repo):
dependencies_list = Requires(resolve=True).sbo(name)
find_pkg = sbo_search_pkg(name)
else:
PACKAGES_TXT = Utils().read_file(_m.lib_path + "{0}_repo/"
PACKAGES_TXT = Utils().read_file(_meta_.lib_path + "{0}_repo/"
"PACKAGES.TXT".format(repo))
dependencies_list = Dependencies(PACKAGES_TXT, repo).binary(
name, resolve=True)
@ -63,25 +63,26 @@ def track_dep(name, repo):
pkg_len = len(name) + 24
print("") # new line at start
Msg().template(pkg_len)
print("| Package {0}{1}{2} dependencies :".format(_m.color["CYAN"],
print("| Package {0}{1}{2} dependencies :".format(_meta_.color["CYAN"],
name,
_m.color["ENDC"]))
_meta_.color["ENDC"]))
Msg().template(pkg_len)
print("\\")
print(" +---{0}[ Tree of dependencies ]{1}".format(_m.color["YELLOW"],
_m.color["ENDC"]))
print(" +---{0}[ Tree of dependencies ]{1}".format(
_meta_.color["YELLOW"], _meta_.color["ENDC"]))
index = 0
for pkg in dependencies:
index += 1
if find_package(pkg + _m.sp, _m.pkg_path):
if find_package(pkg + _meta_.sp, _meta_.pkg_path):
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index,
_m.color["GREEN"],
pkg, _m.color["ENDC"]))
_meta_.color["GREEN"],
pkg, _meta_.color["ENDC"]))
else:
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, _m.color["RED"],
pkg, _m.color["ENDC"]))
print(" {0}{1}: {2}{3}{4}".format("+--", index,
_meta_.color["RED"], pkg,
_meta_.color["ENDC"]))
print("") # new line at end
else:
print("\nNo package was found to match\n")

View file

@ -25,7 +25,7 @@
import sys
import urllib2
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
class URL(object):
@ -42,7 +42,8 @@ class URL(object):
return f.read()
except (urllib2.URLError, ValueError):
print("\n{0}Can't read file '{1}'{2}".format(
_m.color["RED"], self.link.split("/")[-1], _m.color["ENDC"]))
_meta_.color["RED"], self.link.split("/")[-1],
_meta_.color["ENDC"]))
return " "
except KeyboardInterrupt:
print("") # new line at exit

View file

@ -22,13 +22,13 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __metadata__ import MetaData as _m
from __metadata__ import MetaData as _meta_
def prog_version():
"""
Print version, license and email
"""
print("Version : {0}".format(_m.__version__))
print("Licence : {0}".format(_m.__license__))
print("Email : {0}".format(_m.__email__))
print("Version : {0}".format(_meta_.__version__))
print("Licence : {0}".format(_meta_.__license__))
print("Email : {0}".format(_meta_.__email__))