def list(self, all_apps=False, verbose=False): """ Lists all environments in the current application or all environments in all applications. :param all_apps: Lists all environments from all applications. :param verbose: Provides more detailed information about all environments, including instances. :return: List of Elastic Beanstalk applications """ def verbose_env(environment): return environment.split(' : ')[0].replace('* ', '') def verbose_ec2(environment): return environment.split(' : ')[-1].replace("['", '').replace("']", '') self.initialize() cmd = 'eb list' cmd += ' --all' if all_apps else '' if verbose: output = SystemCommand(cmd + ' --verbose').output response = { 'region': output.pop(0).replace('Region: ', ''), 'application': output.pop(0).replace('Application: ', '') } output.pop(0).replace('Environments: ', '') response['environments'] = { verbose_env(i): verbose_ec2(i) for i in output } return response else: return set( [i.replace('* ', '') for i in SystemCommand(cmd).output])
def images(self): """Return a list of Docker images on the current machine.""" output = SystemCommand(self.cmd.images).output output.pop(0) return [ row.split(' ', 1)[0] + ':' + row.split(' ', 1)[1].strip().split(' ', 1)[0] for row in output ]