Esempio n. 1
0
    def get(self):
        feed_url = self.request.full_url()
        base_url = 'http://%s' % self.request.host
        feed = pyatom.AtomFeed(title=settings.TITLE,
                               subtitle=settings.SUB_TITLE,
                               feed_url=feed_url,
                               url=base_url,
                               author=settings.DOMAIN_NAME)

        recently = datetime.datetime.now() - datetime.timedelta(seconds=10)
        gist_search = {'add_date': {'$lt': recently}}
        for gist in self.db.Gist.find(gist_search)\
          .limit(20).sort('add_date', DESCENDING):
            content_type = "text"
            content = ""
            if gist.discussion:
                content = markdown.markdown(gist.discussion)
                content_type = "html"
            full_gist_url = 'http://%s%s' % \
              (self.request.host, self.reverse_url('view_gist', gist.gist_id))
            feed.add(
                title="%s: %s" % (gist.gist_id, gist.description),
                content=content,
                content_type=content_type,
                author=gist.user.name if gist.user.name else gist.user.login,
                url=full_gist_url,
                id=gist.gist_id,
                updated=gist.add_date,
            )
        self.set_header("Content-Type", "application/atom+xml; charset=UTF-8")
        self.write(feed.to_string())
Esempio n. 2
0
def make_feed(userid):

    for _ in range(3):
        try:
            s = steem.Steem()
            account = s.get_account(userid)
            profile = json.loads(account['json_metadata'])['profile']
        except Exception as e:
            error = e
        else:
            break
    else:
        raise error

    feed = pyatom.AtomFeed(author=profile.get('name', userid),
                           title=profile.get('name', userid),
                           subtitle=profile.get('about'),
                           url=f'https://steemit.com/@{userid}',
                           logo=profile['profile_image'])

    for post in s.get_discussions_by_blog({'tag': userid, 'limit': 10}):
        feed.add(
            title=post['title'],
            author=post['author'],
            id=f'@kjwon15/{post["permlink"]}',
            url=
            f'https://steemit.com/{post["category"]}/@{post["author"]}/{post["permlink"]}',
            updated=datetime.strptime(post['last_update'],
                                      '%Y-%m-%dT%H:%M:%S'),
            content=md.convert(post['body']),
            content_type='html')

    return feed.to_string()
 def createFeed(items, request):
     # build a feed
     # TODO: add the feed url; will currently break the test
     feed = pyatom.AtomFeed(
         title=self.model + " items",
         id=str(request.URLPath()),
         #feed_url=str(request.URLPath())
     )
     for item in items:
         if not item['name']:
             item['name'] = "None"
         if 'user_id' in item and item['user_id']:
             feed.add(title=item['name'],
                      url="%s/%s" % (request.URLPath(), item['id']),
                      updated=localTimeStringToUtcDatetime(
                          item['__last_update']),
                      author=[{
                          'name': item['user_id'][1]
                      }])
         else:
             feed.add(title=item['name'],
                      url="%s/%s" % (request.URLPath(), item['id']),
                      updated=localTimeStringToUtcDatetime(
                          item['__last_update']),
                      author=[{
                          'name': 'None'
                      }])
     request.setHeader("Content-Type",
                       "application/atom+xml; charset=utf-8")
     request.write(str(feed.to_string().encode('utf-8')))
     request.finish()
Esempio n. 4
0
def get_feed(md):
    url = db.get_setting('url')
    feed = pyatom.AtomFeed(title=db.get_setting('title'),
                           url=url,
                           feed_url=url + '/feed.atom')
    for post in db.iter_posts(allowed_flags=0):
        feed.add(title=post.title,
                 content=md(post.body),
                 content_type='html',
                 author=post.username,
                 url='%s/post/%d' % (url, post.id),
                 updated=post.datetime())
    return feed.to_string()
Esempio n. 5
0
 def exception_hook(exc_type, exc_value, exc_traceback):
     """Atom feed generator for exceptions"""
     feed = pyatom.AtomFeed(**feed_args)
     time_of_exception = datetime.datetime.utcnow()
     import traceback
     feed.add(title="Exception has occured!",
              content="<p>" + "<br />".join(
                  traceback.format_exception(exc_type, exc_value,
                                             exc_traceback)) + "</p>",
              content_type="html",
              updated=time_of_exception,
              id=str(time_of_exception))
     print(feed.to_string())
     sys.exit()
Esempio n. 6
0
def main():
    """Entrypoint"""
    # This should NOT be replaced; it should be updated so that
    # exception_hook can use this instance to create its own special
    # feed with as accurate arguments as possible
    feed_args = dict(title='(Unknown Lenovo pcsupport driver)',
                     url='about:blank')

    def exception_hook(exc_type, exc_value, exc_traceback):
        """Atom feed generator for exceptions"""
        feed = pyatom.AtomFeed(**feed_args)
        time_of_exception = datetime.datetime.utcnow()
        import traceback
        feed.add(title="Exception has occured!",
                 content="<p>" + "<br />".join(
                     traceback.format_exception(exc_type, exc_value,
                                                exc_traceback)) + "</p>",
                 content_type="html",
                 updated=time_of_exception,
                 id=str(time_of_exception))
        print(feed.to_string())
        sys.exit()

    sys.excepthook = exception_hook

    # Load driver details
    driver_document = json.load(sys.stdin)
    driver_details, changelog_text = _parse_driver_document(driver_document)
    assert driver_details

    # Setup feed and metadata
    _populate_feed_meta(feed_args, driver_details)
    feed = pyatom.AtomFeed(**feed_args)

    # Populate feed entries
    populate_feed_entries(feed, driver_details, changelog_text)

    # Output feed
    print(feed.to_string())
Esempio n. 7
0
def main():
    """Entrypoint"""
    # This should NOT be replaced; it should be updated so that
    # exception_hook can use this instance to create its own special
    # feed with as accurate arguments as possible
    feed_args = dict(title='NVIDIA GeForce Drivers',
                     url='https://www.geforce.com/drivers')

    def exception_hook(exc_type, exc_value, exc_traceback):
        """Atom feed generator for exceptions"""
        feed = pyatom.AtomFeed(**feed_args)
        time_of_exception = datetime.datetime.utcnow()
        import traceback
        feed.add(title="Exception has occured!",
                 content="<p>" + "<br />".join(
                     traceback.format_exception(exc_type, exc_value,
                                                exc_traceback)) + "</p>",
                 content_type="html",
                 updated=time_of_exception,
                 id=str(time_of_exception))
        print(feed.to_string())
        sys.exit()

    sys.excepthook = exception_hook

    # Load search results
    search_results = json.load(sys.stdin)
    driver_list = _parse_search_results(search_results)
    assert driver_list

    # Setup feed and metadata
    feed = pyatom.AtomFeed(**feed_args)

    # Populate feed entries
    populate_feed_entries(feed, driver_list)

    # Output feed
    print(feed.to_string())
Esempio n. 8
0
 def init_feed():
     return pyatom.AtomFeed(title="CWS: " + extension_id,
                 subtitle="Feed for reviews and support issues",
                 url="https://chrome.google.com/webstore/detail/" + extension_id)
Esempio n. 9
0
 def init_feed():
     """Initialize feed"""
     return pyatom.AtomFeed(title="Chrome Releases",
                            subtitle="Chrome releases from Omahaproxy",
                            url="https://omahaproxy.appspot.com/")