1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-09-20 17:26:15 +02:00

fix triggerreason on empty packages.

When running osc triggerreason on newly created (empty) packages
the command failes with AttributeError: 'NoneType' object has no attribute 'text'
because root.find('explain') is NoneType.

Solution:

Check if root.find('explain') is None and print "No triggerreaseon found".
In this case also do not try to get the triggertime. It will result in the same error.
This commit is contained in:
lethliel 2019-05-14 10:50:24 +02:00
parent 53d3cc7bb5
commit 877d5e50b6

View File

@ -5646,9 +5646,13 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print(apiurl, project, package, repository, arch)
xml = show_package_trigger_reason(apiurl, project, package, repository, arch)
root = ET.fromstring(xml)
reason = root.find('explain').text
triggertime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(root.find('time').text)))
print("%s (at %s)" % (reason, triggertime))
if root.find('explain') is None:
reason = "No triggerreason found"
print(reason)
else:
reason = root.find('explain').text
triggertime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(int(root.find('time').text)))
print("%s (at %s)" % (reason, triggertime))
if reason == "meta change":
print("changed keys:")
for package in root.findall('packagechange'):