summaryrefslogtreecommitdiffstats
path: root/ipa-admintools
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@notas.(none)>2008-07-21 12:25:37 +0200
committerRob Crittenden <rcrit@ipa.greyoak.com>2008-07-23 10:05:06 -0400
commitf7ca405716b1ee8b92a940e07cd611f6b025795d (patch)
tree5246bd49daa8b72fe39f55d90b4280a8ec1d8b3e /ipa-admintools
parent72a3114a01d0c67cf3b8faf7b28da93e8a6f2de3 (diff)
downloadfreeipa-f7ca405716b1ee8b92a940e07cd611f6b025795d.tar.gz
freeipa-f7ca405716b1ee8b92a940e07cd611f6b025795d.tar.xz
freeipa-f7ca405716b1ee8b92a940e07cd611f6b025795d.zip
Wrap up the raw_input() to user_input() for convenience and uniformity.
Diffstat (limited to 'ipa-admintools')
-rw-r--r--ipa-admintools/ipa-addgroup17
-rw-r--r--ipa-admintools/ipa-adduser50
-rw-r--r--ipa-admintools/ipa-moduser55
3 files changed, 14 insertions, 108 deletions
diff --git a/ipa-admintools/ipa-addgroup b/ipa-admintools/ipa-addgroup
index caf4e93dc..cc813836c 100644
--- a/ipa-admintools/ipa-addgroup
+++ b/ipa-admintools/ipa-addgroup
@@ -81,29 +81,16 @@ def main():
if options.usage:
usage()
- cont = False
-
if (len(args) != 2):
- while (cont != True):
- cn = raw_input("Group name: ")
- if (ipavalidate.String(cn, notEmpty=True)):
- print "Please enter a value"
- else:
- cont = True
+ cn = ipautil.user_input("Group name", allow_empty = False)
else:
cn = args[1]
if (ipavalidate.String(cn, notEmpty=True)):
print "Please enter a value"
return 1
- cont = False
if not options.desc:
- while (cont != True):
- desc = raw_input("Description: ")
- if (ipavalidate.String(desc, notEmpty=True)):
- print "Please enter a value"
- else:
- cont = True
+ desc = ipautil.user_input("Description", allow_empty = False)
else:
desc = options.desc
if (ipavalidate.String(desc, notEmpty=True)):
diff --git a/ipa-admintools/ipa-adduser b/ipa-admintools/ipa-adduser
index 2c32d1e58..17c75edf8 100644
--- a/ipa-admintools/ipa-adduser
+++ b/ipa-admintools/ipa-adduser
@@ -102,7 +102,6 @@ def main():
groups = ""
match = False
- cont = False
all_interactive = False
@@ -116,40 +115,23 @@ def main():
all_interactive = True
if not options.gn:
- while (cont != True):
- givenname = raw_input("First name: ")
- if (ipavalidate.String(givenname, notEmpty=True)):
- print "Please enter a value"
- else:
- cont = True
+ givenname = ipautil.user_input("First name", allow_empty = False)
else:
givenname = options.gn
if (ipavalidate.String(givenname, notEmpty=True)):
print "Please enter a value"
return 1
- cont = False
if not options.sn:
- while (cont != True):
- lastname = raw_input("Last name: ")
- if (ipavalidate.String(lastname, notEmpty=True)):
- print "Please enter a value"
- else:
- cont = True
+ lastname = ipautil.user_input("Last name", allow_empty = False)
else:
lastname = options.sn
if (ipavalidate.String(lastname, notEmpty=True)):
print "Please enter a value"
return 1
- cont = False
if (len(args) != 2):
- while (cont != True):
- username = raw_input("Login name: ")
- if (ipavalidate.Plain(username, notEmpty=True, allowSpaces=False)):
- print "Please enter a value"
- else:
- cont = True
+ username = ipautil.user_input_plain("Login name", allow_empty = False, allow_spaces = False)
else:
username = args[1]
if (ipavalidate.Plain(username, notEmpty=True, allowSpaces=False)):
@@ -180,32 +162,12 @@ def main():
# Ask the questions we don't normally force. We don't require answers
# for these.
if all_interactive is True:
- cont = False
if not options.gecos:
- while (cont != True):
- gecos = raw_input("gecos []: ")
- if (ipavalidate.String(gecos, notEmpty=False)):
- print "Please enter a value"
- else:
- cont = True
- cont = False
+ gecos = ipautil.user_input("gecos")
if not options.directory:
- while (cont != True):
- directory = raw_input("home directory [/home/"+username+"]: ")
- if directory == "":
- directory = "/home/"+username
- if (ipavalidate.Path(directory, notEmpty=False)):
- print "Please enter a value"
- else:
- cont = True
- cont = False
+ directory = ipautil.user_input_path("Home directory", "/home/" + username, allow_empty = True)
if not options.shell:
- while (cont != True):
- shell = raw_input("shell [/bin/sh]: ")
-
- if len(shell) < 1:
- shell = None
- cont = True
+ shell = ipautil.user_input("Shell", "/bin/sh", allow_empty = False)
else:
gecos = options.gecos
diff --git a/ipa-admintools/ipa-moduser b/ipa-admintools/ipa-moduser
index 22f231893..4b3bd5c9c 100644
--- a/ipa-admintools/ipa-moduser
+++ b/ipa-admintools/ipa-moduser
@@ -97,7 +97,6 @@ def main():
shell = ""
match = False
- cont = False
options, args = parse_options()
@@ -141,46 +140,23 @@ def main():
shell = options.shell
else:
if not options.gn:
- while (cont != True):
- givenname = raw_input("First name: [%s] " % user.getValue('givenname'))
- if (ipavalidate.String(givenname, notEmpty=False)):
- print "Please enter a value"
- else:
- cont = True
- if len(givenname) < 1:
- givenname = None
- cont = True
+ givenname = ipautil.user_input("First name", user.getValue('givenname'), allow_empty = False)
else:
givenname = options.gn
if (ipavalidate.String(givenname, notEmpty=True)):
print "Please enter a value"
return 1
- cont = False
if not options.sn:
- while (cont != True):
- lastname = raw_input(" Last name: [%s] " % user.getValue('sn'))
- if (ipavalidate.String(lastname, notEmpty=False)):
- print "Please enter a value"
- else:
- cont = True
- if len(lastname) < 1:
- lastname = None
- cont = True
+ lastname = ipautil.user_input("Last name", user.getValue('sn'), allow_empty = False)
else:
lastname = options.sn
if (ipavalidate.String(lastname, notEmpty=True)):
print "Please enter a value"
return 1
- cont = False
if not options.mail:
- while (cont != True):
- mail = raw_input("E-mail addr: [%s]" % user.getValue('mail'))
- if (ipavalidate.Email(mail, notEmpty=False)):
- print "E-mail must include a user and domain name"
- else:
- cont = True
+ mail = ipautil.user_input_email("E-mail address", user.getValue('mail'), allow_empty = True)
else:
mail = options.mail
if (ipavalidate.Email(mail)):
@@ -189,32 +165,13 @@ def main():
# Ask the questions we don't normally force. We don't require answers
# for these.
- cont = False
if not options.gecos:
- while (cont != True):
- gecos = raw_input("gecos: [%s] " % user.getValue('gecos'))
- if (ipavalidate.String(gecos, notEmpty=False)):
- print "Please enter a value"
- else:
- cont = True
+ gecos = ipautil.user_input("gecos", user.getValue('gecos'))
- cont = False
if not options.directory:
- while (cont != True):
- directory = raw_input("home directory: [%s] " % user.getValue('homeDirectory'))
- if (ipavalidate.Path(gecos, notEmpty=False)):
- print "Valid path is required"
- else:
- cont = True
- cont = False
+ directory = ipautil.user_input_path("Home directory", user.getValue('homeDirectory'))
if not options.shell:
- while (cont != True):
- shell = raw_input("shell: [%s] " % user.getValue('loginshell'))
-
- if len(shell) < 1:
- shell = None
- cont = True
- cont = False
+ shell = ipautil.user_input("Shell", user.getValue('loginshell'), allow_empty = False)
if givenname:
user.setValue('givenname', givenname)