mirror of
				https://github.com/openSUSE/osc.git
				synced 2025-11-03 21:08:53 +01:00 
			
		
		
		
	- add "osc results --watch" command to wait for build results in efficient way
This commit is contained in:
		
							
								
								
									
										1
									
								
								NEWS
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								NEWS
									
									
									
									
									
								
							@@ -1,6 +1,7 @@
 | 
				
			|||||||
0.134
 | 
					0.134
 | 
				
			||||||
  - patchinfo call can work without checked out copy now
 | 
					  - patchinfo call can work without checked out copy now
 | 
				
			||||||
  - use qemu as fallback for building not directly supported architectures
 | 
					  - use qemu as fallback for building not directly supported architectures
 | 
				
			||||||
 | 
					  - "results --watch" option to watch build results until they finished building
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Features which requires OBS 2.3
 | 
					# Features which requires OBS 2.3
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4191,6 +4191,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
 | 
				
			|||||||
                        help='Show results only for specified architecture(s)')
 | 
					                        help='Show results only for specified architecture(s)')
 | 
				
			||||||
    @cmdln.option('-v', '--verbose', action='store_true', default=False,
 | 
					    @cmdln.option('-v', '--verbose', action='store_true', default=False,
 | 
				
			||||||
                        help='more verbose output')
 | 
					                        help='more verbose output')
 | 
				
			||||||
 | 
					    @cmdln.option('-w', '--watch', action='store_true', default=False,
 | 
				
			||||||
 | 
					                        help='permanently watch the result')
 | 
				
			||||||
    @cmdln.option('', '--xml', action='store_true', default=False,
 | 
					    @cmdln.option('', '--xml', action='store_true', default=False,
 | 
				
			||||||
                        help='generate output in XML (former results_meta)')
 | 
					                        help='generate output in XML (former results_meta)')
 | 
				
			||||||
    @cmdln.option('', '--csv', action='store_true', default=False,
 | 
					    @cmdln.option('', '--csv', action='store_true', default=False,
 | 
				
			||||||
@@ -4245,7 +4247,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
 | 
				
			|||||||
            print '\n'.join(format_results(get_package_results(*args), opts.format))
 | 
					            print '\n'.join(format_results(get_package_results(*args), opts.format))
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            args.append(opts.verbose)
 | 
					            args.append(opts.verbose)
 | 
				
			||||||
            print '\n'.join(get_results(*args))
 | 
					            args.append(opts.watch)
 | 
				
			||||||
 | 
					            args.append("\n")
 | 
				
			||||||
 | 
					            get_results(*args)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # WARNING: this function is also called by do_results. You need to set a default there
 | 
					    # WARNING: this function is also called by do_results. You need to set a default there
 | 
				
			||||||
    #          as well when adding a new option!
 | 
					    #          as well when adding a new option!
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										30
									
								
								osc/core.py
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								osc/core.py
									
									
									
									
									
								
							@@ -4634,10 +4634,12 @@ def get_binarylist_published(apiurl, prj, repo, arch):
 | 
				
			|||||||
    return r
 | 
					    return r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[]):
 | 
					def show_results_meta(apiurl, prj, package=None, lastbuild=None, repository=[], arch=[], oldstate=None):
 | 
				
			||||||
    query = {}
 | 
					    query = {}
 | 
				
			||||||
    if package:
 | 
					    if package:
 | 
				
			||||||
        query['package'] = package
 | 
					        query['package'] = package
 | 
				
			||||||
 | 
					    if oldstate:
 | 
				
			||||||
 | 
					        query['oldstate'] = oldstate
 | 
				
			||||||
    if lastbuild:
 | 
					    if lastbuild:
 | 
				
			||||||
        query['lastbuild'] = 1
 | 
					        query['lastbuild'] = 1
 | 
				
			||||||
    u = makeurl(apiurl, ['build', prj, '_result'], query=query)
 | 
					    u = makeurl(apiurl, ['build', prj, '_result'], query=query)
 | 
				
			||||||
@@ -4655,13 +4657,15 @@ def show_prj_results_meta(apiurl, prj):
 | 
				
			|||||||
    return f.readlines()
 | 
					    return f.readlines()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
 | 
					def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], oldstate=None):
 | 
				
			||||||
    """ return a package results as a list of dicts """
 | 
					    """ return a package results as a list of dicts """
 | 
				
			||||||
    r = []
 | 
					    r = []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch)
 | 
					    f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch, oldstate)
 | 
				
			||||||
    root = ET.fromstring(''.join(f))
 | 
					    root = ET.fromstring(''.join(f))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    r.append( {'_oldstate': root.get('state')} )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for node in root.findall('result'):
 | 
					    for node in root.findall('result'):
 | 
				
			||||||
        rmap = {}
 | 
					        rmap = {}
 | 
				
			||||||
        rmap['project'] = rmap['prj'] = prj
 | 
					        rmap['project'] = rmap['prj'] = prj
 | 
				
			||||||
