Exemple #1
0
 def test_symlinks1(self):
     """Basic test for symlinks."""
     #{{{
     self.assertEqual(find(self._pathto('ac'), '*', 0, 2),
                      self._format_result('ac', 'aca', 'acaa', 'acab'))
     self.assertEqual(
         find(self._pathto('baaab'), '*', 2, 4),
         self._format_result('baaabaa', 'ca', 'caa', 'cab', 'cac', 'caba'))
Exemple #2
0
 def test_cycles(self):
     """Test the processing of cycles in the directory structure."""
     self.assertEqual(
         find(self._pathto('b'), 'ca??', 0, None), self._format_result(
             'caba'))
     self.assertEqual(
         find(self._pathto('b'), 'c?', 0, None), self._format_result(
             'ca'))
Exemple #3
0
 def test_ignore_globs(self):
     """Test the functionality of ignore globs."""
     self.assertEqual(find(self._pathto('ac'), '*', 0, 2, ['aca?']),
                      self._format_result('ac', 'aca'))
     self.assertEqual(find(self._pathto('ac'), '*', 0, 2, ['ac', 'ac?a']),
                      set())
     self.assertEqual(find(self._pathto('baaab'), '*', 2, 4, ['*b']),
                      self._format_result('baaabaa', 'ca', 'caa', 'cac'))
Exemple #4
0
 def test_depth(self):
     """Tests mindepth and maxdepth."""
     #{{{
     self.assertEqual(find(self.testroot, '*', 0, 1),
                      self._format_result('.', 'a', 'b', 'c', 'd'))
     self.assertEqual(find(self._pathto('ac'), '*', 0, 1),
                      self._format_result('ac', 'aca'))
     self.assertEqual(find(self._pathto('ac'), '*', 0, 0),
                      self._format_result('ac', ))
     self.assertEqual(find(self._pathto('ac'), '*', 0, -1), set())
Exemple #5
0
 def test_symlinks1(self):
     """Basic test for symlinks."""
 #{{{
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, 2), self._format_result(
             'ac','aca','acaa','acab'))
     self.assertEqual(
         find(self._pathto('baaab'), '*', 2, 4), self._format_result(
             'baaabaa', 'ca',
             'caa', 'cab', 'cac',
             'caba'))
Exemple #6
0
 def test_globs(self):
     """Tests processing of the selection glob."""
     #{{{
     self.assertEqual(find(self._pathto('ac'), '*b', 0, 2),
                      self._format_result('acab'))
     self.assertEqual(find(self._pathto('ac'), 'aca?', 0, 2),
                      self._format_result('acaa', 'acab'))
     self.assertEqual(find(self._pathto('b'), '[!b]*', 4, 7),
                      self._format_result('ca', 'caa', 'cab'))
     self.assertEqual(find(self._pathto('b'), '??[bc]', 4, 7),
                      self._format_result('cab'))
Exemple #7
0
 def test_ignore_globs(self):
     """Test the functionality of ignore globs."""
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, 2, ['aca?']),
         self._format_result('ac','aca'))
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, 2, ['ac','ac?a']),
         set())
     self.assertEqual(
         find(self._pathto('baaab'), '*', 2, 4, ['*b']),
         self._format_result('baaabaa', 'ca', 'caa', 'cac'))
Exemple #8
0
 def test_depth(self):
     """Tests mindepth and maxdepth."""
 #{{{
     self.assertEqual(
         find(self.testroot, '*', 0, 1), self._format_result(
             '.', 'a', 'b', 'c', 'd'))
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, 1), self._format_result(
             'ac', 'aca'))
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, 0), self._format_result(
             'ac',))
     self.assertEqual(
         find(self._pathto('ac'), '*', 0, -1), set())
Exemple #9
0
 def test_globs(self):
     """Tests processing of the selection glob."""
 #{{{
     self.assertEqual(
         find(self._pathto('ac'), '*b', 0, 2), self._format_result(
             'acab'))
     self.assertEqual(
         find(self._pathto('ac'), 'aca?', 0, 2), self._format_result(
             'acaa', 'acab'))
     self.assertEqual(
         find(self._pathto('b'), '[!b]*', 4, 7), self._format_result(
             'ca', 'caa', 'cab'))
     self.assertEqual(
         find(self._pathto('b'), '??[bc]', 4, 7), self._format_result(
             'cab'))
Exemple #10
0
def test_find_not_recursive():
    
    files = [f for f in list(fs.list(TEST_DIR)) if fs.extname(f) == '.txt']
    fs_files = list( fs.find('*.txt', TEST_DIR, recursive=False) )

    assert len(files) > 0
    assert len(files) is len(fs_files)
    assert sorted(files) == sorted(fs_files)
Exemple #11
0
def test_find_not_recursive():

    files = [f for f in list(fs.list(TEST_DIR)) if fs.extname(f) == '.txt']
    fs_files = list(fs.find('*.txt', TEST_DIR, recursive=False))

    assert len(files) > 0
    assert len(files) is len(fs_files)
    assert sorted(files) == sorted(fs_files)
def get_backup_file_list(monitoring_dir, ELAPSED_TIME):
    backup_file_list = []
    now = int(time.time())
    for f in fs.find('*', path=monitoring_dir):
        last_accessed = fs.stat(f).st_atime
        diff = now - last_accessed
        if diff > ELAPSED_TIME:
            backup_file_list.append(f)
    return backup_file_list
