data = Function(conn, i)
try:
data.find_idl()
- except Exception, e:
+ except Exception as e:
print "Error: %r" % e
ldif += "\nobjectClass: " + o.name
try:
ldb.add(ldif)
- except LdbError, e:
+ except LdbError as e:
print "error adding %s: %s" % (o.name, e)
print "%s" % ldif
return
attrs = ["allowedAttributes"]
try:
res = ldb.search("objectClass=*", dn, SCOPE_BASE, attrs)
- except LdbError, e:
+ except LdbError as e:
print >>sys.stderr, "Unable to fetch allowedAttributes for '%s' - %r" % (dn, e)
return
allattrs = res[0]["allowedAttributes"]
try:
res = ldb.search("objectClass=*", dn, SCOPE_BASE, allattrs)
- except LdbError, e:
+ except LdbError as e:
print >>sys.stderr, "Unable to fetch all attributes for '%s' - %s" % (dn, e)
return
msg = res[0]
try:
res = ldb.search("objectClass=*", namingContext, SCOPE_DEFAULT,
["objectClass"])
- except LdbError, e:
+ except LdbError as e:
print >>sys.stderr, "Unable to fetch objectClasses for '%s' - %s" % (namingContext, e)
return
for msg in res:
try:
Cmd.onecmd(self, line)
- except dcerpc.NTSTATUS, arg:
+ except dcerpc.NTSTATUS as arg:
print 'The command returned an error: %s' % arg[1]
# Command handlers
try:
retval = cmd._run("samba-tool", subcommand, *args)
-except SystemExit, e:
+except SystemExit as e:
retval = e.code
-except Exception, e:
+except Exception as e:
cmd.show_command_error(e)
retval = 1
sys.exit(retval)
error_count = error_count + 1
if opts.verbose:
print("Failed nsupdate: %d" % ret)
- except Exception, estr:
+ except Exception as estr:
if opts.fail_immediately:
sys.exit(1)
error_count = error_count + 1
error_count = error_count + 1
if opts.verbose:
print("Failed 'samba-tool dns' based update of %s" % (str(d)))
- except Exception, estr:
+ except Exception as estr:
if opts.fail_immediately:
sys.exit(1)
error_count = error_count + 1
if ret_names.names[0].status != 0:
print("Failed to set DNS entry: %s (status %u)" % (d, ret_names.names[0].status))
error_count = error_count + 1
- except RuntimeError, reason:
+ except RuntimeError as reason:
print("Error setting DNS entry of type %u: %s: %s" % (t, d, reason))
error_count = error_count + 1
attempt_live_connections=opts.attempt_live_connections)
sys.exit(rc)
-except GraphError, e:
+except GraphError as e:
print e
sys.exit(1)
net = Net(creds=creds, lp=lp)
try:
cldap_ret = net.finddc(domain=domain, flags=nbt.NBT_SERVER_DS | nbt.NBT_SERVER_WRITABLE)
- except Exception, reason:
+ except Exception as reason:
print("Unable to find writeable DC for domain '%s' to send DRS writeSPN to : %s" % (domain, reason))
sys.exit(1)
server = cldap_ret.pdc_dns_name
binding_options += ",print"
drs = drsuapi.drsuapi('ncacn_ip_tcp:%s[%s]' % (server, binding_options), lp, creds)
(drs_handle, supported_extensions) = drs_utils.drs_DsBind(drs)
- except Exception, reason:
+ except Exception as reason:
print("Unable to connect to DC '%s' for domain '%s' : %s" % (server, domain, reason))
sys.exit(1)
req1 = drsuapi.DsWriteAccountSpnRequest1()
zone = dns.zone.from_file(paths.dns, relativize=False)
rrset = zone.get_rdataset("%s." % dnsdomain, dns.rdatatype.SOA)
serial = int(rrset[0].serial)
- except Exception, e:
+ except Exception as e:
logger.warn("Error parsing DNS data from '%s' (%s)" % (paths.dns, str(e)))
logger.warn("DNS records will be automatically created")
autofill = True
message(SIMPLE, "There are %d changed objects" % (changed))
return 1
- except StandardError, err:
+ except StandardError as err:
message(ERROR, "Exception during upgrade of samdb:")
(typ, val, tb) = sys.exc_info()
traceback.print_exception(typ, val, tb)
delta["nTSecurityDescriptor"] = MessageElement(descr, FLAG_MOD_REPLACE,
"nTSecurityDescriptor")
samdb.modify(delta, ["sd_flags:1:%d" % sd_flags,"relax:0","local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK])
- except LdbError, e:
+ except LdbError as e:
samdb.transaction_cancel()
res = samdb.search(expression="objectClass=*", base=str(delta.dn),
scope=SCOPE_BASE,
if opts.full:
try:
update_gpo(paths, ldbs.sam, names, lp, message)
- except ProvisioningError, e:
+ except ProvisioningError as e:
message(ERROR, "The policy for domain controller is missing. "
"You should restart upgradeprovision with --full")
message(SIMPLE, "Reindexing finished")
shutil.rmtree(provisiondir)
- except StandardError, err:
+ except StandardError as err:
message(ERROR, "A problem occurred while trying to upgrade your "
"provision. A full backup is located at %s" % backupdir)
if opts.debugall or opts.debugchange:
for line in fp:
html_str += line.strip()
fp.close()
- except IOError, e:
+ except IOError as e:
print "error loading url: " + e.strerror
pass