def run(self): # Check which shell. shell = "/bin/sh" if self.options["--sh"] else "/bin/bash" # Get the docker client. docker_client = docker.from_env() # Determine the app. app = self.options["<app>"] if App.check_running(docker_client, app): # Execute a shell. subprocess.call(["docker-compose", "exec", app, shell])
def run(self): # Get a docker client. docker_client = docker.from_env() # Check all the build parameters. apps = App.get_apps() for app in apps: # Check images. if not App.check_docker_images(docker_client, app): logger.error("({}) Container image does not exist, build and" " try again...".format(app)) return # Ensure it is running. if not App.check_running(docker_client, app): logger.error( "({}) Container is not running, ensure all containers" " are started...".format(app)) return # Capture and redirect output. Stack.run(["nosetests", "-s", "-v"])
def update_apps(package): # Find all services listing this package for app, config in Stack.get_config("apps").items(): try: # Check packages if config.get("packages") and package in config.get("packages"): # Get the docker client. docker_client = docker.from_env() # Determine the app. if App.check_running(docker_client, app): logger.info( "App '{}' depends on '{}', reinstalling...".format( app, package ) ) # Build the uninstall command uninstall = [ "docker-compose", "exec", app, "pip", "uninstall", "-y", package, ] # Execute a shell. code = Stack.run(uninstall) if code == 0: logger.info(" ... uninstalled ...") # Build the install command install = [ "docker-compose", "exec", app, "pip", "install", package, ] # Execute a shell. code = Stack.run(install) if code == 0: logger.info(" ... reinstall succeeded!") else: logger.error( " .... failed with exit code: {}".format(code) ) else: logger.error( " .... failed with exit code: {}".format(code) ) else: logger.error( " .... App {} is not running, cannot update".format(app) ) except Exception as e: logger.exception( "Error reinstalling package for {}: {}".format(app, e), exc_info=True, )