PEP8: fix E101: indentation contains mixed spaces and tabs
authorJoe Guo <joeg@catalyst.net.nz>
Mon, 3 Sep 2018 13:05:20 +0000 (01:05 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 6 Sep 2018 10:10:11 +0000 (12:10 +0200)
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/script/tests/getset_quota.py
source3/script/tests/test_smbcquota.py
source3/selftest/tests.py

index 0254aa5a3b3fd078cb9e0b30664fe936017368c6..4daae3d7b2322412f1a5618fea9e057cd5a50ab5 100755 (executable)
@@ -29,126 +29,126 @@ GROUP_DEFAULT_QUOTAS = 4
 #Quota model
 
 class Quota:
-       def __init__(self):
-               self.flags = 0
-               self.quotatype = USER_DEFAULT_QUOTAS
-               self.uid = 0
-               self.usedblocks = 0
-               self.softlimit = 0
-               self.hardlimit = 0
-               self.hardlimit = 0
-               self.usedinodes = 0
-               self.slimitinodes = 0
-               self.hlimitinodes = 0
+    def __init__(self):
+        self.flags = 0
+        self.quotatype = USER_DEFAULT_QUOTAS
+        self.uid = 0
+        self.usedblocks = 0
+        self.softlimit = 0
+        self.hardlimit = 0
+        self.hardlimit = 0
+        self.usedinodes = 0
+        self.slimitinodes = 0
+        self.hlimitinodes = 0
 
 def quota_to_str(item):
-       result = str(item.flags) + " " + str(item.usedblocks) + " " + str(item.softlimit) + " " + str(item.hardlimit) + " " + str(item.usedinodes) + " " + str(item.slimitinodes) + " " + str(item.hlimitinodes)
-       return result
+    result = str(item.flags) + " " + str(item.usedblocks) + " " + str(item.softlimit) + " " + str(item.hardlimit) + " " + str(item.usedinodes) + " " + str(item.slimitinodes) + " " + str(item.hlimitinodes)
+    return result
 
 def quota_to_db_str(item):
-       result = item.uid + " " + str(item.usedblocks) + " " + str(item.softlimit) + " " + str(item.hardlimit) + " " + str(item.usedinodes) + " " + str(item.slimitinodes) + " " + str(item.hlimitinodes)
-       return result
+    result = item.uid + " " + str(item.usedblocks) + " " + str(item.softlimit) + " " + str(item.hardlimit) + " " + str(item.usedinodes) + " " + str(item.slimitinodes) + " " + str(item.hlimitinodes)
+    return result
 
 def load_quotas(input_file):
-       fileContents = open(input_file,"r")
-       lineno = 0
-       quotas = []
-       for line in fileContents:
-               if line.strip().startswith("#"):
-                       continue
-               content = line.strip().split()
-               quota = Quota()
-               if len(content) < 7:
-                       logging.debug("ignoring line %d, doesn't have enough fields\n"%lineno)
-               else:
-                       quota.flags = 2
-                       quota.uid = content[0]
-                       quota.usedblocks = content[1]
-                       quota.softlimit = content[2]
-                       quota.hardlimit = content[3]
-                       quota.usedinodes = content[4]
-                       quota.slimitinodes = content[5]
-                       quota.hlimitinodes = content[6]
-                       quotas.append(quota)
+    fileContents = open(input_file,"r")
+    lineno = 0
+    quotas = []
+    for line in fileContents:
+        if line.strip().startswith("#"):
+            continue
+        content = line.strip().split()
+        quota = Quota()
+        if len(content) < 7:
+            logging.debug("ignoring line %d, doesn't have enough fields\n"%lineno)
+        else:
+            quota.flags = 2
+            quota.uid = content[0]
+            quota.usedblocks = content[1]
+            quota.softlimit = content[2]
+            quota.hardlimit = content[3]
+            quota.usedinodes = content[4]
+            quota.slimitinodes = content[5]
+            quota.hlimitinodes = content[6]
+            quotas.append(quota)
 
-       fileContents.close()
-       return quotas
+    fileContents.close()
+    return quotas
 
 def set_quotas(quota_list, output_file):
-       filecontents = open(output_file,"w+")
-       if filecontents == None:
-               return False;
-       lines = ""
-       for quota in quota_list:
-               next_line = quota_to_db_str(quota)
-               if next_line:
-                       lines = lines + next_line + "\n"
-       filecontents.write(lines)
-       filecontents.close()
-       return True
+    filecontents = open(output_file,"w+")
+    if filecontents == None:
+        return False;
+    lines = ""
+    for quota in quota_list:
+        next_line = quota_to_db_str(quota)
+        if next_line:
+            lines = lines + next_line + "\n"
+    filecontents.write(lines)
+    filecontents.close()
+    return True
 
 def get_quotas(uid, quota_list):
-       logging.debug("in get_quotas\n")
-       for quota in quota_list:
-               if quota.uid == uid:
-                       return quota
-       return None
+    logging.debug("in get_quotas\n")
+    for quota in quota_list:
+        if quota.uid == uid:
+            return quota
+    return None
 
 def main():
-       logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
-       logging.debug("system args passed are %s\n"% str(sys.argv))
-       quota_file_dir = os.path.dirname(sys.argv[0]);
-       quota_file_db = os.path.join(quota_file_dir,"quotas.db")
-       logging.debug("quota db is located %s\n", quota_file_db)
-       quota_list = load_quotas(quota_file_db)
-       logging.debug("quotas loaded have %s entries\n", len(quota_list))
-       result = None
-       if len(sys.argv) == 4:
-               # Get Quota
-               directory = sys.argv[1]
-               if sys.argv[2] == "1":
-                       query_type = USER_QUOTAS
-               elif sys.argv[2] == "2":
-                       query_type = USER_DEFAULT_QUOTAS
-               elif sys.argv[2] == "3":
-                       query_type = GROUP_QUOTAS
-               elif sys.argv[2] == "4":
-                       query_type = GROUP_DEFAULT_QUOTAS
-               uid = sys.argv[3]
-               quota = get_quotas(uid, quota_list)
-               if quota is None:
-                       logging.debug("no result for uid %s"%uid)
-               else:
-                       result = quota_to_str(quota)
-                       logging.debug("got result for uid %s\n"%uid);
-               if result is None:
-                       result = "0 0 0 0 0 0 0"
-               logging.debug("for uid %s returning quotas %s\n"%(uid,result))
-               print("%s"%result)
-       elif len(sys.argv) > 8:
-               # Set Quota
-               quota = Quota()
-               directory = sys.argv[1]
-               quota.query_type = sys.argv[2]
-               quota.uid = sys.argv[3]
-               quota.flags = sys.argv[4]
-               quota.softlimit = sys.argv[5]
-               quota.hardlimit = sys.argv[6]
-               quota.slimitinodes = sys.argv[7]
-               quota.hlimitinodes = sys.argv[8]
-               found = get_quotas(quota.uid, quota_list)
-               if found:
-                       found.query_type = quota.query_type
-                       found.uid = quota.uid
-                       found.flags = quota.flags
-                       found.softlimit = quota.softlimit
-                       found.hardlimit = quota.hardlimit
-                       found.slimitinodes = quota.slimitinodes
-                       found.hlimitinodes = quota.hlimitinodes
-               else:
-                       quota_list.append(quota)
-               if set_quotas(quota_list,quota_file_db):
-                       print ("%s\n"%quota_to_str(quota_list[-1]))
-       return
+    logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
+    logging.debug("system args passed are %s\n"% str(sys.argv))
+    quota_file_dir = os.path.dirname(sys.argv[0]);
+    quota_file_db = os.path.join(quota_file_dir,"quotas.db")
+    logging.debug("quota db is located %s\n", quota_file_db)
+    quota_list = load_quotas(quota_file_db)
+    logging.debug("quotas loaded have %s entries\n", len(quota_list))
+    result = None
+    if len(sys.argv) == 4:
+        # Get Quota
+        directory = sys.argv[1]
+        if sys.argv[2] == "1":
+            query_type = USER_QUOTAS
+        elif sys.argv[2] == "2":
+            query_type = USER_DEFAULT_QUOTAS
+        elif sys.argv[2] == "3":
+            query_type = GROUP_QUOTAS
+        elif sys.argv[2] == "4":
+            query_type = GROUP_DEFAULT_QUOTAS
+        uid = sys.argv[3]
+        quota = get_quotas(uid, quota_list)
+        if quota is None:
+            logging.debug("no result for uid %s"%uid)
+        else:
+            result = quota_to_str(quota)
+            logging.debug("got result for uid %s\n"%uid);
+        if result is None:
+            result = "0 0 0 0 0 0 0"
+        logging.debug("for uid %s returning quotas %s\n"%(uid,result))
+        print("%s"%result)
+    elif len(sys.argv) > 8:
+        # Set Quota
+        quota = Quota()
+        directory = sys.argv[1]
+        quota.query_type = sys.argv[2]
+        quota.uid = sys.argv[3]
+        quota.flags = sys.argv[4]
+        quota.softlimit = sys.argv[5]
+        quota.hardlimit = sys.argv[6]
+        quota.slimitinodes = sys.argv[7]
+        quota.hlimitinodes = sys.argv[8]
+        found = get_quotas(quota.uid, quota_list)
+        if found:
+            found.query_type = quota.query_type
+            found.uid = quota.uid
+            found.flags = quota.flags
+            found.softlimit = quota.softlimit
+            found.hardlimit = quota.hardlimit
+            found.slimitinodes = quota.slimitinodes
+            found.hlimitinodes = quota.hlimitinodes
+        else:
+            quota_list.append(quota)
+        if set_quotas(quota_list,quota_file_db):
+            print ("%s\n"%quota_to_str(quota_list[-1]))
+    return
 if __name__ == '__main__':
     main()
index 52061f2989fe7b9f3e32cfa5b7f87b99ac12c87f..1e8f06386b8dbf62bdea3fdf74c17f8c03ecdb23 100755 (executable)
@@ -30,215 +30,215 @@ DEFAULT_SOFTLIM = 2
 DEFAULT_HARDLIM = 4
 
 class test_env:
-       def __init__(self):
-               self.server = None
-               self.domain = None
-               self.username = None
-               self.password = None
-               self.envdir = None
-               self.quota_db = None
-               self.smbcquotas = None
-               self.users = []
+    def __init__(self):
+        self.server = None
+        self.domain = None
+        self.username = None
+        self.password = None
+        self.envdir = None
+        self.quota_db = None
+        self.smbcquotas = None
+        self.users = []
 
 class user_info:
-       def __init__(self):
-               self.uid = 0
-               self.username = ""
-               self.softlim = 0
-               self.hardlim = 0
+    def __init__(self):
+        self.uid = 0
+        self.username = ""
+        self.softlim = 0
+        self.hardlim = 0
 
 class Quota:
-       def __init__(self):
-               self.flags = 0
-               self.quotatype = USER_DEFAULT_QUOTAS
-               self.uid = 0
-               self.usedblocks = 0
-               self.softlimit = 0
-               self.hardlimit = 0
-               self.hardlimit = 0
-               self.usedinodes = 0
-               self.slimitinodes = 0
-               self.hlimitinodes = 0
+    def __init__(self):
+        self.flags = 0
+        self.quotatype = USER_DEFAULT_QUOTAS
+        self.uid = 0
+        self.usedblocks = 0
+        self.softlimit = 0
+        self.hardlimit = 0
+        self.hardlimit = 0
+        self.usedinodes = 0
+        self.slimitinodes = 0
+        self.hlimitinodes = 0
 
 def init_quota_db(users, output_file):
-       filecontents = open(output_file,"w+")
-       lines = ""
-       default_values = "0 " + str(DEFAULT_SOFTLIM) + " " + str(DEFAULT_HARDLIM) + " 0 0 0"
-       for user in users:
-               lines = lines + user.uid + " " + default_values + "\n"
-       filecontents.write(lines)
-       filecontents.close()
+    filecontents = open(output_file,"w+")
+    lines = ""
+    default_values = "0 " + str(DEFAULT_SOFTLIM) + " " + str(DEFAULT_HARDLIM) + " 0 0 0"
+    for user in users:
+        lines = lines + user.uid + " " + default_values + "\n"
+    filecontents.write(lines)
+    filecontents.close()
 
 def load_quotas(input_file):
-       fileContents = open(input_file,"r")
-       lineno = 0
-       quotas = []
-       for line in fileContents:
-               if line.strip().startswith("#"):
-                       continue
-               content = line.strip().split()
-               quota = Quota()
-               if len(content) < 7:
-                       logging.debug("ignoring line %d, doesn't have enough fields\n"%lineno)
-               else:
-                       quota.flags = 2
-                       quota.uid = content[0]
-                       quota.usedblocks = content[1]
-                       quota.softlimit = content[2]
-                       quota.hardlimit = content[3]
-                       quota.usedinodes = content[4]
-                       quota.slimitinodes = content[5]
-                       quota.hlimitinodes = content[6]
-                       quotas.append(quota)
-
-       fileContents.close()
-       return quotas
+    fileContents = open(input_file,"r")
+    lineno = 0
+    quotas = []
+    for line in fileContents:
+        if line.strip().startswith("#"):
+            continue
+        content = line.strip().split()
+        quota = Quota()
+        if len(content) < 7:
+            logging.debug("ignoring line %d, doesn't have enough fields\n"%lineno)
+        else:
+            quota.flags = 2
+            quota.uid = content[0]
+            quota.usedblocks = content[1]
+            quota.softlimit = content[2]
+            quota.hardlimit = content[3]
+            quota.usedinodes = content[4]
+            quota.slimitinodes = content[5]
+            quota.hlimitinodes = content[6]
+            quotas.append(quota)
+
+    fileContents.close()
+    return quotas
 
 def get_quotas(uid, quota_list):
-       for quota in quota_list:
-               if quota.uid == uid:
-                       return quota
-       return None
+    for quota in quota_list:
+        if quota.uid == uid:
+            return quota
+    return None
 
 def get_users():
-       output = subprocess.Popen(['getent', 'passwd'],
-                                 stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
-       users = []
-       for line in output:
-               info = line.split(':')
-               if len(info) > 3 and info[0]:
-                       user = user_info()
-                       user.username = info[0]
-                       user.uid = info[2]
-                       logging.debug("Adding user ->%s<-\n"%user.username)
-                       users.append(user)
-       return users
+    output = subprocess.Popen(['getent', 'passwd'],
+                             stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
+    users = []
+    for line in output:
+        info = line.split(':')
+        if len(info) > 3 and info[0]:
+            user = user_info()
+            user.username = info[0]
+            user.uid = info[2]
+            logging.debug("Adding user ->%s<-\n"%user.username)
+            users.append(user)
+    return users
 
 
 
 def smbcquota_output_to_userinfo(output):
-       infos = []
-       for line in output:
-               if len(line) > 1:
-                       username = line.strip(':').split()[0]
-                       quota_info = line.split(':')[1].split('/')
-                       if len(quota_info) > 2:
-                               info = user_info()
-                               info.username = username.strip()
-                               info.softlim = int(quota_info[1].strip()) / BLOCK_SIZE
-                               info.hardlim = int(quota_info[2].strip()) / BLOCK_SIZE
-                               infos.append(info)
-       return infos
+    infos = []
+    for line in output:
+        if len(line) > 1:
+            username = line.strip(':').split()[0]
+            quota_info = line.split(':')[1].split('/')
+            if len(quota_info) > 2:
+                info = user_info()
+                info.username = username.strip()
+                info.softlim = int(quota_info[1].strip()) / BLOCK_SIZE
+                info.hardlim = int(quota_info[2].strip()) / BLOCK_SIZE
+                infos.append(info)
+    return infos
 
 def check_quota_limits(infos, softlim, hardlim):
-       if len(infos) < 1:
-               logging.debug("no users info to check :-(\n")
-               return False
-       for info in infos:
-               if int(info.softlim) != softlim:
-                       logging.debug("expected softlimit %s got ->%s<-\n"%(softlim, info.softlim))
-                       return False
-               if int(info.hardlim) != hardlim:
-                       logging.debug("expected hardlimit limit %s got %s\n"%(hardlim,info.hardlim))
-                       return False
-       return True
+    if len(infos) < 1:
+        logging.debug("no users info to check :-(\n")
+        return False
+    for info in infos:
+        if int(info.softlim) != softlim:
+            logging.debug("expected softlimit %s got ->%s<-\n"%(softlim, info.softlim))
+            return False
+        if int(info.hardlim) != hardlim:
+            logging.debug("expected hardlimit limit %s got %s\n"%(hardlim,info.hardlim))
+            return False
+    return True
 
 class test_base:
-       def __init__(self, env):
-               self.env = env
-       def run(self, protocol):
-               pass
+    def __init__(self, env):
+        self.env = env
+    def run(self, protocol):
+        pass
 
 class listtest(test_base):
-       def run(self, protocol):
-               init_quota_db(self.env.users, self.env.quota_db)
-               quotas = load_quotas(self.env.quota_db)
-               args = [self.env.smbcquotas];
-               remaining_args = ['-U' + self.env.username + "%" + self.env.password, '-L', '//' + self.env.server + '/quotadir']
-               if protocol == 'smb2':
-                       args.append('-m smb2')
-               args.extend(remaining_args)
-               output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '-L', '//' + self.env.server + '/quotadir'], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
-               infos = smbcquota_output_to_userinfo(output)
-               return check_quota_limits(infos, DEFAULT_SOFTLIM, DEFAULT_HARDLIM)
+    def run(self, protocol):
+        init_quota_db(self.env.users, self.env.quota_db)
+        quotas = load_quotas(self.env.quota_db)
+        args = [self.env.smbcquotas];
+        remaining_args = ['-U' + self.env.username + "%" + self.env.password, '-L', '//' + self.env.server + '/quotadir']
+        if protocol == 'smb2':
+            args.append('-m smb2')
+        args.extend(remaining_args)
+        output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '-L', '//' + self.env.server + '/quotadir'], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
+        infos = smbcquota_output_to_userinfo(output)
+        return check_quota_limits(infos, DEFAULT_SOFTLIM, DEFAULT_HARDLIM)
 def get_uid(name, users):
-       for user in users:
-               if user.username == name:
-                       return user.uid
-       return None
+    for user in users:
+        if user.username == name:
+            return user.uid
+    return None
 
 class gettest(test_base):
-       def run(self, protocol):
-               init_quota_db(self.env.users, self.env.quota_db)
-               quotas = load_quotas(self.env.quota_db)
-               uid = get_uid(self.env.username, self.env.users)
-               output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '-u' + self.env.username, '//' + self.env.server + '/quotadir'], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
-               user_infos = smbcquota_output_to_userinfo(output)
-               db_user_info = get_quotas(uid, quotas)
-               # double check, we compare the results from the db file
-               # the quota script the server uses compared to what
-               # smbcquota is telling us
-               return check_quota_limits(user_infos, int(db_user_info.softlimit), int(db_user_info.hardlimit))
+    def run(self, protocol):
+        init_quota_db(self.env.users, self.env.quota_db)
+        quotas = load_quotas(self.env.quota_db)
+        uid = get_uid(self.env.username, self.env.users)
+        output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '-u' + self.env.username, '//' + self.env.server + '/quotadir'], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
+        user_infos = smbcquota_output_to_userinfo(output)
+        db_user_info = get_quotas(uid, quotas)
+        # double check, we compare the results from the db file
+        # the quota script the server uses compared to what
+        # smbcquota is telling us
+        return check_quota_limits(user_infos, int(db_user_info.softlimit), int(db_user_info.hardlimit))
 
 class settest(test_base):