@@ -4692,11 +4696,18 @@ def format_results(results, format):
 | 
				
			|||||||
    """apply selected format on each dict in results and return it as a list of strings"""
 | 
					    """apply selected format on each dict in results and return it as a list of strings"""
 | 
				
			||||||
    return [format % r for r in results]
 | 
					    return [format % r for r in results]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False):
 | 
					def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], verbose=False, wait=False, printJoin=None):
 | 
				
			||||||
    r = []
 | 
					    r = []
 | 
				
			||||||
    result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
 | 
					    result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
 | 
				
			||||||
 | 
					    oldstate = None
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for res in get_package_results(apiurl, prj, package, lastbuild, repository, arch):
 | 
					    while True:
 | 
				
			||||||
 | 
					       waiting = False
 | 
				
			||||||
 | 
					       r = []
 | 
				
			||||||
 | 
					       for res in get_package_results(apiurl, prj, package, lastbuild, repository, arch, oldstate):
 | 
				
			||||||
 | 
					           if res.has_key('_oldstate'):
 | 
				
			||||||
 | 
					               oldstate = res['_oldstate']
 | 
				
			||||||
 | 
					               continue
 | 
				
			||||||
           res['status'] = res['code']
 | 
					           res['status'] = res['code']
 | 
				
			||||||
           if verbose and res['details'] != '':
 | 
					           if verbose and res['details'] != '':
 | 
				
			||||||
               if res['status'] in ('unresolvable', 'expansion error'):
 | 
					               if res['status'] in ('unresolvable', 'expansion error'):
 | 
				
			||||||
@@ -4706,13 +4717,22 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[], ve
 | 
				
			|||||||
               else:
 | 
					               else:
 | 
				
			||||||
                   res['status'] += ': %s' % (res['details'], )
 | 
					                   res['status'] += ': %s' % (res['details'], )
 | 
				
			||||||
           if res['dirty']:
 | 
					           if res['dirty']:
 | 
				
			||||||
 | 
					               waiting=True
 | 
				
			||||||
               if verbose:
 | 
					               if verbose:
 | 
				
			||||||
                   res['status'] = 'outdated (was: %s)' % res['status']
 | 
					                   res['status'] = 'outdated (was: %s)' % res['status']
 | 
				
			||||||
               else:
 | 
					               else:
 | 
				
			||||||
                   res['status'] += '*'
 | 
					                   res['status'] += '*'
 | 
				
			||||||
 | 
					           if res['status'] in ('scheduled', 'finished', 'building', 'signing', 'dispatching'):
 | 
				
			||||||
 | 
					               waiting=True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
           r.append(result_line_templ % res)
 | 
					           r.append(result_line_templ % res)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       if printJoin:
 | 
				
			||||||
 | 
					           print printJoin.join(r)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					       if wait==False or waiting==False:
 | 
				
			||||||
 | 
					           break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return r
 | 
					    return r
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None, show_excluded=None):
 | 
					def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None, show_excluded=None):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user