Package caldavclientlibrary :: Package browser :: Package commands :: Module principal
[hide private]
[frames] | no frames]

Source Code for Module caldavclientlibrary.browser.commands.principal

  1  ## 
  2  # Copyright (c) 2007-2016 Apple Inc. All rights reserved. 
  3  # 
  4  # Licensed under the Apache License, Version 2.0 (the "License"); 
  5  # you may not use this file except in compliance with the License. 
  6  # You may obtain a copy of the License at 
  7  # 
  8  # http://www.apache.org/licenses/LICENSE-2.0 
  9  # 
 10  # Unless required by applicable law or agreed to in writing, software 
 11  # distributed under the License is distributed on an "AS IS" BASIS, 
 12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 13  # See the License for the specific language governing permissions and 
 14  # limitations under the License. 
 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  import getopt 
 22  import shlex 
 23   
24 -class Cmd(Command):
25
26 - def __init__(self):
27 super(Command, self).__init__() 28 self.cmds = ("principal", )
29
30 - def execute(self, name, options):
31 refresh = False 32 resolve = True 33 principal = None 34 print_proxies = False 35 36 opts, args = getopt.getopt(shlex.split(options), 'fnp:x') 37 38 for name, value in opts: 39 40 if name == "-f": 41 refresh = True 42 elif name == "-n": 43 resolve = False 44 elif name == "-p": 45 principal = self.shell.account.getPrincipal(URL(url=value), refresh=refresh) 46 elif name == "-x": 47 print_proxies = True 48 else: 49 print "Unknown option: %s" % (name,) 50 print self.usage(name) 51 raise WrongOptions 52 53 if len(args) > 0: 54 print "Wrong number of arguments: %d" % (len(args),) 55 print self.usage(name) 56 raise WrongOptions 57 58 if not principal: 59 principal = self.shell.account.getPrincipal(refresh=refresh) 60 61 print """ 62 Principal Path : %s 63 Display Name : %s 64 Principal URL : %s 65 Alternate URLs : %s 66 Group Members : %s 67 Memberships : %s 68 Calendar Homes : %s 69 Outbox URL : %s 70 Inbox URL : %s 71 Calendar Addresses: %s 72 """ % ( 73 principal.principalPath, 74 principal.getSmartDisplayName(), 75 principal.principalURL, 76 utils.printList(principal.alternateURIs), 77 utils.printPrincipalPaths(self.shell.account, principal.memberset, resolve, refresh), 78 utils.printPrincipalPaths(self.shell.account, principal.memberships, resolve, refresh), 79 utils.printList(principal.homeset), 80 principal.outboxURL, 81 principal.inboxURL, 82 utils.printList(principal.cuaddrs), 83 ), 84 85 if print_proxies: 86 utils.printProxyPrincipals(self.shell.account, principal, True, True, resolve, False, refresh) 87 88 return True
89
90 - def usage(self, name):
91 return """Usage: %s [OPTIONS] 92 Options: 93 -f force reload of all cached principals to be returned 94 -p principal path to request proxies for [OPTIONAL] 95 if not present, the current user's principal is used. 96 -n do not resolve references to other principals. 97 -x print proxy details as well. 98 """ % (name,)
99
100 - def helpDescription(self):
101 return "Displays the current server login id."
102