def _sanitize_config_for_upload(self, config: OSConfig): raw_config = copy.deepcopy(config.ecosystem) raw_config.pop('from', None) lock = Lock() rewrite_ops = [] rewrite_ops.append( self.config.executor.submit(self._maybe_inject_config_version, lock, config, raw_config)) for app in raw_config.get('apps') or []: rewrite_ops.append( self.config.executor.submit(self._maybe_inject_app_version, lock, app)) rewrite_ops.append( self.config.executor.submit(self._maybe_inject_media_versions, lock, raw_config, 'bootanimation')) rewrite_ops.append( self.config.executor.submit(self._maybe_inject_media_versions, lock, raw_config, 'splash')) wait_for_futures(self.config.executor, rewrite_ops) config_file = os.path.join(self.working_dir, os.path.basename(config.binary)) with open(config_file, 'w') as f: f.write(yaml.safe_dump(raw_config)) rewritten_config = OSConfig.parse(self.config, config_file) rewritten_config.user_binary = config.user_binary return rewritten_config
def register(self, configs): register_ops = [] for config in configs: register_ops.append( self.config.executor.submit(self.register_artifact, config.binary, config)) wait_for_futures(self.config.executor, register_ops)
def register(self, apk_registration: RegisterApkCommand, apks: list, media_registrations: list, media_artifacts: list, stage, configs: list, register: RegisterConfigCommand): register_ops = apk_registration.start_register_ops(apks) for num, media in enumerate(media_registrations): register_ops.append( self.config.executor.submit(media.register, media_artifacts[num])) wait_for_futures(self.config.executor, register_ops) stage.register(configs, register)
def prepare(self): # Needs to be a local import to prevent recursion from cli.internal.commands.stage import StageCommand masonrc = self._validated_masonrc() context = self._parse_context(masonrc) raw_config_files = self._validated_files( context.get('configs') or 'mason.yml', 'yml') apk_files = self._validated_files(context.get('apps'), 'apk') raw_boot_animations = self._validated_media( context.get('bootanimations')) raw_splash_screens = self._validated_media(context.get('splashes')) apk_registration = RegisterApkCommand(self.config, apk_files) media_registrations = [] for anim in raw_boot_animations: media_registrations.append( RegisterMediaCommand(self.config, anim.get('name'), 'bootanimation', 'latest', anim.get('file'))) for splash in raw_splash_screens: media_registrations.append( RegisterMediaCommand(self.config, splash.get('name'), 'splash', 'latest', splash.get('file'))) apk_preps = apk_registration.start_prepare_ops() media_preps = [] for reg in media_registrations: media_preps.append(self.config.executor.submit(reg.prepare)) apks = wait_for_futures(self.config.executor, apk_preps) media_artifacts = [] for (_, media) in wait_for_futures(self.config.executor, media_preps): media_artifacts.append(media) config_files = [] for raw_config_file in raw_config_files: config_files.append( self._rewritten_config(raw_config_file, apks, media_artifacts)) stage = StageCommand(self.config, config_files, True, None, self.working_dir) stage_prep = stage.prepare() configs = stage_prep[0] register = stage_prep[2] return [*apks, *media_artifacts, *configs], \ apk_registration, apks, \ media_registrations, media_artifacts, \ stage, configs, register
def register(self, configs: list, register: RegisterConfigCommand): register.register(configs) build_ops = [] for config in configs: build_command = BuildCommand( self.config, config.get_name(), config.get_version(), self.block, self.mason_version) build_ops.append(self.config.executor.submit(self._build, build_command)) wait_for_futures(self.config.executor, build_ops)
def deploy_artifact(self): self._log_details(self.groups) if not self.config.execute_ops: return if not self.config.skip_verify: click.confirm('Continue deployment?', default=True, abort=True) deploy_ops = [] for group in self.groups: deploy_ops.append( self.config.executor.submit(self.config.api.deploy_artifact, self.type, self.name, self.version, group, self.config.push, self.config.no_https)) wait_for_futures(self.config.executor, deploy_ops) self.config.logger.info("{} '{}' deployed.".format( self.type.capitalize(), self.name))
def register(self, apks): register_ops = self.start_register_ops(apks) wait_for_futures(self.config.executor, register_ops)
def prepare(self): prepare_ops = self.start_prepare_ops() apks = wait_for_futures(self.config.executor, prepare_ops) return apks, apks