diff options
author | morpheus65535 <[email protected]> | 2022-11-07 13:06:49 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2022-11-07 13:08:27 -0500 |
commit | bbe2483e21c2c1549ceeed16f021f9581b899f70 (patch) | |
tree | bcc2bef2f55789ec6e6c64809c07fb4f4d3d9c86 /libs/apscheduler | |
parent | 708fbfcd8ec0620647975be39a1f6acbbf08f767 (diff) | |
download | bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.tar.gz bazarr-bbe2483e21c2c1549ceeed16f021f9581b899f70.zip |
Updated vendored dependencies.
Diffstat (limited to 'libs/apscheduler')
-rw-r--r-- | libs/apscheduler/jobstores/mongodb.py | 4 | ||||
-rw-r--r-- | libs/apscheduler/schedulers/base.py | 5 | ||||
-rw-r--r-- | libs/apscheduler/schedulers/qt.py | 11 | ||||
-rw-r--r-- | libs/apscheduler/triggers/cron/__init__.py | 7 | ||||
-rw-r--r-- | libs/apscheduler/triggers/interval.py | 6 | ||||
-rw-r--r-- | libs/apscheduler/util.py | 23 |
6 files changed, 33 insertions, 23 deletions
diff --git a/libs/apscheduler/jobstores/mongodb.py b/libs/apscheduler/jobstores/mongodb.py index ea3097ddc..5a00f9415 100644 --- a/libs/apscheduler/jobstores/mongodb.py +++ b/libs/apscheduler/jobstores/mongodb.py @@ -106,7 +106,7 @@ class MongoDBJobStore(BaseJobStore): raise JobLookupError(job_id) def remove_all_jobs(self): - self.collection.remove() + self.collection.delete_many({}) def shutdown(self): self.client.close() @@ -133,7 +133,7 @@ class MongoDBJobStore(BaseJobStore): # Remove all the jobs we failed to restore if failed_job_ids: - self.collection.remove({'_id': {'$in': failed_job_ids}}) + self.collection.delete_many({'_id': {'$in': failed_job_ids}}) return jobs diff --git a/libs/apscheduler/schedulers/base.py b/libs/apscheduler/schedulers/base.py index 3dfb74377..444de8ef9 100644 --- a/libs/apscheduler/schedulers/base.py +++ b/libs/apscheduler/schedulers/base.py @@ -191,12 +191,11 @@ class BaseScheduler(six.with_metaclass(ABCMeta)): self.state = STATE_STOPPED # Shut down all executors - with self._executors_lock: + with self._executors_lock, self._jobstores_lock: for executor in six.itervalues(self._executors): executor.shutdown(wait) - # Shut down all job stores - with self._jobstores_lock: + # Shut down all job stores for jobstore in six.itervalues(self._jobstores): jobstore.shutdown() diff --git a/libs/apscheduler/schedulers/qt.py b/libs/apscheduler/schedulers/qt.py index dda77d796..600f6e677 100644 --- a/libs/apscheduler/schedulers/qt.py +++ b/libs/apscheduler/schedulers/qt.py @@ -9,13 +9,16 @@ except (ImportError, RuntimeError): # pragma: nocover from PyQt4.QtCore import QObject, QTimer except ImportError: try: - from PySide2.QtCore import QObject, QTimer # noqa + from PySide6.QtCore import QObject, QTimer # noqa except ImportError: try: - from PySide.QtCore import QObject, QTimer # noqa + from PySide2.QtCore import QObject, QTimer # noqa except ImportError: - raise ImportError('QtScheduler requires either PyQt5, PyQt4, PySide2 ' - 'or PySide installed') + try: + from PySide.QtCore import QObject, QTimer # noqa + except ImportError: + raise ImportError('QtScheduler requires either PyQt5, PyQt4, PySide6, PySide2 ' + 'or PySide installed') class QtScheduler(BaseScheduler): diff --git a/libs/apscheduler/triggers/cron/__init__.py b/libs/apscheduler/triggers/cron/__init__.py index fec6e3b5c..b5389dd22 100644 --- a/libs/apscheduler/triggers/cron/__init__.py +++ b/libs/apscheduler/triggers/cron/__init__.py @@ -6,7 +6,8 @@ import six from apscheduler.triggers.base import BaseTrigger from apscheduler.triggers.cron.fields import ( BaseField, MonthField, WeekField, DayOfMonthField, DayOfWeekField, DEFAULT_VALUES) -from apscheduler.util import datetime_ceil, convert_to_datetime, datetime_repr, astimezone +from apscheduler.util import ( + datetime_ceil, convert_to_datetime, datetime_repr, astimezone, localize, normalize) class CronTrigger(BaseTrigger): @@ -143,7 +144,7 @@ class CronTrigger(BaseTrigger): i += 1 difference = datetime(**values) - dateval.replace(tzinfo=None) - return self.timezone.normalize(dateval + difference), fieldnum + return normalize(dateval + difference), fieldnum def _set_field_value(self, dateval, fieldnum, new_value): values = {} @@ -156,7 +157,7 @@ class CronTrigger(BaseTrigger): else: values[field.name] = new_value - return self.timezone.localize(datetime(**values)) + return localize(datetime(**values), self.timezone) def get_next_fire_time(self, previous_fire_time, now): if previous_fire_time: diff --git a/libs/apscheduler/triggers/interval.py b/libs/apscheduler/triggers/interval.py index 61094aa13..b0e2dbddb 100644 --- a/libs/apscheduler/triggers/interval.py +++ b/libs/apscheduler/triggers/interval.py @@ -4,7 +4,9 @@ from math import ceil from tzlocal import get_localzone from apscheduler.triggers.base import BaseTrigger -from apscheduler.util import convert_to_datetime, timedelta_seconds, datetime_repr, astimezone +from apscheduler.util import ( + convert_to_datetime, normalize, timedelta_seconds, datetime_repr, + astimezone) class IntervalTrigger(BaseTrigger): @@ -63,7 +65,7 @@ class IntervalTrigger(BaseTrigger): next_fire_time = self._apply_jitter(next_fire_time, self.jitter, now) if not self.end_date or next_fire_time <= self.end_date: - return self.timezone.normalize(next_fire_time) + return normalize(next_fire_time) def __getstate__(self): return { diff --git a/libs/apscheduler/util.py b/libs/apscheduler/util.py index 1e643bffa..d929a4822 100644 --- a/libs/apscheduler/util.py +++ b/libs/apscheduler/util.py @@ -34,7 +34,7 @@ except ImportError: __all__ = ('asint', 'asbool', 'astimezone', 'convert_to_datetime', 'datetime_to_utc_timestamp', 'utc_timestamp_to_datetime', 'timedelta_seconds', 'datetime_ceil', 'get_callable_name', 'obj_to_ref', 'ref_to_obj', 'maybe_ref', 'repr_escape', 'check_callable_args', - 'TIMEOUT_MAX') + 'normalize', 'localize', 'TIMEOUT_MAX') class _Undefined(object): @@ -90,9 +90,7 @@ def astimezone(obj): if isinstance(obj, six.string_types): return timezone(obj) if isinstance(obj, tzinfo): - if not hasattr(obj, 'localize') or not hasattr(obj, 'normalize'): - raise TypeError('Only timezones from the pytz library are supported') - if obj.zone == 'local': + if obj.tzname(None) == 'local': raise ValueError( 'Unable to determine the name of the local timezone -- you must explicitly ' 'specify the name of the local timezone. Please refrain from using timezones like ' @@ -162,11 +160,7 @@ def convert_to_datetime(input, tz, arg_name): if isinstance(tz, six.string_types): tz = timezone(tz) - try: - return tz.localize(datetime_, is_dst=None) - except AttributeError: - raise TypeError( - 'Only pytz timezones are supported (need the localize() and normalize() methods)') + return localize(datetime_, tz) def datetime_to_utc_timestamp(timeval): @@ -431,3 +425,14 @@ def iscoroutinefunction_partial(f): # The asyncio version of iscoroutinefunction includes testing for @coroutine # decorations vs. the inspect version which does not. return iscoroutinefunction(f) + + +def normalize(dt): + return datetime.fromtimestamp(dt.timestamp(), dt.tzinfo) + + +def localize(dt, tzinfo): + if hasattr(tzinfo, 'localize'): + return tzinfo.localize(dt) + + return normalize(dt.replace(tzinfo=tzinfo)) |