From e14e741b27e313707ca0462df61aeb39e1d85947 Mon Sep 17 00:00:00 2001 From: Michael Hofmann Date: Mon, 5 Feb 2024 21:34:38 +0100 Subject: [PATCH 1/4] Fix invalid escape sequences on Python 3.12 in client code Candidate sites were found via find . -iname '*.py' -exec pylint --disable all --enable W1401 {} + and git grep '\ --- Client/src/bkr/client/__init__.py | 2 +- .../bkr/client/commands/cmd_workflow_xslt.py | 2 +- Client/src/bkr/client/tests/test_wizard.py | 2 +- Client/src/bkr/client/wizard.py | 80 +++++++++---------- .../inttest/client/test_update_inventory.py | 2 +- .../bkr/inttest/client/test_watchdogs_show.py | 2 +- .../inttest/client/test_workflow_simple.py | 20 ++--- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Client/src/bkr/client/__init__.py b/Client/src/bkr/client/__init__.py index 29efc5da6..b7ca89859 100644 --- a/Client/src/bkr/client/__init__.py +++ b/Client/src/bkr/client/__init__.py @@ -61,7 +61,7 @@ def host_filter_presets(): for f in config_files: with open(f) as fobj: for line in fobj: - matched = re.match('^(\w+)\s+(\S+.*)$', line) + matched = re.match(r'^(\w+)\s+(\S+.*)$', line) if matched: preset, xml = matched.groups() _host_filter_presets[preset] = xml diff --git a/Client/src/bkr/client/commands/cmd_workflow_xslt.py b/Client/src/bkr/client/commands/cmd_workflow_xslt.py index 9ea230252..8d599b85b 100644 --- a/Client/src/bkr/client/commands/cmd_workflow_xslt.py +++ b/Client/src/bkr/client/commands/cmd_workflow_xslt.py @@ -35,7 +35,7 @@ def __init__(self): self.arguments = {} self.current = None self.current_node = None - self.re_tag = re.compile('(.*)(\[@(.*)=(.*)\])') + self.re_tag = re.compile(r'(.*)(\[@(.*)=(.*)\])') def add_argument(self, name, argtype, tagname, tagvaltype, tagvalname, tagnamelmnt, value, optional): diff --git a/Client/src/bkr/client/tests/test_wizard.py b/Client/src/bkr/client/tests/test_wizard.py index 3c541fe8b..ffdac2693 100644 --- a/Client/src/bkr/client/tests/test_wizard.py +++ b/Client/src/bkr/client/tests/test_wizard.py @@ -125,7 +125,7 @@ def test_shell_metachars_escaped_in_makefile(self): desc = wizard.Desc(options, suggest="Test for BZ#1234567 " "(I ran `rm -rf ~` and everything's gone suddenly)") self.assertEqual( - """\n \t@echo "Description: Test for BZ#1234567 (I ran \`rm -rf ~\` and everything's gone suddenly)" >> $(METADATA)""", + """\n \t@echo "Description: Test for BZ#1234567 (I ran \\`rm -rf ~\\` and everything's gone suddenly)" >> $(METADATA)""", desc.formatMakefileLine()) diff --git a/Client/src/bkr/client/wizard.py b/Client/src/bkr/client/wizard.py index 01ad8c987..a91f61746 100755 --- a/Client/src/bkr/client/wizard.py +++ b/Client/src/bkr/client/wizard.py @@ -364,24 +364,24 @@ WizardVersion = "2.3.2" # Regular expressions -RegExpPackage = re.compile("^(?![._+-])[.a-zA-Z0-9_+-]+(?", options.opt.owner) + m = re.search(r"(.*)\s+<(.*)>", options.opt.owner) if m: options.opt.author = m.group(1) options.opt.email = m.group(2) @@ -1237,9 +1237,9 @@ def defaultify(self): def normalize(self): """ Remove trailing and double spaces """ if not self.data: return - self.data = re.sub("^\s*", "", self.data) - self.data = re.sub("\s*$", "", self.data) - self.data = re.sub("\s+", " ", self.data) + self.data = re.sub(r"^\s*", "", self.data) + self.data = re.sub(r"\s*$", "", self.data) + self.data = re.sub(r"\s+", " ", self.data) def read(self): """ @@ -1259,7 +1259,7 @@ def read(self): if answer != "": # append the data if the answer starts with a "+", # but ignore if only "+" is present - m = re.search("^\+\S+(.*)", answer) + m = re.search(r"^\+\S+(.*)", answer) if m and isinstance(self.data, list): self.data.append(m.group(1)) else: @@ -1289,7 +1289,7 @@ def singleName(self): def matchName(self, text): """ Return true if the text matches inquisitor's name """ # remove any special characters from the search string - text = re.sub("[^\w\s]", "", text) + text = re.sub(r"[^\w\s]", "", text) return re.search(text, self.name, re.I) def describe(self): @@ -1649,7 +1649,7 @@ def init(self): self.default(self.options.time()) def valid(self): - m = re.match("^(\d{1,2})[mhd]$", self.data) + m = re.match(r"^(\d{1,2})[mhd]$", self.data) return m is not None and int(m.group(1)) > 0 @@ -1664,7 +1664,7 @@ def init(self): self.default(self.options.version()) def valid(self): - return re.match("^\d+\.\d+$", self.data) + return re.match(r"^\d+\.\d+$", self.data) class Priority(SingleChoice): @@ -1965,7 +1965,7 @@ def fetchBugDetails(self): def getSummary(self): """ Return short summary fetched from bugzilla """ if self.bug: - return re.sub("CVE-\d{4}-\d{4}\s*", "", removeEmbargo(self.bug.summary)) + return re.sub(r"CVE-\d{4}-\d{4}\s*", "", removeEmbargo(self.bug.summary)) def getComponent(self): """ Return bug component fetched from bugzilla """ @@ -2256,7 +2256,7 @@ def init(self): rlJournalStart rlPhaseStartSetup rlAssertRpm $PACKAGE - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "TmpDir=\\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd @@ -2283,7 +2283,7 @@ def init(self): rlJournalStart rlPhaseStartSetup rlAssertRpm $PACKAGE || rlDie "$PACKAGE not installed" - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "TmpDir=\\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd @@ -2373,7 +2373,7 @@ def init(self): rlAssertRpm $PACKAGE rlLog "Server: $SERVERS" rlLog "Client: $CLIENTS" - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "TmpDir=\\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd @@ -2409,7 +2409,7 @@ def init(self): rlJournalStart rlPhaseStartSetup rlRun "rlImport /" - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "TmpDir=\\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd @@ -2456,7 +2456,7 @@ def init(self): rlJournalStart rlPhaseStartSetup rlAssertRpm --all - rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "TmpDir=\\$(mktemp -d)" 0 "Creating tmp directory" rlRun "pushd $TmpDir" rlPhaseEnd @@ -2716,7 +2716,7 @@ def getRuntest(self, test = None): # substitute variables, convert to plain text skeleton = self.replaceVariables(skeleton, test) # return dedented skeleton without trailing whitespace - skeleton = re.sub("\n\s+$", "\n", skeleton) + skeleton = re.sub(r"\n\s+$", "\n", skeleton) return dedentText(skeleton) def getRhtsRequires(self): diff --git a/IntegrationTests/src/bkr/inttest/client/test_update_inventory.py b/IntegrationTests/src/bkr/inttest/client/test_update_inventory.py index 6c56deb55..2019bf736 100644 --- a/IntegrationTests/src/bkr/inttest/client/test_update_inventory.py +++ b/IntegrationTests/src/bkr/inttest/client/test_update_inventory.py @@ -69,7 +69,7 @@ def test_update_inventory_wait(self): proc = start_client(args) out = proc.stdout.readline().rstrip() self.assert_(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) out = proc.stdout.readline().rstrip() self.assert_('Watching tasks (this may be safely interrupted)...' == out) diff --git a/IntegrationTests/src/bkr/inttest/client/test_watchdogs_show.py b/IntegrationTests/src/bkr/inttest/client/test_watchdogs_show.py index f8fee0997..70165c3d7 100644 --- a/IntegrationTests/src/bkr/inttest/client/test_watchdogs_show.py +++ b/IntegrationTests/src/bkr/inttest/client/test_watchdogs_show.py @@ -24,7 +24,7 @@ def test_watchdog_show_running_task(self): datetime.timedelta(seconds=99) out = run_client(['bkr', 'watchdog-show', str(t1.id)]) # Let's just check it is somewhere between 10-99 - self.assertTrue(re.match('%s: \d\d\\n' % t1.id, out)) + self.assertTrue(re.match(r'%s: \d\d\n' % t1.id, out)) def test_watchdog_show_non_running_task(self): with session.begin(): diff --git a/IntegrationTests/src/bkr/inttest/client/test_workflow_simple.py b/IntegrationTests/src/bkr/inttest/client/test_workflow_simple.py index 1ceacb138..0e98bad2f 100644 --- a/IntegrationTests/src/bkr/inttest/client/test_workflow_simple.py +++ b/IntegrationTests/src/bkr/inttest/client/test_workflow_simple.py @@ -65,7 +65,7 @@ def test_job_group(self): '--job-group', group.group_name, '--task', self.task.name], config=config1) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -98,7 +98,7 @@ def test_job_owner(self): '--family', self.distro.osversion.osmajor.osmajor, '--task', self.task.name], config=config) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -120,7 +120,7 @@ def test_submit_job_wait(self): proc = start_client(args) out = proc.stdout.readline().rstrip() self.assert_(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) out = proc.stdout.readline().rstrip() @@ -334,7 +334,7 @@ def test_servers_default_zero(self): '--task', '/distribution/reservesys', '--clients', '2']) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -349,7 +349,7 @@ def test_clients_default_zero(self): '--task', '/distribution/reservesys', '--servers', '2']) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -362,7 +362,7 @@ def submit_job_and_check_arches(self, workflow_options, expected_arches): out = run_client(['bkr', 'workflow-simple', '--task', self.task.name] + workflow_options) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -435,7 +435,7 @@ def test_kickstart_template(self): '--task', self.task.name, '--kickstart', template_file.name]) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -456,7 +456,7 @@ def test_kickstart_template_with_kernel_options(self): '--task', self.task.name, '--kickstart', template_file.name]) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -484,7 +484,7 @@ def test_no_default_install_method(self): out = run_client(['bkr', 'workflow-simple', '--distro', self.distro.name, '--task', self.task.name]) self.assertTrue(out.startswith('Submitted:'), out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) @@ -557,7 +557,7 @@ def _verify_check_install(self, distro): '--distro', distro.name, '--task', self.task.name]) self.assertIn('Submitted:', out) - m = re.search('J:(\d+)', out) + m = re.search(r'J:(\d+)', out) job_id = m.group(1) with session.begin(): job = Job.by_id(job_id) From 7564bcb12e221a7104f946bfc9904a6188cdb976 Mon Sep 17 00:00:00 2001 From: Martin Styk Date: Fri, 9 Feb 2024 22:11:05 +0100 Subject: [PATCH 2/4] Refactor error message handling Resolves: #210 Signed-off-by: Martin Styk --- Common/bkr/common/hub.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Common/bkr/common/hub.py b/Common/bkr/common/hub.py index 0b31da996..4a34296b9 100644 --- a/Common/bkr/common/hub.py +++ b/Common/bkr/common/hub.py @@ -200,8 +200,9 @@ def get_server_principal(service=None, realm=None): ) except gssapi.raw.GSSError as ex: if ex.min_code == krb5kdc_err_s_principal_unknown: # pylint: disable=no-member - ex.message += ". Make sure you correctly set KRB_REALM (current value: %s)." % realm - ex.args = (ex.message, ) + message = str(ex) + message += ". Make sure you correctly set KRB_REALM (current value: %s)." % realm + ex.args = (message,) raise ex if six.PY2: req_enc = base64.encodestring(res.token) From a8c67e8a4d00a93c048aac3cba57040e9988ab5f Mon Sep 17 00:00:00 2001 From: Martin Styk Date: Sun, 11 Feb 2024 15:52:14 +0100 Subject: [PATCH 3/4] Release 29.1 Signed-off-by: Martin Styk --- documentation/whats-new/release-29.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/documentation/whats-new/release-29.rst b/documentation/whats-new/release-29.rst index fa41be922..630aeffca 100644 --- a/documentation/whats-new/release-29.rst +++ b/documentation/whats-new/release-29.rst @@ -37,3 +37,13 @@ A number of bug fixes are also included in this release: * | `GH#177 `_: Fixed issue where JUnit result wasn't properly decoded in Beaker client. | (Contributed by `Bill Peck `_) + +Beaker 29.1 +~~~~~~~~~~~ +* | `GH#210 `_: + Refactored error message handling when dealing with Kerberos realm settings. + | (Contributed by `Martin Styk `_) +* | `GH#211 `_: + Fixed invalid escape sequences in Python 3.12 across various client code. + | (Contributed by `Michael Hofmann `_) + From 9092199cc3287f23642486bbd52743577910ff6a Mon Sep 17 00:00:00 2001 From: Martin Styk Date: Sun, 11 Feb 2024 20:00:39 +0100 Subject: [PATCH 4/4] Automatic commit of release 29.1 --- Client/setup.py | 2 +- Common/bkr/common/__init__.py | 2 +- Common/setup.py | 2 +- IntegrationTests/setup.py | 2 +- LabController/setup.py | 2 +- Server/setup.py | 2 +- beaker.spec | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Client/setup.py b/Client/setup.py index 17e553166..b8a828717 100644 --- a/Client/setup.py +++ b/Client/setup.py @@ -23,7 +23,7 @@ def bash_completion_dir(): setup( name='beaker-client', - version='29.0', + version='29.1', description=DESCRIPTION, # XXX: Create proper README for this package and use it for long description long_description=DESCRIPTION, diff --git a/Common/bkr/common/__init__.py b/Common/bkr/common/__init__.py index edac96545..cdf54a2fb 100644 --- a/Common/bkr/common/__init__.py +++ b/Common/bkr/common/__init__.py @@ -2,4 +2,4 @@ # code in bkr.__init__), the version details are retrieved from here in # order to correctly handle module shadowing on sys.path -__version__ = '29.0' +__version__ = '29.1' diff --git a/Common/setup.py b/Common/setup.py index 734e49317..816cfd15b 100644 --- a/Common/setup.py +++ b/Common/setup.py @@ -14,7 +14,7 @@ setup( name='beaker-common', - version='29.0', + version='29.1', description=DESCRIPTION, # XXX: Create proper README for this package and use it for long description long_description=DESCRIPTION, diff --git a/IntegrationTests/setup.py b/IntegrationTests/setup.py index dbbb3a1c9..4bb54eb59 100644 --- a/IntegrationTests/setup.py +++ b/IntegrationTests/setup.py @@ -12,7 +12,7 @@ def get_compose_layout(): setup( name='beaker-integration-tests', - version='29.0', + version='29.1', description='Integration tests for Beaker', author='Red Hat, Inc.', author_email='beaker-devel@lists.fedorahosted.org', diff --git a/LabController/setup.py b/LabController/setup.py index a4dca4c08..cd7337f84 100644 --- a/LabController/setup.py +++ b/LabController/setup.py @@ -49,7 +49,7 @@ def systemd_tmpfiles_dir(): setup( name='beaker-lab-controller', - version='29.0', + version='29.1', description='Daemons for controlling a Beaker lab', author='Red Hat, Inc.', author_email='beaker-devel@lists.fedorahosted.org', diff --git a/Server/setup.py b/Server/setup.py index 80a7399d2..e63492643 100644 --- a/Server/setup.py +++ b/Server/setup.py @@ -186,7 +186,7 @@ def find_data_recursive(dest_dir, src_dir, exclude=frozenset()): setup( name='beaker-server', namespace_packages = ['bkr'], - version='29.0', + version='29.1', description='Beaker scheduler and web interface', long_description= 'Beaker is a system for full stack software integration testing ' diff --git a/beaker.spec b/beaker.spec index 0027c7d46..f5150ece7 100644 --- a/beaker.spec +++ b/beaker.spec @@ -15,10 +15,10 @@ # not representable in RPM. For example, a release candidate might be 0.15.0rc1 # but that is not usable for the RPM Version because it sorts higher than # 0.15.0, so the RPM will have Version 0.15.0 and Release 0.rc1 in that case. -%global upstream_version 29.0 +%global upstream_version 29.1 Name: beaker -Version: 29.0 +Version: 29.1 Release: 1%{?dist} Summary: Full-stack software and hardware integration testing system Group: Applications/Internet