From: Rob van der Linde Date: Wed, 13 Mar 2024 07:59:27 +0000 (+1300) Subject: python: pep8: fix import sorting after move X-Git-Tag: tdb-1.4.11~1427 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fafb268bf9553e21fa511eb6f50ab0b61628981;p=thirdparty%2Fsamba.git python: pep8: fix import sorting after move Only touch files where samba.domain.models import was moved Signed-off-by: Rob van der Linde Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/domain/auth/policy.py b/python/samba/netcmd/domain/auth/policy.py index 8e45a3f0834..8cc6598f3fa 100644 --- a/python/samba/netcmd/domain/auth/policy.py +++ b/python/samba/netcmd/domain/auth/policy.py @@ -21,12 +21,11 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand -from samba.domain.models import (AuthenticationPolicy, - AuthenticationSilo, Group, - MAX_TGT_LIFETIME, MIN_TGT_LIFETIME, - StrongNTLMPolicy) +from samba.domain.models import (MAX_TGT_LIFETIME, MIN_TGT_LIFETIME, + AuthenticationPolicy, AuthenticationSilo, + Group, StrongNTLMPolicy) from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.netcmd.validators import Range diff --git a/python/samba/netcmd/domain/auth/silo.py b/python/samba/netcmd/domain/auth/silo.py index cfa7b3827d5..861f47c8e7c 100644 --- a/python/samba/netcmd/domain/auth/silo.py +++ b/python/samba/netcmd/domain/auth/silo.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.domain.models import AuthenticationPolicy, AuthenticationSilo from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand from .silo_member import cmd_domain_auth_silo_member diff --git a/python/samba/netcmd/domain/auth/silo_member.py b/python/samba/netcmd/domain/auth/silo_member.py index e8777c45608..02e5cd53163 100644 --- a/python/samba/netcmd/domain/auth/silo_member.py +++ b/python/samba/netcmd/domain/auth/silo_member.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.domain.models import AuthenticationSilo, User from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_domain_auth_silo_member_grant(Command): diff --git a/python/samba/netcmd/domain/claim/claim_type.py b/python/samba/netcmd/domain/claim/claim_type.py index 36e251d290a..312742fede6 100644 --- a/python/samba/netcmd/domain/claim/claim_type.py +++ b/python/samba/netcmd/domain/claim/claim_type.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand -from samba.domain.models import AttributeSchema, ClassSchema, ClaimType, ValueType +from samba.domain.models import AttributeSchema, ClaimType, ClassSchema, ValueType from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_domain_claim_claim_type_create(Command): diff --git a/python/samba/netcmd/domain/claim/value_type.py b/python/samba/netcmd/domain/claim/value_type.py index 738cda57e78..b7f92947f58 100644 --- a/python/samba/netcmd/domain/claim/value_type.py +++ b/python/samba/netcmd/domain/claim/value_type.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.domain.models import ValueType from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_domain_claim_value_type_list(Command): diff --git a/python/samba/netcmd/service_account/group_msa_membership.py b/python/samba/netcmd/service_account/group_msa_membership.py index c285cd86246..34e7fa45b59 100644 --- a/python/samba/netcmd/service_account/group_msa_membership.py +++ b/python/samba/netcmd/service_account/group_msa_membership.py @@ -19,10 +19,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from samba.getopt import CredentialsOptions, HostOptions, Option, SambaOptions -from samba.netcmd import Command, CommandError, SuperCommand from samba.domain.models import Group, GroupManagedServiceAccount, Model, User from samba.domain.models.exceptions import ModelError +from samba.getopt import CredentialsOptions, HostOptions, Option, SambaOptions +from samba.netcmd import Command, CommandError, SuperCommand class cmd_service_account_group_msa_membership_show(Command): diff --git a/python/samba/netcmd/service_account/service_account.py b/python/samba/netcmd/service_account/service_account.py index 0801b1d6aa9..e4871198349 100644 --- a/python/samba/netcmd/service_account/service_account.py +++ b/python/samba/netcmd/service_account/service_account.py @@ -20,12 +20,12 @@ # along with this program. If not, see . # -from samba.getopt import CredentialsOptions, HostOptions, Option, SambaOptions -from samba.netcmd import Command, CommandError from samba.domain.models import (AccountType, Computer, Group, GroupManagedServiceAccount, SupportedEncryptionTypes, User) from samba.domain.models.exceptions import ModelError +from samba.getopt import CredentialsOptions, HostOptions, Option, SambaOptions +from samba.netcmd import Command, CommandError class cmd_service_account_list(Command): diff --git a/python/samba/netcmd/shell.py b/python/samba/netcmd/shell.py index 58bae299ba1..54c4019df36 100644 --- a/python/samba/netcmd/shell.py +++ b/python/samba/netcmd/shell.py @@ -28,8 +28,8 @@ import ldb import samba.getopt as options from samba import version -from samba.netcmd import Command from samba.domain.models import MODELS +from samba.netcmd import Command class cmd_shell(Command): diff --git a/python/samba/netcmd/sites.py b/python/samba/netcmd/sites.py index c4fb1f7f5cd..f66c7911c70 100644 --- a/python/samba/netcmd/sites.py +++ b/python/samba/netcmd/sites.py @@ -16,16 +16,11 @@ # along with this program. If not, see . # -from samba import sites, subnets import samba.getopt as options -from samba.netcmd import ( - Command, - CommandError, - SuperCommand, - Option, -) +from samba import sites, subnets from samba.domain.models import Site, Subnet from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_sites_list(Command): diff --git a/python/samba/netcmd/user/auth/policy.py b/python/samba/netcmd/user/auth/policy.py index 36aa650ec6c..cb1244bae9e 100644 --- a/python/samba/netcmd/user/auth/policy.py +++ b/python/samba/netcmd/user/auth/policy.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.domain.models import AuthenticationPolicy, User from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_user_auth_policy_assign(Command): diff --git a/python/samba/netcmd/user/auth/silo.py b/python/samba/netcmd/user/auth/silo.py index cbde58aa00e..0f58e8ed131 100644 --- a/python/samba/netcmd/user/auth/silo.py +++ b/python/samba/netcmd/user/auth/silo.py @@ -21,9 +21,9 @@ # import samba.getopt as options -from samba.netcmd import Command, CommandError, Option, SuperCommand from samba.domain.models import AuthenticationSilo, User from samba.domain.models.exceptions import ModelError +from samba.netcmd import Command, CommandError, Option, SuperCommand class cmd_user_auth_silo_assign(Command): diff --git a/python/samba/tests/krb5/authn_policy_tests.py b/python/samba/tests/krb5/authn_policy_tests.py index 9e441216268..b36fb0a8d38 100755 --- a/python/samba/tests/krb5/authn_policy_tests.py +++ b/python/samba/tests/krb5/authn_policy_tests.py @@ -17,31 +17,31 @@ # along with this program. If not, see . # -import sys import os +import sys sys.path.insert(0, 'bin/python') os.environ['PYTHONUNBUFFERED'] = '1' -from datetime import datetime -from enum import Enum import random import re +from datetime import datetime +from enum import Enum import ldb +import samba.tests +import samba.tests.krb5.kcrypto as kcrypto +import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 from samba import dsdb, ntstatus from samba.dcerpc import netlogon, security from samba.dcerpc import windows_event_ids as win_event -from samba.ndr import ndr_pack from samba.domain.models import AuthenticationPolicy, AuthenticationSilo - -import samba.tests -import samba.tests.krb5.kcrypto as kcrypto from samba.hresult import HRES_SEC_E_INVALID_TOKEN, HRES_SEC_E_LOGON_DENIED +from samba.ndr import ndr_pack +from samba.tests.auth_log_base import AuthLogTestBase, NoMessageException from samba.tests.krb5.kdc_base_test import GroupType from samba.tests.krb5.kdc_tgs_tests import KdcTgsBaseTests -from samba.tests.auth_log_base import AuthLogTestBase, NoMessageException from samba.tests.krb5.raw_testcase import RawKerberosTest from samba.tests.krb5.rfc4120_constants import ( FX_FAST_ARMOR_AP_REQUEST, @@ -53,7 +53,6 @@ from samba.tests.krb5.rfc4120_constants import ( NT_SRV_INST, PADATA_FX_FAST, ) -import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 SidType = RawKerberosTest.SidType diff --git a/python/samba/tests/krb5/kdc_base_test.py b/python/samba/tests/krb5/kdc_base_test.py index 7ad2f19d17e..f7301f4c235 100644 --- a/python/samba/tests/krb5/kdc_base_test.py +++ b/python/samba/tests/krb5/kdc_base_test.py @@ -16,38 +16,40 @@ # along with this program. If not, see . # -import sys import os +import sys sys.path.insert(0, "bin/python") os.environ["PYTHONUNBUFFERED"] = "1" import binascii import collections -from datetime import datetime, timezone -from enum import Enum -from functools import partial import numbers import secrets import tempfile +from collections import namedtuple +from datetime import datetime, timezone +from enum import Enum +from functools import partial from typing import Optional -from collections import namedtuple import ldb from ldb import SCOPE_BASE + from samba import ( NTSTATUSError, arcfour_encrypt, common, generate_random_password, + net, ntstatus, ) from samba.auth import system_session from samba.credentials import ( - Credentials, DONT_USE_KERBEROS, MUST_USE_KERBEROS, SPECIFIED, + Credentials, ) from samba.crypto import des_crypt_blob_16, md4_hash_blob from samba.dcerpc import ( @@ -63,49 +65,44 @@ from samba.dcerpc import ( samr, security, ) +from samba.dcerpc.misc import SEC_CHAN_BDC, SEC_CHAN_NULL, SEC_CHAN_WKSTA +from samba.domain.models import AuthenticationPolicy, AuthenticationSilo from samba.drs_utils import drs_Replicate, drsuapi_connect from samba.dsdb import ( - DSDB_SYNTAX_BINARY_DN, DS_DOMAIN_FUNCTION_2000, DS_DOMAIN_FUNCTION_2008, DS_GUID_COMPUTERS_CONTAINER, DS_GUID_DOMAIN_CONTROLLERS_CONTAINER, DS_GUID_MANAGED_SERVICE_ACCOUNTS_CONTAINER, DS_GUID_USERS_CONTAINER, + DSDB_SYNTAX_BINARY_DN, GTYPE_SECURITY_DOMAIN_LOCAL_GROUP, GTYPE_SECURITY_GLOBAL_GROUP, GTYPE_SECURITY_UNIVERSAL_GROUP, + UF_NO_AUTH_DATA_REQUIRED, UF_NORMAL_ACCOUNT, UF_NOT_DELEGATED, - UF_NO_AUTH_DATA_REQUIRED, UF_PARTIAL_SECRETS_ACCOUNT, UF_SERVER_TRUST_ACCOUNT, UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION, UF_WORKSTATION_TRUST_ACCOUNT, ) -from samba.dcerpc.misc import ( - SEC_CHAN_BDC, - SEC_CHAN_NULL, - SEC_CHAN_WKSTA, -) from samba.join import DCJoinContext from samba.ndr import ndr_pack, ndr_unpack -from samba import net -from samba.domain.models import AuthenticationPolicy, AuthenticationSilo from samba.param import LoadParm from samba.samdb import SamDB, dsdb_Dn rc4_bit = security.KERB_ENCTYPE_RC4_HMAC_MD5 aes256_sk_bit = security.KERB_ENCTYPE_AES256_CTS_HMAC_SHA1_96_SK -from samba.tests import TestCaseInTempDir, delete_force import samba.tests.krb5.kcrypto as kcrypto +import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 +from samba.tests import TestCaseInTempDir, delete_force from samba.tests.krb5.raw_testcase import ( KerberosCredentials, KerberosTicketCreds, RawKerberosTest, ) -import samba.tests.krb5.rfc4120_pyasn1 as krb5_asn1 from samba.tests.krb5.rfc4120_constants import ( AD_IF_RELEVANT, AD_WIN2K_PAC, @@ -122,8 +119,8 @@ from samba.tests.krb5.rfc4120_constants import ( KU_TICKET, NT_PRINCIPAL, NT_SRV_INST, - PADATA_ENCRYPTED_CHALLENGE, PADATA_ENC_TIMESTAMP, + PADATA_ENCRYPTED_CHALLENGE, PADATA_ETYPE_INFO2, ) diff --git a/python/samba/tests/samba_tool/domain_auth_policy.py b/python/samba/tests/samba_tool/domain_auth_policy.py index e0a1956c6f3..eed8d3bb1ad 100644 --- a/python/samba/tests/samba_tool/domain_auth_policy.py +++ b/python/samba/tests/samba_tool/domain_auth_policy.py @@ -25,8 +25,8 @@ from optparse import OptionValueError from unittest.mock import patch from samba.dcerpc import security -from samba.ndr import ndr_pack, ndr_unpack from samba.domain.models.exceptions import ModelError +from samba.ndr import ndr_pack, ndr_unpack from samba.samdb import SamDB from samba.sd_utils import SDUtils diff --git a/python/samba/tests/samba_tool/domain_models.py b/python/samba/tests/samba_tool/domain_models.py index 52d58157f19..b78e865d85e 100644 --- a/python/samba/tests/samba_tool/domain_models.py +++ b/python/samba/tests/samba_tool/domain_models.py @@ -24,11 +24,12 @@ import os from datetime import datetime, timezone from xml.etree import ElementTree -from ldb import FLAG_MOD_ADD, MessageElement, SCOPE_ONELEVEL +from ldb import FLAG_MOD_ADD, SCOPE_ONELEVEL, MessageElement + from samba.dcerpc import security from samba.dcerpc.misc import GUID from samba.domain.models import (AccountType, Computer, Group, Site, - User, StrongNTLMPolicy, fields) + StrongNTLMPolicy, User, fields) from samba.ndr import ndr_pack, ndr_unpack from .base import SambaToolCmdTest diff --git a/python/samba/tests/samba_tool/user_get_kerberos_ticket.py b/python/samba/tests/samba_tool/user_get_kerberos_ticket.py index 5e9535aef88..53be43d18e3 100644 --- a/python/samba/tests/samba_tool/user_get_kerberos_ticket.py +++ b/python/samba/tests/samba_tool/user_get_kerberos_ticket.py @@ -22,23 +22,22 @@ # along with this program. If not, see . # -import sys import os +import sys sys.path.insert(0, "bin/python") os.environ["PYTHONUNBUFFERED"] = "1" from ldb import SCOPE_BASE + from samba import credentials from samba.credentials import MUST_USE_KERBEROS from samba.dcerpc import security -from samba.dsdb import UF_WORKSTATION_TRUST_ACCOUNT, UF_NORMAL_ACCOUNT from samba.domain.models import User +from samba.dsdb import UF_NORMAL_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT from samba.ndr import ndr_pack, ndr_unpack -from samba.tests import connect_samdb, delete_force - -from samba.tests import BlackboxTestCase, BlackboxProcessError - +from samba.tests import (BlackboxProcessError, BlackboxTestCase, connect_samdb, + delete_force) # If not specified, this is None, meaning local sam.ldb PW_READ_URL = os.environ.get("PW_READ_URL") diff --git a/python/samba/tests/samba_tool/user_getpassword_gmsa.py b/python/samba/tests/samba_tool/user_getpassword_gmsa.py index cde87707feb..552d18f3889 100644 --- a/python/samba/tests/samba_tool/user_getpassword_gmsa.py +++ b/python/samba/tests/samba_tool/user_getpassword_gmsa.py @@ -20,25 +20,25 @@ # along with this program. If not, see . # -import sys import os +import sys sys.path.insert(0, "bin/python") os.environ["PYTHONUNBUFFERED"] = "1" -import datetime, shlex +import datetime +import shlex from ldb import SCOPE_BASE from samba.credentials import MUST_USE_KERBEROS -from samba.dcerpc import security, samr -from samba.dsdb import UF_WORKSTATION_TRUST_ACCOUNT +from samba.dcerpc import samr, security from samba.domain.models import User +from samba.dsdb import UF_WORKSTATION_TRUST_ACCOUNT from samba.ndr import ndr_pack, ndr_unpack from samba.nt_time import nt_time_from_datetime -from samba.tests import connect_samdb, connect_samdb_env, delete_force - -from samba.tests import BlackboxTestCase +from samba.tests import (BlackboxTestCase, connect_samdb, connect_samdb_env, + delete_force) DC_SERVER = os.environ["SERVER"] SERVER = os.environ["SERVER"]