From b18c2e5e1f7388331ed4ff98f348ce771b33243d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 10 Oct 2005 12:20:28 +0000 Subject: [PATCH] * fixx0r #570: do not store destdir option as relative path * short option -N for --no-color --- pisi/cli/commands.py | 16 ++++++++++++++-- pisi/config.py | 8 ++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index fc6537d9..d4736d2e 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -64,7 +64,7 @@ class Command(object): (self.options, self.args) = self.parser.parse_args() self.args.pop(0) # exclude command arg - self.check_auth_info() + self.process_opts() def commonopts(self): '''common options''' @@ -85,7 +85,7 @@ class Command(object): p.add_option("-n", "--dry-run", action="store_true", default=False, help = _("do not perform any action, just show what\ would be done")) - p.add_option("", "--no-color", action="store_true", default=False, + p.add_option("-N", "--no-color", action="store_true", default=False, help = _("print like a man")) return p @@ -94,6 +94,18 @@ class Command(object): options function it will be called""" pass + def process_opts(self): + self.check_auth_info() + + # make destdir absolute + if self.options.destdir: + dir = str(self.options.destdir) + import os.path + if not os.path.exists(dir): + raise Exception, _('Destination directory %s does not exist') % dir + self.options.destdir = os.path.realpath(dir) + + def check_auth_info(self): username = self.options.username password = self.options.password diff --git a/pisi/config.py b/pisi/config.py index 2ca22eb7..2a04f6b1 100644 --- a/pisi/config.py +++ b/pisi/config.py @@ -47,9 +47,13 @@ class Config(object): def dest_dir(self): dir = self.get_option('destdir') if dir: - return str(dir) + dir = str(dir) else: - return self.values.general.destinationdirectory + dir = self.values.general.destinationdirectory + import os.path + if not os.path.exists(dir): + raise Exception, _('Destination directory %s does not exist') % dir + return dir def lib_dir(self): return join(self.dest_dir(), self.values.dirs.lib_dir)