From: "Darrick J. Wong" <djwong@kernel.org>
To: Christian Kujau <lists@nerdbynature.de>
Cc: linux-xfs@vger.kernel.org, Andrey Albershteyn <aalbersh@redhat.com>
Subject: Re: xfsprogs: fix utcnow deprecation warning in xfs_scrub_all.py [v2]
Date: Tue, 26 Aug 2025 09:10:51 -0700 [thread overview]
Message-ID: <20250826161051.GC19817@frogsfrogsfrogs> (raw)
In-Reply-To: <9ad33531-f8c0-07cf-59e4-7e6bbb173ebc@nerdbynature.de>
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@nerdbynature.de>
That also works for me--
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--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
>
prev parent reply other threads:[~2025-08-26 16:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-26 13:15 xfsprogs: fix utcnow deprecation warning in xfs_scrub_all.py Christian Kujau
2025-08-26 15:57 ` Darrick J. Wong
2025-08-26 16:06 ` xfsprogs: fix utcnow deprecation warning in xfs_scrub_all.py [v2] Christian Kujau
2025-08-26 16:10 ` Darrick J. Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250826161051.GC19817@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=lists@nerdbynature.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox