summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 5543301c0..5ef812f75 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -1022,15 +1022,21 @@ class cli(backend.Executioner):
"""
for p in cmd.params():
if isinstance(p, File):
+ # FIXME: this only reads the first file
+ raw = None
if p.name in kw:
+ if type(kw[p.name]) in (tuple, list):
+ fname = kw[p.name][0]
+ else:
+ fname = kw[p.name]
try:
- f = open(kw[p.name], 'r')
+ f = open(fname, 'r')
raw = f.read()
f.close()
except IOError, e:
raise ValidationError(
name=to_cli(p.cli_name),
- error='%s: %s:' % (kw[p.name], e[1])
+ error='%s: %s:' % (fname, e[1])
)
elif p.stdin_if_missing:
try:
@@ -1039,6 +1045,10 @@ class cli(backend.Executioner):
raise ValidationError(
name=to_cli(p.cli_name), error=e[1]
)
+ if not raw:
+ raise ValidationError(
+ name=to_cli(p.cli_name), error=_('No file to read')
+ )
kw[p.name] = self.Backend.textui.decode(raw)