Running xfs_scrub_all under Python 3.13.5 prints the following warning:
----------------------------------------------
$ /usr/sbin/xfs_scrub_all --auto-media-scan-stamp \
/var/lib/xfsprogs/xfs_scrub_all_media.stamp \
--auto-media-scan-interval 1d
/usr/sbin/xfs_scrub_all:489: DeprecationWarning:
datetime.datetime.utcnow() is deprecated and scheduled for removal in a
future version. Use timezone-aware objects to represent datetimes in UTC:
datetime.datetime.now(datetime.UTC).
dt = datetime.utcnow()
Automatically enabling file data scrub.
----------------------------------------------
Python documentation for context:
https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
Fix this by using datetime.now() instead.
NB: Debian/13 ships Python 3.13.5 and has a xfs_scrub_all.timer active,
I'd assume that many systems will have that warning now in their logs :-)
Signed-off-by: Christian Kujau <lists@nerdbynature.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
return timedelta(seconds = float(string[:-1]))
return timedelta(seconds = int(string))
-def utcnow():
- '''Create a representation of the time right now, in UTC.'''
-
- dt = datetime.utcnow()
- return dt.replace(tzinfo = timezone.utc)
-
def enable_automatic_media_scan(args):
'''Decide if we enable media scanning automatically.'''
already_enabled = args.x
else:
try:
last_run = p.stat().st_mtime
- now = utcnow().timestamp()
+ now = datetime.now(timezone.utc).timestamp()
res = last_run + interval.total_seconds() < now
except FileNotFoundError:
res = True