Update of /cvsroot/pywin32/pywin32/com/win32comext/adsi/demos
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20331/com/win32comext/adsi/demos
Modified Files:
Tag: py3k
objectPicker.py scp.py search.py test.py
Log Message:
many more upgrades to py3k syntax
Index: search.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/demos/search.py,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -C2 -d -r1.3 -r1.3.4.1
*** search.py 31 May 2005 12:43:16 -0000 1.3
--- search.py 26 Nov 2008 09:03:29 -0000 1.3.4.1
***************
*** 32,36 ****
def log(level, msg, *args):
if options.verbose >= level:
! print "log:", msg % args
def getGC():
--- 32,36 ----
def log(level, msg, *args):
if options.verbose >= level:
! print("log:", msg % args)
def getGC():
***************
*** 50,56 ****
if len(value) == 1:
value = value[0]
! print " %s=%r" % (prop_name, value)
else:
! print " %s is None" % (prop_name,)
def search():
--- 50,56 ----
if len(value) == 1:
value = value[0]
! print(" %s=%r" % (prop_name, value))
else:
! print(" %s is None" % (prop_name,))
def search():
***************
*** 72,76 ****
hr = gc.GetNextRow(h)
while hr != S_ADS_NOMORE_ROWS:
! print "-- new row --"
if attributes is None:
# Loop over all columns returned
--- 72,76 ----
hr = gc.GetNextRow(h)
while hr != S_ADS_NOMORE_ROWS:
! print("-- new row --")
if attributes is None:
# Loop over all columns returned
***************
*** 87,91 ****
data = gc.GetColumn(h, a)
print_attribute(data)
! except adsi.error, details:
if details[0] != E_ADS_COLUMN_NOT_SET:
raise
--- 87,91 ----
data = gc.GetColumn(h, a)
print_attribute(data)
! except adsi.error as details:
if details[0] != E_ADS_COLUMN_NOT_SET:
raise
Index: scp.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/demos/scp.py,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -C2 -d -r1.3 -r1.3.4.1
*** scp.py 31 May 2005 12:44:34 -0000 1.3
--- scp.py 26 Nov 2008 09:03:29 -0000 1.3.4.1
***************
*** 242,246 ****
def log(level, msg, *args):
if verbose >= level:
! print msg % args
class _NoDefault: pass
--- 242,246 ----
def log(level, msg, *args):
if verbose >= level:
! print(msg % args)
class _NoDefault: pass
***************
*** 274,278 ****
try:
ScpDelete(sc)
! except adsi.error, details:
if details[0] != winerror.ERROR_DS_OBJ_NOT_FOUND:
raise
--- 274,278 ----
try:
ScpDelete(sc)
! except adsi.error as details:
if details[0] != winerror.ERROR_DS_OBJ_NOT_FOUND:
raise
***************
*** 469,476 ****
except:
if options.show_tracebacks:
! print "--show-tracebacks specified - dumping exception"
traceback.print_exc()
raise
! except adsi.error, (hr, desc, exc, argerr):
if exc:
extra_desc = exc[2]
--- 469,477 ----
except:
if options.show_tracebacks:
! print("--show-tracebacks specified - dumping exception")
traceback.print_exc()
raise
! except adsi.error as xxx_todo_changeme:
! (hr, desc, exc, argerr) = xxx_todo_changeme.args
if exc:
extra_desc = exc[2]
***************
*** 480,484 ****
if extra_desc:
err_msg += "\n\t" + extra_desc
! except win32api.error, (hr, func, msg):
err_msg = msg
if err_msg:
--- 481,486 ----
if extra_desc:
err_msg += "\n\t" + extra_desc
! except win32api.error as xxx_todo_changeme1:
! (hr, func, msg) = xxx_todo_changeme1.args
err_msg = msg
if err_msg:
***************
*** 489,491 ****
main()
except KeyboardInterrupt:
! print "*** Interrupted"
--- 491,493 ----
main()
except KeyboardInterrupt:
! print("*** Interrupted")
Index: test.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/demos/test.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** test.py 24 Sep 2004 07:31:16 -0000 1.1
--- test.py 26 Nov 2008 09:03:29 -0000 1.1.4.1
***************
*** 16,25 ****
for item in rootdse.Get("SupportedLDAPVersion"):
! print "%s supports ldap version %s" % (path, item)
attributes = ["CurrentTime", "defaultNamingContext"]
for attr in attributes:
val = rootdse.Get(attr)
! print " %s=%s" % (attr, val)
###############################################
--- 16,25 ----
for item in rootdse.Get("SupportedLDAPVersion"):
! print("%s supports ldap version %s" % (path, item))
attributes = ["CurrentTime", "defaultNamingContext"]
for attr in attributes:
val = rootdse.Get(attr)
! print(" %s=%s" % (attr, val))
###############################################
***************
*** 39,43 ****
try:
val = child.Get(attr)
! except pythoncom.com_error, details:
continue
# ###
--- 39,43 ----
try:
val = child.Get(attr)
! except pythoncom.com_error as details:
continue
# ###
***************
*** 46,50 ****
val = "<Error: %s>" % (msg,)
if verbose_level >= 2:
! print " %s: %s=%s" % (child.Class, attr, val)
def DumpSchema():
--- 46,50 ----
val = "<Error: %s>" % (msg,)
if verbose_level >= 2:
! print(" %s: %s=%s" % (child.Class, attr, val))
def DumpSchema():
***************
*** 57,61 ****
# Bind to the actual schema container.
path= "LDAP://" + server + name
! print "Binding to", path
ob = ADsGetObject(path)
nclasses = nattr = nsub = nunk = 0
--- 57,61 ----
# Bind to the actual schema container.
path= "LDAP://" + server + name
! print("Binding to", path)
ob = ADsGetObject(path)
nclasses = nattr = nsub = nunk = 0
***************
*** 74,88 ****
nsub = nsub + 1
else:
! print "Unknown class:", class_name
nunk = nunk + 1
if verbose_level:
! print "Processed", nclasses, "classes"
! print "Processed", nattr, "attributes"
! print "Processed", nsub, "sub-schema's"
! print "Processed", nunk, "unknown types"
def _DumpObject(ob, level = 0):
prefix = " " * level
! print "%s%s object: %s" % (prefix, ob.Class, ob.Name)
# Do the directory object thing
try:
--- 74,88 ----
nsub = nsub + 1
else:
! print("Unknown class:", class_name)
nunk = nunk + 1
if verbose_level:
! print("Processed", nclasses, "classes")
! print("Processed", nattr, "attributes")
! print("Processed", nsub, "sub-schema's")
! print("Processed", nunk, "unknown types")
def _DumpObject(ob, level = 0):
prefix = " " * level
! print("%s%s object: %s" % (prefix, ob.Class, ob.Name))
# Do the directory object thing
try:
***************
*** 92,96 ****
if dir_ob is not None:
info = dir_ob.GetObjectInformation()
! print "%s RDN='%s', ObjectDN='%s'" % (prefix, info.RDN, info.ObjectDN)
# Create a list of names to fetch
names = ["distinguishedName"]
--- 92,96 ----
if dir_ob is not None:
info = dir_ob.GetObjectInformation()
! print("%s RDN='%s', ObjectDN='%s'" % (prefix, info.RDN, info.ObjectDN))
# Create a list of names to fetch
names = ["distinguishedName"]
***************
*** 98,102 ****
for attr in attrs:
for val, typ in attr.Values:
! print "%s Attribute '%s' = %s" % (prefix, attr.AttrName, val)
for child in ob:
--- 98,102 ----
for attr in attrs:
for val, typ in attr.Values:
! print("%s Attribute '%s' = %s" % (prefix, attr.AttrName, val))
for child in ob:
***************
*** 111,115 ****
# Bind to the actual schema container.
path= "LDAP://" + server + name
! print "Binding to", path
ob = ADsGetObject(path)
--- 111,115 ----
# Bind to the actual schema container.
path= "LDAP://" + server + name
! print("Binding to", path)
ob = ADsGetObject(path)
***************
*** 144,148 ****
iid_name = win32com.util.IIDToInterfaceName(item.PrimaryInterface)
if verbose_level >= 2:
! print "Class: Name=%s, Flags=%s, Primary Interface=%s" % (item.Name, desc, iid_name)
nclass = nclass + 1
elif item_class == "property":
--- 144,148 ----
iid_name = win32com.util.IIDToInterfaceName(item.PrimaryInterface)
if verbose_level >= 2:
! print("Class: Name=%s, Flags=%s, Primary Interface=%s" % (item.Name, desc, iid_name))
nclass = nclass + 1
elif item_class == "property":
***************
*** 152,166 ****
val_type = "Single-Valued"
if verbose_level >= 2:
! print "Property: Name=%s, %s" % (item.Name, val_type)
nprop = nprop + 1
elif item_class == "syntax":
data_type = vt_map.get(item.OleAutoDataType, "<unknown type>")
if verbose_level >= 2:
! print "Syntax: Name=%s, Datatype = %s" % (item.Name, data_type)
nsyntax = nsyntax + 1
if verbose_level >= 1:
! print "Processed", nclass, "classes"
! print "Processed", nprop, "properties"
! print "Processed", nsyntax, "syntax items"
def DumpGC():
--- 152,166 ----
val_type = "Single-Valued"
if verbose_level >= 2:
! print("Property: Name=%s, %s" % (item.Name, val_type))
nprop = nprop + 1
elif item_class == "syntax":
data_type = vt_map.get(item.OleAutoDataType, "<unknown type>")
if verbose_level >= 2:
! print("Syntax: Name=%s, Datatype = %s" % (item.Name, data_type))
nsyntax = nsyntax + 1
if verbose_level >= 1:
! print("Processed", nclass, "classes")
! print("Processed", nprop, "properties")
! print("Processed", nsyntax, "syntax items")
def DumpGC():
***************
*** 168,172 ****
ob = ADsGetObject("GC:", IID_IADsContainer)
for sub_ob in ob:
! print "GC ob: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath)
def DumpLocalUsers():
--- 168,172 ----
ob = ADsGetObject("GC:", IID_IADsContainer)
for sub_ob in ob:
! print("GC ob: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath))
def DumpLocalUsers():
***************
*** 176,180 ****
ob.put_Filter(["User", "Group"])
for sub_ob in ob:
! print "User/Group: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath)
def DumpLocalGroups():
--- 176,180 ----
ob.put_Filter(["User", "Group"])
for sub_ob in ob:
! print("User/Group: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath))
def DumpLocalGroups():
***************
*** 185,204 ****
ob.put_Filter(["Group"])
for sub_ob in ob:
! print "Group: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath)
# get the members
members = sub_ob.Members()
for member in members:
! print " Group member: %s (%s)" % (member.Name, member.ADsPath)
def usage(tests):
import os
! print "Usage: %s [-s server ] [-v] [Test ...]" % os.path.basename(sys.argv[0])
! print " -v : Verbose - print more information"
! print " -s : server - execute the tests against the named server"
! print "where Test is one of:"
for t in tests:
! print t.__name__,":", t.__doc__
! print
! print "If not tests are specified, all tests are run"
sys.exit(1)
--- 185,204 ----
ob.put_Filter(["Group"])
for sub_ob in ob:
! print("Group: %s (%s)" % (sub_ob.Name, sub_ob.ADsPath))
# get the members
members = sub_ob.Members()
for member in members:
! print(" Group member: %s (%s)" % (member.Name, member.ADsPath))
def usage(tests):
import os
! print("Usage: %s [-s server ] [-v] [Test ...]" % os.path.basename(sys.argv[0]))
! print(" -v : Verbose - print more information")
! print(" -s : server - execute the tests against the named server")
! print("where Test is one of:")
for t in tests:
! print(t.__name__,":", t.__doc__)
! print()
! print("If not tests are specified, all tests are run")
sys.exit(1)
***************
*** 223,227 ****
if len(args)==0:
! print "Running all tests - use '-h' to see command-line options..."
dotests = tests
else:
--- 223,227 ----
if len(args)==0:
! print("Running all tests - use '-h' to see command-line options...")
dotests = tests
else:
***************
*** 233,239 ****
break
else:
! print "Test '%s' unknown - skipping" % arg
if not len(dotests):
! print "Nothing to do!"
usage(tests)
for test in dotests:
--- 233,239 ----
break
else:
! print("Test '%s' unknown - skipping" % arg)
if not len(dotests):
! print("Nothing to do!")
usage(tests)
for test in dotests:
***************
*** 241,245 ****
test()
except:
! print "Test %s failed" % test.__name__
traceback.print_exc()
--- 241,245 ----
test()
except:
! print("Test %s failed" % test.__name__)
traceback.print_exc()
Index: objectPicker.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32comext/adsi/demos/objectPicker.py,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** objectPicker.py 26 May 2005 11:39:18 -0000 1.1
--- objectPicker.py 26 Nov 2008 09:03:29 -0000 1.1.4.1
***************
*** 48,57 ****
for item in data:
name, klass, adspath, upn, attrs, flags = item
! print "Item", name
! print " Class:", klass
! print " AdsPath:", adspath
! print " UPN:", upn
! print " Attrs:", attrs
! print " Flags:", flags
if __name__=='__main__':
--- 48,57 ----
for item in data:
name, klass, adspath, upn, attrs, flags = item
! print("Item", name)
! print(" Class:", klass)
! print(" AdsPath:", adspath)
! print(" UPN:", upn)
! print(" Attrs:", attrs)
! print(" Flags:", flags)
if __name__=='__main__':
|