* fixx0r #570: do not store destdir option as relative path
* short option -N for --no-color
This commit is contained in:
+14
-2
@@ -64,7 +64,7 @@ class Command(object):
|
|||||||
(self.options, self.args) = self.parser.parse_args()
|
(self.options, self.args) = self.parser.parse_args()
|
||||||
self.args.pop(0) # exclude command arg
|
self.args.pop(0) # exclude command arg
|
||||||
|
|
||||||
self.check_auth_info()
|
self.process_opts()
|
||||||
|
|
||||||
def commonopts(self):
|
def commonopts(self):
|
||||||
'''common options'''
|
'''common options'''
|
||||||
@@ -85,7 +85,7 @@ class Command(object):
|
|||||||
p.add_option("-n", "--dry-run", action="store_true", default=False,
|
p.add_option("-n", "--dry-run", action="store_true", default=False,
|
||||||
help = _("do not perform any action, just show what\
|
help = _("do not perform any action, just show what\
|
||||||
would be done"))
|
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"))
|
help = _("print like a man"))
|
||||||
return p
|
return p
|
||||||
|
|
||||||
@@ -94,6 +94,18 @@ class Command(object):
|
|||||||
options function it will be called"""
|
options function it will be called"""
|
||||||
pass
|
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):
|
def check_auth_info(self):
|
||||||
username = self.options.username
|
username = self.options.username
|
||||||
password = self.options.password
|
password = self.options.password
|
||||||
|
|||||||
+6
-2
@@ -47,9 +47,13 @@ class Config(object):
|
|||||||
def dest_dir(self):
|
def dest_dir(self):
|
||||||
dir = self.get_option('destdir')
|
dir = self.get_option('destdir')
|
||||||
if dir:
|
if dir:
|
||||||
return str(dir)
|
dir = str(dir)
|
||||||
else:
|
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):
|
def lib_dir(self):
|
||||||
return join(self.dest_dir(), self.values.dirs.lib_dir)
|
return join(self.dest_dir(), self.values.dirs.lib_dir)
|
||||||
|
|||||||
Reference in New Issue
Block a user