1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from caldavclientlibrary.browser.command import Command
18 from caldavclientlibrary.browser.command import WrongOptions
19 from caldavclientlibrary.protocol.url import URL
20 from caldavclientlibrary.browser import utils
21 from caldavclientlibrary.browser.subshell import SubShell
22 from caldavclientlibrary.browser import commands
23 import getopt
24 import shlex
25
27
32
34
35 interactive = False
36 read = False
37 write = False
38 principal = self.shell.account.getPrincipal()
39
40 try:
41 opts, args = getopt.getopt(shlex.split(options), 'irwp:')
42 except getopt.GetoptError, e:
43 print str(e)
44 print self.usage(name)
45 raise WrongOptions
46
47 for name, value in opts:
48
49 if name == "-i":
50 interactive = True
51 elif name == "-r":
52 read = True
53 elif name == "-w":
54 write = True
55 elif name == "-p":
56 principal = self.shell.account.getPrincipal(URL(url=value))
57 else:
58 print "Unknown option: %s" % (name,)
59 print self.usage(name)
60 raise WrongOptions
61
62 if len(args) > 0:
63 print "Wrong number of arguments: %d" % (len(args),)
64 print self.usage(name)
65 raise WrongOptions
66
67 if interactive:
68 self.doInteractiveMode(principal)
69 else:
70 utils.printProxyPrincipals(self.shell.account, principal, read or not write, write or not read, True)
71
72 return True
73
89
91 return """Usage: %s [OPTIONS]
92 PRINCIPAL - principal path to request proxies for.
93
94 Options:
95 -i interactive mode for adding, changing and deleting proxies.
96 -r read proxies [OPTIONAL]
97 -w write proxies [OPTIONAL]
98 if neither is present, both are displayed.
99
100 -p principal path to request proxies for [OPTIONAL]
101 if not present, the current user's principal is used.
102 """ % (name,)
103
105 return "Displays the delegates for the chosen user."
106
108
110 read = False
111 write = False
112
113 try:
114 opts, args = getopt.getopt(options.split(), 'rw')
115 except getopt.GetoptError, e:
116 print str(e)
117 print self.usage(name)
118 raise WrongOptions
119
120 for name, _ignore_value in opts:
121
122 if name == "-r":
123 read = True
124 if write:
125 print "Only one of -r and -w may be specified."
126 print self.usage(name)
127 raise WrongOptions
128 elif name == "-w":
129 write = True
130 if read:
131 print "Only one of -r and -w may be specified."
132 print self.usage(name)
133 raise WrongOptions
134 else:
135 print "Unknown option: %s" % (name,)
136 print self.usage(name)
137 raise WrongOptions
138
139 if not read and not write:
140 print "One of -r and -w must be specified."
141 print self.usage(name)
142 raise WrongOptions
143
144 if len(args) > 0:
145 print "Wrong number of arguments: %d" % (len(args),)
146 print self.usage(name)
147 raise WrongOptions
148
149 return read
150
162
163 -class Add(CommonProxiesCommand):
167
185
187 return """Usage: %s [OPTIONS]
188
189 Options:
190 -r add to read-only proxy list
191 -w add to read-write proxy list
192 one of -r or -w must be present.
193 """ % (name,)
194
196 return "Add proxies on principal."
197
198 -class Remove(CommonProxiesCommand):
202
218
220 return """Usage: %s [OPTIONS]
221
222 Options:
223 -r remove from read-only proxy list
224 -w remove from read-write proxy list
225 one of -r or -w must be present.
226 """ % (name,)
227
229 return "Remove proxies on principal."
230
231 -class List(CommonProxiesCommand):
235
240
242 return """Usage: %s
243 """ % (name,)
244
246 return "List current ACLs on existing resource."
247