1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from caldavclientlibrary.browser.baseshell import BaseShell
18 from caldavclientlibrary.browser.command import Command
19 from caldavclientlibrary.client.account import CalDAVAccount
20 from getpass import getpass
21 from caldavclientlibrary.protocol.url import URL
22 import caldavclientlibrary.browser.commands
23 import atexit
24 import getopt
25 import sys
26 import urlparse
27
29
30 - def __init__(self, server, path, user, pswd, logging):
47
55
64
70
72 return """Usage: shell [OPTIONS]
73
74 Options:
75 -l start with HTTP logging on.
76 --server=HOST url of the server include http/https scheme and port [REQUIRED].
77 --user=USER user name to login as - will be prompted if not prsent [OPTIONAL].
78 --pswd=PSWD password for user - will be prompted if not prsent [OPTIONAL].
79 """
80
82 logging = False
83 server = None
84 user = None
85 pswd = None
86
87 opts, _ignore_args = getopt.getopt(sys.argv[1:], 'lh', ["help", "server=", "user=", "pswd="])
88
89 for name, value in opts:
90
91 if name == "-l":
92 logging = True
93 elif name == "--server":
94 server = value
95 elif name == "--user":
96 user = value
97 elif name == "--pswd":
98 pswd = value
99 else:
100 print usage()
101 raise SystemExit()
102
103 if not server or not (server.startswith("http://") or server.startswith("https://")):
104 print usage()
105 raise SystemExit()
106 splits = urlparse.urlsplit(server)
107 server = splits.scheme + "://" + splits.netloc
108 path = splits.path
109 if not path:
110 path = "/"
111
112 if not user:
113 user = raw_input("User: ")
114 if not pswd:
115 pswd = getpass("Password: ")
116
117 shell = Shell(server, path, user, pswd, logging)
118 shell.run()
119
120 if __name__ == '__main__':
121
122 runit()
123