Example #1
0
    def handle(self, *args, **options):
        logger = logging.getLogger(__name__)
        output_dir = options.get('output_dir')
        filenames = options.get('filenames')
        repo_name = options.get('repo-name')
        allow_failure = options.get('allow-failure')

        deploy_url = get_deploy_url(repo_name)
        try:
            upstream_deploy_url = get_upstream_deploy_url()
        except RuntimeError as e:
            upstream_deploy_url = None
            logger.info(str(e))

        for filename in filenames:
            r = requests.get(deploy_url + '/' + filename)
            try:
                r.raise_for_status()
            except Exception:
                if upstream_deploy_url:
                    r = requests.get(upstream_deploy_url + '/' + filename)
                    if not allow_failure:
                        r.raise_for_status()
                else:
                    if allow_failure:
                        return
                    else:
                        raise

            filename = os.path.basename(filename)
            with open(os.path.join(output_dir, filename), 'wb') as f:
                f.write(r.content)
Example #2
0
class LatestTasksFeed(Feed):
    title = 'GCI tasks feed'
    link = get_deploy_url() + '/gci/tasks/rss.xml'
    description = 'GCI tasks ordered by modification time.'
    author_name = get_org_name()
    author_link = get_deploy_url()

    def items(self):
        yaml = YAML()
        with open(os.path.join('_site', 'tasks.yaml')) as f:
            res = list(yaml.load(f).values())

        res.sort(key=lambda x: x['last_modified'], reverse=True)

        return res

    def item_title(self, item):
        return item['name']

    def item_description(self, item):
        desc = item['description']
        if item['external_url']:
            desc += '\n\nExternal URL: [{url}]({url})'.format(
                url=item['external_url'])
        return markdown2.markdown(desc)

    def item_link(self, item):
        return 'https://codein.withgoogle.com/tasks/' + str(item['id'])

    def item_pubdate(self, item):
        return dateutil.parser.parse(item['last_modified'])

    def item_updateddate(self, item):
        return dateutil.parser.parse(item['last_modified'])

    def item_author_name(self):
        return self.author_name

    def item_categories(self, item):
        return tuple(item['tags'])
    def handle(self, *args, **options):
        output_dir = options.get('output_dir')

        deploy_url = get_deploy_url()

        r = requests.get(deploy_url + '/static/tasks.yaml')
        r.raise_for_status()

        with open(os.path.join(output_dir, 'tasks.yaml'), 'wb') as f:
            f.write(r.content)

        r = requests.get(deploy_url + '/static/instances.yaml')
        r.raise_for_status()

        with open(os.path.join(output_dir, 'instances.yaml'), 'wb') as f:
            f.write(r.content)
Example #4
0
 def test_deploy_url(self):
     url = get_deploy_url()
     self.assertIn('/community', url)