docker: add "probe" command for configure
This is a helper function for the configure script. It replies yes, sudo or no to inform the user if non-interactive docker support is available. We trap the Exception to fail gracefully. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
		
							parent
							
								
									1d889f2a8b
								
							
						
					
					
						commit
						15df9d3783
					
				@ -390,6 +390,24 @@ class ImagesCommand(SubCommand):
 | 
				
			|||||||
    def run(self, args, argv):
 | 
					    def run(self, args, argv):
 | 
				
			||||||
        return Docker().command("images", argv, args.quiet)
 | 
					        return Docker().command("images", argv, args.quiet)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class ProbeCommand(SubCommand):
 | 
				
			||||||
 | 
					    """Probe if we can run docker automatically"""
 | 
				
			||||||
 | 
					    name = "probe"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def run(self, args, argv):
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            docker = Docker()
 | 
				
			||||||
 | 
					            if docker._command[0] == "docker":
 | 
				
			||||||
 | 
					                print "yes"
 | 
				
			||||||
 | 
					            elif docker._command[0] == "sudo":
 | 
				
			||||||
 | 
					                print "sudo"
 | 
				
			||||||
 | 
					        except Exception:
 | 
				
			||||||
 | 
					            print "no"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    parser = argparse.ArgumentParser(description="A Docker helper",
 | 
					    parser = argparse.ArgumentParser(description="A Docker helper",
 | 
				
			||||||
            usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
 | 
					            usage="%s <subcommand> ..." % os.path.basename(sys.argv[0]))
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user