From: Tim Beale Date: Fri, 27 Jul 2018 01:42:18 +0000 (+1200) Subject: Fix PEP8 warning E302 expected 2 blank lines X-Git-Tag: tdb-1.3.17~2131 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8920aab21325010fe161a9fd7a279fc3de7790d;p=thirdparty%2Fsamba.git Fix PEP8 warning E302 expected 2 blank lines Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- diff --git a/python/samba/netcmd/pso.py b/python/samba/netcmd/pso.py index 468967348b8..8f027b4927c 100644 --- a/python/samba/netcmd/pso.py +++ b/python/samba/netcmd/pso.py @@ -24,9 +24,11 @@ from samba.auth import system_session NEVER_TIMESTAMP = int(-0x8000000000000000) + def pso_container(samdb): return "CN=Password Settings Container,CN=System,%s" % samdb.domain_dn() + def timestamp_to_mins(timestamp_str): """Converts a timestamp in -100 nanosecond units to minutes""" # treat a timestamp of 'never' the same as zero (this should work OK for @@ -37,20 +39,24 @@ def timestamp_to_mins(timestamp_str): else: return abs(int(timestamp_str)) / (1e7 * 60) + def timestamp_to_days(timestamp_str): """Converts a timestamp in -100 nanosecond units to days""" return timestamp_to_mins(timestamp_str) / (60 * 24) + def mins_to_timestamp(mins): """Converts a value in minutes to -100 nanosecond units""" timestamp = -int((1e7) * 60 * mins) return str(timestamp) + def days_to_timestamp(days): """Converts a value in days to -100 nanosecond units""" timestamp = mins_to_timestamp(days * 60 * 24) return str(timestamp) + def show_pso_by_dn(outf, samdb, dn, show_applies_to=True): """Displays the password settings for a PSO specified by DN""" @@ -100,6 +106,7 @@ def show_pso_by_dn(outf, samdb, dn, show_applies_to=True): else: outf.write("\nNote: PSO does not apply to any users or groups.\n") + def check_pso_valid(samdb, pso_dn, name): """Gracefully bail out if we can't view/modify the PSO specified""" # the base scope search for the PSO throws an error if it doesn't exist @@ -116,6 +123,7 @@ def check_pso_valid(samdb, pso_dn, name): if 'msDS-PasswordSettingsPrecedence' not in res[0]: raise CommandError("You may not have permission to view/modify PSOs") + def show_pso_for_user(outf, samdb, username): """Displays the password settings for a specific user""" @@ -146,6 +154,7 @@ def show_pso_for_user(outf, samdb, username): else: outf.write("\nPSO applies to user via group membership.\n") + def make_pso_ldb_msg(outf, samdb, pso_dn, create, lockout_threshold=None, complexity=None, precedence=None, store_plaintext=None, history_length=None, min_pwd_length=None, @@ -217,6 +226,7 @@ def make_pso_ldb_msg(outf, samdb, pso_dn, create, lockout_threshold=None, return m + def check_pso_constraints(min_pwd_length=None, history_length=None, min_pwd_age=None, max_pwd_age=None): """Checks PSO settings fall within valid ranges""" @@ -255,6 +265,7 @@ pwd_settings_options = [ Option("--reset-account-lockout-after", help="After this time is elapsed, the recorded number of attempts restarts from zero (). Default is domain setting.", type=int)] + def num_options_in_args(options, args): """ Returns the number of options specified that are present in the args. @@ -269,6 +280,7 @@ def num_options_in_args(options, args): num_opts += 1 return num_opts + class cmd_domain_pwdsettings_pso_create(Command): """Creates a new Password Settings Object (PSO). @@ -412,6 +424,7 @@ class cmd_domain_pwdsettings_pso_create(Command): raise CommandError("Failed to create PSO '%s': %s" % (pso_dn, msg)) + class cmd_domain_pwdsettings_pso_set(Command): """Modifies a Password Settings Object (PSO).""" @@ -529,6 +542,7 @@ def pso_cmp(a, b): b_precedence = int(b['msDS-PasswordSettingsPrecedence'][0]) return a_precedence - b_precedence + class cmd_domain_pwdsettings_pso_list(Command): """Lists all Password Settings Objects (PSOs).""" @@ -572,6 +586,7 @@ class cmd_domain_pwdsettings_pso_list(Command): precedence = pso['msDS-PasswordSettingsPrecedence'] self.outf.write("%-10s | %s\n" % (precedence, pso['name'])) + class cmd_domain_pwdsettings_pso_show(Command): """Display a Password Settings Object's details.""" @@ -755,6 +770,7 @@ class cmd_domain_pwdsettings_pso_unapply(Command): self.message("PSO '%s' no longer applies to '%s'" % (psoname, user_or_group)) + class cmd_domain_passwordsettings_pso(SuperCommand): """Manage fine-grained Password Settings Objects (PSOs).""" diff --git a/python/samba/tests/pso.py b/python/samba/tests/pso.py index ef365d9effc..0d37108e060 100644 --- a/python/samba/tests/pso.py +++ b/python/samba/tests/pso.py @@ -25,6 +25,7 @@ from ldb import FLAG_MOD_DELETE, FLAG_MOD_ADD, FLAG_MOD_REPLACE from samba.dcerpc.samr import (DOMAIN_PASSWORD_COMPLEX, DOMAIN_PASSWORD_STORE_CLEARTEXT) + class TestUser: def __init__(self, username, samdb, userou=None): initial_password = "Initial12#" @@ -145,6 +146,7 @@ userPassword: %s "primaryGroupID") self.ldb.modify(m) + class PasswordSettings: def default_settings(self, samdb): """ diff --git a/python/samba/tests/samba_tool/passwordsettings.py b/python/samba/tests/samba_tool/passwordsettings.py index e8eb084c087..9c934b41dc9 100644 --- a/python/samba/tests/samba_tool/passwordsettings.py +++ b/python/samba/tests/samba_tool/passwordsettings.py @@ -21,6 +21,7 @@ import ldb from samba.tests.samba_tool.base import SambaToolCmdTest from samba.tests.pso import PasswordSettings, TestUser + class PwdSettingsCmdTestCase(SambaToolCmdTest): """Tests for 'samba-tool domain passwordsettings' subcommands""" diff --git a/source4/dsdb/tests/python/password_settings.py b/source4/dsdb/tests/python/password_settings.py index d46528e25c5..9b1f833acfb 100644 --- a/source4/dsdb/tests/python/password_settings.py +++ b/source4/dsdb/tests/python/password_settings.py @@ -41,6 +41,7 @@ from samba.credentials import Credentials from samba import gensec import base64 + class PasswordSettingsTestCase(PasswordTestCase): def setUp(self): super(PasswordSettingsTestCase, self).setUp() diff --git a/source4/torture/drs/python/getncchanges.py b/source4/torture/drs/python/getncchanges.py index 123a19cc3de..ef3e2fdcee0 100644 --- a/source4/torture/drs/python/getncchanges.py +++ b/source4/torture/drs/python/getncchanges.py @@ -36,6 +36,7 @@ import random from samba.dcerpc import drsuapi + class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase): def setUp(self): super(DrsReplicaSyncIntegrityTestCase, self).setUp() diff --git a/source4/torture/drs/python/link_conflicts.py b/source4/torture/drs/python/link_conflicts.py index 347298b5885..5f4c555e9de 100644 --- a/source4/torture/drs/python/link_conflicts.py +++ b/source4/torture/drs/python/link_conflicts.py @@ -42,6 +42,7 @@ from samba.dcerpc import drsuapi, misc DC1_TO_DC2 = 1 DC2_TO_DC1 = 2 + class DrsReplicaLinkConflictTestCase(drs_base.DrsBaseTestCase): def setUp(self): super(DrsReplicaLinkConflictTestCase, self).setUp()