]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4-python: Various formatting fixes.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 18 Feb 2012 22:59:48 +0000 (23:59 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 18 Feb 2012 22:59:48 +0000 (23:59 +0100)
source4/scripting/python/samba/__init__.py
source4/scripting/python/samba/common.py
source4/scripting/python/samba/dbchecker.py
source4/scripting/python/samba/tests/dcerpc/registry.py
source4/scripting/python/samba/tests/dcerpc/rpc_talloc.py
source4/scripting/python/samba/tests/strings.py
source4/scripting/python/samba/tests/upgrade.py
source4/scripting/python/samba/tests/upgradeprovisionneeddc.py
source4/scripting/python/samba/tests/xattr.py

index d81a25cbcf79d2dbaf6c16ccdc224a2886706699..20e6e709200636ef1737a649f4150178fc4a42ae 100644 (file)
@@ -28,15 +28,17 @@ import os
 import sys
 import samba.param
 
+
 def source_tree_topdir():
     """Return the top level source directory."""
-    paths = [ "../../..", "../../../.." ]
+    paths = ["../../..", "../../../.."]
     for p in paths:
         topdir = os.path.normpath(os.path.join(os.path.dirname(__file__), p))
         if os.path.exists(os.path.join(topdir, 'source4')):
             return topdir
     raise RuntimeError("unable to find top level source directory")
 
+
 def in_source_tree():
     """Return True if we are running from within the samba source tree"""
     try:
@@ -49,6 +51,7 @@ def in_source_tree():
 import ldb
 from samba._ldb import Ldb as _Ldb
 
+
 class Ldb(_Ldb):
     """Simple Samba-specific LDB subclass that takes care
     of setting up the modules dir, credentials pointers, etc.
@@ -166,7 +169,8 @@ class Ldb(_Ldb):
         # Try to delete user/computer accounts to allow deletion of groups
         self.erase_users_computers(basedn)
 
-        # Delete the 'visible' records, and the invisble 'deleted' records (if this DB supports it)
+        # Delete the 'visible' records, and the invisble 'deleted' records (if
+        # this DB supports it)
         for msg in self.search(basedn, ldb.SCOPE_SUBTREE,
                        "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
                        [], controls=["show_deleted:0", "show_recycled:0"]):
@@ -178,7 +182,8 @@ class Ldb(_Ldb):
                     raise
 
         res = self.search(basedn, ldb.SCOPE_SUBTREE,
-            "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", [], controls=["show_deleted:0", "show_recycled:0"])
+            "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
+            [], controls=["show_deleted:0", "show_recycled:0"])
         assert len(res) == 0
 
         # delete the specials
index b67036cb1d5242aeef3b8dc421177132effa5a7c..2ba60a053748d6c04f72f26381925525d0337d98 100644 (file)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-import ldb, dsdb
+
+import ldb
+import dsdb
+
 
 def confirm(msg, forced=False, allow_all=False):
     """confirm an action with the user
@@ -73,7 +76,7 @@ class dsdb_Dn(object):
                 syntax_oid = dsdb.DSDB_SYNTAX_STRING_DN
             else:
                 syntax_oid = dsdb.DSDB_SYNTAX_OR_NAME
-        if syntax_oid in [ dsdb.DSDB_SYNTAX_BINARY_DN, dsdb.DSDB_SYNTAX_STRING_DN ]:
+        if syntax_oid in [dsdb.DSDB_SYNTAX_BINARY_DN, dsdb.DSDB_SYNTAX_STRING_DN]:
             # it is a binary DN
             colons = dnstring.split(':')
             if len(colons) < 4:
index ff3fd6ee3869197f0023dcf0b768751175fe116f..7f2c9799b018d872b182569fe948974f2573b941 100644 (file)
@@ -27,11 +27,12 @@ from samba.ndr import ndr_unpack
 from samba.dcerpc import drsblobs
 from samba.common import dsdb_Dn
 
+
 class dbcheck(object):
     """check a SAM database for errors"""
 
-    def __init__(self, samdb, samdb_schema=None, verbose=False, fix=False, yes=False,
-                 quiet=False, in_transaction=False):
+    def __init__(self, samdb, samdb_schema=None, verbose=False, fix=False,
+                 yes=False, quiet=False, in_transaction=False):
         self.samdb = samdb
         self.dict_oid_name = None
         self.samdb_schema = (samdb_schema or samdb)
@@ -67,20 +68,14 @@ class dbcheck(object):
         if error_count != 0 and not self.fix:
             self.report("Please use --fix to fix these errors")
 
-
         self.report('Checked %u objects (%u errors)' % (len(res), error_count))
-
         return error_count
 
-
     def report(self, msg):
         '''print a message unless quiet is set'''
         if not self.quiet:
             print(msg)
 
-
-    ################################################################
-    # a local confirm function that obeys the --fix and --yes options
     def confirm(self, msg, allow_all=False, forced=False):
         '''confirm a change'''
         if not self.fix:
@@ -114,7 +109,6 @@ class dbcheck(object):
             return True
         return c
 
-
     def do_modify(self, m, controls, msg, validate=True):
         '''perform a modify with optional verbose output'''
         if self.verbose:
@@ -126,9 +120,6 @@ class dbcheck(object):
             return False
         return True
 
-
-    ################################################################
-    # handle empty attributes
     def err_empty_attribute(self, dn, attrname):
         '''fix empty attributes'''
         self.report("ERROR: Empty attribute %s in %s" % (attrname, dn))
@@ -143,15 +134,13 @@ class dbcheck(object):
                           "Failed to remove empty attribute %s" % attrname, validate=False):
             self.report("Removed empty attribute %s" % attrname)
 