-       def run(self, protocol):
-               init_quota_db(self.env.users, self.env.quota_db)
-               quotas = load_quotas(self.env.quota_db)
-               uid = get_uid(self.env.username, self.env.users)
-               old_db_user_info = get_quotas(uid, quotas)
+    def run(self, protocol):
+        init_quota_db(self.env.users, self.env.quota_db)
+        quotas = load_quotas(self.env.quota_db)
+        uid = get_uid(self.env.username, self.env.users)
+        old_db_user_info = get_quotas(uid, quotas)
 
-               #increase limits by 2 blocks
-               new_soft_limit = (int(old_db_user_info.softlimit) + 2) * BLOCK_SIZE
-               new_hard_limit = (int(old_db_user_info.hardlimit) + 2) * BLOCK_SIZE
+        #increase limits by 2 blocks
+        new_soft_limit = (int(old_db_user_info.softlimit) + 2) * BLOCK_SIZE
+        new_hard_limit = (int(old_db_user_info.hardlimit) + 2) * BLOCK_SIZE
 
-               new_limits = "UQLIM:%s:%d/%d"%(self.env.username, new_soft_limit, new_hard_limit)
-               logging.debug("setting new limits %s"%new_limits)
+        new_limits = "UQLIM:%s:%d/%d"%(self.env.username, new_soft_limit, new_hard_limit)
+        logging.debug("setting new limits %s"%new_limits)
 
