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

Source Code for Module caldavclientlibrary.browser.commands.logging

 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  import getopt 
20  import shlex 
21   
22 -class Cmd(Command):
23
24 - def __init__(self):
25 super(Command, self).__init__() 26 self.cmds = ("logging", )
27
28 - def execute(self, name, options):
29 opts, args = getopt.getopt(shlex.split(options), '') 30 if len(opts) or len(args) > 1: 31 print self.usage(name) 32 raise WrongOptions() 33 if args and args[0] not in ("on", "off",): 34 print self.usage(name) 35 raise WrongOptions() 36 37 if args: 38 state = args[0] 39 else: 40 state = ("off" if self.shell.account.session.loghttp else "on") 41 if state == "on": 42 self.shell.account.session.loghttp = True 43 print "HTTP logging turned on" 44 else: 45 self.shell.account.session.loghttp = False 46 print "HTTP logging turned off" 47 return True
48
49 - def usage(self, name):
50 return """Usage: %s [on|off] 51 on - turn HTTP protocol logging on 52 off - turn HTTP protocol logging off 53 without either argument - toggle the state of logging 54 """ % (name,)
55
56 - def helpDescription(self):
57 return "Changes the current state of HTTP logging."
58