mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-26 14:46:14 +01: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:
parent
53d3cc7bb5
commit
877d5e50b6
@ -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'):
|
||||
|
Loading…
Reference in New Issue
Block a user