Skip to content

Commit ef0bc9c

Browse files
committed
Merge branch 'release-29' into python-3
2 parents 0067a65 + 69b9677 commit ef0bc9c

File tree

15 files changed

+101
-63
lines changed

15 files changed

+101
-63
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'beaker-*'
7+
8+
jobs:
9+
build-python-package:
10+
strategy:
11+
matrix:
12+
component:
13+
- "Common"
14+
- "Client"
15+
name: Build python package
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout source code
19+
uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.x"
24+
- name: Install python dependencies
25+
run: pip install --upgrade pip && pip install build
26+
- name: Build python package
27+
run: cd ${{ matrix.component }} && python -m build
28+
- name: Upload python artifacts
29+
uses: actions/upload-artifact@v4
30+
with:
31+
path: ${{ matrix.component }}/dist
32+
name: artifact-${{ matrix.component }}
33+
34+
publish-python-package:
35+
needs:
36+
- "build-python-package"
37+
environment: production
38+
permissions:
39+
id-token: write
40+
strategy:
41+
matrix:
42+
component:
43+
- "Common"
44+
- "Client"
45+
name: Publish package to PyPI
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Download artifacts
49+
uses: actions/download-artifact@v4
50+
with:
51+
name: artifact-${{ matrix.component }}
52+
- name: Display structure of downloaded files
53+
run: ls -R
54+
- name: Publish package distributions to PyPI
55+
uses: pypa/gh-action-pypi-publish@release/v1
56+
with:
57+
print-hash: true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea/
12
*.pyc
23
*.swp
34
*.tmp

Client/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def bash_completion_dir():
2222

2323
setup(
2424
name='beaker-client',
25-
version='29.0rc1',
25+
version='29.0rc2',
2626
description='Command-line client for interacting with Beaker',
2727
author='Red Hat, Inc.',
2828
author_email='[email protected]',

Client/src/bkr/client/commands/cmd_update_inventory.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@
8787

8888
from __future__ import print_function
8989

90-
import cgi
9190
import sys
9291
from xml.dom.minidom import parseString
9392

9493
from requests.exceptions import HTTPError
9594

9695
from bkr.client import BeakerCommand
9796
from bkr.client.task_watcher import watch_tasks
97+
from bkr.common.helpers_six import parse_content_type
9898

9999

100100
class Update_Inventory(BeakerCommand):
@@ -152,7 +152,7 @@ def run(self, *args, **kwargs):
152152
res.raise_for_status()
153153
except HTTPError as e:
154154
sys.stderr.write('HTTP error: %s, %s\n' % (fqdn, e))
155-
content_type, _ = cgi.parse_header(e.response.headers.get(
155+
content_type = parse_content_type(e.response.headers.get(
156156
'Content-Type', ''))
157157
if content_type == 'text/plain':
158158
sys.stderr.write('\t' +

Client/src/bkr/client/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
# the Free Software Foundation; either version 2 of the License, or
66
# (at your option) any later version.
77

8-
import cgi
98
import errno
109
import logging
1110
import signal
@@ -22,6 +21,7 @@
2221
from bkr.client.command import ClientCommandContainer
2322
from bkr.client.command import CommandOptionParser
2423
from bkr.common import __version__
24+
from bkr.common.helpers_six import parse_content_type
2525
from bkr.log import log_to_stream
2626

2727
__all__ = (
@@ -129,7 +129,7 @@ def main():
129129
except maybe_http_error as e:
130130
warn_on_version_mismatch(e.response)
131131
sys.stderr.write('HTTP error: %s\n' % e)
132-
content_type, _ = cgi.parse_header(e.response.headers.get('Content-Type', ''))
132+
content_type = parse_content_type(e.response.headers.get('Content-Type', ''))
133133
if content_type == 'text/plain':
134134
sys.stderr.write(e.response.content.decode('utf-8').rstrip('\n') + '\n')
135135
return 1

Common/bkr/common/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# code in bkr.__init__), the version details are retrieved from here in
33
# order to correctly handle module shadowing on sys.path
44

5-
__version__ = '29.0rc1'
5+
__version__ = '29.0rc2'

Common/bkr/common/helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,4 +277,3 @@ def total_seconds(td):
277277
represented by the given timedelta.
278278
"""
279279
return (float(td.microseconds) + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
280-

Common/bkr/common/helpers_six.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
# This program is free software; you can redistribute it and/or modify
3+
# it under the terms of the GNU General Public License as published by
4+
# the Free Software Foundation; either version 2 of the License, or
5+
# (at your option) any later version.
6+
7+
def parse_content_type(value):
8+
"""
9+
Return just content type, without options
10+
"""
11+
groups = value.split(';', 1)
12+
return groups[0]

Common/bkr/common/test_helpers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# This program is free software; you can redistribute it and/or modify
2+
# it under the terms of the GNU General Public License as published by
3+
# the Free Software Foundation; either version 2 of the License, or
4+
# (at your option) any later version.
5+
6+
import unittest
7+
8+
from bkr.common.helpers_six import parse_content_type
9+
10+
11+
class ParsingContentType(unittest.TestCase):
12+
13+
def test_ok(self):
14+
self.assertEqual(parse_content_type('type/subtype; charset=utf-8'), 'type/subtype')
15+
self.assertEqual(parse_content_type('type/subtype'), 'type/subtype')
16+
17+
def test_empty(self):
18+
self.assertEqual(parse_content_type(''), '')

0 commit comments

Comments
 (0)