Exemple #1
0
        def _cache_group(group_id, content, gpath=gpath):
            if not user_id:
                if INS.get('put_group_in_session'):
                    INS['groups'][group_id] = content

                INS.get('temp_groups', {}).pop(group_id, None)
                file_dump(gpath, content)
            return content
Exemple #2
0
    def groupFromScratch(self, group_id):
        rsp_json = self.request('groups.pools.getPhotos',
            "photos from group %s", [group_id], per_page=1, group_id=group_id)
        total = int(rsp_json['photos']['total'])

        Logger().info("groupFromScratch %s %s" % (group_id, total))

        def _get_path(batch):
            return os.path.join(OPT.groups_full_content_dir,
                "%s_%s" % (group_id, batch))

        page_in_batch = 100
        per_page = 500
        maxbatch = 1 + total / (page_in_batch * per_page)

        for batch in range(0, maxbatch):
            content = self.getGroupPhotosFromScratch(group_id, batch,
                page_in_batch, per_page)

            file_dump(_get_path(batch), content)