def update_singh(self): try: logger.info('[Update] TU Singh') menu = get_menu() for day in get_date_range(): day_menu = menu.get(day.weekday()) if day_menu: cache.hset(day.strftime(cache_date_format), 'tu_singh', day_menu) cache.expire(day.strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)
def update_bsr(self): try: logger.info('[Update] BSR Canteen') for day in get_date_range(): day_website = day.strftime('%d.%m.%Y') menu = get_menu(date=day_website) if menu: menu = '[BSR Kantine](%s) (%s)\n\n*Speiseplan*\n%s\n\n*Öffnungszeiten*\nMo - Fr: 05:45 - 14 Uhr' % ( URL, day_website, menu) cache.hset(day.strftime(cache_date_format), 'bsr', menu) cache.expire(day.strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)
def update_studierendenwerk_by_date(self, canteen_id, date, business_hours, notes): try: day = datetime.datetime.strptime(date, DATE_FORMAT_API) logger.info('[Update] %s (%s)' % (CANTEENS[canteen_id]['name'], date)) menu = get_full_text(canteen_id, business_hours, notes, date=day) if menu.strip() == '': logger.info('No menu for %s (%s)' % (CANTEENS[canteen_id]['name'], date)) raise self.retry() else: logger.info('Caching %s (%s)' % (CANTEENS[canteen_id]['name'], date)) cache.hset(day.strftime(cache_date_format), CANTEENS[canteen_id]['command'], menu) cache.expire(day.strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)
def update_cafenero(self): """ Celery task to update cafenero. """ try: logger.info('[Update] TU Cafenero') menu = main() if menu: cache.hset(datetime.date.today().strftime(cache_date_format), 'tu_cafenero', menu) cache.expire(datetime.date.today().strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)
def update_personalkantine(self): try: logger.info('[Update] TU Personalkantine') for day in get_date_range(): day_website = day.strftime('%d.%m.%Y') menu = get_menu(date=day_website, canteen=EMPLOYEE_CANTEEN) if menu: menu = '[Personalkantine](%s) (%s) (11:00-16:00)\n%s' % ( URL, day_website, menu) cache.hset(day.strftime(cache_date_format), 'tu_personalkantine', menu) cache.expire(day.strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)
def update_en_canteen(self): try: logger.info('[Update] TU EN Canteen') for day in get_date_range(): day_website = day.strftime('%d.%m.%Y') menu = get_menu(date=day_website, canteen=EN_CANTEEN) if menu: menu = '[EN Kantine](%s) (%s)\n%s\n\n*Öffnungszeiten*\nMo - Do: 07 - 17 Uhr\nFr: 07 - 16 Uhr' \ % (URL, day_website, menu) cache.hset(day.strftime(cache_date_format), 'tu_en_kantine', menu) cache.expire(day.strftime(cache_date_format), cache_ttl) except Exception as ex: raise self.retry(exc=ex)