Пример #1
0
    def method_get_builds(self):
        channels = self.params.get('channels', None)
        device = self.params.get('device', None)
        after = int(self.params.get('after', 0))
        if not channels or not device:
            self.set_status(500)
            return self.fail("Invalid Parameters")

        cache_key = 'api_after_%s_%s_%s' % (device, "_".join(sorted(channels)), str(round(after, -4)))
        result = cache.get(cache_key)
        if result is not None:
            return self.success(result)

        result = []

        if 'snapshot' in channels and 'RC' not in channels:
            channels.append('RC')

        for channel in channels:
            file_obj = File.get_build(channel, device, after)
            if file_obj is not None:
                changesfile = re.sub(file_obj.filename, "CHANGES.txt", file_obj.full_path)
                result.append({
                    'channel': channel,
                    'filename': file_obj.filename,
                    'url': "http://get.galliumos.org/get/%s" % file_obj.full_path,
                    'changes': "http://get.galliumos.org/get/%s" % changesfile,
                    'md5sum': file_obj.md5sum,
                    'timestamp': file_obj.date_created.strftime('%s')
                })

        cache.set(cache_key, result)

        return self.success(result)
Пример #2
0
    def method_get_builds(self):
        channels = self.params.get('channels', None)
        device = self.params.get('device', None)
        after = int(self.params.get('after', 0))
        if not channels or not device:
            self.set_status(500)
            return self.fail("Invalid Parameters")

        cache_key = 'api_after_%s_%s_%s' % (device, "_".join(
            sorted(channels)), str(round(after, -4)))
        result = cache.get(cache_key)
        if result is not None:
            return self.success(result)

        result = []

        if 'snapshot' in channels and 'RC' not in channels:
            channels.append('RC')

        for channel in channels:
            file_obj = File.get_build(channel, device, after)
            if file_obj is not None:
                changesfile = re.sub(file_obj.filename, "CHANGES.txt",
                                     file_obj.full_path)
                result.append({
                    'channel':
                    channel,
                    'filename':
                    file_obj.filename,
                    'url':
                    "http://get.galliumos.org/get/%s" % file_obj.full_path,
                    'changes':
                    "http://get.galliumos.org/get/%s" % changesfile,
                    'md5sum':
                    file_obj.md5sum,
                    'timestamp':
                    file_obj.date_created.strftime('%s')
                })

        cache.set(cache_key, result)

        return self.success(result)