From 22dc364545848ba5d07735d20561ba8690d510a2 Mon Sep 17 00:00:00 2001 From: sshathee Date: Wed, 16 Oct 2024 05:24:13 -0400 Subject: [PATCH] Improving reprepro distributions config file creation This commit introduces try-catch statement to caputre any errors during creation of distributions config file. PASS: Run software-controller-init.sh and check user.log Story: 2010676 Task: 51179 Change-Id: I78d8b9e9da5f28e622da72a4c7fb3b6897bb8020 Signed-off-by: sshathee --- apt_ostree/repo.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/apt_ostree/repo.py b/apt_ostree/repo.py index 68d7858..5d43c4b 100644 --- a/apt_ostree/repo.py +++ b/apt_ostree/repo.py @@ -46,16 +46,20 @@ class Repo: sys.exit(1) else: self.logging.info("Creating reprepro configuration.") - config.write_text( - textwrap.dedent(f"""\ - Origin: {self.state.origin} - Label: {self.label} - Codename: {self.state.release} - Architectures: amd64 - Components: {self.state.origin} - Description: {self.description} - """) - ) + try: + config.write_text( + textwrap.dedent(f"""\ + Origin: {self.state.origin} + Label: {self.label} + Codename: {self.state.release} + Architectures: amd64 + Components: {self.state.origin} + Description: {self.description} + """) + ) + except Exception as e: + self.logging.error("Error writing distributions \ + config file: %s" % str(e)) options = self.repo.joinpath("options") if not options.exists(): options.write_text(