Ejemplo n.º 1
0
    def GET(self):
        params = web.input()
        if not params.has_key('location'):
            raise web.seeother('../')
        location_id = params.location

        length_update = Dbevent.updateDb(location_id)
        length_delete = Dbevent.deleteDb(location_id)
        Calendar.deleteMemcacheCity(location_id)
        db.put(SyncQueue(key_name=location_id,
                         location_id=location_id,
                         update_at=datetime.utcnow()))
        logging.info('update %s %d' %(location_id, length_update))
        logging.info('delete %s %d' %(location_id, length_delete))

        return 'ok'
Ejemplo n.º 2
0
    def __getICalendar(self):
        """获取该日历对应的 iCalendar"""
        cal = ICalendar()
        cal.add('prodid', '-//Google Inc//Google Calendar 70.9054//EN')
        cal.add('version', '2.0')
        cal.add('X-WR-TIMEZONE', 'Asia/Shanghai')
        cal.add('CLASS', 'PUBLIC')
        cal.add('METHOD', 'PUBLISH')
        cal.add('CALSCALE', 'GREGORIAN')
        cal.add('X-WR-CALNAME', u'豆瓣%s - %s活动' \
                %(self.location_id, self._categoryMap[self._category]))
        desc = u'dbevent2gc - 豆瓣%s - %s活动 \n' \
                %(self.location_id, self._categoryMap[self._category])
        if not self._length is None:
            desc += u'活动时间长度:%d小时以内' %self._length
        desc += u'via https://github.com/alswl/dbevent2gc\n' \
                u'by alswl(http://log4d.com)'
        cal.add('X-WR-CALDESC', desc)
        cal['dtstamp'] = datetime.strftime(datetime.utcnow(),
                                           '%Y%m%dT%H%M%SZ')

        dbevents = Dbevent.getDbevents(self.location_id, self._category,
                                       self._length)

        #将活动添加到日历
        map(lambda e: cal.add_component(e.parse_event()), dbevents)
        return cal
Ejemplo n.º 3
0
    def __getICalendar(self):
        """获取该日历对应的 iCalendar"""
        cal = ICalendar()
        cal.add("prodid", "-//Google Inc//Google Calendar 70.9054//EN")
        cal.add("version", "2.0")
        cal.add("X-WR-TIMEZONE", "Asia/Shanghai")
        cal.add("CLASS", "PUBLIC")
        cal.add("METHOD", "PUBLISH")
        cal.add("CALSCALE", "GREGORIAN")
        cal.add("X-WR-CALNAME", u"豆瓣%s - %s活动" % (self.location_id, self._categoryMap[self._category]))
        desc = u"dbevent2gc - 豆瓣%s - %s活动 \n" % (self.location_id, self._categoryMap[self._category])
        if not self._length is None:
            desc += u"活动时间长度:%d小时以内" % self._length
        desc += u"via https://github.com/alswl/dbevent2gc\n" u"by alswl(http://log4d.com)"
        cal.add("X-WR-CALDESC", desc)
        cal["dtstamp"] = datetime.strftime(datetime.utcnow(), "%Y%m%dT%H%M%SZ")

        dbevents = Dbevent.getDbevents(self.location_id, self._category, self._length)

        # 将活动添加到日历
        map(lambda e: cal.add_component(e.parse_event()), dbevents)
        return cal
Ejemplo n.º 4
0
 def GET(self, location):
     return Dbevent.deleteDb(location)
Ejemplo n.º 5
0
 def GET(self, location):
     return Dbevent.updateDb(location)
Ejemplo n.º 6
0
 def GET(self, location):
     return Dbevent.deleteDb(location)
Ejemplo n.º 7
0
 def GET(self, location):
     return Dbevent.updateDb(location)