-               output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '//' + self.env.server + '/quotadir', '-S', new_limits], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
-               logging.debug("output from smbcquota is %s"%output)
-               user_infos = smbcquota_output_to_userinfo(output)
-               return check_quota_limits(user_infos, new_soft_limit / BLOCK_SIZE, new_hard_limit / BLOCK_SIZE)
+        output = subprocess.Popen([self.env.smbcquotas, '-U' + self.env.username + "%" + self.env.password, '//' + self.env.server + '/quotadir', '-S', new_limits], stdout=subprocess.PIPE).communicate()[0].decode("utf-8").split('\n')
+        logging.debug("output from smbcquota is %s"%output)
+        user_infos = smbcquota_output_to_userinfo(output)
+        return check_quota_limits(user_infos, new_soft_limit / BLOCK_SIZE, new_hard_limit / BLOCK_SIZE)
 
 # map of tests
 subtest_descriptions = {
-       "list test" : listtest,
-       "get test" : gettest,
-       "set test" : settest
+        "list test" : listtest,
+        "get test" : gettest,
+        "set test" : settest
 }
 
 def main():
-       logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
-
-       logging.debug("got args %s\n"%str(sys.argv))
-
-       if len(sys.argv) < 7:
-               logging.debug ("Usage: test_smbcquota.py server domain username password envdir smbcquotas\n")
-               sys.exit(1)
-       env = test_env()
-       env.server = sys.argv[1]
-       env.domain = sys.argv[2]
-       env.username = sys.argv[3]
-       env.password = sys.argv[4]
-       env.envdir = sys.argv[5]
-       env.smbcquotas = sys.argv[6]
-       quota_script = os.path.join(os.path.dirname(sys.argv[0]),
-                               "getset_quota.py")
-       #copy the quota script to the evironment
-       shutil.copy2(quota_script, env.envdir)
-
-       env.quota_db = os.path.join(env.envdir, "quotas.db")
-       env.users = get_users()
-       for protocol in ['smb1', 'smb2']:
-               for key in subtest_descriptions.keys():
-                       test = subtest_descriptions[key](env)
-                       logging.debug("running subtest '%s' using protocol '%s'\n"%(key,protocol))
-                       result = test.run(protocol)
-                       if result == False:
-                               logging.debug("subtest '%s' for '%s' failed\n"%(key,protocol))
-                               sys.exit(1)
-                       else:
-                               logging.debug("subtest '%s' for '%s' passed\n"%(key,protocol))
-       sys.exit(0)
+    logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
+
+    logging.debug("got args %s\n"%str(sys.argv))
+
+    if len(sys.argv) < 7:
+        logging.debug ("Usage: test_smbcquota.py server domain username password envdir smbcquotas\n")
+        sys.exit(1)
+    env = test_env()
+    env.server = sys.argv[1]
+    env.domain = sys.argv[2]
+    env.username = sys.argv[3]
+    env.password = sys.argv[4]
+    env.envdir = sys.argv[5]
+    env.smbcquotas = sys.argv[6]
+    quota_script = os.path.join(os.path.dirname(sys.argv[0]),
+                            "getset_quota.py")
+    #copy the quota script to the evironment
+    shutil.copy2(quota_script, env.envdir)
+
+    env.quota_db = os.path.join(env.envdir, "quotas.db")
+    env.users = get_users()
+    for protocol in ['smb1', 'smb2']:
+        for key in subtest_descriptions.keys():
+            test = subtest_descriptions[key](env)
+            logging.debug("running subtest '%s' using protocol '%s'\n"%(key,protocol))
+            result = test.run(protocol)
+            if result == False:
+                logging.debug("subtest '%s' for '%s' failed\n"%(key,protocol))
+                sys.exit(1)
+            else:
+                logging.debug("subtest '%s' for '%s' passed\n"%(key,protocol))
+    sys.exit(0)
 
 if __name__ == '__main__':
     main()
