def nodes(subject, argv): if len(argv) == 0: fail("Missing node action") action = argv.pop(0) if action == 'add': if len(argv) == 0: fail("Missing browser, use phantomjs|firefox|chrome") browser = argv.pop(0) if not HubController.is_valid_browser(browser): fail("Invalid browser please use phantomjs|firefox|chrome") info("Adding node...") status = HubController.add(browser) if not status: fail("Failed to start node") ok("Node Added Successfully!") elif action == 'stop': info("Stopping nodes...") HubController.stop_nodes() ok("Nodes stopped") elif action == 'restart': info("Restarting nodes...") browser = None if len(argv) == 1 and not HubController.is_valid_browser(argv.pop(0)): fail( 'Restarting by browser requires either phantomjs, chrome or firefox' ) HubController.restart_nodes(browser) ok("Nodes restarted") elif action == 'rebuild': # TODO: print "Rebuild Nodes optional by browser" else: fail("Unknown node action: " + action)
def nodes(subject, argv): if len(argv) == 0: fail("Missing node action") action = argv.pop(0) if action == "add": if len(argv) == 0: fail("Missing browser, use phantomjs|firefox|chrome") browser = argv.pop(0) if not HubController.is_valid_browser(browser): fail("Invalid browser please use phantomjs|firefox|chrome") info("Adding node...") status = HubController.add(browser) if not status: fail("Failed to start node") ok("Node Added Successfully!") elif action == "stop": info("Stopping nodes...") HubController.stop_nodes() ok("Nodes stopped") elif action == "restart": info("Restarting nodes...") browser = None if len(argv) == 1 and not HubController.is_valid_browser(argv.pop(0)): fail("Restarting by browser requires either phantomjs, chrome or firefox") HubController.restart_nodes(browser) ok("Nodes restarted") elif action == "rebuild": # TODO: print "Rebuild Nodes optional by browser" else: fail("Unknown node action: " + action)