From 3ba560569f3d6a96c211477b0467ed95f05114a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 8 May 2006 21:24:42 +0000 Subject: [PATCH] * fix: do not fail info command if files.xml is not available * fix: add missing repo parameter to PGraph (necessary because you might want to look at a specific repo, or only installed guys, or only repos, etc.) * fix: look at only graph of installed repo when considering remove op * fix: catch and translate exception in download of readxml --- pisi/api.py | 6 +++++- pisi/operations.py | 4 ++-- pisi/pgraph.py | 21 +++++++++++---------- pisi/pxml/xmlfilepiks.py | 5 ++++- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index ed92efd8..0d37b7c5 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -287,7 +287,11 @@ def info_name(package_name, installed=False): metadata.source = None #TODO: fetch the files from server if possible (wow, you maniac -- future exa) if installed and ctx.installdb.is_installed(package.name): - files = ctx.installdb.files(package.name) + try: + files = ctx.installdb.files(package.name) + except pisi.Error, e: + ctx.ui.warning(e) + files = None else: files = None return metadata, files diff --git a/pisi/operations.py b/pisi/operations.py index da4dacac..e329c0a5 100644 --- a/pisi/operations.py +++ b/pisi/operations.py @@ -114,7 +114,7 @@ in the respective order to satisfy extra dependencies: install_pkg_names(extra_packages) class PackageDB: - def get_package(self, key): + def get_package(self, key, repo = None): return d_t[str(key)] packagedb = PackageDB() @@ -546,7 +546,7 @@ def plan_remove(A): # try to construct a pisi graph of packages to # install / reinstall - G_f = pgraph.PGraph(ctx.packagedb) # construct G_f + G_f = pgraph.PGraph(ctx.packagedb, pisi.itembyrepodb.installed) # construct G_f # find the (install closure) graph of G_f by package # set A using packagedb diff --git a/pisi/pgraph.py b/pisi/pgraph.py index ce7d4d99..dee7a9e6 100644 --- a/pisi/pgraph.py +++ b/pisi/pgraph.py @@ -18,22 +18,23 @@ from graph import * class PGraph(Digraph): - def __init__(self, packagedb): + def __init__(self, packagedb, repo = pisi.itembyrepodb.repos): super(PGraph, self).__init__() self.packagedb = packagedb + self.repo = repo def add_package(self, pkg): - pkg1 = self.packagedb.get_package(pkg) + pkg1 = self.packagedb.get_package(pkg, self.repo) self.add_vertex(str(pkg), (pkg1.version, pkg1.release)) def add_plain_dep(self, pkg1name, pkg2name): pkg1data = None if not pkg1name in self.vertices(): - pkg1 = self.packagedb.get_package(pkg1name) + pkg1 = self.packagedb.get_package(pkg1name, self.repo) pkg1data = (pkg1.version, pkg1.release) pkg2data = None if not pkg2name in self.vertices(): - pkg2 = self.packagedb.get_package(pkg2name) + pkg2 = self.packagedb.get_package(pkg2name, self.repo) pkg2data = (pkg2.version, pkg2.release) self.add_edge(str(pkg1name), str(pkg2name), ('d', None), pkg1data, pkg2data ) @@ -41,11 +42,11 @@ class PGraph(Digraph): def add_dep(self, pkg, depinfo): pkg1data = None if not pkg in self.vertices(): - pkg1 = self.packagedb.get_package(pkg) + pkg1 = self.packagedb.get_package(pkg, self.repo) pkg1data = (pkg1.version, pkg1.release) pkg2data = None if not depinfo.package in self.vertices(): - pkg2 = self.packagedb.get_package(depinfo.package) + pkg2 = self.packagedb.get_package(depinfo.package, self.repo) pkg2data = (pkg2.version, pkg2.release) self.add_edge(str(pkg), str(depinfo.package), ('d', depinfo), pkg1data, pkg2data ) @@ -53,11 +54,11 @@ class PGraph(Digraph): def add_rev_dep(self, depinfo, pkg): pkg1data = None if not pkg in self.vertices(): - pkg1 = self.packagedb.get_package(depinfo.package) + pkg1 = self.packagedb.get_package(depinfo.package, self.repo) pkg1data = (pkg1.version, pkg1.release) pkg2data = None if not depinfo.package in self.vertices(): - pkg2 = self.packagedb.get_package(pkg) + pkg2 = self.packagedb.get_package(pkg, self.repo) pkg2data = (pkg2.version, pkg2.release) self.add_edge(str(depinfo.package), str(pkg), ('d', depinfo), pkg1data, pkg2data ) @@ -65,11 +66,11 @@ class PGraph(Digraph): def add_conflict(self, pkg, conflinfo): pkg1data = None if not pkg in self.vertices(): - pkg1 = self.packagedb.get_package(pkg) + pkg1 = self.packagedb.get_package(pkg, self.repo) pkg1data = (pkg1.version, pkg1.release) pkg2data = None if not pkg in self.vertices(): - pkg2 = self.packagedb.get_package(conflinfo.package) + pkg2 = self.packagedb.get_package(conflinfo.package, self.repo) pkg2data = (pkg2.version, pkg2.release) self.add_biedge(str(pkg), str(conflinfo.package), ('c', conflinfo) diff --git a/pisi/pxml/xmlfilepiks.py b/pisi/pxml/xmlfilepiks.py index 2b4486e8..92d89d5c 100644 --- a/pisi/pxml/xmlfilepiks.py +++ b/pisi/pxml/xmlfilepiks.py @@ -57,7 +57,10 @@ class XmlFile(object): def readxml(self, uri, tmpDir='/tmp', sha1sum=False, compress=None, sign=None): uri = File.make_uri(uri) - localpath = File.download(uri, tmpDir,sha1sum=sha1sum,compress=compress,sign=sign) + try: + localpath = File.download(uri, tmpDir,sha1sum=sha1sum,compress=compress,sign=sign) + except Exception, e: + raise Error(_("Cannot access URI %s") % (uri) ) try: self.doc = iks.parse(localpath) return self.doc