-
-    ################################################################
-    # handle normalisation mismatches
     def err_normalise_mismatch(self, dn, attrname, values):
         '''fix attribute normalisation errors'''
         self.report("ERROR: Normalisation error for attribute %s in %s" % (attrname, dn))
         mod_list = []
         for val in values:
-            normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, [val])
+            normalised = self.samdb.dsdb_normalise_attributes(
+                self.samdb_schema, attrname, [val])
             if len(normalised) != 1:
                 self.report("Unable to normalise value '%s'" % val)
                 mod_list.append((val, ''))
@@ -168,7 +157,8 @@ class dbcheck(object):
             (val, nval) = mod_list[i]
             m['value_%u' % i] = ldb.MessageElement(val, ldb.FLAG_MOD_DELETE, attrname)
             if nval != '':
-                m['normv_%u' % i] = ldb.MessageElement(nval, ldb.FLAG_MOD_ADD, attrname)
+                m['normv_%u' % i] = ldb.MessageElement(nval, ldb.FLAG_MOD_ADD,
+                    attrname)
 
         if self.do_modify(m, ["relax:0", "show_recycled:1"],
                           "Failed to normalise attribute %s" % attrname,
@@ -179,10 +169,8 @@ class dbcheck(object):
         '''see if a dsdb_Dn is the special Deleted Objects DN'''
         return dsdb_dn.prefix == "B:32:18E2EA80684F11D2B9AA00C04F79F805:"
 
-
-    ################################################################
-    # handle a DN pointing to a deleted object
     def err_deleted_dn(self, dn, attrname, val, dsdb_dn, correct_dn):
+        """handle a DN pointing to a deleted object"""
         self.report("ERROR: target DN is deleted for %s in object %s - %s" % (attrname, dn, val))
         self.report("Target GUID points at deleted DN %s" % correct_dn)
         if not self.confirm_all('Remove DN link?', 'remove_all_deleted_DN_links'):
@@ -195,9 +183,8 @@ class dbcheck(object):
                           "Failed to remove deleted DN attribute %s" % attrname):
             self.report("Removed deleted DN on attribute %s" % attrname)
 
-    ################################################################
-    # handle a missing target DN (both GUID and DN string form are missing)
     def err_missing_dn_GUID(self, dn, attrname, val, dsdb_dn):
+        """handle a missing target DN (both GUID and DN string form are missing)"""
         # check if its a backlink
         linkID = self.samdb_schema.get_linkId_from_lDAPDisplayName(attrname)
         if (linkID & 1 == 0) and str(dsdb_dn).find('DEL\\0A') == -1:
@@ -205,10 +192,8 @@ class dbcheck(object):
             return
         self.err_deleted_dn(dn, attrname, val, dsdb_dn, dsdb_dn)
 
-
-    ################################################################
-    # handle a missing GUID extended DN component
     def err_incorrect_dn_GUID(self, dn, attrname, val, dsdb_dn, errstr):
