[SCM] Samba Shared Repository - branch master updated
Douglas Bagnall
dbagnall at samba.org
Wed Oct 10 07:29:02 UTC 2018
The branch, master has been updated
via 131f98e tests/python/ldap: use int instead of long for time_t
via 79e1ed1 python/upgradehelpers: use int not long for PY3
via 77ef686 pyauth: Remove imessaging_ctx parameter to new
via 473c1c0 popt_common_creds: actually use the ignore_missing_conf flag
via 126a14b netcmd: apply the new get_logger to cmds
via 0979d96 netcmd: modify Command.get_logger to use get_samba_logger
via 4260fb8 script/traffic_replay: apply new logger to replace print
via 57594c8 script/traffic_replay: get debug level via api
via 33ce1fa script/traffic_replay: print packets data to stderr
via e8a1773 emulate/traffic: apply new logger to replace print
via e5cf5a6 samba/logger: add logger module for python
via ea6421d emulate/traffic: allow traffic_replay to run users and groups generate multiple times
from 37f6e2a lib: Remove lib/crypto/crc32.[ch]
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 131f98ed1601c925b5a689606e55b078d7b4e9e2
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Thu Oct 4 15:30:21 2018 +1300
tests/python/ldap: use int instead of long for time_t
Python int is at least a C long; Python long disappears in Py3.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Noel Power <nopower at suse.com>
Autobuild-User(master): Douglas Bagnall <dbagnall at samba.org>
Autobuild-Date(master): Wed Oct 10 09:28:20 CEST 2018 on sn-devel-144
commit 79e1ed1ffa172c9ed4d79668d7fb6adb56770ef7
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Thu Oct 4 15:29:02 2018 +1300
python/upgradehelpers: use int not long for PY3
int works OK for py2 also.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Noel Power <nopower at suse.com>
commit 77ef686f59fb5f227a57838221d1857433c74c65
Author: Gary Lockyer <gary at catalyst.net.nz>
Date: Mon Oct 1 12:20:44 2018 +1300
pyauth: Remove imessaging_ctx parameter to new
The pyauth code assumes the messaging context code is a py_talloc
object. But the code in pymessaging returns a wrapped talloc object.
Removing the parameter as it's not currently used by any code.
Signed-off-by: Gary Lockyer <gary at catalyst.net.nz>
Reviewed-by: Noel Power <nopower at suse.com>
commit 473c1c00f977d135fae241e6ddc0bc13d582fb08
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Wed Oct 3 11:42:22 2018 +1300
popt_common_creds: actually use the ignore_missing_conf flag
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Pair-programmed-with: Olly Betts <olly at survex.com>
Reviewed-by: Noel Power <nopower at suse.com>
commit 126a14b443d7fd238d693a3e4e434b83bba96065
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Tue Aug 21 12:45:15 2018 +1200
netcmd: apply the new get_logger to cmds
This is an example of how to use the new logger.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 0979d96006b7220fb8838dc34f57dcb6f1ad011a
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Tue Aug 21 12:08:59 2018 +1200
netcmd: modify Command.get_logger to use get_samba_logger
By doing this, we don't need to repeat the log level convert code any more.
Also, logs have colors now.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 4260fb87edd1719ecf6d07b3b5230a070410f629
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Mon Aug 20 14:13:33 2018 +1200
script/traffic_replay: apply new logger to replace print
Use logger to replace print
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 57594c8772aac6341516fb78f452564f83cec54a
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Mon Aug 20 16:18:45 2018 +1200
script/traffic_replay: get debug level via api
The -d option will set samba global debug level automatically.
We should not parse and use the passed in value.
Use samba.get_debug_level instead.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit 33ce1fa23e8dfc0e392aa09733f36c5f2418a6fe
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Mon Aug 20 16:31:32 2018 +1200
script/traffic_replay: print packets data to stderr
This is debug info, should print to stderr.
Otherwise it will flood stdout.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit e8a1773ce238cef8735ddcd445e591c33e17d37e
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Wed Aug 22 16:42:12 2018 +1200
emulate/traffic: apply new logger to replace print
These print are actually progress infomation, should use logger to
print to stderr, other than stdout.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit e5cf5a687042d4898166ce3c8e1ad3bd810b91ca
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Tue Aug 21 10:48:04 2018 +1200
samba/logger: add logger module for python
We need a consitent way for logging in Samba Python code.
This module provides a factory method `get_samba_logger` to create logger,
with a reasonable default format and optional color.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
commit ea6421d734ec538325560cf2bd9a0a03280a8cee
Author: Joe Guo <joeg at catalyst.net.nz>
Date: Thu Aug 9 15:49:17 2018 +1200
emulate/traffic: allow traffic_replay to run users and groups generate multiple times
When we run `traffic_replay --generate-users-only`, if we cancel it or
it breaks in middle, it won't do anything when we try to run it again.
This is because the code will check the first user/group to create. If
it's already there, then it thought task already done, and break the loop.
This commit change the behavior:
We search existing users/groups first, skip existing ones, and
create non-existing ones. So we can run it multi-times to make sure the
expected users and groups are actually created.
Signed-off-by: Joe Guo <joeg at catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
python/samba/emulate/traffic.py | 48 ++++++------
python/samba/logger.py | 66 ++++++++++++++++
python/samba/netcmd/__init__.py | 11 +--
python/samba/netcmd/dns.py | 8 +-
python/samba/netcmd/domain.py | 38 ++--------
python/samba/netcmd/drs.py | 9 +--
python/samba/tests/samba_tool/computer.py | 3 +-
python/samba/upgradehelpers.py | 3 +-
script/traffic_replay | 121 ++++++++++++++++--------------
source3/lib/popt_common_cmdline.c | 2 +-
source4/auth/pyauth.c | 24 +++---
source4/dsdb/tests/python/ldap.py | 4 +-
12 files changed, 185 insertions(+), 152 deletions(-)
create mode 100644 python/samba/logger.py
Changeset truncated at 500 lines:
diff --git a/python/samba/emulate/traffic.py b/python/samba/emulate/traffic.py
index ca05108..35100ca 100644
--- a/python/samba/emulate/traffic.py
+++ b/python/samba/emulate/traffic.py
@@ -51,6 +51,7 @@ from samba.dcerpc.misc import SEC_CHAN_BDC
from samba import gensec
from samba import sd_utils
from samba.compat import get_string
+from samba.logger import get_samba_logger
SLEEP_OVERHEAD = 3e-4
@@ -89,6 +90,8 @@ NO_WAIT_LOG_TIME_RANGE = (-10, -3)
# DEBUG_LEVEL can be changed by scripts with -d
DEBUG_LEVEL = 0
+LOGGER = get_samba_logger(name=__name__)
+
def debug(level, msg, *args):
"""Print a formatted debug message to standard error.
@@ -1438,7 +1441,7 @@ def replay(conversations,
end = start + duration
- print("Replaying traffic for %u conversations over %d seconds"
+ LOGGER.info("Replaying traffic for %u conversations over %d seconds"
% (len(conversations), duration))
children = {}
@@ -1548,6 +1551,7 @@ def openLdb(host, creds, lp):
session = system_session()
ldb = SamDB(url="ldap://%s" % host,
session_info=session,
+ options=['modules:paged_searches'],
credentials=creds,
lp=lp)
return ldb
@@ -1671,7 +1675,7 @@ def create_machine_account(ldb, instance_id, netbios_name, machinepass):
"unicodePwd": utf16pw})
end = time.time()
duration = end - start
- print("%f\t0\tcreate\tmachine\t%f\tTrue\t" % (end, duration))
+ LOGGER.info("%f\t0\tcreate\tmachine\t%f\tTrue\t" % (end, duration))
def create_user_account(ldb, instance_id, username, userpass):
@@ -1694,7 +1698,7 @@ def create_user_account(ldb, instance_id, username, userpass):
end = time.time()
duration = end - start
- print("%f\t0\tcreate\tuser\t%f\tTrue\t" % (end, duration))
+ LOGGER.info("%f\t0\tcreate\tuser\t%f\tTrue\t" % (end, duration))
def create_group(ldb, instance_id, name):
@@ -1710,7 +1714,7 @@ def create_group(ldb, instance_id, name):
})
end = time.time()
duration = end - start
- print("%f\t0\tcreate\tgroup\t%f\tTrue\t" % (end, duration))
+ LOGGER.info("%f\t0\tcreate\tgroup\t%f\tTrue\t" % (end, duration))
def user_name(instance_id, i):
@@ -1718,21 +1722,24 @@ def user_name(instance_id, i):
return "STGU-%d-%d" % (instance_id, i)
+def search_objectclass(ldb, objectclass='user', attr='sAMAccountName'):
+ """Seach objectclass, return attr in a set"""
+ objs = ldb.search(
+ expression="(objectClass={})".format(objectclass),
+ attrs=[attr]
+ )
+ return {str(obj[attr]) for obj in objs}
+
+
def generate_users(ldb, instance_id, number, password):
"""Add users to the server"""
+ existing_objects = search_objectclass(ldb, objectclass='user')
users = 0
for i in range(number, 0, -1):
- try:
- username = user_name(instance_id, i)
- create_user_account(ldb, instance_id, username, password)
+ name = user_name(instance_id, i)
+ if name not in existing_objects:
+ create_user_account(ldb, instance_id, name, password)
users += 1
- except LdbError as e:
- (status, _) = e.args
- # Stop if entry exists
- if status == 68:
- break
- else:
- raise
return users
@@ -1744,19 +1751,14 @@ def group_name(instance_id, i):
def generate_groups(ldb, instance_id, number):
"""Create the required number of groups on the server."""
+ existing_objects = search_objectclass(ldb, objectclass='group')
groups = 0
for i in range(number, 0, -1):
- try:
- name = group_name(instance_id, i)
+ name = group_name(instance_id, i)
+ if name not in existing_objects:
create_group(ldb, instance_id, name)
groups += 1
- except LdbError as e:
- (status, _) = e.args
- # Stop if entry exists
- if status == 68:
- break
- else:
- raise
+
return groups
diff --git a/python/samba/logger.py b/python/samba/logger.py
new file mode 100644
index 0000000..a3db3be
--- /dev/null
+++ b/python/samba/logger.py
@@ -0,0 +1,66 @@
+# Samba common functions
+#
+# Copyright (C) Joe Guo <joeg at catalyst.net.nz>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import sys
+import logging
+from samba.colour import GREY, YELLOW, GREEN, RED, DARK_RED, C_NORMAL
+
+LEVEL_COLORS = {
+ logging.CRITICAL: DARK_RED,
+ logging.ERROR: RED,
+ logging.WARNING: YELLOW,
+ logging.INFO: GREEN,
+ logging.DEBUG: GREY,
+}
+
+
+class ColoredFormatter(logging.Formatter):
+ """Add color to log according to level"""
+
+ def format(self, record):
+ log = super(ColoredFormatter, self).format(record)
+ color = LEVEL_COLORS.get(record.levelno, GREY)
+ return color + log + C_NORMAL
+
+
+def get_samba_logger(
+ name='samba', stream=sys.stderr, use_color=True,
+ level=None, verbose=False, quiet=False,
+ fmt=('%(levelname)s %(asctime)s pid:%(process)d '
+ '%(pathname)s #%(lineno)d: %(message)s'),
+ datefmt=None):
+ """
+ Get a logger instance and config it.
+ """
+ logger = logging.getLogger(name)
+
+ if not level:
+ # if level not specified, map options to level
+ level = ((verbose and logging.DEBUG) or
+ (quiet and logging.WARNING) or logging.INFO)
+
+ logger.setLevel(level)
+
+ Formatter = use_color and ColoredFormatter or logging.Formatter
+ formatter = Formatter(fmt=fmt, datefmt=datefmt)
+
+ handler = logging.StreamHandler(stream=stream)
+ handler.setFormatter(formatter)
+ logger.addHandler(handler)
+
+ return logger
diff --git a/python/samba/netcmd/__init__.py b/python/samba/netcmd/__init__.py
index 3c785a1..0687016 100644
--- a/python/samba/netcmd/__init__.py
+++ b/python/samba/netcmd/__init__.py
@@ -20,6 +20,7 @@ import optparse
import samba
from samba import getopt as options
from samba import colour
+from samba.logger import get_samba_logger
from ldb import LdbError
import sys
import traceback
@@ -189,12 +190,12 @@ class Command(object):
"""Run the command. This should be overridden by all subclasses."""
raise NotImplementedError(self.run)
- def get_logger(self, name="netcmd"):
+ def get_logger(self, name="", verbose=False, quiet=False, **kwargs):
"""Get a logger object."""
- import logging
- logger = logging.getLogger(name)
- logger.addHandler(logging.StreamHandler(self.errf))
- return logger
+ return get_samba_logger(
+ name=name or self.name, stream=self.errf,
+ verbose=verbose, quiet=quiet,
+ **kwargs)
def apply_colour_choice(self, requested):
"""Heuristics to work out whether the user wants colour output, from a
diff --git a/python/samba/netcmd/dns.py b/python/samba/netcmd/dns.py
index 783a1d5..b50e7b7 100644
--- a/python/samba/netcmd/dns.py
+++ b/python/samba/netcmd/dns.py
@@ -1104,13 +1104,7 @@ class cmd_cleanup_record(Command):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
samdb = SamDB(url="ldap://%s" % server,
session_info=system_session(),
diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py
index ce4f36a..7d0af53 100644
--- a/python/samba/netcmd/domain.py
+++ b/python/samba/netcmd/domain.py
@@ -368,11 +368,7 @@ class cmd_domain_provision(Command):
plaintext_secrets=False,
backend_store=None):
- self.logger = self.get_logger("provision")
- if quiet:
- self.logger.setLevel(logging.WARNING)
- else:
- self.logger.setLevel(logging.INFO)
+ self.logger = self.get_logger(name="provision", quiet=quiet)
lp = sambaopts.get_loadparm()
smbconf = lp.configfile
@@ -616,13 +612,7 @@ class cmd_domain_dcpromo(Command):
creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress)
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
netbios_name = lp.get("netbios name")
@@ -688,13 +678,7 @@ class cmd_domain_join(Command):
creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress)
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
netbios_name = lp.get("netbios name")
@@ -771,13 +755,7 @@ class cmd_domain_demote(Command):
creds = credopts.get_credentials(lp)
net = Net(creds, lp, server=credopts.ipaddress)
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
if remove_other_dead_server is not None:
if server is not None:
@@ -1615,13 +1593,7 @@ class cmd_domain_classicupgrade(Command):
if not dbdir and not testparm:
raise CommandError("Please specify either dbdir or testparm")
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
if dbdir and testparm:
logger.warning("both dbdir and testparm specified, ignoring dbdir.")
diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py
index 5ed34c6..4641de0 100644
--- a/python/samba/netcmd/drs.py
+++ b/python/samba/netcmd/drs.py
@@ -38,7 +38,6 @@ from samba.join import join_clone
from samba.ndr import ndr_unpack
from samba.dcerpc import drsblobs
from samba import colour
-import logging
def drsuapi_connect(ctx):
@@ -760,13 +759,7 @@ class cmd_drs_clone_dc_database(Command):
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
- logger = self.get_logger()
- if verbose:
- logger.setLevel(logging.DEBUG)
- elif quiet:
- logger.setLevel(logging.WARNING)
- else:
- logger.setLevel(logging.INFO)
+ logger = self.get_logger(verbose=verbose, quiet=quiet)
if targetdir is None:
raise CommandError("--targetdir option must be specified")
diff --git a/python/samba/tests/samba_tool/computer.py b/python/samba/tests/samba_tool/computer.py
index 94f6230..38ea5f7 100644
--- a/python/samba/tests/samba_tool/computer.py
+++ b/python/samba/tests/samba_tool/computer.py
@@ -65,7 +65,8 @@ class ComputerCmdTestCase(SambaToolCmdTest):
(result, out, err) = self._create_computer(computer)
self.assertCmdSuccess(result, out, err)
- self.assertEquals(err, "", "There shouldn't be any error message")
+ self.assertNotIn(
+ "ERROR", err, "There shouldn't be any error message")
self.assertIn("Computer '%s' created successfully" %
computer["name"], out)
diff --git a/python/samba/upgradehelpers.py b/python/samba/upgradehelpers.py
index 804d820..e3d1ce0 100644
--- a/python/samba/upgradehelpers.py
+++ b/python/samba/upgradehelpers.py
@@ -831,7 +831,6 @@ def int64range2str(value):
:param value: The int64 range
:return: A string of the representation of the range
"""
-
- lvalue = long(value)
+ lvalue = int(value)
str = "%d-%d" % (lvalue &0xFFFFFFFF, lvalue >>32)
return str
diff --git a/script/traffic_replay b/script/traffic_replay
index f414015..6578c84 100755
--- a/script/traffic_replay
+++ b/script/traffic_replay
@@ -26,9 +26,10 @@ import random
sys.path.insert(0, "bin/python")
-from samba import gensec
+from samba import gensec, get_debug_level
from samba.emulate import traffic
import samba.getopt as options
+from samba.logger import get_samba_logger
def print_err(*args, **kwargs):
@@ -134,8 +135,17 @@ def main():
parser.print_usage()
return
+ debuglevel = get_debug_level()
+ logger = get_samba_logger(name=__name__,
+ verbose=debuglevel > 3,
+ quiet=debuglevel < 1)
+
+ traffic.DEBUG_LEVEL = debuglevel
+ # pass log level down to traffic module to make sure level is controlled
+ traffic.LOGGER.setLevel(logger.getEffectiveLevel())
+
if opts.clean_up:
- print_err("Removing user and machine accounts")
+ logger.info("Removing user and machine accounts")
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
creds.set_gensec_features(creds.get_gensec_features() | gensec.FEATURE_SEAL)
@@ -145,17 +155,17 @@ def main():
if summary:
if not os.path.exists(summary):
- print_err("Summary file %s doesn't exist" % summary)
+ logger.error("Summary file %s doesn't exist" % summary)
sys.exit(1)
# the summary-file can be ommitted for --generate-users-only and
# --cleanup-up, but it should be specified in all other cases
elif not opts.generate_users_only:
- print_err("No summary-file specified to replay traffic from")
+ logger.error("No summary-file specified to replay traffic from")
sys.exit(1)
if not opts.fixed_password:
- print_err(("Please use --fixed-password to specify a password"
- " for the users created as part of this test"))
+ logger.error(("Please use --fixed-password to specify a password"
+ " for the users created as part of this test"))
sys.exit(1)
if opts.random_seed:
@@ -171,60 +181,58 @@ def main():
else:
domain = lp.get("workgroup")
if domain == "WORKGROUP":
- print_err(("NETBIOS domain does not appear to be "
- "specified, use the --workgroup option"))
+ logger.error(("NETBIOS domain does not appear to be "
+ "specified, use the --workgroup option"))
sys.exit(1)
if not opts.realm and not lp.get('realm'):
- print_err("Realm not specified, use the --realm option")
+ logger.error("Realm not specified, use the --realm option")
sys.exit(1)
if opts.generate_users_only and not (opts.number_of_users or
opts.number_of_groups):
- print_err(("Please specify the number of users and/or groups "
- "to generate."))
+ logger.error(("Please specify the number of users and/or groups "
+ "to generate."))
sys.exit(1)
if opts.group_memberships and opts.average_groups_per_user:
- print_err(("--group-memberships and --average-groups-per-user"
- " are incompatible options - use one or the other"))
+ logger.error(("--group-memberships and --average-groups-per-user"
+ " are incompatible options - use one or the other"))
sys.exit(1)
if not opts.number_of_groups and opts.average_groups_per_user:
- print_err(("--average-groups-per-user requires "
- "--number-of-groups"))
+ logger.error(("--average-groups-per-user requires "
+ "--number-of-groups"))
sys.exit(1)
if opts.number_of_groups and opts.average_groups_per_user:
if opts.number_of_groups < opts.average_groups_per_user:
- print_err(("--average-groups-per-user can not be more than "
- "--number-of-groups"))
+ logger.error(("--average-groups-per-user can not be more than "
+ "--number-of-groups"))
sys.exit(1)
if not opts.number_of_groups and opts.group_memberships:
- print_err("--group-memberships requires --number-of-groups")
+ logger.error("--group-memberships requires --number-of-groups")
sys.exit(1)
if opts.timing_data not in ('-', None):
try:
open(opts.timing_data, 'w').close()
- except IOError as e:
- print_err(("the supplied timing data destination "
- "(%s) is not writable" % opts.timing_data))
- print_err(e)
+ except IOError:
+ # exception info will be added to log automatically
+ logger.exception(("the supplied timing data destination "
+ "(%s) is not writable" % opts.timing_data))
sys.exit()
if opts.traffic_summary not in ('-', None):
try:
open(opts.traffic_summary, 'w').close()
- except IOError as e:
--
Samba Shared Repository
More information about the samba-cvs
mailing list