libkas: Improve further on error/success output
Don't add a newline to stderr dumps on failing commands, the logger does that already. And don't print success messages if the fetch command actually failed. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
		
				
					committed by
					
						
						Daniel Wagner
					
				
			
			
				
	
			
			
			
						parent
						
							1e405f155d
						
					
				
				
					commit
					f0a18868c9
				
			@@ -118,7 +118,7 @@ def run_cmd_async(cmd, cwd, env=None, fail=True, shell=False, liveupdate=True):
 | 
				
			|||||||
    ret = yield from process.wait()
 | 
					    ret = yield from process.wait()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if ret and fail:
 | 
					    if ret and fail:
 | 
				
			||||||
        msg = 'Command "{cwd}$ {cmd}" failed\n'.format(cwd=cwd, cmd=cmdstr)
 | 
					        msg = 'Command "{cwd}$ {cmd}" failed'.format(cwd=cwd, cmd=cmdstr)
 | 
				
			||||||
        for line in logo.stderr:
 | 
					        for line in logo.stderr:
 | 
				
			||||||
            msg += line
 | 
					            msg += line
 | 
				
			||||||
        logging.error(msg)
 | 
					        logging.error(msg)
 | 
				
			||||||
@@ -166,9 +166,10 @@ def _repo_fetch_async(config, repo):
 | 
				
			|||||||
        cmd = ['/usr/bin/git', 'clone', '-q', repo.url, repo.path]
 | 
					        cmd = ['/usr/bin/git', 'clone', '-q', repo.url, repo.path]
 | 
				
			||||||
        if config.get_repo_ref_dir() and os.path.exists(gitsrcdir):
 | 
					        if config.get_repo_ref_dir() and os.path.exists(gitsrcdir):
 | 
				
			||||||
            cmd.extend(['--reference', gitsrcdir])
 | 
					            cmd.extend(['--reference', gitsrcdir])
 | 
				
			||||||
        yield from run_cmd_async(cmd,
 | 
					        (retc, _) = yield from run_cmd_async(cmd,
 | 
				
			||||||
                                             env=config.environ,
 | 
					                                             env=config.environ,
 | 
				
			||||||
                                             cwd=config.kas_work_dir)
 | 
					                                             cwd=config.kas_work_dir)
 | 
				
			||||||
 | 
					        if retc == 0:
 | 
				
			||||||
            logging.info('Repository %s cloned', repo.name)
 | 
					            logging.info('Repository %s cloned', repo.name)
 | 
				
			||||||
        return
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -194,6 +195,7 @@ def _repo_fetch_async(config, repo):
 | 
				
			|||||||
    if retc:
 | 
					    if retc:
 | 
				
			||||||
        logging.warning('Could not update repository %s: %s',
 | 
					        logging.warning('Could not update repository %s: %s',
 | 
				
			||||||
                        repo.name, output)
 | 
					                        repo.name, output)
 | 
				
			||||||
 | 
					    else:
 | 
				
			||||||
        logging.info('Repository %s updated', repo.name)
 | 
					        logging.info('Repository %s updated', repo.name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user