+        """handle a missing GUID extended DN component"""
         self.report("ERROR: %s component for %s in object %s - %s" % (errstr, attrname, dn, val))
         controls=["extended_dn:1:1", "show_recycled:1"]
         try:
@@ -236,10 +221,8 @@ class dbcheck(object):
                           "Failed to fix %s on attribute %s" % (errstr, attrname)):
             self.report("Fixed %s on attribute %s" % (errstr, attrname))
 
-
-    ################################################################
-    # handle a DN string being incorrect
     def err_dn_target_mismatch(self, dn, attrname, val, dsdb_dn, correct_dn, errstr):
+        """handle a DN string being incorrect"""
         self.report("ERROR: incorrect DN string component for %s in object %s - %s" % (attrname, dn, val))
         dsdb_dn.dn = correct_dn
 
@@ -254,8 +237,6 @@ class dbcheck(object):
                           "Failed to fix incorrect DN string on attribute %s" % attrname):
             self.report("Fixed incorrect DN string on attribute %s" % (attrname))
 
-    ################################################################
-    # handle an unknown attribute error
     def err_unknown_attribute(self, obj, attrname):
         '''handle an unknown attribute error'''
         self.report("ERROR: unknown attribute '%s' in %s" % (attrname, obj.dn))
@@ -269,9 +250,6 @@ class dbcheck(object):
                           "Failed to remove unknown attribute %s" % attrname):
             self.report("Removed unknown attribute %s" % (attrname))
 
-
-    ################################################################
-    # handle a missing backlink
     def err_missing_backlink(self, obj, attrname, val, backlink_name, target_dn):
         '''handle a missing backlink value'''
         self.report("ERROR: missing backlink attribute '%s' in %s for link %s in %s" % (backlink_name, target_dn, attrname, obj.dn))
@@ -286,9 +264,6 @@ class dbcheck(object):
                           "Failed to fix missing backlink %s" % backlink_name):
             self.report("Fixed missing backlink %s" % (backlink_name))
 
-
-    ################################################################
-    # handle a orphaned backlink
     def err_orphaned_backlink(self, obj, attrname, val, link_name, target_dn):
         '''handle a orphaned backlink value'''
         self.report("ERROR: orphaned backlink attribute '%s' in %s for link %s in %s" % (attrname, obj.dn, link_name, target_dn))
@@ -302,9 +277,6 @@ class dbcheck(object):
                           "Failed to fix orphaned backlink %s" % link_name):
             self.report("Fixed orphaned backlink %s" % (link_name))
 
-
-    ################################################################
-    # specialised checking for a dn attribute
     def check_dn(self, obj, attrname, syntax_oid):
         '''check a DN attribute for correctness'''
         error_count = 0
@@ -315,12 +287,13 @@ class dbcheck(object):
             guid = dsdb_dn.dn.get_extended_component("GUID")
             if guid is None:
                 error_count += 1
-                self.err_incorrect_dn_GUID(obj.dn, attrname, val, dsdb_dn, "missing GUID")
+                self.err_incorrect_dn_GUID(obj.dn, attrname, val, dsdb_dn,
+                    "missing GUID")
                 continue
 
             guidstr = str(misc.GUID(guid))
 
-            attrs=['isDeleted']
+            attrs = ['isDeleted']
             linkID = self.samdb_schema.get_linkId_from_lDAPDisplayName(attrname)
             reverse_link_name = self.samdb_schema.get_backlink_from_lDAPDisplayName(attrname)
             if reverse_link_name is not None:
@@ -415,9 +388,6 @@ class dbcheck(object):
                           "Failed to fix metadata for attribute %s" % attr):
             self.report("Fixed metadata for attribute %s" % attr)
 
-
-    ################################################################
-    # check one object - calls to individual error handlers above
     def check_object(self, dn, attrs=['*']):
         '''check one object'''
         if self.verbose:
@@ -454,7 +424,6 @@ class dbcheck(object):
                 got_repl_property_meta_data = True
                 continue
 
-
             # check for empty attributes
             for val in obj[attrname]:
                 if val == '':
index b5495c7015c6f34d7b4c32af93e0ecbf0c7c8483..c3b28520a80ddd81e72d557f4f2e38c43b5eed44 100644 (file)
@@ -27,15 +27,15 @@ class WinregTests(RpcInterfaceTestCase):
 
     def setUp(self):
         super(WinregTests, self).setUp()
