diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2018-02-14 10:18:36 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2018-02-15 00:18:30 +0100 |
commit | 4885937bf87e6c37c60cda890dc18d46b5868a91 (patch) | |
tree | 0802ebd0f6086dbf2a81d3882a34181858264493 /python | |
parent | a485ac32438b74315ffd4a7188909f00e175d4fa (diff) | |
download | samba-4885937bf87e6c37c60cda890dc18d46b5868a91.tar.gz |
samba python libs: convert 'except X, e' to 'except X as e'
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/samba/dbchecker.py | 10 | ||||
-rw-r--r-- | python/samba/drs_utils.py | 6 | ||||
-rw-r--r-- | python/samba/kcc/__init__.py | 4 | ||||
-rw-r--r-- | python/samba/kcc/graph_utils.py | 2 | ||||
-rw-r--r-- | python/samba/kcc/kcc_utils.py | 6 | ||||
-rw-r--r-- | python/samba/kcc/ldif_import_export.py | 2 | ||||
-rw-r--r-- | python/samba/provision/backend.py | 2 | ||||
-rw-r--r-- | python/samba/upgrade.py | 30 | ||||
-rw-r--r-- | python/samba/web_server/__init__.py | 2 |
9 files changed, 32 insertions, 32 deletions
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py index b2b8b0c9558..5e06d1f3b40 100644 --- a/python/samba/dbchecker.py +++ b/python/samba/dbchecker.py @@ -369,7 +369,7 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix), try: controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK] self.samdb.delete(dn, controls=controls) - except Exception, err: + except Exception as err: if self.in_transaction: raise CommandError("%s : %s" % (msg, err)) self.report("%s : %s" % (msg, err)) @@ -383,7 +383,7 @@ systemFlags: -1946157056%s""" % (dn, guid_suffix), try: controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK] self.samdb.modify(m, controls=controls, validate=validate) - except Exception, err: + except Exception as err: if self.in_transaction: raise CommandError("%s : %s" % (msg, err)) self.report("%s : %s" % (msg, err)) @@ -402,7 +402,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) to_dn = to_rdn + to_base controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK] self.samdb.rename(from_dn, to_dn, controls=controls) - except Exception, err: + except Exception as err: if self.in_transaction: raise CommandError("%s : %s" % (msg, err)) self.report("%s : %s" % (msg, err)) @@ -1565,7 +1565,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) cls = None try: cls = obj["objectClass"][-1] - except KeyError, e: + except KeyError as e: pass if cls is None: @@ -2191,7 +2191,7 @@ newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base))) # special handling for some specific attribute types try: syntax_oid = self.samdb_schema.get_syntax_oid_from_lDAPDisplayName(attrname) - except Exception, msg: + except Exception as msg: self.err_unknown_attribute(obj, attrname) error_count += 1 continue diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py index ded072ca4f6..1940d2d1b27 100644 --- a/python/samba/drs_utils.py +++ b/python/samba/drs_utils.py @@ -54,7 +54,7 @@ def drsuapi_connect(server, lp, creds): try: drsuapiBind = drsuapi.drsuapi(binding_string, lp, creds) (drsuapiHandle, bindSupportedExtensions) = drs_DsBind(drsuapiBind) - except Exception, e: + except Exception as e: raise drsException("DRS connection to %s failed: %s" % (server, e)) return (drsuapiBind, drsuapiHandle, bindSupportedExtensions) @@ -83,7 +83,7 @@ def sendDsReplicaSync(drsuapiBind, drsuapi_handle, source_dsa_guid, try: drsuapiBind.DsReplicaSync(drsuapi_handle, 1, req1) - except Exception, estr: + except Exception as estr: raise drsException("DsReplicaSync failed %s" % estr) @@ -106,7 +106,7 @@ def sendRemoveDsServer(drsuapiBind, drsuapi_handle, server_dsa_dn, domain): req1.commit = 1 drsuapiBind.DsRemoveDSServer(drsuapi_handle, 1, req1) - except Exception, estr: + except Exception as estr: raise drsException("DsRemoveDSServer failed %s" % estr) diff --git a/python/samba/kcc/__init__.py b/python/samba/kcc/__init__.py index 6f8be1c4b4f..b9e491a5ba8 100644 --- a/python/samba/kcc/__init__.py +++ b/python/samba/kcc/__init__.py @@ -2718,7 +2718,7 @@ class KCC(object): try: self.samdb = ldif_import_export.ldif_to_samdb(dburl, lp, ldif_file, forced_local_dsa) - except ldif_import_export.LdifError, e: + except ldif_import_export.LdifError as e: logger.critical(e) return 1 return 0 @@ -2743,7 +2743,7 @@ class KCC(object): try: ldif_import_export.samdb_to_ldif_file(self.samdb, dburl, lp, creds, ldif_file) - except ldif_import_export.LdifError, e: + except ldif_import_export.LdifError as e: logger.critical(e) return 1 return 0 diff --git a/python/samba/kcc/graph_utils.py b/python/samba/kcc/graph_utils.py index 5e909f3881e..a3b51092076 100644 --- a/python/samba/kcc/graph_utils.py +++ b/python/samba/kcc/graph_utils.py @@ -303,7 +303,7 @@ def verify_graph(title, edges, vertices=None, directed=False, properties=(), try: f(edges, vertices, edge_vertices) debug(" %s%18s:%s verified!" % (DARK_GREEN, p, C_NORMAL)) - except GraphError, e: + except GraphError as e: errors.append((p, e)) if errors: diff --git a/python/samba/kcc/kcc_utils.py b/python/samba/kcc/kcc_utils.py index e4b99f42841..df5da6d028e 100644 --- a/python/samba/kcc/kcc_utils.py +++ b/python/samba/kcc/kcc_utils.py @@ -373,7 +373,7 @@ class NCReplica(NamingContext): try: samdb.modify(m) - except ldb.LdbError, estr: + except ldb.LdbError as estr: raise KCCError("Could not set repsFrom for (%s) - (%s)" % (self.nc_dnstr, estr)) @@ -524,7 +524,7 @@ class NCReplica(NamingContext): try: samdb.modify(m) - except ldb.LdbError, estr: + except ldb.LdbError as estr: raise KCCError("Could not set repsTo for (%s) - (%s)" % (self.nc_dnstr, estr)) @@ -1686,7 +1686,7 @@ class Site(object): try: samdb.modify(m) - except ldb.LdbError, estr: + except ldb.LdbError as estr: raise KCCError( "Could not set interSiteTopologyGenerator for (%s) - (%s)" % (ssdn, estr)) diff --git a/python/samba/kcc/ldif_import_export.py b/python/samba/kcc/ldif_import_export.py index 5e0f337acfd..1cfffa3b10c 100644 --- a/python/samba/kcc/ldif_import_export.py +++ b/python/samba/kcc/ldif_import_export.py @@ -77,7 +77,7 @@ dsServiceName: CN=NTDS Settings,%s - """) - except Exception, estr: + except Exception as estr: tmpdb.transaction_cancel() raise LdifError("Failed to import %s: %s" % (ldif_file, estr)) diff --git a/python/samba/provision/backend.py b/python/samba/provision/backend.py index 512e7b77da6..2dbd4f786b1 100644 --- a/python/samba/provision/backend.py +++ b/python/samba/provision/backend.py @@ -200,7 +200,7 @@ class LDAPBackend(ProvisionBackend): expression="(objectClass=OpenLDAProotDSE)") try: f = open(self.slapd_pid, "r") - except IOError, err: + except IOError as err: if err != errno.ENOENT: raise else: diff --git a/python/samba/upgrade.py b/python/samba/upgrade.py index 38563235841..22ab228f18b 100644 --- a/python/samba/upgrade.py +++ b/python/samba/upgrade.py @@ -91,7 +91,7 @@ def import_sam_policy(samdb, policy, logger): try: samdb.modify(m) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn("Could not set account policy, (%s)", str(e)) @@ -124,7 +124,7 @@ def add_posix_attrs(logger, samdb, sid, name, nisdomain, xid_type, home=None, str(nisdomain), ldb.FLAG_MOD_REPLACE, 'msSFU30NisDomain') samdb.modify(m) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn( 'Could not add posix attrs for AD entry for sid=%s, (%s)', str(sid), str(e)) @@ -154,7 +154,7 @@ def add_ad_posix_idmap_entry(samdb, sid, xid, xid_type, logger): "posixGroup", ldb.FLAG_MOD_ADD, 'objectClass') samdb.modify(m) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn( 'Could not modify AD idmap entry for sid=%s, id=%s, type=%s (%s)', str(sid), str(xid), xid_type, str(e)) @@ -185,7 +185,7 @@ def add_idmap_entry(idmapdb, sid, xid, xid_type, logger): m['type'] = ldb.MessageElement( xid_type, ldb.FLAG_MOD_REPLACE, 'type') idmapdb.modify(m) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn( 'Could not modify idmap entry for sid=%s, id=%s, type=%s (%s)', str(sid), str(xid), xid_type, str(e)) @@ -197,7 +197,7 @@ def add_idmap_entry(idmapdb, sid, xid, xid_type, logger): "objectSid": ndr_pack(sid), "type": xid_type, "xidNumber": str(xid)}) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn( 'Could not add idmap entry for sid=%s, id=%s, type=%s (%s)', str(sid), str(xid), xid_type, str(e)) @@ -213,7 +213,7 @@ def import_idmap(idmapdb, samba3, logger): try: samba3_idmap = samba3.get_idmap_db() - except IOError, e: + except IOError as e: logger.warn('Cannot open idmap database, Ignoring: %s', str(e)) return @@ -293,7 +293,7 @@ def add_group_from_mapping_entry(samdb, groupmap, logger): try: samdb.add(m, controls=["relax:0"]) - except ldb.LdbError, e: + except ldb.LdbError as e: logger.warn('Could not add group name=%s (%s)', groupmap.nt_name, str(e)) @@ -408,7 +408,7 @@ def get_posix_attr_from_ldap_backend(logger, ldb_object, base_dn, user, attr): msg = ldb_object.search(base_dn, scope=ldb.SCOPE_SUBTREE, expression=("(&(objectClass=posixAccount)(uid=%s))" % (user)), attrs=[attr]) - except ldb.LdbError, e: + except ldb.LdbError as e: raise ProvisioningError("Failed to retrieve attribute %s for user %s, the error is: %s" % (attr, user, e)) else: if msg.count <= 1: @@ -440,7 +440,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, # secrets db try: secrets_db = samba3.get_secrets_db() - except IOError, e: + except IOError as e: raise ProvisioningError("Could not open '%s', the Samba3 secrets database: %s. Perhaps you specified the incorrect smb.conf, --testparm or --dbdir option?" % (samba3.privatedir_path("secrets.tdb"), str(e))) if not domainname: @@ -518,7 +518,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, try: members = s3db.enum_aliasmem(group.sid) groupmembers[str(group.sid)] = members - except passdb.error, e: + except passdb.error as e: logger.warn("Ignoring group '%s' %s listed but then not found: %s", group.nt_name, group.sid, e) continue @@ -526,7 +526,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, try: members = s3db.enum_group_members(group.sid) groupmembers[str(group.sid)] = members - except passdb.error, e: + except passdb.error as e: logger.warn("Ignoring group '%s' %s listed but then not found: %s", group.nt_name, group.sid, e) continue @@ -540,7 +540,7 @@ def upgrade_from_samba3(samba3, logger, targetdir, session_info=None, try: members = s3db.enum_aliasmem(group.sid) groupmembers[str(group.sid)] = members - except passdb.error, e: + except passdb.error as e: logger.warn("Ignoring group '%s' %s listed but then not found: %s", group.nt_name, group.sid, e) continue @@ -624,7 +624,7 @@ Please fix this account before attempting to upgrade again groupmembers[str(group)].append(user.user_sid) else: groupmembers[str(group)] = [user.user_sid]; - except passdb.error, e: + except passdb.error as e: logger.warn("Ignoring group memberships of '%s' %s: %s", username, user.user_sid, e) @@ -667,7 +667,7 @@ Please fix this account before attempting to upgrade again for url in urls.split(): try: ldb_object = Ldb(url, credentials=creds) - except ldb.LdbError, e: + except ldb.LdbError as e: raise ProvisioningError("Could not open ldb connection to %s, the error message is: %s" % (url, e)) else: break @@ -710,7 +710,7 @@ Please fix this account before attempting to upgrade again samba3_winsdb = None try: samba3_winsdb = samba3.get_wins_db() - except IOError, e: + except IOError as e: logger.warn('Cannot open wins database, Ignoring: %s', str(e)) if not (serverrole == "ROLE_DOMAIN_BDC" or serverrole == "ROLE_DOMAIN_PDC"): diff --git a/python/samba/web_server/__init__.py b/python/samba/web_server/__init__.py index 78ce953c612..9fbd0ddfb9a 100644 --- a/python/samba/web_server/__init__.py +++ b/python/samba/web_server/__init__.py @@ -47,7 +47,7 @@ def __call__(environ, start_response): try: import swat - except ImportError, e: + except ImportError as e: print "NO SWAT: %r" % e have_swat = False else: |