Skip to content

Commit f6e7a77

Browse files
authored
Merge pull request #763 from xcp-ng/gln/fix-vendor-tags-oqkk
Fix update_vendor_tags.py
2 parents ef5283f + 844e4dd commit f6e7a77

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

scripts/koji/update_vendor_tags.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
import subprocess
8+
from subprocess import DEVNULL
89

910
XS_buildhosts = [
1011
'1b68968c4e4e',
@@ -42,9 +43,9 @@ def update_vendor_tag_for_build(build, is_bootstrap=False):
4243
rpm_path = ""
4344
for line in output.splitlines():
4445
first_element = line.split()[0]
45-
if re.match('.+/src/.+\.src\.rpm', first_element):
46+
if re.match(r'.+/src/.+\.src\.rpm', first_element):
4647
srpm_path = ""
47-
if re.match('.+\.rpm', first_element):
48+
if re.match(r'.+\.rpm', first_element):
4849
rpm_path = first_element
4950

5051
if not rpm_path:
@@ -58,10 +59,12 @@ def update_vendor_tag_for_build(build, is_bootstrap=False):
5859

5960
# get vendor information
6061
output = subprocess.check_output(
61-
['rpm', '-qp', rpm_path, '--qf', '%{vendor};;%{buildhost}'], stderr=devprocess.DEVNULL
62+
['rpm', '-qp', rpm_path, '--qf', '%{vendor};;%{buildhost}'], stderr=DEVNULL
6263
).decode()
6364
vendor, buildhost = output.split(';;')
64-
package = re.search('/packages/([^/]+)/', rpm_path).group(1)
65+
match = re.search('/packages/([^/]+)/', rpm_path)
66+
assert match is not None
67+
package = match.group(1)
6568

6669
tag = None
6770
if buildhost in XS_buildhosts:
@@ -119,24 +122,19 @@ def main():
119122
# read last known event from our data directory
120123
last_sync_event_filepath = os.path.join(data_dir, 'last_sync_event')
121124

122-
need_update = True
123125
if os.path.exists(last_sync_event_filepath):
124126
with open(last_sync_event_filepath) as f:
125127
last_sync_event = json.loads(f.read())
126128

127129
if last_sync_event == last_event:
128-
need_update = False
130+
if not quiet:
131+
print("No update needed.")
132+
return
129133
else:
130134
timestamp = last_sync_event['ts']
131135
else:
132136
timestamp = 0 # first update ever
133137

134-
135-
if not need_update:
136-
if not quiet:
137-
print("No update needed.")
138-
return
139-
140138
# get the list of builds since last event
141139
output = subprocess.check_output(['koji', 'list-builds', '--quiet', '--state=COMPLETE',
142140
'--type=rpm', '--after=%s' % timestamp]).decode()

0 commit comments

Comments
 (0)