Ejemplo n.º 1
0
def populate_directory(fargs):
    """
    Populates queue for workers. Consumes lots of disk I/O.

    """
    directory, checkmodes = fargs
    start_time = time.time()
    try:
        if not validate_directory(directory, checkmodes):
            return time.time() - start_time
        logging.debug('Populating: %s', directory)
        for filename in filepaths_in_dir(directory, checkmodes):
            for appname in database.issues:
                for loc in database.locations(appname, with_lists=False):
                    if filename.endswith(loc):
                        queue.put((filename, loc, appname))
    except Exception:
        logging.error(traceback.format_exc())
    return time.time() - start_time
Ejemplo n.º 2
0
def populate_directory(fargs):
    """
    Populates queue for workers. Consumes lots of disk I/O.

    """
    directory, checkmodes = fargs
    start_time = time.time()
    try:
        if not validate_directory(directory, checkmodes):
            return time.time() - start_time
        logging.debug('Populating: %s', directory)
        for filename in filepaths_in_dir(directory, checkmodes):
            for appname in database.issues:
                for loc in database.locations(appname, with_lists=False):
                    if filename.endswith(loc):
                        queue.put((filename, loc, appname))
    except Exception:
        logging.error(traceback.format_exc())
    return time.time() - start_time
Ejemplo n.º 3
0
 def test_filepaths(self):
     """File paths in directory are detected correctly."""
     paths = filepaths_in_dir('testfiles/', False)
     self.assertEqual(sum(1 for _ in paths), 4)
     paths = filepaths_in_dir('testfiles/', True)
     self.assertEqual(sum(1 for _ in paths), 4)
Ejemplo n.º 4
0
 def test_filepaths(self):
     """File paths in directory are detected correctly."""
     paths = filepaths_in_dir('testfiles/', False)
     self.assertEqual(sum(1 for _ in paths), 2)
     paths = filepaths_in_dir('testfiles/', True)
     self.assertEqual(sum(1 for _ in paths), 2)