-        self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(), 
+        self.conn = winreg.winreg("ncalrpc:", self.get_loadparm(),
                                   self.get_credentials())
 
     def get_hklm(self):
-        return self.conn.OpenHKLM(None, 
+        return self.conn.OpenHKLM(None,
              winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
 
     def test_hklm(self):
-        handle = self.conn.OpenHKLM(None, 
+        handle = self.conn.OpenHKLM(None,
                  winreg.KEY_QUERY_VALUE | winreg.KEY_ENUMERATE_SUB_KEYS)
         self.conn.CloseKey(handle)
 
index 9ee2850405f34a13b03aa517a851ffb953c0549e..41286c621940f764296944633ac97140b8ed7fc9 100755 (executable)
@@ -37,6 +37,7 @@ import talloc
 
 talloc.enable_null_tracking()
 
+
 class TallocTests(samba.tests.TestCase):
     '''test talloc behaviour of pidl generated python code'''
 
@@ -54,7 +55,7 @@ class TallocTests(samba.tests.TestCase):
         # we expect one block for the object, and one for the structure
         self.check_blocks(partial_attribute_set, 2)
 
-        attids = [ 1, 2, 3]
+        attids = [1, 2, 3]
         partial_attribute_set.version = 1
         partial_attribute_set.attids     = attids
         partial_attribute_set.num_attids = len(attids)
index 0c96f5cb1982264c1e46e7c86977ddfba9a557bb..48ad24224e2a34a6881231ce52db593b41caff61 100644 (file)
@@ -67,6 +67,7 @@ class strcasecmp_m_Tests(samba.tests.TestCase):
 
 class strstr_m_Tests(samba.tests.TestCase):
     """strstr_m tests in simple ASCII and unicode strings"""
+
     def test_strstr_m(self):
         # A, B, strstr_m(A, B)
         cases = [('hello', 'hello', 'hello'),
index f522831bfafee1fd8cf500bfa9d7ced3a1d7f251..1348ca604d47fefe8207630292464c26bf2e6f99 100644 (file)
@@ -22,6 +22,7 @@
 from samba.upgrade import import_wins
 from samba.tests import LdbTestCase
 
+
 class WinsUpgradeTests(LdbTestCase):
 
     def test_upgrade(self):
@@ -30,10 +31,12 @@ class WinsUpgradeTests(LdbTestCase):
         }
         import_wins(self.ldb, winsdb)
 
-        self.assertEquals(['name=FOO,type=0x20'], 
-                          [str(m.dn) for m in self.ldb.search(expression="(objectClass=winsRecord)")])
+        self.assertEquals(
+            ['name=FOO,type=0x20'],
+            [str(m.dn) for m in
+                self.ldb.search(expression="(objectClass=winsRecord)")])
 
     def test_version(self):
         import_wins(self.ldb, {})
-        self.assertEquals("VERSION", 
+        self.assertEquals("VERSION",
                 str(self.ldb.search(expression="(objectClass=winsMaxVersion)")[0]["cn"]))
index 596cff6d3aabd639b76b35dbe5083f2ce90a1f83..008622394e0d4c4aea823e6bfdb7075c1a3562e0 100644 (file)
@@ -161,7 +161,8 @@ class UpgradeProvisionWithLdbTestCase(TestCaseInTempDir):
         self.assertNotEquals(oem, "")
 
     def test_update_dns_account(self):
-        update_dns_account_password(self.ldbs.sam, self.ldbs.secrets, self.names)
+        update_dns_account_password(self.ldbs.sam, self.ldbs.secrets,
+            self.names)
 
     def test_updateOEMInfo(self):
         realm = self.lp.get("realm")
index f978ee5b2ad6434862ad960b9864f7b97bb57cff..7b4627fdad987b91536a27b377bf3c38f4127820 100644 (file)
@@ -83,7 +83,7 @@ class XattrTests(TestCase):
         ntacl.version = 1
         open(tempf, 'w').write("empty")
         try:
-            self.assertRaises(IOError, samba.xattr_tdb.wrap_setxattr, 
+            self.assertRaises(IOError, samba.xattr_tdb.wrap_setxattr,
                     os.path.join("nonexistent", "eadb.tdb"), tempf,
                     "user.unittests", ndr_pack(ntacl))
         finally: