Example #1
0
 def fetchLinks(self):
   ac = self.webapp.getContext()
   # Do not run fetcher in staging mode
   if ac.staging:
     return
   
   if self.format == 'internal':
     try:
       item = ac.linkqueue.get(False)
       print "DEBUG:" , item
       uri = item['url']
       title = item['title']
       content = item['description']
       tags = item['tags']
       when = time.localtime(item['time'])
       author = self.webapp.getConfigItem('author')
       self.assembleItem(locals())
     except Queue.Empty:
       pass
   elif self.format == 'rss':
     print "LinkBlog: Fetching feed %s" % self.url
     result = fetch.fetchURL(self.url)
     data = feedparser.parse(result['data'])
     for item in data.entries:
       try: 
         author = self.authors[item.author]
       except:
         author = self.webapp.getConfigItem('author')
       #try:
       when = time.localtime(calendar.timegm(item.updated_parsed))
       uri = item.link
       title = item.title
       content = converthtml(item.description.replace("#x26;",""))
       #soup = BeautifulSoup(item.description, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
       tags = ' '.join([tag['term'] for tag in item.tags])
       self.assembleItem(locals())
       #except:
       #  pass
   #elif self.format == 'greadernotes':
   #  TODO: implement Google Reader note parsing (getting tags from original item, etc.)
   #  pass
   elif self.format == 'json':
     nuts = simplejson.loads(result['data'])
     for item in nuts['value']['items']:
       try: 
         author = self.authors[item['dc:creator']]
       except:
         author = self.webapp.getConfigItem('author')
       try:
         when = time.strptime(item['dc:date'],'%Y-%m-%dT%H:%M:%SZ')
         uri = item['rdf:about']
         title = item['title']
         content = item['description']
         tags = item['dc:subject'].lower()
         self.assembleItem(locals())
       except:
         pass
   print "LinkBlog: Fetch and processing completed"
   return True
Example #2
0
    def fetchLinks(self):
        ac = self.webapp.getContext()
        # Do not run fetcher in staging mode
        if ac.staging:
            return

        if self.format == 'internal':
            try:
                item = ac.linkqueue.get(False)
                print "DEBUG:", item
                uri = item['url']
                title = item['title']
                content = item['description']
                tags = item['tags']
                when = time.localtime(item['time'])
                author = self.webapp.getConfigItem('author')
                self.assembleItem(locals())
            except Queue.Empty:
                pass
        elif self.format == 'rss':
            print "LinkBlog: Fetching feed %s" % self.url
            result = fetch.fetchURL(self.url)
            data = feedparser.parse(result['data'])
            for item in data.entries:
                try:
                    author = self.authors[item.author]
                except:
                    author = self.webapp.getConfigItem('author')
                #try:
                when = time.localtime(calendar.timegm(item.updated_parsed))
                uri = item.link
                title = item.title
                content = converthtml(item.description.replace("#x26;", ""))
                #soup = BeautifulSoup(item.description, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
                tags = ' '.join([tag['term'] for tag in item.tags])
                self.assembleItem(locals())
                #except:
                #  pass
        #elif self.format == 'greadernotes':
        #  TODO: implement Google Reader note parsing (getting tags from original item, etc.)
        #  pass
        elif self.format == 'json':
            nuts = simplejson.loads(result['data'])
            for item in nuts['value']['items']:
                try:
                    author = self.authors[item['dc:creator']]
                except:
                    author = self.webapp.getConfigItem('author')
                try:
                    when = time.strptime(item['dc:date'], '%Y-%m-%dT%H:%M:%SZ')
                    uri = item['rdf:about']
                    title = item['title']
                    content = item['description']
                    tags = item['dc:subject'].lower()
                    self.assembleItem(locals())
                except:
                    pass
        print "LinkBlog: Fetch and processing completed"
        return True
Example #3
0
def fetchTut():
  # URL mods
  title = 'fetching tutorials'
  msg = '\tBy default, the program fetches tutorials from:\n'+ url + '\nContinue with this URL?'

  if eg.ccbox(msg, title, choices=('C[o]ntinue', '[N]o. Let me change it')):
    url = defURL
  else:
    url = fetch.initURL()

  # get response
  response = fetch.fetchURL(url)

  if not fetch.checkBackup(tutPklFilePath):
    tutPklFilePath = fetch.makeListTC(tutPklFilePath)

  tutList = fetch.getBackupPK(tutPklFilePath)

  title = 'fetch complete.'
  msg = 'Available tutorials have been fetched.'
  eg.msgbox(msg, title)