From 095a6e7bba15592e21f2f14be1310cb1ebadca38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 5 Jun 2006 17:28:15 +0000 Subject: [PATCH] * fix: make local repos work, there was a problem with Index.read(), it had to be another name. Also, copylocal didn't work, preventing the sha1sum shortcut * add shortcuts for frequently used commands --- pisi/api.py | 12 ++++++------ pisi/cli/commands.py | 6 +++--- pisi/file.py | 9 ++++----- pisi/index.py | 13 +++++++------ pisi/pxml/xmlfilepiks.py | 10 +++++----- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pisi/api.py b/pisi/api.py index 26017bee..1d65061e 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -368,12 +368,12 @@ def update_repo(repo, force=False): if ctx.repodb.has_repo(repo): repouri = ctx.repodb.get_repo(repo).indexuri.get_uri() try: - index.read_uri(repouri, repo) + index.read_uri_of_repo(repouri, repo) except pisi.file.AlreadyHaveException, e: ctx.ui.info(_('No updates available for repository %s.') % repo) if force: ctx.ui.info(_('Updating database at any rate as requested')) - index.read_uri(repouri, repo, force = force) + index.read_uri_of_repo(repouri, repo, force = force) else: return try: @@ -400,10 +400,11 @@ def rebuild_repo(repo): indexpath = pisi.util.join_path(ctx.config.index_dir(), repo, indexname) tmpdir = os.path.join(ctx.config.tmp_dir(), 'index') pisi.util.clean_dir(tmpdir) + pisi.util.check_dir(tmpdir) try: - index.read(indexpath, tmpdir) - except IOError: - ctx.ui.warning(_("Repo index file '%s' not found.") % uri_str) + index.read_uri(indexpath, tmpdir, force=True) # don't look for sha1sum there + except IOError, e: + ctx.ui.warning(_("Input/Output error while reading %s: %s") % (indexpath, unicode(e))) return ctx.txn_proc(lambda txn : index.update_db(repo, txn=txn)) ctx.ui.info(_('OK.')) @@ -487,7 +488,6 @@ def rebuild_db(files=False): finalize() # construct new database version init(database=True, options=options, ui=ui, comar=comar) - #ctx.txn_proc(reload) clean_duplicates() reload_packages(files, None) reload_indices(None) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 838fee9f..a69f132f 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -206,7 +206,7 @@ If run without parameters, it prints the general help.""" #self.__doc__ += commands_string() super(Help, self).__init__() - name = ("help", "h") + name = ("help", "?") def run(self): @@ -249,7 +249,7 @@ class DeleteCache(Command): def __init__(self): super(DeleteCache, self).__init__() - name = ("delete-cache", None) + name = ("delete-cache", "dc") def run(self): self.init(database=False, write=True) @@ -1183,7 +1183,7 @@ in summary, description, and package name fields. def __init__(self): super(Search, self).__init__() - name = ("search", None) + name = ("search", "sr") def options(self): super(Search, self).options() diff --git a/pisi/file.py b/pisi/file.py index 08ec80a3..d49e697b 100644 --- a/pisi/file.py +++ b/pisi/file.py @@ -118,10 +118,10 @@ class File: ctx.ui.info(_("Fetching %s") % uri.get_uri()) fetch_url(uri, transfer_dir) else: - # copy to transfer dir, it's okay if transfer_dir is the same - if not os.path.samefile(uri.get_uri(), join(transfer_dir, uri.filename())): - ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri()) - shutil.copy(uri.get_uri(), transfer_dir) + # copy to transfer dir, + localfile = join(transfer_dir, uri.filename()) + ctx.ui.info(_("Copying %s to transfer dir") % uri.get_uri()) + shutil.copy(uri.get_uri(), transfer_dir) else: localfile = uri.get_uri() #TODO: use a special function here? if not os.path.exists(localfile): @@ -132,7 +132,6 @@ class File: shutil.copy(oldfn, localfile) if sha1sum: - if (pisi.util.sha1_file(localfile) != newsha1): raise Error(_("File integrity of %s compromised.") % uri) diff --git a/pisi/index.py b/pisi/index.py index 4676da67..814684ee 100644 --- a/pisi/index.py +++ b/pisi/index.py @@ -54,12 +54,12 @@ class Index(XmlFile): def name(): return self.distribution.name + self.distribution.repositoryname - def read(filename, tmpdir): - XmlFile.read(filename, tmpDir=tmpdir, sha1sum=not force, - compress=File.auto, sign=File.detached, copylocal = True) + def read_uri(self, uri, tmpdir, force = False): + self.read(uri, tmpDir=tmpdir, sha1sum=not force, + compress=File.auto, sign=File.detached, copylocal = True) # read index for a given repo, force means download even if remote not updated - def read_uri(self, filename, repo = None, force = False): + def read_uri_of_repo(self, uri, repo = None, force = False): """Read PSPEC file""" if repo: tmpdir = os.path.join(ctx.config.index_dir(), repo) @@ -70,9 +70,10 @@ class Index(XmlFile): # write uri urlfile = file(pisi.util.join_path(tmpdir, 'uri'), 'w') - urlfile.write(filename) # uri + urlfile.write(uri) # uri + urlfile.close() - self.read(filename, tmpdir) + self.read_uri(uri, tmpdir, force) if not repo: repo = self.distribution.name() diff --git a/pisi/pxml/xmlfilepiks.py b/pisi/pxml/xmlfilepiks.py index 12f6c58c..e7b143e6 100644 --- a/pisi/pxml/xmlfilepiks.py +++ b/pisi/pxml/xmlfilepiks.py @@ -58,11 +58,11 @@ class XmlFile(object): def readxml(self, uri, tmpDir='/tmp', sha1sum=False, compress=None, sign=None, copylocal = False): uri = File.make_uri(uri) - try: - localpath = File.download(uri, tmpDir, sha1sum=sha1sum, - compress=compress,sign=sign, copylocal=copylocal) - except IOError: - raise Error(_("Cannot access URI %s") % (uri) ) + #try: + localpath = File.download(uri, tmpDir, sha1sum=sha1sum, + compress=compress,sign=sign, copylocal=copylocal) + #except IOError, e: + # raise Error(_("Cannot read URI %s: %s") % (uri, unicode(e)) ) try: self.doc = iks.parse(localpath) return self.doc