1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

pynet: Raise proper exceptions rather than invoking sys.exit.

This commit is contained in:
Jelmer Vernooij
2010-05-19 00:26:56 +02:00
parent d18fbda0d0
commit ac9341245a
2 changed files with 6 additions and 8 deletions

View File

@ -20,8 +20,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import samba.getopt as options import samba.getopt as options
from samba.netcmd import Command, Option from samba.netcmd import Command, CommandError, Option
import sys, ldb import ldb
from getpass import getpass from getpass import getpass
from samba.auth import system_session from samba.auth import system_session
@ -61,6 +61,6 @@ class cmd_newuser(Command):
samdb.newuser(username, password, samdb.newuser(username, password,
force_password_change_at_next_login_req=must_change_at_next_login) force_password_change_at_next_login_req=must_change_at_next_login)
except ldb.LdbError, (num, msg): except ldb.LdbError, (num, msg):
print('Failed to create user "%s" : %s' % (username, msg)) raise CommandError('Failed to create user "%s" : %s' % (
sys.exit(1) username, msg))

View File

@ -22,7 +22,6 @@
import samba.getopt as options import samba.getopt as options
from samba.netcmd import Command, CommandError, Option from samba.netcmd import Command, CommandError, Option
import sys
from getpass import getpass from getpass import getpass
from samba.auth import system_session from samba.auth import system_session
from samba.samdb import SamDB from samba.samdb import SamDB
@ -73,6 +72,5 @@ class cmd_setpassword(Command):
force_change_at_next_login=must_change_at_next_login, force_change_at_next_login=must_change_at_next_login,
username=username) username=username)
except: except:
print('Failed to set password for user "%s"' % username) raise CommandError('Failed to set password for user "%s"' %
sys.exit(1) username)