]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
upgradeprovision: Remove unused imports, use shutil.rmtree rather than
authorJelmer Vernooij <jelmer@samba.org>
Mon, 1 Mar 2010 02:25:07 +0000 (03:25 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 1 Mar 2010 02:25:07 +0000 (03:25 +0100)
rmall.

source4/scripting/bin/upgradeprovision
source4/scripting/python/samba/upgradehelpers.py

index ac9ab64e372f754cdaa3bcd6c806bc32c7216628..d09a6f26ac5bed4f99c30c477f81d064c8db7256 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-import getopt
 import shutil
 import optparse
 import os
 import sys
-import random
-import string
 import re
+import shutil
 import tempfile
 # Allow to run from s4 source directory (without installing samba)
 sys.path.insert(0, "bin/python")
 
-
 import samba
 import samba.getopt as options
 from samba.credentials import DONT_USE_KERBEROS
 from samba.auth import system_session, admin_session
 from samba import Ldb
-from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError,\
+from ldb import SCOPE_SUBTREE, SCOPE_BASE, \
                                FLAG_MOD_REPLACE, FLAG_MOD_ADD, FLAG_MOD_DELETE,\
                                MessageElement, Message, Dn
-from samba.samdb import SamDB
 from samba import param
 from samba import glue
 from samba.misc import messageEltFlagToString
 from samba.provision import  find_setup_dir, get_domain_descriptor, get_config_descriptor, secretsdb_self_join
 from samba.provisionexceptions import ProvisioningError
-from samba.schema import get_dnsyntax_attributes, get_linked_attributes, Schema, get_schema_descriptor
-from samba.dcerpc import misc, security
-from samba.ndr import ndr_pack, ndr_unpack
+from samba.schema import get_linked_attributes, Schema, get_schema_descriptor
+from samba.dcerpc import security
+from samba.ndr import ndr_unpack
 from samba.dcerpc.misc import SEC_CHAN_BDC
-from samba.upgradehelpers import dn_sort, get_paths, newprovision, find_provision_key_parameters, rmall
+from samba.upgradehelpers import dn_sort, get_paths, newprovision, find_provision_key_parameters
 
 never=0
 replace=2^FLAG_MOD_REPLACE
@@ -912,4 +908,4 @@ if not m:
        check_updated_sd(newpaths, paths, creds, session, names)
        message(SIMPLE,"Upgrade finished !")
        # remove reference provision now that everything is done !
-       rmall(provisiondir)
+       shutil.rmtree(provisiondir)
index 190a8f76c934f7ab829e1dd7a64773b0c9056e78..6af49fccbd8f498fd21cd2ae6b7e86d5c8cc593f 100755 (executable)
 
 
 import os
-import sys
 import string
 import re
 
 import samba
 from samba import Ldb, DS_DOMAIN_FUNCTION_2000
-from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError
+from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE
 import ldb
-from samba.provision import  ProvisionNames,provision_paths_from_lp,FILL_FULL,provision
+from samba.provision import ProvisionNames, provision_paths_from_lp, FILL_FULL, provision
 from samba.provisionexceptions import ProvisioningError
 from samba.dcerpc import misc, security
-from samba.ndr import ndr_pack, ndr_unpack
+from samba.ndr import ndr_unpack
 
-def get_paths(param,targetdir=None,smbconf=None):
+
+def get_paths(param, targetdir=None, smbconf=None):
        """Get paths to important provision objects (smb.conf, ldb files, ...)
 
        :param param: Param object
@@ -59,7 +59,7 @@ def get_paths(param,targetdir=None,smbconf=None):
        return paths
 
 
-def find_provision_key_parameters(param,credentials,session_info,paths,smbconf):
+def find_provision_key_parameters(param, credentials, session_info, paths, smbconf):
        """Get key provision parameters (realm, domain, ...) from a given provision
 
        :param param: Param object
@@ -151,11 +151,11 @@ def find_provision_key_parameters(param,credentials,session_info,paths,smbconf):
        return names
 
 
-# Create a fresh new reference provision
-# This provision will be the reference for knowing what has changed in the
-# since the latest upgrade in the current provision
 def newprovision(names,setup_dir,creds,session,smbconf,provdir,messagefunc):
-       """Create a new provision
+       """Create a new provision.
+
+    This provision will be the reference for knowing what has changed in the
+    since the latest upgrade in the current provision
 
        :param names: List of provision parameters
        :param setup_dis: Directory where the setup files are stored
@@ -165,15 +165,11 @@ def newprovision(names,setup_dir,creds,session,smbconf,provdir,messagefunc):
        :param provdir: Directory where the provision will be stored
        :param messagefunc: A function for displaying the message of the provision"""
        if os.path.isdir(provdir):
-               rmall(provdir)
+               shutil.rmtree(provdir)
        logstd=os.path.join(provdir,"log.std")
        os.chdir(os.path.join(setup_dir,".."))
        os.mkdir(provdir)
-       #os.close(2)
-       #sys.stderr = open("%s/provision.log"%provdir, "w")
        messagefunc("Provision stored in %s"%provdir)
-       #messagefunc("STDERR message of provision will be logged in %s/provision.log"%provdir)
-       #sys.stderr = open("/dev/stdout", "w")
        provision(setup_dir, messagefunc,
                session, creds, smbconf=smbconf, targetdir=provdir,
                samdb_fill=FILL_FULL, realm=names.realm, domain=names.domain,
@@ -228,18 +224,3 @@ def dn_sort(x,y):
                                else:
                                        return -1
        return ret
-
-
-def rmall(topdir):
-       """Remove a directory its contents and all its subdirectory
-
-       :param topdir: Directory to remove"""
-       for root, dirs, files in os.walk(topdir, topdown=False):
-               for name in files:
-                       os.remove(os.path.join(root, name))
-               for name in dirs:
-                       os.rmdir(os.path.join(root, name))
-       os.rmdir(topdir)
-
-
-