Kaydet (Commit) 4cad1340 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Merge branch 'patch-41836' into 'master'

Son kalan optimize hataları

See merge request sulinos/devel/inary!11
......@@ -38,6 +38,7 @@ packages from all repositories.
super(ListNewest, self).__init__(args)
self.componentdb = inary.db.componentdb.ComponentDB()
self.packagedb = inary.db.packagedb.PackageDB()
self.historydb=inary.db.historydb.HistoryDB()
name = ("list-newest", "ln")
......@@ -55,7 +56,6 @@ packages from all repositories.
def run(self):
self.init(database=True, write=False)
if self.args:
for arg in self.args:
self.print_packages(arg)
......@@ -68,14 +68,12 @@ packages from all repositories.
if ctx.config.get_option('since'):
since = ctx.config.get_option('since')
elif ctx.config.get_option('last'):
since = inary.db.historydb.HistoryDB().get_last_repo_update(int(ctx.config.get_option('last')))
since = self.historydb.get_last_repo_update(int(ctx.config.get_option('last')))
else:
since = None
l = self.packagedb.list_newest(repo, since)
l = self.packagedb.list_newest(repo, since,self.historydb)
if not l:
return
if since:
ctx.ui.info(_("Packages added to \'{0}\' since \"{1}\":\n").format(repo, since))
else:
......@@ -86,9 +84,9 @@ packages from all repositories.
l.sort()
for p in l:
package = self.packagedb.get_package(p, repo)
pkgsum = self.packagedb.get_summary(p)
lenp = len(p)
p += ' ' * max(0, maxlen - lenp)
ctx.ui.info('{0} - {1} '.format(p, str(package.summary)))
ctx.ui.info('{0} - {1} '.format(p, str(pkgsum)))
print()
......@@ -56,9 +56,9 @@ Lists the packages that will be upgraded.
import inary.operations as operations
self.init(database=True, write=False)
installdb = inary.db.installdb.InstallDB()
is_upgradable = operations.upgrade.is_upgradable
packagedb = inary.db.packagedb.PackageDB()
upgradable_pkgs = list(filter(is_upgradable, installdb.list_installed()))
upgradable_pkgs = operations.upgrade.list_upgradeable(installdb,packagedb)
# replaced packages can not pass is_upgradable test, so we add them manually
# upgradable_pkgs.extend(list_replaces())
......@@ -86,13 +86,12 @@ Lists the packages that will be upgraded.
sys.stdout.write('===========================================================================')
for pkg in upgradable_pkgs:
package = self.installdb.get_package(pkg)
inst_info = self.installdb.get_info(pkg)
if self.options.long:
ctx.ui.info(package)
ctx.ui.info(pkg)
sys.stdout.write(inst_info)
elif self.options.install_info:
ctx.ui.info('%-20s |%s ' % (package.name, inst_info.one_liner()))
ctx.ui.info('%-20s |%s ' % (pkg, inst_info.one_liner()))
else:
package.name += ' ' * max(0, maxlen - len(package.name))
ctx.ui.info('{0} - {1}'.format(package.name, str(package.summary)))
package.name += ' ' * max(0, maxlen - len(pkg))
ctx.ui.info('{0} - {1}'.format(pkg, str(packagedb.get_summary(pkg))))
......@@ -123,8 +123,6 @@ class HistoryDB(lazydb.LazyDB):
def get_last_repo_update(self, last=1):
repoupdates = [l for l in self.__logs if l.endswith("repoupdate.xml")]
repoupdates.reverse()
if not len(repoupdates) >= 2:
return None
if last != 1 and len(repoupdates) <= last:
return None
......
......@@ -165,6 +165,15 @@ class PackageDB(lazydb.LazyDB):
release = xmlext.getNodeAttribute(update, 'release')
return release
@staticmethod
def __get_last_date(meta_doc):
history = xmlext.getNode(meta_doc, 'History')
update = xmlext.getNode(history, 'Update')
date = xmlext.getNodeText(update, 'Date')
return date
@staticmethod
def __get_summary(meta_doc):
......@@ -210,6 +219,14 @@ class PackageDB(lazydb.LazyDB):
pkg_doc = xmlext.parseString(self.pdb.get_item(name, repo))
return self.__get_release(pkg_doc)
def get_last_date(self, name, repo):
if not self.has_package(name, repo):
raise Exception(_('Package \"{}\" not found.').format(name))
pkg_doc = xmlext.parseString(self.pdb.get_item(name, repo))
return self.__get_last_date(pkg_doc)
def get_package_repo(self, name, repo=None):
pkg, repo = self.pdb.get_item_repo(name, repo)
......@@ -283,9 +300,10 @@ class PackageDB(lazydb.LazyDB):
def list_packages(self, repo):
return self.pdb.get_item_keys(repo)
def list_newest(self, repo, since=None):
def list_newest(self, repo, since=None,historydb=None):
packages = []
historydb = inary.db.historydb.HistoryDB()
if not historydb:
historydb = inary.db.historydb.HistoryDB()
if since:
since_date = datetime.datetime(*time.strptime(since, "%Y-%m-%d")[0:6])
else:
......@@ -294,16 +312,16 @@ class PackageDB(lazydb.LazyDB):
for pkg in self.list_packages(repo):
failed = False
try:
enter_date = datetime.datetime(*time.strptime(self.get_package(pkg).history[-1].date, "%m-%d-%Y")[0:6])
enter_date = datetime.datetime(*time.strptime(self.get_last_date(pkg,repo), "%m-%d-%Y")[0:6])
except:
failed = True
if failed:
try:
enter_date = datetime.datetime(
*time.strptime(self.get_package(pkg).history[-1].date, "%Y-%m-%d")[0:6])
*time.strptime(self.get_last_date(pkg,repo), "%Y-%m-%d")[0:6])
except:
enter_date = datetime.datetime(
*time.strptime(self.get_package(pkg).history[-1].date, "%Y-%d-%m")[0:6])
*time.strptime(self.get_last_date(pkg,repo), "%Y-%d-%m")[0:6])
if enter_date >= since_date:
packages.append(pkg)
......
......@@ -304,7 +304,7 @@ def plan_install_pkg_names(A):
for x in A:
G_f.add_package(x)
B = A
not_satisfied=dict()
while len(B) > 0:
Bp = set()
for x in B:
......@@ -314,15 +314,10 @@ def plan_install_pkg_names(A):
# we don't deal with already *satisfied* dependencies
if not dep.satisfied_by_installed():
if not dep.satisfied_by_repo(packagedb=packagedb) and not ctx.config.get_option('ignore_satisfy'):
if dep in not_satisfied:
not_satisfied[dep]+=[pkg.name]
else:
not_satisfied[dep]=[pkg.name]
pass
raise Exception(_('\"{0}\" dependency of package \"{1}\" is not satisfied.').format(dep, pkg.name))
if not dep.package in G_f.vertices():
Bp.add(str(dep.package))
G_f.add_dep(x, dep)
if ctx.config.values.general.allow_docs:
dep = x + ctx.const.doc_package_end
if packagedb.has_package(dep):
......@@ -343,12 +338,8 @@ def plan_install_pkg_names(A):
if packagedb.has_package(dep):
Bp.add(dep)
G_f.add_package(dep)
B = Bp
if not_satisfied:
msg=_("Following packages are not satisfied:\n")
for ns in not_satisfied:
msg+=(_(' -> \"{0}\" dependency(s) of package \"{1}\" is not satisfied.\n').format(not_satisfied[ns], ns))
raise Exception(msg)
if ctx.config.get_option('debug'):
G_f.write_graphviz(sys.stdout)
order = G_f.topological_sort()
......
......@@ -464,6 +464,12 @@ def is_upgradable(name,installdb,packagedb):
return int(i_release) < int(release)
def list_upgradeable(installdb,packagedb):
listup=[]
for pkg in installdb.list_installed():
if is_upgradable(pkg,installdb,packagedb):
listup.append(pkg)
return listup
def get_upgrade_order(packages):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment