def filter(self, request, repos):
        if 'name' in request.GET:
            pattern = re.compile(request.GET['name'])
            repos = filter(lambda d: pattern.match(d), repos)

        if 'tag' in request.GET:
            tags = set(request.GET['tag'].split(','))
            taggingService = RepoTaggingService()
            repos = filter(lambda d: len(tags.intersection(taggingService.getTags(d))) > 0, repos)

        if 'notag' in request.GET:
            forbiddentags = set(request.GET['notag'].split(','))
            taggingService = RepoTaggingService()
            repos = filter(lambda d: len(forbiddentags.intersection(taggingService.getTags(d))) == 0, repos)

        if 'older' in request.GET:
            pastTime = self.get_past_time(int(request.GET['older']))
            configService = RepoConfigService()
            repos = filter(lambda d: os.stat(configService.getStaticRepoDir(d)).st_mtime < pastTime, repos)

        if 'newer' in request.GET:
            pastTime = self.get_past_time(int(request.GET['newer']))
            configService = RepoConfigService()
            repos = filter(lambda d: os.stat(configService.getStaticRepoDir(d)).st_mtime > pastTime, repos)

        return repos
Example #2
0
def static_repo_info(request, reponame):
    config = RepoTaggingService()
    tags = config.getTags(reponame)
    template = loader.select_template(['static/static_repo_info.html'])
    context = Context({
        'reponame' : reponame,
        'tags' : tags,
        'defaultTags' : config.getDefaultTags() - tags,
        })
    return HttpResponse(template.render(context))
Example #3
0
def static_repo_info(request, reponame):
    config = RepoTaggingService()
    tags = config.getTags(reponame)
    template = loader.select_template(['static/static_repo_info.html'])
    context = Context({
        'reponame': reponame,
        'tags': tags,
        'defaultTags': config.getDefaultTags() - tags,
    })
    return HttpResponse(template.render(context))
Example #4
0
class FileInfo(object):

    taggingService = RepoTaggingService()
    filename = 'foo'
    fullpath = 'bar'
    isDir = False
    tags = []
    
    def __init__(self, filename, parentDir, parentDirType = ParentDirType.NONE):
        self.filename = filename
        self.fullpath = os.path.join(parentDir, filename)
        self.isDir = os.path.isdir(self.fullpath)
        if self.isDir:
            self.filename += '/'
        else :
            self.size = os.path.getsize(self.fullpath)
        
        self.mtime = time.strftime("%d.%m.%Y %H:%M:%S", time.localtime(os.path.getctime(self.fullpath)))
        self.mimetype = self.getMimeType()
        self.isFile = not self.isDir
        if parentDirType == ParentDirType.STATIC and filename != '':
            self.tags = self.taggingService.getTags(filename)

        self.hasInfo = parentDirType == ParentDirType.STATIC or parentDirType == ParentDirType.VIRTUAL
            
    def getMimeType(self):
        if self.isDir:
            return 'folder'
        else:
            for fileType in KWOWN_FILE_TYPES:
                if self.filename.endswith(fileType):
                    return fileType[1:]
            
            return 'unknown'
    def filter(self, request, repos):
        if 'name' in request.GET:
            pattern = re.compile(request.GET['name'])
            repos = filter(lambda d: pattern.match(d), repos)

        if 'tag' in request.GET:
            tags = set(request.GET['tag'].split(','))
            taggingService = RepoTaggingService()
            repos = filter(
                lambda d: len(tags.intersection(taggingService.getTags(d))) >
                0, repos)

        if 'notag' in request.GET:
            forbiddentags = set(request.GET['notag'].split(','))
            taggingService = RepoTaggingService()
            repos = filter(
                lambda d: len(
                    forbiddentags.intersection(taggingService.getTags(d))) ==
                0, repos)

        if 'older' in request.GET:
            pastTime = self.get_past_time(int(request.GET['older']))
            configService = RepoConfigService()
            repos = filter(
                lambda d: os.stat(configService.getStaticRepoDir(d)).st_mtime <
                pastTime, repos)

        if 'newer' in request.GET:
            pastTime = self.get_past_time(int(request.GET['newer']))
            configService = RepoConfigService()
            repos = filter(
                lambda d: os.stat(configService.getStaticRepoDir(d)).st_mtime >
                pastTime, repos)

        return repos
class RepoTaggingHandler(BaseHandler):

    repoConfigService = RepoConfigService()
    repoTaggingService = RepoTaggingService()
    repoAuditService = RepoAuditService()

    def create(self, request, repodir,tag):
        try:
            tag = self.check_request_sanity(request)
        except RequestFailException, rfe:
            return rfe.args[0]

        try:
            result = self.repoTaggingService.tagRepo(repodir,tag)
        except CouldNotLockTagsException, lockErr:
            response = rc.BAD_REQUEST
            response.content = "Could not lock tags file"
            return response