Exemple #13
0
def make():
	"""Generate the current shell scripts from the templates"""
	clean()

	for _file in fs.find('*.sh', SRC_DIR):
		tplname = _file.replace(SRC_DIR + '/', "")
		dest = fs.join(DIST_DIR, fs.filename(tplname))
		tpl = env.get_template(tplname)
		fs.write(dest, tpl.render())
		print("Writing template %s" % tplname)
def get_backup_dir_list(monitoring_dir, ELAPSED_TIME):
    backup_dir_list = []
    now = int(time.time())
    for f in fs.find('*', path=monitoring_dir):
        last_accessed = fs.stat(f).st_atime
        diff = now - last_accessed
        if diff > ELAPSED_TIME:
            if not fs.dirname(f) in backup_dir_list:
                backup_dir_list.append(fs.dirname(f))
    return list(set(backup_dir_list))
Exemple #15
0
def test_find():

    files = []
    for root, dirnames, filenames in os.walk(TEST_DIR):
        for f in filenames:
            if os.path.isfile(os.path.join(TEST_DIR, f)):
                if fs.extname(f) == '.txt':
                    files.append(os.path.join(TEST_DIR, f))

    fs_files = list(fs.find('*.txt', TEST_DIR))

    assert len(files) > 0
    assert len(files) is len(fs_files)
    assert sorted(files) == sorted(fs_files)
Exemple #16
0
def test_find():
    
    files = [] 
    for root, dirnames, filenames in os.walk(TEST_DIR):
        for f in filenames:
            if os.path.isfile(os.path.join(TEST_DIR,f)):
                if fs.extname(f) == '.txt':
                    files.append(os.path.join(TEST_DIR,f)) 

    fs_files = list( fs.find('*.txt', TEST_DIR) )

    assert len(files) > 0
    assert len(files) is len(fs_files)
    assert sorted(files) == sorted(fs_files)
    def findFile(self):
        path = self.path
        print(path)
        correctFile = []
    
        for p in path:
            print(p)
            for extname in self.ext:
                for filename in fs.find('*.'+extname, path=p):       
                
                    correctFile.append(filename)
                
 
        #  correctFile.extend(self.findCorrectFile(files))
        
        print('Find '+ str(len(correctFile))+' files with extension name ' + str(self.ext))
        self.correctFile = correctFile
Exemple #18
0
# THIS IS ONLY A TEST FILE TO TEST THE CLOB PARSER

import log
log = log.log

import sys, fs, parsers
paths = fs.find(sys.argv[1], parsers.parse)

from ptree import Path, PrefixTree

# expand dots into real paths
# replace with identity to disable
def exp_path(path):
  import string
  return path if path == [] else Path(reduce(list.__add__, map(lambda s: string.split(s, '.'), path)))
  
tree = PrefixTree({ exp_path(k): v for (k, v) in paths.items() })
# log(tree)

import yaml

def literal_presenter(dumper, data):
  return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')

def dict_presenter(dumper, data):
  return dumper.represent_mapping('tag:yaml.org,2002:map', data.items())

yaml.add_representer(parsers.clob, literal_presenter)
yaml.add_representer(PrefixTree, dict_presenter)

yaml.safe_dump(tree, sys.stdout, default_flow_style=False)
ds_train = Dataset(DATASET_DIR, 'train')
ds_test = Dataset(DATASET_DIR, 'test')

# Initialize the preprocessing pipeline
print("Setting up preprocessing ...")
tform = get_normalization_transform(
    means=ds_train.get_mean(per_channel=True),
    stds=ds_train.get_stddev(per_channel=True),
)

# Initialize the MiniBatch generators
print("Initializing minibatch generators ...")
mb_test = MiniBatchGenerator(ds_test, test_batchsize, tform)

print(" [%s] %i samples, %i minibatches of size %i" %
      (ds_test.split, mb_test.dataset.size(), mb_test.nbatches(),
       mb_test.batchsize()))

# Load latest model
latest_model = max(fs.find('*.h5', path=MODEL_DIR), key=fs.ctime)

# Test best model
print("Testing model %s on test set ..." % latest_model)
utils.test(load_model(latest_model), mb_test)

# Visualize model
# utils.visualise_with_quiver(load_model(latest_model), '/home/patrick', class_type='gender')
if "gender" in ds_test.__class__.__name__:
    utils.visualise_with_quiver(load_model(latest_model), class_type='gender')
else:
    utils.visualise_with_quiver(load_model(latest_model), class_type='age')
Exemple #20
0
 def test_cycles(self):
     """Test the processing of cycles in the directory structure."""
     self.assertEqual(find(self._pathto('b'), 'ca??', 0, None),
                      self._format_result('caba'))
     self.assertEqual(find(self._pathto('b'), 'c?', 0, None),
                      self._format_result('ca'))
Exemple #21
0
 def test_wrong_args(self):
     """Test for handling wrong arguments."""
     #{{{
     self.assertEqual(find(self._pathto('baaaba'), '*', 41, 35), set())
Exemple #22
0
 def test_wrong_args(self):
     """Test for handling wrong arguments."""
 #{{{
     self.assertEqual(
         find(self._pathto('baaaba'), '*', 41, 35), set())