def run(argv): opts = util.parse_docopt(__doc__, argv, True) image = opts["<image>"] biobox_type = opts["<biobox_type>"] tty = not "--no-tty" in opts["<args>"] remove = not "--no-rm" in opts["<args>"] docker.exit_if_no_image_available(image) params = get_login_parameters(biobox_type) if params is None: error.err_exit("unknown_command", { "command_type": "biobox type", "command": biobox_type }) volumes = list( map(lambda d: create_login_volume(d['directory'], d['files']), params)) ctnr = docker.create_tty(image, tty, volumes) docker.login(ctnr) rm_login_dir() if remove: docker.remove(ctnr)
def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", { "command_type": "biobox type", "command": biobox }) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list) ]) longest_name = fn.thread( [statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join) ]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join) ]) error.err_exit('failed_verification', { 'image': image, 'error': msg, 'biobox': biobox })
def select_module(module, name): """ Select and return a biobox module """ mod_name = ".".join(["biobox_cli", module, name]) try: __import__(mod_name) except ImportError: error.err_exit('unknown_command', {'command_type': str.replace(module, '_', ' '), 'command': name}) return sys.modules[mod_name]
def run(argv): opts = util.parse_docopt(__doc__, argv, False) biobox = opts['<biobox_type>'] image = opts['<image>'] task = opts['--task'] verbose = opts['--verbose'] log = opts['--log'] if not behave.features_available(biobox): error.err_exit("unknown_command", {"command_type" : "biobox type", "command" : biobox}) ctn.exit_if_no_image_available(image) if verbose: results = behave.run(biobox, image, task, False) else: results = behave.run(biobox, image, task) if verbose: if log: sys.stdout = open(log, "w+") statuses = fn.thread([ behave.get_scenarios_and_statuses(results), F(map, lambda x: name_and_status(*x)), F(list)]) longest_name = fn.thread([ statuses, F(map, fn.first), F(map, len), max]) def justify(x, y): return x.ljust(longest_name), y output = fn.thread([ statuses, F(map, lambda x: justify(*x)), F(map, F(" ".join)), fn.unique, F("\n".join)]) print(output) if behave.is_failed(results): exit(1) elif behave.is_failed(results): if log: sys.stderr = open(log, "w+") msg = fn.thread([ behave.get_failing_scenarios(results), F(map, behave.scenario_name), F("\n".join)]) error.err_exit('failed_verification', {'image': image, 'error': msg, 'biobox' : biobox})
def select_module(module, name): """ Select and return a biobox module """ mod_name = ".".join(["biobox_cli", module, name]) try: __import__(mod_name) except ImportError: error.err_exit('unknown_command', { 'command_type': str.replace(module, '_', ' '), 'command': name }) return sys.modules[mod_name]
def run(argv): opts = util.parse_docopt(__doc__, argv, True) image = opts["<image>"] biobox_type = opts["<biobox_type>"] tty = not "--no-tty" in opts["<args>"] remove = not "--no-rm" in opts["<args>"] docker.exit_if_no_image_available(image) params = get_login_parameters(biobox_type) if params is None: error.err_exit("unknown_command", {"command_type": "biobox type", "command": biobox_type}) volumes = list(map(lambda d: create_login_volume(d["directory"], d["files"]), params)) ctnr = docker.create_tty(image, tty, volumes) docker.login(ctnr) rm_login_dir() if remove: docker.remove(ctnr)
def exit_if_no_image_available(image): if not is_image_available(image): error.err_exit('unknown_image', {'image': image})
def exit_if_no_image_available(image): from biobox.exception import NoImageFound try: avail.get_image(image) except NoImageFound: error.err_exit('unknown_image', {'image': image})