summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2011-10-08 14:13:04 +0200
committerJelmer Vernooij <jelmer@samba.org>2011-10-08 15:46:46 +0200
commit8111001977101288ca8277d5249776377c941974 (patch)
treef9c876d5cda08eea63f708041857beb6e7a44f4e /source4/scripting
parentdc3df567bef9a462fd48d233f88ee59dbadcbd89 (diff)
downloadsamba-8111001977101288ca8277d5249776377c941974.tar.gz
samba-8111001977101288ca8277d5249776377c941974.tar.bz2
samba-8111001977101288ca8277d5249776377c941974.zip
netcmd: Avoid catching all exceptions, avoid using ';' at the end of lines.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Oct 8 15:46:46 CEST 2011 on sn-devel-104
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/python/samba/netcmd/gpo.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/source4/scripting/python/samba/netcmd/gpo.py b/source4/scripting/python/samba/netcmd/gpo.py
index 06fa01c142..8b96d37d50 100644
--- a/source4/scripting/python/samba/netcmd/gpo.py
+++ b/source4/scripting/python/samba/netcmd/gpo.py
@@ -34,8 +34,7 @@ from samba.netcmd import (
SuperCommand,
)
from samba.samdb import SamDB
-from samba import drs_utils, nttime2string, dsdb, dcerpc
-from samba.dcerpc import misc
+from samba import dsdb, dcerpc
from samba.ndr import ndr_unpack
import samba.security
import samba.auth
@@ -170,14 +169,14 @@ def get_gpo_info(samdb, gpo=None, displayname=None, dn=None):
def parse_unc(unc):
'''Parse UNC string into a hostname, a service, and a filepath'''
if unc.startswith('\\\\') and unc.startswith('//'):
- return []
+ raise ValueError("UNC doesn't start with \\\\ or //")
tmp = unc[2:].split('/', 2)
if len(tmp) == 3:
return tmp
tmp = unc[2:].split('\\', 2)
if len(tmp) == 3:
- return tmp;
- return []
+ return tmp
+ raise ValueError("Invalid UNC string: %s" % unc)
def copy_directory_remote_to_local(conn, remotedir, localdir):
@@ -602,7 +601,7 @@ class cmd_dellink(Command):
gplist.remove(g)
break
else:
- raise CommandError("Specified GPO is not linked to this container");
+ raise CommandError("Specified GPO is not linked to this container")
m = ldb.Message()
m.dn = ldb.Dn(self.samdb, container_dn)
@@ -658,7 +657,7 @@ class cmd_getinheritance(Command):
inheritance = 0
if 'gPOptions' in msg:
- inheritance = int(msg['gPOptions'][0]);
+ inheritance = int(msg['gPOptions'][0])
if inheritance == dsdb.GPO_BLOCK_INHERITANCE:
print("Container has GPO_BLOCK_INHERITANCE")
@@ -713,7 +712,7 @@ class cmd_setinheritance(Command):
if 'gPOptions' in msg:
m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_REPLACE, 'gPOptions')
else:
- m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_ADD, 'gPOptions');
+ m['new_value'] = ldb.MessageElement(str(inheritance), ldb.FLAG_MOD_ADD, 'gPOptions')
try:
self.samdb.modify(m)
@@ -757,7 +756,7 @@ class cmd_fetch(Command):
unc = msg['gPCFileSysPath'][0]
try:
[dom_name, service, sharepath] = parse_unc(unc)
- except:
+ except ValueError:
raise CommandError("Invalid GPO path (%s)" % unc)
# SMB connect to DC