00e3963a96
Monotone-Parent: f1c001048ccc36181a09a459327f563dbc26e12f Monotone-Revision: aab1e060a1d26a9624f7f84c30d1414ca1969560 Monotone-Author: ludovic@Sophos.ca Monotone-Date: 2010-01-24T20:40:12 Monotone-Branch: ca.inverse.sogo
46 lines
1,016 B
Python
Executable file
46 lines
1,016 B
Python
Executable file
#!/usr/bin/python
|
|
|
|
from config import hostname, port, username, password
|
|
|
|
import webdavlib
|
|
|
|
import sys
|
|
import getopt
|
|
import xml.dom.ext
|
|
|
|
def parseArguments():
|
|
arguments = {}
|
|
|
|
depth = "0"
|
|
quiet = False
|
|
(opts, args) = getopt.getopt(sys.argv[1:], "d:q", ["depth=", "quiet"])
|
|
|
|
for pair in opts:
|
|
if (pair[0] == "-d" or pair[0] == "--depth"):
|
|
depth = pair[1]
|
|
elif (pair[0] == "-q" or pair[0] == "--quiet"):
|
|
quiet = True
|
|
|
|
# print "depth: " + depth
|
|
|
|
nargs = len(args)
|
|
if (nargs > 0):
|
|
resource = args[0]
|
|
if (nargs > 1):
|
|
properties = args[1:]
|
|
else:
|
|
properties = [ "allprop" ]
|
|
else:
|
|
print "resource required"
|
|
sys.exit(-1)
|
|
|
|
client = webdavlib.WebDAVClient(hostname, port, username, password)
|
|
propfind = webdavlib.WebDAVPROPFIND(resource, properties, depth)
|
|
client.execute(propfind)
|
|
|
|
print "response:\n\n%s" % propfind.response["body"]
|
|
|
|
if propfind.response.has_key("document"):
|
|
print "document tree:"
|
|
xml.dom.ext.PrettyPrint(propfind.response["document"])
|