parent
d2247940b6
commit
4e6aca0bd0
3 changed files with 26 additions and 37 deletions
|
|
@ -7086,12 +7086,13 @@ def anon_handle_wait_repo(options, session, args):
|
||||||
warn("nvr %s is not current in tag %s\n latest build in %s is %s" %
|
warn("nvr %s is not current in tag %s\n latest build in %s is %s" %
|
||||||
(expected_nvr, tag, tag, present_nvr))
|
(expected_nvr, tag, tag, present_nvr))
|
||||||
|
|
||||||
try:
|
success, msg = watch_builds(session, tag_id, builds,
|
||||||
watch_builds(
|
poll_interval=options.poll_interval, timeout=suboptions.timeout)
|
||||||
session, tag_id, builds, quiet=suboptions.quiet,
|
if success:
|
||||||
poll_interval=options.poll_interval, timeout=suboptions.timeout)
|
if not suboptions.quiet:
|
||||||
except koji.GenericError as e:
|
print(msg)
|
||||||
error(str(e))
|
else:
|
||||||
|
error('' if suboptions.quiet else msg)
|
||||||
|
|
||||||
|
|
||||||
def handle_regen_repo(options, session, args):
|
def handle_regen_repo(options, session, args):
|
||||||
|
|
|
||||||
|
|
@ -831,25 +831,23 @@ def _list_tasks(options, session):
|
||||||
return tasklist
|
return tasklist
|
||||||
|
|
||||||
|
|
||||||
def watch_builds(session, tag_id, builds, quiet=False, poll_interval=5, timeout=120):
|
def watch_builds(session, tag_id, builds, poll_interval=5, timeout=120):
|
||||||
"""Watch for given builds to appear in given tag. If no build are given,
|
"""Watch for given builds to appear in given tag. If no builds are given,
|
||||||
watch for new repo for given tag.
|
watch for new repo for given tag.
|
||||||
|
|
||||||
:param session: Koji session object
|
:param session: Koji session object
|
||||||
:param tag_id: Tag id
|
:param int tag_id: Tag id
|
||||||
:param builds: List of builds as NVR dicts
|
:param [dict] builds: List of builds as NVR dicts
|
||||||
:param quiet: no/verbose
|
:param int poll_interval: Poll interval in seconds
|
||||||
:param poll_interval: Poll interval in seconds
|
:param int timeout: Watch timeout in minutes
|
||||||
:param timeout: Watch timeout in minutes"""
|
:returns bool, msg: False if timeouted
|
||||||
|
"""
|
||||||
last_repo = None
|
last_repo = None
|
||||||
repo = session.getRepo(tag_id)
|
repo = session.getRepo(tag_id)
|
||||||
|
|
||||||
# String representations for logs and exceptions
|
# String representations for logs and exceptions
|
||||||
builds_str = koji.util.printList(
|
builds_str = koji.util.printList([koji.buildLabel(build) for build in builds])
|
||||||
[koji.buildLabel(build) for build in builds])
|
tag_info = session.getTag(tag_id, strict=True)
|
||||||
tag_info = session.getTag(tag_id)
|
|
||||||
if not tag_info:
|
|
||||||
raise koji.GenericError("No tag with id: %s" % tag_id)
|
|
||||||
tag_name = tag_info['name']
|
tag_name = tag_info['name']
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
@ -857,24 +855,16 @@ def watch_builds(session, tag_id, builds, quiet=False, poll_interval=5, timeout=
|
||||||
if builds and repo and repo != last_repo:
|
if builds and repo and repo != last_repo:
|
||||||
if koji.util.checkForBuilds(session, tag_id, builds,
|
if koji.util.checkForBuilds(session, tag_id, builds,
|
||||||
repo['create_event'], latest=True):
|
repo['create_event'], latest=True):
|
||||||
if not quiet:
|
return (True, "Successfully waited %s for %s to appear in the %s repo" %
|
||||||
print("Successfully waited %s for %s "
|
(koji.util.duration(start), builds_str, tag_name))
|
||||||
"to appear in the %s repo" %
|
|
||||||
(koji.util.duration(start), builds_str, tag_name))
|
|
||||||
return
|
|
||||||
|
|
||||||
if (time.time() - start >= timeout * 60.0):
|
if (time.time() - start >= timeout * 60.0):
|
||||||
if not quiet:
|
if builds:
|
||||||
if builds:
|
return (False, "Unsuccessfully waited %s for %s to appear in the %s repo" %
|
||||||
raise koji.GenericError(
|
|
||||||
"Unsuccessfully waited %s for %s "
|
|
||||||
"to appear in the %s repo" %
|
|
||||||
(koji.util.duration(start), builds_str, tag_name))
|
(koji.util.duration(start), builds_str, tag_name))
|
||||||
else:
|
else:
|
||||||
raise koji.GenericError(
|
return (False, "Unsuccessfully waited %s for a new %s repo" %
|
||||||
"Unsuccessfully waited %s for a new %s repo" %
|
|
||||||
(koji.util.duration(start), tag_name))
|
(koji.util.duration(start), tag_name))
|
||||||
raise koji.GenericError()
|
|
||||||
|
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
last_repo = repo
|
last_repo = repo
|
||||||
|
|
@ -882,10 +872,8 @@ def watch_builds(session, tag_id, builds, quiet=False, poll_interval=5, timeout=
|
||||||
|
|
||||||
if not builds:
|
if not builds:
|
||||||
if repo != last_repo:
|
if repo != last_repo:
|
||||||
if not quiet:
|
return (True, "Successfully waited %s for a new %s repo" %
|
||||||
print("Successfully waited %s for a new %s repo" %
|
(koji.util.duration(start), tag_name))
|
||||||
(koji.util.duration(start), tag_name))
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def format_inheritance_flags(parent):
|
def format_inheritance_flags(parent):
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class TestWaitRepo(utils.CliTestCase):
|
||||||
|
|
||||||
self.options = mock.MagicMock()
|
self.options = mock.MagicMock()
|
||||||
self.options.quiet = True
|
self.options.quiet = True
|
||||||
self.options.poll_interval = 1 # second
|
self.options.poll_interval = 0.0001 # keep it fast
|
||||||
self.options.weburl = 'https://localhost.local'
|
self.options.weburl = 'https://localhost.local'
|
||||||
|
|
||||||
self.session = mock.MagicMock()
|
self.session = mock.MagicMock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue