diff options
-rw-r--r-- | python/samba/netcmd/__init__.py | 2 | ||||
-rw-r--r-- | python/samba/netcmd/delegation.py | 8 | ||||
-rw-r--r-- | python/samba/netcmd/dns.py | 2 | ||||
-rw-r--r-- | python/samba/netcmd/domain.py | 14 | ||||
-rw-r--r-- | python/samba/netcmd/drs.py | 14 | ||||
-rw-r--r-- | python/samba/netcmd/fsmo.py | 6 | ||||
-rw-r--r-- | python/samba/netcmd/gpo.py | 24 | ||||
-rw-r--r-- | python/samba/netcmd/group.py | 14 | ||||
-rw-r--r-- | python/samba/netcmd/ldapcmp.py | 2 | ||||
-rw-r--r-- | python/samba/netcmd/ntacl.py | 8 | ||||
-rw-r--r-- | python/samba/netcmd/ou.py | 24 | ||||
-rw-r--r-- | python/samba/netcmd/rodc.py | 4 | ||||
-rw-r--r-- | python/samba/netcmd/sites.py | 10 | ||||
-rw-r--r-- | python/samba/netcmd/testparm.py | 2 | ||||
-rw-r--r-- | python/samba/netcmd/user.py | 20 |
15 files changed, 77 insertions, 77 deletions
diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py index fcad7f6399d..9037d033190 100644 --- a/python/samba/netcmd/__init__.py +++ b/python/samba/netcmd/__init__.py @@ -174,7 +174,7 @@ class Command(object): try: return self.run(*args, **kwargs) - except Exception, e: + except Exception as e: self.show_command_error(e) return -1 diff --git a/python/samba/netcmd/delegation.py b/python/samba/netcmd/delegation.py index 39397bbcc75..49e5957c2b7 100644 --- a/python/samba/netcmd/delegation.py +++ b/python/samba/netcmd/delegation.py @@ -138,7 +138,7 @@ class cmd_delegation_for_any_service(Command): sam.toggle_userAccountFlags(search_filter, flag, flags_str="Trusted-for-Delegation", on=on, strict=True) - except Exception, err: + except Exception as err: raise CommandError(err) @@ -192,7 +192,7 @@ class cmd_delegation_for_any_protocol(Command): sam.toggle_userAccountFlags(search_filter, flag, flags_str="Trusted-to-Authenticate-for-Delegation", on=on, strict=True) - except Exception, err: + except Exception as err: raise CommandError(err) @@ -246,7 +246,7 @@ class cmd_delegation_add_service(Command): "msDS-AllowedToDelegateTo") try: sam.modify(msg) - except Exception, err: + except Exception as err: raise CommandError(err) @@ -300,7 +300,7 @@ class cmd_delegation_del_service(Command): "msDS-AllowedToDelegateTo") try: sam.modify(msg) - except Exception, err: + except Exception as err: raise CommandError(err) diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py index 33f81ee7fca..8bd6a9bf8a0 100644 --- a/python/samba/netcmd/dns.py +++ b/python/samba/netcmd/dns.py @@ -47,7 +47,7 @@ def dns_connect(server, lp, creds): binding_str = "ncacn_ip_tcp:%s[sign]" % server try: dns_conn = dnsserver.dnsserver(binding_str, lp, creds) - except RuntimeError, e: + except RuntimeError as e: raise CommandError('Connecting to DNS RPC server %s failed with %s' % (server, e)) return dns_conn diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 2cb14f150ec..52c70acfacc 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -499,7 +499,7 @@ class cmd_domain_provision(Command): base_schema=base_schema, plaintext_secrets=plaintext_secrets) - except ProvisioningError, e: + except ProvisioningError as e: raise CommandError("Provision failed", e) result.report_logger(self.logger) @@ -865,7 +865,7 @@ class cmd_domain_demote(Command): dc_dn = res[0].dn uac = int(str(res[0]["userAccountControl"])) - except Exception, e: + except Exception as e: if not (dsa_options & DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL) and not samdb.am_rodc(): self.errf.write( "Error while demoting, re-enabling inbound replication\n") @@ -897,7 +897,7 @@ class cmd_domain_demote(Command): "userAccountControl") try: remote_samdb.modify(msg) - except Exception, e: + except Exception as e: if not (dsa_options & DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL) and not samdb.am_rodc(): self.errf.write( "Error while demoting, re-enabling inbound replication") @@ -952,7 +952,7 @@ class cmd_domain_demote(Command): try: newdn = ldb.Dn(remote_samdb, "%s,%s" % (newrdn, str(computer_dn))) remote_samdb.rename(dc_dn, newdn) - except Exception, e: + except Exception as e: if not (dsa_options & DS_NTDSDSA_OPT_DISABLE_OUTBOUND_REPL) and not samdb.am_rodc(): self.errf.write( "Error while demoting, re-enabling inbound replication\n") @@ -1012,7 +1012,7 @@ class cmd_domain_demote(Command): try: remote_samdb.delete(ldb.Dn(remote_samdb, "%s,%s" % (s, str(newdn)))) - except ldb.LdbError, l: + except ldb.LdbError as l: pass self.errf.write("Demote successful\n") @@ -1328,7 +1328,7 @@ class cmd_domain_passwordsettings(Command): else: cur_account_lockout_duration = abs(int(res[0]["lockoutDuration"][0])) / (1e7 * 60) cur_reset_account_lockout_after = abs(int(res[0]["lockOutObservationWindow"][0])) / (1e7 * 60) - except Exception, e: + except Exception as e: raise CommandError("Could not retrieve password properties!", e) if subcommand == "show": @@ -3853,7 +3853,7 @@ This command expunges tombstones from the database.""" current_time=current_time, tombstone_lifetime=tombstone_lifetime) - except Exception, err: + except Exception as err: if started_transaction: samdb.transaction_cancel() raise CommandError("Failed to expunge / garbage collect tombstones", err) diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index a45b9062827..5498f098714 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -42,7 +42,7 @@ def drsuapi_connect(ctx): '''make a DRSUAPI connection to the server''' try: (ctx.drsuapi, ctx.drsuapi_handle, ctx.bind_supported_extensions) = drs_utils.drsuapi_connect(ctx.server, ctx.lp, ctx.creds) - except Exception, e: + except Exception as e: raise CommandError("DRS connection to %s failed" % ctx.server, e) def samdb_connect(ctx): @@ -51,7 +51,7 @@ def samdb_connect(ctx): ctx.samdb = SamDB(url="ldap://%s" % ctx.server, session_info=system_session(), credentials=ctx.creds, lp=ctx.lp) - except Exception, e: + except Exception as e: raise CommandError("LDAP connection to %s failed" % ctx.server, e) def drs_errmsg(werr): @@ -143,7 +143,7 @@ class cmd_drs_showrepl(Command): try: (info_type, info) = self.drsuapi.DsReplicaGetInfo( self.drsuapi_handle, 1, req1) - except Exception, e: + except Exception as e: raise CommandError("DsReplicaGetInfo of type %u failed" % info_type, e) return (info_type, info) @@ -166,7 +166,7 @@ class cmd_drs_showrepl(Command): (site, server) = drs_parse_ntds_dn(ntds_dn) try: ntds = self.samdb.search(base=ntds_dn, scope=ldb.SCOPE_BASE, attrs=['options', 'objectGUID', 'invocationId']) - except Exception, e: + except Exception as e: raise CommandError("Failed to search NTDS DN %s" % ntds_dn) dsa_details = { @@ -300,7 +300,7 @@ class cmd_drs_kcc(Command): req1 = drsuapi.DsExecuteKCC1() try: self.drsuapi.DsExecuteKCC(self.drsuapi_handle, 1, req1) - except Exception, e: + except Exception as e: raise CommandError("DsExecuteKCC failed", e) self.message("Consistency check on %s successful." % DC) @@ -351,7 +351,7 @@ def drs_local_replicate(self, SOURCE_DC, NC, full_sync=False, single_object=Fals source_dsa_invocation_id, destination_dsa_guid, rodc=rodc, full_sync=full_sync, exop=exop, sync_forced=sync_forced) - except Exception, e: + except Exception as e: raise CommandError("Error replicating DN %s" % NC, e) self.samdb.transaction_commit() @@ -452,7 +452,7 @@ class cmd_drs_replicate(Command): try: drs_utils.sendDsReplicaSync(server_bind, server_bind_handle, source_dsa_guid, NC, req_options) - except drs_utils.drsException, estr: + except drs_utils.drsException as estr: raise CommandError("DsReplicaSync failed", estr) if async_op: self.message("Replicate from %s to %s was started." % (SOURCE_DC, DEST_DC)) diff --git a/python/samba/netcmd/fsmo.py b/python/samba/netcmd/fsmo.py index 62b3e438e18..c00e8dda45b 100644 --- a/python/samba/netcmd/fsmo.py +++ b/python/samba/netcmd/fsmo.py @@ -126,7 +126,7 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb): try: connection = samba.drs_utils.drsuapi_connect(samdb.host_dns_name(), lp, creds) - except samba.drs_utils.drsException, e: + except samba.drs_utils.drsException as e: raise CommandError("Drsuapi Connect failed", e) try: @@ -138,7 +138,7 @@ def transfer_dns_role(outf, sambaopts, credopts, role, samdb): drsuapi_handle, master_guid, NC, req_options) - except samba.drs_utils.drsException, estr: + except samba.drs_utils.drsException as estr: raise CommandError("Replication failed", estr) outf.write("FSMO transfer of '%s' role successful\n" % role) @@ -463,7 +463,7 @@ class cmd_fsmo_show(Command): self.message("%s owner: %s" % (long_name, str(master))) else: self.message("%s has no current owner" % (long_name)) - except CommandError, e: + except CommandError as e: self.message("%s: * %s" % (long_name, e.message)) class cmd_fsmo_transfer(Command): diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 23b562eb635..5f4ad0ebca0 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -52,7 +52,7 @@ def samdb_connect(ctx): ctx.samdb = SamDB(url=ctx.url, session_info=system_session(), credentials=ctx.creds, lp=ctx.lp) - except Exception, e: + except Exception as e: raise CommandError("LDAP connection to %s failed " % ctx.url, e) @@ -113,7 +113,7 @@ def dc_url(lp, creds, url=None, dc=None): if dc is None: try: dc = netcmd_finddc(lp, creds) - except Exception, e: + except Exception as e: raise RuntimeError("Could not find a DC for domain", e) url = 'ldap://' + dc return url @@ -159,7 +159,7 @@ def get_gpo_info(samdb, gpo=None, displayname=None, dn=None, 'displayName', 'gPCFileSysPath'], controls=['sd_flags:1:%d' % sd_flags]) - except Exception, e: + except Exception as e: if gpo is not None: mesg = "Cannot get information for GPO %s" % gpo else: @@ -175,7 +175,7 @@ def get_gpo_containers(samdb, gpo): search_expr = "(&(objectClass=*)(gPLink=*%s*))" % gpo try: msg = samdb.search(expression=search_expr, attrs=['gPLink']) - except Exception, e: + except Exception as e: raise CommandError("Could not find container(s) with GPO %s" % gpo, e) return msg @@ -188,7 +188,7 @@ def del_gpo_link(samdb, container_dn, gpo): msg = samdb.search(base=container_dn, scope=ldb.SCOPE_BASE, expression="(objectClass=*)", attrs=['gPLink'])[0] - except Exception, e: + except Exception as e: raise CommandError("Container '%s' does not exist" % container_dn, e) found = False @@ -215,7 +215,7 @@ def del_gpo_link(samdb, container_dn, gpo): m['d0'] = ldb.MessageElement(msg['gPLink'][0], ldb.FLAG_MOD_DELETE, 'gPLink') try: samdb.modify(m) - except Exception, e: + except Exception as e: raise CommandError("Error removing GPO from container", e) @@ -617,7 +617,7 @@ class cmd_setlink(Command): try: self.samdb.modify(m) - except Exception, e: + except Exception as e: raise CommandError("Error adding GPO Link", e) self.outf.write("Added/Updated GPO link\n") @@ -793,7 +793,7 @@ class cmd_setinheritance(Command): try: self.samdb.modify(m) - except Exception, e: + except Exception as e: raise CommandError("Error setting inheritance state %s" % inherit_state, e) @@ -864,7 +864,7 @@ class cmd_fetch(Command): try: os.mkdir(gpodir) copy_directory_remote_to_local(conn, sharepath, gpodir) - except Exception, e: + except Exception as e: # FIXME: Catch more specific exception raise CommandError("Error copying GPO from DC", e) self.outf.write('GPO copied to %s\n' % gpodir) @@ -944,14 +944,14 @@ class cmd_create(Command): os.mkdir(os.path.join(gpodir, "User")) gpt_contents = "[General]\r\nVersion=0\r\n" file(os.path.join(gpodir, "GPT.INI"), "w").write(gpt_contents) - except Exception, e: + except Exception as e: raise CommandError("Error Creating GPO files", e) # Connect to DC over SMB [dom_name, service, sharepath] = parse_unc(unc_path) try: conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds) - except Exception, e: + except Exception as e: raise CommandError("Error connecting to '%s' using SMB" % dc_hostname, e) self.samdb.transaction_start() @@ -1064,7 +1064,7 @@ class cmd_del(Command): [dom_name, service, sharepath] = parse_unc(unc_path) try: conn = smb.SMB(dc_hostname, service, lp=self.lp, creds=self.creds) - except Exception, e: + except Exception as e: raise CommandError("Error connecting to '%s' using SMB" % dc_hostname, e) self.samdb.transaction_start() diff --git a/python/samba/netcmd/group.py b/python/samba/netcmd/group.py index 782a1ef1014..a4969cc6ba9 100644 --- a/python/samba/netcmd/group.py +++ b/python/samba/netcmd/group.py @@ -124,7 +124,7 @@ Example3 adds a new RFC2307 enabled group for NIS domain samdom and GID 12345 (b samdb.newgroup(groupname, groupou=groupou, grouptype = gtype, description=description, mailaddress=mail_address, notes=notes, gidnumber=gid_number, nisdomain=nis_domain) - except Exception, e: + except Exception as e: # FIXME: catch more specific exception raise CommandError('Failed to create group "%s"' % groupname, e) self.outf.write("Added group %s\n" % groupname) @@ -186,7 +186,7 @@ Example2 deletes group Group2 from the local server. The command is run under r try: samdb.delete(group_dn) - except Exception, e: + except Exception as e: # FIXME: catch more specific exception raise CommandError('Failed to remove group "%s"' % groupname, e) self.outf.write("Deleted group %s\n" % groupname) @@ -239,7 +239,7 @@ Example2 shows how to add a single user account, User2, to the supergroup AD gro groupmembers = listofmembers.split(',') samdb.add_remove_group_members(groupname, groupmembers, add_members_operation=True) - except Exception, e: + except Exception as e: # FIXME: catch more specific exception raise CommandError('Failed to add members "%s" to group "%s"' % ( listofmembers, groupname), e) @@ -290,7 +290,7 @@ Example2 shows how to remove a single user account, User2, from the supergroup A credentials=creds, lp=lp) samdb.add_remove_group_members(groupname, listofmembers.split(","), add_members_operation=False) - except Exception, e: + except Exception as e: # FIXME: Catch more specific exception raise CommandError('Failed to remove members "%s" from group "%s"' % (listofmembers, groupname), e) self.outf.write("Removed members from group %s\n" % groupname) @@ -418,7 +418,7 @@ samba-tool group listmembers \"Domain Users\" -H ldap://samba.samdom.example.com member_name = msg.get("cn", idx=0) self.outf.write("%s\n" % member_name) - except Exception, e: + except Exception as e: raise CommandError('Failed to list members of "%s" group ' % groupname, e) class cmd_group_move(Command): @@ -485,7 +485,7 @@ class cmd_group_move(Command): try: full_new_parent_dn = samdb.normalize_dn_in_domain(new_parent_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid new_parent_dn "%s": %s' % (new_parent_dn, e.message)) @@ -495,7 +495,7 @@ class cmd_group_move(Command): try: samdb.rename(group_dn, full_new_group_dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to move group "%s"' % groupname, e) self.outf.write('Moved group "%s" into "%s"\n' % (groupname, full_new_parent_dn)) diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index 7b8d93e07fa..0c0a76cadba 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -131,7 +131,7 @@ class LDAPBase(object): def delete_force(self, object_dn): try: self.ldb.delete(object_dn) - except Ldb.LdbError, e: + except Ldb.LdbError as e: assert "No such object" in str(e) def get_attribute_name(self, key): diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py index eaea0e7af17..5aeb667d8fb 100644 --- a/python/samba/netcmd/ntacl.py +++ b/python/samba/netcmd/ntacl.py @@ -71,7 +71,7 @@ class cmd_ntacl_set(Command): try: samdb = SamDB(session_info=system_session(), lp=lp) - except Exception, e: + except Exception as e: raise CommandError("Unable to open samdb:", e) if not use_ntvfs and not use_s3fs: @@ -146,7 +146,7 @@ class cmd_ntacl_get(Command): try: samdb = SamDB(session_info=system_session(), lp=lp) - except Exception, e: + except Exception as e: raise CommandError("Unable to open samdb:", e) if not use_ntvfs and not use_s3fs: @@ -199,7 +199,7 @@ class cmd_ntacl_sysvolreset(Command): try: samdb = SamDB(session_info=system_session(), lp=lp) - except Exception, e: + except Exception as e: raise CommandError("Unable to open samdb:", e) if not use_ntvfs and not use_s3fs: @@ -259,7 +259,7 @@ class cmd_ntacl_sysvolcheck(Command): sysvol = lp.get("path", "sysvol") try: samdb = SamDB(session_info=system_session(), lp=lp) - except Exception, e: + except Exception as e: raise CommandError("Unable to open samdb:", e) domain_sid = security.dom_sid(samdb.domain_sid) diff --git a/python/samba/netcmd/ou.py b/python/samba/netcmd/ou.py index 16b7f653f71..61717678cd4 100644 --- a/python/samba/netcmd/ou.py +++ b/python/samba/netcmd/ou.py @@ -70,12 +70,12 @@ class cmd_rename(Command): try: full_old_ou_dn = samdb.normalize_dn_in_domain(old_ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid old_ou_dn "%s": %s' % (old_ou_dn, e.message)) try: full_new_ou_dn = samdb.normalize_dn_in_domain(new_ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid new_ou_dn "%s": %s' % (new_ou_dn, e.message)) @@ -88,7 +88,7 @@ class cmd_rename(Command): return samdb.rename(full_old_ou_dn, full_new_ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to rename ou "%s"' % full_old_ou_dn, e) self.outf.write('Renamed ou "%s" to "%s"\n' % (full_old_ou_dn, full_new_ou_dn)) @@ -134,12 +134,12 @@ class cmd_move(Command): domain_dn = ldb.Dn(samdb, samdb.domain_dn()) try: full_old_ou_dn = samdb.normalize_dn_in_domain(old_ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid old_ou_dn "%s": %s' % (old_ou_dn, e.message)) try: full_new_parent_dn = samdb.normalize_dn_in_domain(new_parent_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid new_parent_dn "%s": %s' % (new_parent_dn, e.message)) @@ -155,7 +155,7 @@ class cmd_move(Command): self.outf.write('Unable to find ou "%s"\n' % full_old_ou_dn) return samdb.rename(full_old_ou_dn, full_new_ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to move ou "%s"' % full_old_ou_dn, e) self.outf.write('Moved ou "%s" into "%s"\n' % (full_old_ou_dn, full_new_parent_dn)) @@ -199,12 +199,12 @@ class cmd_create(Command): try: full_ou_dn = samdb.normalize_dn_in_domain(ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid ou_dn "%s": %s' % (ou_dn, e.message)) try: samdb.create_ou(full_ou_dn, description=description) - except Exception, e: + except Exception as e: raise CommandError('Failed to create ou "%s"' % full_ou_dn, e) self.outf.write('Created ou "%s"\n' % full_ou_dn) @@ -250,7 +250,7 @@ class cmd_listobjects(Command): try: full_ou_dn = samdb.normalize_dn_in_domain(ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid ou_dn "%s": %s' % (ou_dn, e.message)) minchilds = 0 @@ -274,7 +274,7 @@ class cmd_listobjects(Command): child.dn.remove_base_components(len(domain_dn)) self.outf.write("%s\n" % child.dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to list contents of ou "%s"' % full_ou_dn, e) @@ -362,7 +362,7 @@ class cmd_delete(Command): try: full_ou_dn = samdb.normalize_dn_in_domain(ou_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid ou_dn "%s": %s' % (ou_dn, e.message)) controls = [] @@ -377,7 +377,7 @@ class cmd_delete(Command): self.outf.write('Unable to find ou "%s"\n' % ou_dn) return samdb.delete(full_ou_dn, controls) - except Exception, e: + except Exception as e: raise CommandError('Failed to delete ou "%s"' % full_ou_dn, e) self.outf.write('Deleted ou "%s"\n' % full_ou_dn) diff --git a/python/samba/netcmd/rodc.py b/python/samba/netcmd/rodc.py index 533f9446a09..000858d5945 100644 --- a/python/samba/netcmd/rodc.py +++ b/python/samba/netcmd/rodc.py @@ -127,7 +127,7 @@ class cmd_rodc_preload(Command): try: dn = self.get_dn(samdb, account) - except RODCException, e: + except RODCException as e: if not ignore_errors: raise CommandError(str(e)) errors.append(e) @@ -139,7 +139,7 @@ class cmd_rodc_preload(Command): try: repl.replicate(dn, source_dsa_invocation_id, destination_dsa_guid, exop=drsuapi.DRSUAPI_EXOP_REPL_SECRET, rodc=True) - except Exception, e: + except Exception as e: local_samdb.transaction_cancel() if not ignore_errors: raise CommandError("Error replicating DN %s" % dn) diff --git a/python/samba/netcmd/sites.py b/python/samba/netcmd/sites.py index d0b7b9f4e6a..38b251ca8fe 100644 --- a/python/samba/netcmd/sites.py +++ b/python/samba/netcmd/sites.py @@ -57,7 +57,7 @@ class cmd_sites_create(Command): try: sites.create_site(samdb, samdb.get_config_basedn(), sitename) samdb.transaction_commit() - except sites.SiteAlreadyExistsException, e: + except sites.SiteAlreadyExistsException as e: samdb.transaction_cancel() raise CommandError("Error while creating site %s, error: %s" % (sitename, str(e))) @@ -94,7 +94,7 @@ class cmd_sites_delete(Command): try: sites.delete_site(samdb, samdb.get_config_basedn(), sitename) samdb.transaction_commit() - except sites.SiteException, e: + except sites.SiteException as e: samdb.transaction_cancel() raise CommandError( "Error while removing site %s, error: %s" % (sitename, str(e))) @@ -130,7 +130,7 @@ class cmd_sites_subnet_create(Command): subnets.create_subnet(samdb, samdb.get_config_basedn(), subnetname, site_of_subnet) samdb.transaction_commit() - except subnets.SubnetException, e: + except subnets.SubnetException as e: samdb.transaction_cancel() raise CommandError("Error while creating subnet %s: %s" % (subnetname, e)) @@ -167,7 +167,7 @@ class cmd_sites_subnet_delete(Command): try: subnets.delete_subnet(samdb, samdb.get_config_basedn(), subnetname) samdb.transaction_commit() - except subnets.SubnetException, e: + except subnets.SubnetException as e: samdb.transaction_cancel() raise CommandError("Error while removing subnet %s, error: %s" % (subnetname, e)) @@ -203,7 +203,7 @@ class cmd_sites_subnet_set_site(Command): subnets.set_subnet_site(samdb, samdb.get_config_basedn(), subnetname, site_of_subnet) samdb.transaction_commit() - except subnets.SubnetException, e: + except subnets.SubnetException as e: samdb.transaction_cancel() raise CommandError("Error assigning subnet %s to site %s: %s" % (subnetname, site_of_subnet, e)) diff --git a/python/samba/netcmd/testparm.py b/python/samba/netcmd/testparm.py index f9099b34e6d..2cd0897dfea 100644 --- a/python/samba/netcmd/testparm.py +++ b/python/samba/netcmd/testparm.py @@ -84,7 +84,7 @@ class cmd_testparm(Command): try: lp = sambaopts.get_loadparm() - except RuntimeError, err: + except RuntimeError as err: raise CommandError(err) # We need this to force the output diff --git a/python/samba/netcmd/user.py b/python/samba/netcmd/user.py index 478e263a9bd..94959bbe2ba 100644 --- a/python/samba/netcmd/user.py +++ b/python/samba/netcmd/user.py @@ -378,7 +378,7 @@ Example5 shows how to create an RFC2307/NIS domain enabled user account. If uidnumber=uid_number, gidnumber=gid_number, gecos=gecos, loginshell=login_shell, smartcard_required=smartcard_required) - except Exception, e: + except Exception as e: raise CommandError("Failed to add user '%s': " % username, e) self.outf.write("User '%s' created successfully\n" % username) @@ -453,7 +453,7 @@ Example2 shows how to delete a user in the domain against the local server. su try: samdb.delete(user_dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to remove user "%s"' % username, e) self.outf.write("Deleted user %s\n" % username) @@ -557,7 +557,7 @@ Example3 shows how to enable a user in the domain against a local LDAP server. credentials=creds, lp=lp) try: samdb.enable_account(filter) - except Exception, msg: + except Exception as msg: raise CommandError("Failed to enable user '%s': %s" % (username or filter, msg)) self.outf.write("Enabled user '%s'\n" % (username or filter)) @@ -596,7 +596,7 @@ class cmd_user_disable(Command): credentials=creds, lp=lp) try: samdb.disable_account(filter) - except Exception, msg: + except Exception as msg: raise CommandError("Failed to disable user '%s': %s" % (username or filter, msg)) @@ -663,7 +663,7 @@ Example4 shows how to set the account expiration so that it will never expire. try: samdb.setexpiry(filter, days*24*3600, no_expiry_req=noexpiry) - except Exception, msg: + except Exception as msg: # FIXME: Catch more specific exception raise CommandError("Failed to set expiry for user '%s': %s" % ( username or filter, msg)) @@ -714,7 +714,7 @@ class cmd_user_password(Command): try: net.change_password(password.encode('utf-8')) - except Exception, msg: + except Exception as msg: # FIXME: catch more specific exception raise CommandError("Failed to change password : %s" % msg) self.outf.write("Changed password OK\n") @@ -832,7 +832,7 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas samdb.toggle_userAccountFlags(filter, flags, on=True) command = "Failed to enable account for user '%s'" % (username or filter) samdb.enable_account(filter) - except Exception, msg: + except Exception as msg: # FIXME: catch more specific exception raise CommandError("%s: %s" % (command, msg)) self.outf.write("Added UF_SMARTCARD_REQUIRED OK\n") @@ -847,7 +847,7 @@ Example3 shows how an administrator would reset TestUser3 user's password to pas samdb.setpassword(filter, password, force_change_at_next_login=must_change_at_next_login, username=username) - except Exception, msg: + except Exception as msg: # FIXME: catch more specific exception raise CommandError("%s: %s" % (command, msg)) self.outf.write("Changed password OK\n") @@ -2561,7 +2561,7 @@ class cmd_user_move(Command): try: full_new_parent_dn = samdb.normalize_dn_in_domain(new_parent_dn) - except Exception, e: + except Exception as e: raise CommandError('Invalid new_parent_dn "%s": %s' % (new_parent_dn, e.message)) @@ -2571,7 +2571,7 @@ class cmd_user_move(Command): try: samdb.rename(user_dn, full_new_user_dn) - except Exception, e: + except Exception as e: raise CommandError('Failed to move user "%s"' % username, e) self.outf.write('Moved user "%s" into "%s"\n' % (username, full_new_parent_dn)) |