Skip to content

Commit aa5f601

Browse files
committed
Style, linter and other checker fixes
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 30c1de7 commit aa5f601

File tree

5 files changed

+28
-29
lines changed

5 files changed

+28
-29
lines changed

scripts/koji/create_user_target.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
import argparse
3-
import subprocess
43
import logging
4+
import subprocess
55
import sys
66

77
def setup_logger():
@@ -34,4 +34,3 @@ def main():
3434

3535
if __name__ == "__main__":
3636
main()
37-

scripts/koji/koji_import_rpms.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/env python3
22
import argparse
3+
import glob
34
import os
45
import subprocess
5-
import glob
66

77
def get_srpm_info(srpmpath):
8-
return subprocess.check_output(['rpm', '-qp', srpmpath, '--qf', '%{name};;%{nvr}']).split(';;')
8+
return subprocess.check_output(['rpm', '-qp', srpmpath, '--qf', '%{name};;%{nvr}']).decode().split(';;')
99

1010
def check_dir(dirpath):
1111
if not os.path.isdir(dirpath):
@@ -19,11 +19,11 @@ def main():
1919
parser.add_argument('package_tags', help='comma-separated list of tags for the package(s)')
2020
parser.add_argument('build_tags', help='comma-separated list of tags for imported build(s)')
2121
parser.add_argument('--owner', help='owner for the package(s)', default='kojiadmin')
22-
parser.add_argument('--create-build', help='create the build even if there\'s no SRPM', action='store_true', default=False)
22+
parser.add_argument(
23+
'--create-build', help='create the build even if there\'s no SRPM', action='store_true', default=False
24+
)
2325
args = parser.parse_args()
2426

25-
DEVNULL = open(os.devnull, 'w')
26-
2727
srpm_directory = os.path.abspath(check_dir(args.srpm_directory))
2828
rpm_directory = os.path.abspath(check_dir(args.rpm_directory))
2929

scripts/koji/sync_repo_from_koji.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#!/usr/bin/env python3
22
import argparse
3-
import re
4-
import os
5-
import sys
6-
import subprocess
3+
import atexit
74
import glob
5+
import os
6+
import re
87
import shutil
8+
import subprocess
9+
import sys
910
import tempfile
10-
import atexit
11-
1211
from datetime import datetime
12+
from subprocess import DEVNULL
1313

1414
USER_REPO_HTTPS = "https://koji.xcp-ng.org/repos/user/"
1515

@@ -21,7 +21,7 @@
2121
'8.3',
2222
]
2323

24-
DEV_VERSIONS = [
24+
DEV_VERSIONS: list[str] = [
2525
]
2626

2727
VERSIONS = DEV_VERSIONS + RELEASE_VERSIONS
@@ -62,7 +62,7 @@
6262
'v8.0-base',
6363
'v8.1-base',
6464
'v8.2-base',
65-
# 'v8.3-base', # special case: we have a history of pre-release builds that users might need for troubleshooting
65+
# 'v8.3-base', # special case: we have a history of pre-release builds that users might need for troubleshooting
6666
]
6767

6868
# tags for which we want to export a stripped repo for offline updates
@@ -85,10 +85,9 @@
8585

8686
KEY_ID = "3fd3ac9e"
8787

88-
DEVNULL = open(os.devnull, 'w')
89-
9088
def version_from_tag(tag):
9189
matches = re.match(r'v(\d+\.\d+)', tag)
90+
assert matches is not None
9291
return matches.group(1)
9392

9493
def repo_name_from_tag(tag):
@@ -215,7 +214,7 @@ def sign_unsigned_rpms(tag):
215214
for line in output.strip().splitlines():
216215
try:
217216
key, rpm = line.split(' ')
218-
except:
217+
except ValueError:
219218
# couldn't unpack values... no signature.
220219
continue
221220
if key == KEY_ID:
@@ -323,7 +322,9 @@ def offline_repo_dir():
323322
print("\n-- Make koji write the repository for tag %s" % tag)
324323
with_non_latest = [] if tag in RELEASE_TAGS else ['--non-latest']
325324
sys.stdout.flush()
326-
subprocess.check_call(['koji', 'dist-repo', tag, '3fd3ac9e', '--with-src', '--noinherit'] + with_non_latest)
325+
subprocess.check_call(
326+
['koji', 'dist-repo', tag, '3fd3ac9e', '--with-src', '--noinherit'] + with_non_latest
327+
)
327328

328329
# write repository to the appropriate destination directory for the tag
329330
write_repo(tag, dest_dir_for_tag(tag), tmp_root_dir)

scripts/koji/untag_lone_builds.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import koji
3+
import koji # type: ignore
44

55
config = koji.read_config("koji")
66
s = koji.ClientSession('https://kojihub.xcp-ng.org', config)

scripts/koji/update_vendor_tags.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env python3
22
import argparse
3-
import subprocess
43
import json
54
import os
65
import re
7-
8-
DEVNULL = open(os.devnull, 'w')
6+
import subprocess
7+
from subprocess import DEVNULL
98

109
XS_buildhosts = [
1110
'1b68968c4e4e',
@@ -43,9 +42,9 @@ def update_vendor_tag_for_build(build, is_bootstrap=False):
4342
rpm_path = ""
4443
for line in output.splitlines():
4544
first_element = line.split()[0]
46-
if re.match('.+/src/.+\.src\.rpm', first_element):
45+
if re.match(r'.+/src/.+\.src\.rpm', first_element):
4746
srpm_path = ""
48-
if re.match('.+\.rpm', first_element):
47+
if re.match(r'.+\.rpm', first_element):
4948
rpm_path = first_element
5049

5150
if not rpm_path:
@@ -62,7 +61,9 @@ def update_vendor_tag_for_build(build, is_bootstrap=False):
6261
['rpm', '-qp', rpm_path, '--qf', '%{vendor};;%{buildhost}'], stderr=DEVNULL
6362
).decode()
6463
vendor, buildhost = output.split(';;')
65-
package = re.search('/packages/([^/]+)/', rpm_path).group(1)
64+
rpm_match = re.search('/packages/([^/]+)/', rpm_path)
65+
assert rpm_match is not None
66+
package = rpm_match.group(1)
6667

6768
tag = None
6869
if buildhost in XS_buildhosts:
@@ -121,6 +122,7 @@ def main():
121122
last_sync_event_filepath = os.path.join(data_dir, 'last_sync_event')
122123

123124
need_update = True
125+
timestamp = 0
124126
if os.path.exists(last_sync_event_filepath):
125127
with open(last_sync_event_filepath) as f:
126128
last_sync_event = json.loads(f.read())
@@ -129,9 +131,6 @@ def main():
129131
need_update = False
130132
else:
131133
timestamp = last_sync_event['ts']
132-
else:
133-
timestamp = 0 # first update ever
134-
135134

136135
if not need_update:
137136
if not quiet:

0 commit comments

Comments
 (0)