Esempio n. 1
0
def _walk_assignment(assignment, func, args):
    """Walks all user's sources for assignment"""
    from config import options

    for user in os.listdir(vmcheckerpaths.dir_assignment(assignment)):
        path = vmcheckerpaths.dir_user(assignment, user)

        if not os.path.isdir(path):
            _logger.debug('Ignoring %s (not a directory)', path)
            continue

        if not os.path.isfile(os.path.join(path, 'config')):
            _logger.debug("Ignoring %s (no config file)", path)
            continue

        if options.user is not None and options.user != user:
            _logger.debug('Ignoring %s (as requested by --user)', path)
            continue

        if options.recursive:
            if os.path.commonprefix((os.getcwd(), path)) != os.getcwd():
                _logger.debug('Ignoring %s (in current directory)', path)
                continue

        _logger.info('Walking on %s, %s (%s)', assignment, user, path)
        if options.simulate:
            _simulate(assignment, user, path, func.func_name, args)
        else:
            try:
                func(assignment, user, path, *args)
            except:
                _logger.exception('%s failed for %s, %s (%s)',
                                  func.func_name, assignment, user, path)
                if not config.options.ignore:
                    raise
Esempio n. 2
0
    def __init__(self, assignment):
        location = vmcheckerpaths.dir_assignment(assignment)
        if not os.path.isdir(location):
            os.makedirs(location)

        self.__fd = os.open(
                os.path.join(location, '.lock'),
                os.O_CREAT | os.O_RDWR, 0600)
        assert self.__fd != -1
Esempio n. 3
0
def _walk_repository(repository, func, args):
    """Walks the repository."""
    from config import options

    for assignment in os.listdir(repository):
        path = vmcheckerpaths.dir_assignment(assignment)

        if not os.path.isdir(path):
            _logger.debug('Ignoring %s (not a directory)', path)
            continue

        if assignment not in config.assignments:
            _logger.debug('Ignoring %s (not an assignment)', path)
            continue

        if options.assignment is not None and options.assignment != assignment:
            _logger.debug('Ignoring %s (as requested by --assignment)',
                          path)
            continue

        _walk_assignment(assignment, func, args)