On Tue, Aug 26, 2025 at 06:06:26PM +0200, Christian Kujau wrote: > On Tue, 26 Aug 2025, Darrick J. Wong wrote: > > Heh heh heh. That old code was for compatibility with RHEL6(?) back > > when I started writing online fsck. That's indeed no longer needed > > because even RHEL7 supports datetime.now, so thank you for the update! > > Thanks for providing the context. Scrolling through that whole script I'd > say the helper function is not even needed anymore. So, if it's not too > much hassle, here's a version 2 of the same: > > Signed-off-by: Christian Kujau <lists@xxxxxxxxxxxxxxx> That also works for me-- Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx> --D > > Thanks! > > diff --git a/scrub/xfs_scrub_all.py.in b/scrub/xfs_scrub_all.py.in > index 515cc144..ce251dae 100644 > --- a/scrub/xfs_scrub_all.py.in > +++ b/scrub/xfs_scrub_all.py.in > @@ -493,12 +493,6 @@ def scan_interval(string): > 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 > @@ -515,7 +509,7 @@ def enable_automatic_media_scan(args): > 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 > > -- > BOFH excuse #72: > > Satan did it >