1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from caldavclientlibrary.admin.xmlaccounts.commands.command import Command
18 import getopt
19
21 """
22 Command to change the password of an existing directory record.
23 """
24
25 CMDNAME = "passwd"
26
30
32 print """USAGE: %s TYPE [OPTIONS]
33
34 TYPE: One of "users", "groups", "locations" or "resources". Also,
35 "u", "g", "l" or "r" as shortcuts.
36
37 Options:
38 -f file path to accounts.xml
39 --uid UID of record to change
40 """ % (self.cmdname,)
41
43 """
44 Execute the command specified by the command line arguments.
45
46 @param argv: command line arguments.
47 @type argv: C{list}
48
49 @return: 1 for success, 0 for failure.
50 @rtype: C{int}
51 """
52
53
54 argv = self.getTypeArgument(argv)
55 if argv is None:
56 return 0
57
58 opts, args = getopt.getopt(argv, 'f:h', ["help", "uid=",])
59
60 for name, value in opts:
61 if name == "-f":
62 self.path = value
63 elif name in ("-h", "--help"):
64 self.usage()
65 return 1
66 elif name == "--uid":
67 self.uid = value
68 else:
69 print "Unknown option: %s." % (name,)
70 self.usage()
71 return 0
72
73 if not self.path:
74 print "Must specify a path."
75 self.usage()
76 return 0
77 if not self.uid:
78 print "Must specify a UID."
79 self.usage()
80 return 0
81 if args:
82 print "Arguments not allowed."
83 self.usage()
84 return 0
85
86 if not self.loadAccounts():
87 return 0
88 return self.doCommand()
89
97
111