def test_get_timezone_without_pytz(self): prev, timeutils.pytz = timeutils.pytz, None try: self.assertTrue(timezone.get_timezone('UTC')) with self.assertRaises(ImproperlyConfigured): timezone.get_timezone('Europe/Oslo') finally: timeutils.pytz = prev
def timezone(self): from celery.utils.timeutils import timezone conf = self.conf tz = conf.CELERY_TIMEZONE if not tz: return (timezone.get_timezone('UTC') if conf.CELERY_ENABLE_UTC else timezone.local) return timezone.get_timezone(conf.CELERY_TIMEZONE)
def test_get_timezone_without_pytz(self): prev, timeutils.pytz = timeutils.pytz, None try: self.assertTrue(timezone.get_timezone("UTC")) with self.assertRaises(ImproperlyConfigured): timezone.get_timezone("Europe/Oslo") finally: timeutils.pytz = prev
def timezone(self): from celery.utils.timeutils import timezone conf = self.conf tz = conf.CELERY_TIMEZONE if not tz: return (timezone.get_timezone('UTC') if conf.CELERY_ENABLE_UTC else timezone.local) return timezone.get_timezone(self.conf.CELERY_TIMEZONE)
def timezone(self): """Current timezone for this app. This is a cached property taking the time zone from the :setting:`timezone` setting. """ conf = self.conf tz = conf.timezone if not tz: return (timezone.get_timezone('UTC') if conf.enable_utc else timezone.local) return timezone.get_timezone(conf.timezone)
def timezone(self): """Current timezone for this app. This is a cached property taking the time zone from the :setting:`timezone` setting. """ from celery.utils.timeutils import timezone conf = self.conf tz = conf.timezone if not tz: return timezone.get_timezone("UTC") if conf.enable_utc else timezone.local return timezone.get_timezone(conf.timezone)
def timezone(self): """Current timezone for this app. This is a cached property taking the time zone from the :setting:`CELERY_TIMEZONE` setting. """ from celery.utils.timeutils import timezone conf = self.conf tz = conf.CELERY_TIMEZONE if not tz: return (timezone.get_timezone('UTC') if conf.CELERY_ENABLE_UTC else timezone.local) return timezone.get_timezone(conf.CELERY_TIMEZONE)
def test_rrule_timezone(self): tz = timezone.get_timezone('US/Eastern') start1 = datetime(2015, 12, 30, 12, 59, 22, tzinfo=timezone.utc) start2 = start1.astimezone(tz) r1 = rrule('MINUTELY', dtstart=start1, count=1) r2 = rrule('MINUTELY', dtstart=start2, count=1) self.assertEqual(self.dumps(r1), self.dumps(r2))
def __init__(self, *args, **kwargs): self.data = {} self.last_refresh = None if 'LEEK_REDIS_URL' not in current_app.conf: raise Exception('Missing LEEK_REDIS_URL celery config') self.hash_key = current_app.conf.get('LEEK_HASH_KEY', 'leek') self.redis = redis.from_url(current_app.conf.get('LEEK_REDIS_URL')) self.tz = timezone.get_timezone(current_app.conf.get('CELERY_TIMEZONE', 'UTC')) Scheduler.__init__(self, *args, **kwargs) self.max_interval = self.app.conf.get('LEEK_REFRESH_INTERVAL', 5) self.refresh_frequency = timedelta(seconds=self.max_interval)
def test_rrule_timezone(self): tz = timezone.get_timezone('US/Eastern') start1 = datetime(2015, 12, 30, 12, 59, 22, tzinfo=timezone.utc) start2 = start1.astimezone(tz) r1 = rrule('MINUTELY', dtstart=start1, count=1) r2 = rrule('MINUTELY', dtstart=start2, count=1) r1_json = self.dumps(r1) r2_json = self.dumps(r2) r1_parsed = self.loads(r1_json) self.assertEqual(r1_parsed.dtstart.utcoffset(), r1.dtstart.utcoffset()) r2_parsed = self.loads(r2_json) self.assertEqual(r2_parsed.dtstart.utcoffset(), r2.dtstart.utcoffset()) self.assertEqual(r1_parsed.dtstart, r2_parsed.dtstart) self.assertNotEqual(r1_parsed.dtstart.utcoffset(), r2_parsed.dtstart.utcoffset())
def test_timezone__none_set(self): self.app.conf.timezone = None tz = self.app.timezone self.assertEqual(tz, timezone.get_timezone('UTC'))
def test_get_timezone_with_pytz(self): self.assertTrue(timezone.get_timezone('UTC'))
def test_get_timezone_with_pytz(self): prev, timeutils.pytz = timeutils.pytz, Mock() try: self.assertTrue(timezone.get_timezone("UTC")) finally: timeutils.pytz = prev
def test_get_timezone_with_pytz(self): prev, timeutils.pytz = timeutils.pytz, Mock() try: self.assertTrue(timezone.get_timezone('UTC')) finally: timeutils.pytz = prev