예제 #1
0
    def install(self, args):
        """ 
        Grab a Compass package and perform the manifest creation 
        """
        if os.path.exists('out'):
            shutil.rmtree('out')
        os.mkdir('out')

        if args.uncompressed:
            compass_path = args.name
        else:
            if not args.local:
                path, temp_path = utils.download_compass(
                    FRONTEND_API, args.name, args.version)
            else:
                path = args.name
                temp_path = None
            compass_path = utils.untar_compass(path, temp_path)

        files = os.listdir(compass_path)

        # check for config and interactive file
        for fi in files:
            if fi.startswith('config'):
                config_path = compass_path + '/' + fi
            elif fi.startswith('interactive'):
                interactive_path = compass_path + '/' + fi

        if not config_path:
            if self.LOG_LEVEL >= enums.LogLevel.ERROR.value:
                print('{}No configuration file found in {}'.format(
                    ERROR_PREFIX, compass_path))
            exit(1)
        if interactive_path:
            interact = Interactive(interactive_path)
            user_in = interact.do_prompt()
        else:
            user_in = None

        self.compose(compass_path, config_path, user_in, args.log_level)

        if temp_path:
            shutil.rmtree(temp_path)