index 2f474ec2dbf14fd37ce4fffcebd5479fc7d2019f..30796128f0cba4bd7b8cb0f2b6d6a9e320dbf02a 100755 (executable)
@@ -432,9 +432,9 @@ unix = ["unix.info2", "unix.whoami"]
 nbt = ["nbt.dgram"]
 
 libsmbclient = ["libsmbclient.version", "libsmbclient.initialize",
-               "libsmbclient.configuration", "libsmbclient.setConfiguration",
-               "libsmbclient.options", "libsmbclient.opendir",
-               "libsmbclient.list_shares", "libsmbclient.readdirplus"]
+                "libsmbclient.configuration", "libsmbclient.setConfiguration",
+                "libsmbclient.options", "libsmbclient.opendir",
+                "libsmbclient.list_shares", "libsmbclient.readdirplus"]
 
 vfs = ["vfs.fruit", "vfs.acl_xattr", "vfs.fruit_netatalk", "vfs.fruit_file_id", "vfs.fruit_timemachine"]
 
@@ -583,9 +583,9 @@ for t in tests:
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
         plansmbtorture4testsuite(t, "ad_dc", '//$SERVER/tmp -U$USERNAME%$PASSWORD --option=torture:wksname=samba3rpctest')
     elif t.startswith("libsmbclient"):
-       url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp"
-       if t == "libsmbclient.list_shares":
-               url = "smb://$USERNAME:$PASSWORD@$SERVER"
+        url = "smb://$USERNAME:$PASSWORD@$SERVER/tmp"
+        if t == "libsmbclient.list_shares":
+            url = "smb://$USERNAME:$PASSWORD@$SERVER"
 
         plansmbtorture4testsuite(t, "nt4_dc", '//$SERVER_IP/tmp -U$USERNAME%%$PASSWORD '
                                     '--option=torture:smburl=' + url +