Exemplo n.º 1
0
import helipad

class ProjectsHandler(helipad.Handler):
    def get(self, id):
        self.response.out.write("This is project #%s" % id)

main, application = helipad.app({
    '/projects/(\d+)/': ProjectsHandler,
})

if __name__ == '__main__':
    main()

Exemplo n.º 2
0
    USER_SPAM_COUNTERS.bind(spam_count_limit = SPAM_COUNT_LIMIT)
        
    user_counters = USER_SPAM_COUNTERS.fetch(100)
    users = []
    if len(user_counters):
      for counter in user_counters:
        counter.is_banned = True
        users.append(TwitterUser(key_name = counter.key_root))
      
      targets = [user.key().name() for user in users]
      ban_list = Banlist.retrieve()
      ban_list.users += targets
      ban_list.put(_storage=[MEMCACHE,DATASTORE])
      #TwitterUser.update_banlist([user.key().name() for user in users])
      logging.info('Banning users with keys: %s' %[user.key().name() for user in users])
      pdb.put(user_counters+users)
  
main, application = helipad.app({
  '/cron/updatecounters/': CounterUpdate,
  '/cron/rating/minute/': MinuteRating,
  '/cron/cleanup/day/': DailyCleanup,
  '/cron/cleanup/week/': WeeklyCleanup,
  '/cron/cleanup/month/': MonthlyCleanup,
  '/cron/bansynch/': ProductBanSynch,
  '/cron/banspammers/': BanSpammers,
})



if __name__ == '__main__':
    main()
Exemplo n.º 3
0
import helipad

helipad.root('yourapp').template_root('static/templates/')

class TemplateHandler(helipad.Handler):
  def get(self):
    return self.template('template.html', {
      'person': self.request.get('person') or "Nobody!",
    })

main, application = helipad.app(TemplateHandler)

if __name__ == '__main__':
  main()
Exemplo n.º 4
0
class BucketHandler(helipad.Handler):
    def get(self):
        logging.info('Bucket get called')
        self.response.out.write('Bucket get called')

    @prevent_transient_error
    def post(self):
        data = self.request.get('data')
        taskqueue.add(url='/taskworker/bucket/', params={'data': data})


class AffiliateRedirectHandler(helipad.Handler):
    pass


main, application = helipad.app([
    ('/', MainHandler),
    ('/([a-z]{2})/', LocaleHandler),
    ('/([a-z]{2})/day/', CurrentDayHandler),
    ('/([a-z]{2})/week/', CurrentWeekHandler),
    ('/([a-z]{2})/month/', CurrentMonthHandler),
    ('/([a-z]{2})/day/(\d{4})/(\d{2})/(\d{2})/', DayHandler),
    ('/([a-z]{2})/week/(\d{4})/(\d{2})/(\d{2})/', WeekHandler),
    ('/([a-z]{2})/month/(\d{4})/(\d{2})/', MonthHandler),
    ('/task/', BucketHandler),
    ('/.*', NotFoundHandler),
])

if __name__ == '__main__':
    main()
Exemplo n.º 5
0
      key = db.Key.from_path(model_name,key_name)
      db.delete(key)
      self.response.out.write("Deleted %s with key_name: %s" %(model_name,key_name))

class BannedUsers(helipad.Handler):
  def get(self):
    users = TwitterUser.all().fetch(10000)

    return self.template('banned_model.html', {
      'users': users,
    })
      
  def post(self):
    users = self.request.get('users').split('\n')
    
    db_targets = []
    for user_key in users:
      db_targets.append(TwitterUser(key_name = user_key.strip()))
    
    db.put(db_targets)
    TwitterUser.update_banlist(users)
    logging.info('Added banned users')
                
main, application = helipad.app({
    '/remote/delete/(\w+)/': DeleteHandler,
    '/remote/delete/(\w+)/(\w+)/': DeleteKeyHandler,
    '/remote/bannedusers/':BannedUsers,
})

if __name__ == '__main__':
    main()
Exemplo n.º 6
0
class BucketHandler(helipad.Handler):
  def get(self):
    logging.info('Bucket get called')
    self.response.out.write('Bucket get called')

  @prevent_transient_error
  def post(self):
    data = self.request.get('data')
    taskqueue.add(url='/taskworker/bucket/', params={'data': data})


class AffiliateRedirectHandler(helipad.Handler):
    pass
        
main, application = helipad.app([
  ('/',MainHandler),
  ('/([a-z]{2})/',LocaleHandler),
  ('/([a-z]{2})/day/',CurrentDayHandler),
  ('/([a-z]{2})/week/',CurrentWeekHandler),
  ('/([a-z]{2})/month/',CurrentMonthHandler),
  ('/([a-z]{2})/day/(\d{4})/(\d{2})/(\d{2})/',DayHandler),
  ('/([a-z]{2})/week/(\d{4})/(\d{2})/(\d{2})/',WeekHandler),
  ('/([a-z]{2})/month/(\d{4})/(\d{2})/',MonthHandler),
  ('/task/', BucketHandler),
  ('/.*',NotFoundHandler),

])

if __name__ == '__main__':
  main()
Exemplo n.º 7
0
        elif model_kind == 'ProductCounter':
            store_key = Key.from_path('Store', store_key_name)
            query = get_counter_query_for_frequency(frequency, date, store_key)
            keys = query.fetch(200)
        elif model_kind == 'UserCounter':
            query = USER_COUNTER_CLEANUP_TARGETS
            keys = query.fetch(200)
        else:
            logging.error('No type found for CleanupWorker :%s' % model_kind)

        if len(keys):
            recursion_flag = True
            pdb.delete(keys)

        if recursion_flag:
            logging.info('Enqueing cleanup for model %s' % model_kind)
            enqueue_cleanup(model_kind, frequency, str(date), store_key_name)


main, application = helipad.app({
    '/taskworker/bucket/': UrlBucketWorker,
    '/taskworker/url/': UrlFetchWorker,
    '/taskworker/counter/': CounterWorker,
    '/taskworker/rendererupdate/': ProductRendererUpdater,
    '/taskworker/rendererinfo/': ProductRendererInfoFetcher,
    '/taskworker/cleanup/': CleanupWorker,
})

if __name__ == '__main__':
    main()
Exemplo n.º 8
0
      keys = query.fetch(200, TEMPLATE_PRODUCT_COUNT)
    elif model_kind == 'ProductCounter':
      store_key = Key.from_path('Store',store_key_name)
      query = get_counter_query_for_frequency(frequency, date, store_key)
      keys = query.fetch(200)
    elif model_kind == 'UserCounter':
      query = USER_COUNTER_CLEANUP_TARGETS
      keys = query.fetch(200)
    else:
      logging.error('No type found for CleanupWorker :%s' %model_kind)
    
    if len(keys):
      recursion_flag = True
      pdb.delete(keys)
    
    if recursion_flag:
      logging.info('Enqueing cleanup for model %s' %model_kind)
      enqueue_cleanup(model_kind,frequency,str(date),store_key_name)

main, application = helipad.app({
    '/taskworker/bucket/': UrlBucketWorker,
    '/taskworker/url/': UrlFetchWorker,
    '/taskworker/counter/': CounterWorker,
    '/taskworker/rendererupdate/':ProductRendererUpdater,
    '/taskworker/rendererinfo/':ProductRendererInfoFetcher,
    '/taskworker/cleanup/': CleanupWorker,
})

if __name__ == '__main__':
    main()