summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2010-03-01 03:25:07 +0100
committerJelmer Vernooij <jelmer@samba.org>2010-03-01 03:25:07 +0100
commit93d377424a0236ad5b1c58973f597ce69e123239 (patch)
tree4d6c94e9f41a96b0a390856318a59617ca083f2a /source4/scripting
parent254e007bd99ebbd351e78b634c483d604ebdcefc (diff)
downloadsamba-93d377424a0236ad5b1c58973f597ce69e123239.tar.gz
samba-93d377424a0236ad5b1c58973f597ce69e123239.tar.bz2
samba-93d377424a0236ad5b1c58973f597ce69e123239.zip
upgradeprovision: Remove unused imports, use shutil.rmtree rather than
rmall.
Diffstat (limited to 'source4/scripting')
-rwxr-xr-xsource4/scripting/bin/upgradeprovision18
-rwxr-xr-xsource4/scripting/python/samba/upgradehelpers.py41
2 files changed, 18 insertions, 41 deletions
diff --git a/source4/scripting/bin/upgradeprovision b/source4/scripting/bin/upgradeprovision
index ac9ab64e37..d09a6f26ac 100755
--- a/source4/scripting/bin/upgradeprovision
+++ b/source4/scripting/bin/upgradeprovision
@@ -21,38 +21,34 @@
# 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)
diff --git a/source4/scripting/python/samba/upgradehelpers.py b/source4/scripting/python/samba/upgradehelpers.py
index 190a8f76c9..6af49fccbd 100755
--- a/source4/scripting/python/samba/upgradehelpers.py
+++ b/source4/scripting/python/samba/upgradehelpers.py
@@ -23,20 +23,20 @@
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)
-
-
-