From patchwork Sat Jan 13 02:04:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 84030 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CC8353858C56 for ; Sat, 13 Jan 2024 02:05:13 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E9E543858D1E for ; Sat, 13 Jan 2024 02:04:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9E543858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E9E543858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705111490; cv=none; b=kTD6TQEdc9ZuWoG0KnUyxqusO0z9/mu1dse46VBxhWTnKPaYbps/wthHfQkiz594jTi1DtcwUTkmm6xh5ps3nKO0+qNBx0DPM60ZRLbiTaiw8coKgNK0Xcgz+R69rONtlZTg/tea3+Btk807buuART+EwhcJIsXPIsnwVZHH+lU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705111490; c=relaxed/simple; bh=vHN1iYxES0nPrNO1wR72YS9Yr8B0RDx0Ret8rrVDLwo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DJP9zkN5PVfnoV9W6edr47r7HSQplESL8+Sn2Nqj32d1uJ3SkJj01s22i3jgNjD1xVeBlAPOlVZzDFpPsafV4k2sj4hxUXQT7eaiy5HlWOZOGHA7Zs2kB9wZ0RxZeXHX2HBCPaGXc1MfyU9T+K8zowhEJiwEQgJ+n2TBqopk8as= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705111485; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=vg59izIfDau1ByxLNEjIL0JJfBeRtfkGqJqOSk4RQ5g=; b=JnlFyev4t/DkffuFhQbPAqIr5jrfrdW6lFon7/UQ0nsX/DTAZ7dyl/zBLP5cIYG5JXNW5e 9vjhW8YrvZBkiw/cwehLd7idR9kFPjM0fexN03U5MoV6hCkBl4tDY1JMcaMUMUUH2zjp5z /pkctBnD1jo0PhXR85qtjw7/NNjW8dI= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368-xsHqdX-dMV-8iKdJrqlz1g-1; Fri, 12 Jan 2024 21:04:43 -0500 X-MC-Unique: xsHqdX-dMV-8iKdJrqlz1g-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3367e2bd8b0so4466717f8f.1 for ; Fri, 12 Jan 2024 18:04:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705111480; x=1705716280; h=mime-version:message-id:subject:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vg59izIfDau1ByxLNEjIL0JJfBeRtfkGqJqOSk4RQ5g=; b=ox8MxX0MXLmh7IRzi16ii3psU8jVl2RAHJKOPfXNLeismqRSNX4dX6eW8lJRYKBlOQ df4/vW2LJ95xSCfyU0OpRNALa+S2PgnDUgcHG0dLgEecjCjwZCz6C8dMq9QjIcXyIZBb Zonz/5xYCM8PE+Z/enl8ZtY/OqhYhA/7iwCktuPh32CCUuG+K48E+p7Mba26v5RX1chq FxlmH7kPn+M2tKGVH12bHOPuPnRkD5MNi+Vc/ghrWUCxTYGOlOBJKlZ+di4nyFsS0Gzn 5fAzkimjnDSc72+Thc2qzUccx4I3VWdCPNCaaAK123aZrlB/obJYsmMzPpvzNzxeZ0H8 Hu1Q== X-Gm-Message-State: AOJu0Yx+lS8U4BpWJNaf0eSj89N+UP1lBYGfU/Ti4NY6+09ASiCJafR/ QLRM3UfA+VzDHTnJBgmhDrvqlREdrXlWJBwCwFdXe6eql6M7pa/2qCCHJVResetesgARhn69ZuZ REFnu1KrmN1jjxMDTnYfkGCzCedslgvRujformKXZjnlt9GZih+0xzrUPVLcjAwSe3hpdW/2F+3 ug2HQyqGSiO9nO X-Received: by 2002:a05:600c:2215:b0:40d:88f2:fe7c with SMTP id z21-20020a05600c221500b0040d88f2fe7cmr1226848wml.77.1705111480553; Fri, 12 Jan 2024 18:04:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHb80w8m3BtUL1Og0PoJcHxrM6mmPPZiGEkFIVaCKBra9v+jHeA+XaW8cUAr3H35fO33DK1Jw== X-Received: by 2002:a05:600c:2215:b0:40d:88f2:fe7c with SMTP id z21-20020a05600c221500b0040d88f2fe7cmr1226842wml.77.1705111479793; Fri, 12 Jan 2024 18:04:39 -0800 (PST) Received: from digraph.polyomino.org.uk (digraph.polyomino.org.uk. [2001:8b0:bf73:93f7::51bb:e332]) by smtp.gmail.com with ESMTPSA id u13-20020a05600c19cd00b0040e451fd602sm11426588wmq.33.2024.01.12.18.04.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 18:04:39 -0800 (PST) Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.95) (envelope-from ) id 1rOTNQ-000tEJ-BZ for libc-alpha@sourceware.org; Sat, 13 Jan 2024 02:04:00 +0000 Date: Sat, 13 Jan 2024 02:04:00 +0000 (UTC) From: Joseph Myers To: libc-alpha@sourceware.org Subject: Further build-many-glibcs.py fixes for utcnow() deprecation Message-ID: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org It turns out that the replacement of datetime.datetime.utcnow(), for a warning produced early in running build-many-glibcs.py with Python 3.12, (a) wasn't complete (there were other uses elsewhere in the script also needing updating) and (b) broke reading of build-time from build-state.json, because an aware datetime was written out including +00:00 for the timezone, which was not expected by the strptime call. Fix the first by making the change to datetime.datetime.now(datetime.timezone.utc) for all the remaining utcnow() calls. Fix the second by using strftime with an explicit format instead of just str() when formatting build times for build-state.json and and email subjects, and then setting the timezone explicitly when reading from build-state.json. (Other uses, in particular messages output by the bot, continue to use str() as the precise format should not matter in those cases; it shouldn't actually matter for email subjects either but it seems a good idea to keep those short.) Tested with a bot-cycle run and checking the format of times in build-state.json afterwards. diff --git a/scripts/build-many-glibcs.py b/scripts/build-many-glibcs.py index ec2ded6e56..20601ed853 100755 --- a/scripts/build-many-glibcs.py +++ b/scripts/build-many-glibcs.py @@ -1057,7 +1057,8 @@ class Context(object): def update_build_state(self, action, build_time, build_versions): """Update the build state after a build.""" build_time = build_time.replace(microsecond=0) - self.build_state[action]['build-time'] = str(build_time) + self.build_state[action]['build-time'] = build_time.strftime( + '%Y-%m-%d %H:%M:%S') self.build_state[action]['build-versions'] = build_versions build_results = {} for log in self.status_log_list: @@ -1103,15 +1104,17 @@ class Context(object): old_time_str = self.build_state[action]['build-time'] if not old_time_str: return True - old_time = datetime.datetime.strptime(old_time_str, - '%Y-%m-%d %H:%M:%S') - new_time = datetime.datetime.utcnow() + old_time = datetime.datetime.strptime( + old_time_str, '%Y-%m-%d %H:%M:%S').replace( + tzinfo=datetime.timezone.utc) + new_time = datetime.datetime.now(datetime.timezone.utc) delta = new_time - old_time return delta.total_seconds() >= delay def bot_cycle(self): """Run a single round of checkout and builds.""" - print('Bot cycle starting %s.' % str(datetime.datetime.utcnow())) + print('Bot cycle starting %s.' + % str(datetime.datetime.now(datetime.timezone.utc))) self.load_bot_config_json() actions = ('host-libraries', 'compilers', 'glibcs') self.bot_run_self(['--replace-sources'], 'checkout') @@ -1163,12 +1166,13 @@ class Context(object): shutil.copytree(self.logsdir, self.logsdir_old) for a in actions: if must_build[a]: - build_time = datetime.datetime.utcnow() + build_time = datetime.datetime.now(datetime.timezone.utc) print('Rebuilding %s at %s.' % (a, str(build_time))) self.bot_run_self([], a) self.load_build_state_json() self.bot_build_mail(a, build_time) - print('Bot cycle done at %s.' % str(datetime.datetime.utcnow())) + print('Bot cycle done at %s.' + % str(datetime.datetime.now(datetime.timezone.utc))) def bot_build_mail(self, action, build_time): """Send email with the results of a build.""" @@ -1184,7 +1188,7 @@ class Context(object): build_time = build_time.replace(microsecond=0) subject = (self.bot_config['email-subject'] % {'action': action, - 'build-time': str(build_time)}) + 'build-time': build_time.strftime('%Y-%m-%d %H:%M:%S')}) results = self.build_state[action]['build-results'] changes = self.build_state[action]['result-changes'] ever_passed = set(self.build_state[action]['ever-passed']) @@ -1233,7 +1237,8 @@ class Context(object): msg['From'] = self.bot_config['email-from'] msg['To'] = self.bot_config['email-to'] msg['Message-ID'] = email.utils.make_msgid() - msg['Date'] = email.utils.format_datetime(datetime.datetime.utcnow()) + msg['Date'] = email.utils.format_datetime( + datetime.datetime.now(datetime.timezone.utc)) with smtplib.SMTP(self.bot_config['email-server']) as s: s.send_message(msg)