def subcmd_list_platforms(self, args): """ list platform command """ flasher = Flash() print(json.dumps(flasher.get_supported_targets())) return EXIT_CODE_SUCCESS
def subcmd_flash_handler(self, args): """ flash command handler """ if not args.tid: msg = "Target_id is missing" raise FlashError(message=msg, return_code=EXIT_CODE_TARGET_ID_MISSING) check_file(self.logger, args.target_filename or args.input) check_file(self.logger, args.input) check_file_exists(self.logger, args.input) check_file_extension(self.logger, args.target_filename or args.input) flasher = Flash() available = Common(self.logger).get_available_device_mapping( flasher.get_all_flashers(), args.tid) available_target_ids = [] retcode = EXIT_CODE_SUCCESS if args.platform_name: if args.platform_name not in flasher.get_supported_targets(): self.logger.error("Not supported platform: %s", args.platform_name) self.logger.error("Supported platforms: %s", flasher.get_supported_targets()) raise FlashError(message="Platform {} not supported".format( args.platform_name), return_code=EXIT_CODE_NOT_SUPPORTED_PLATFORM) if 'all' in args.tid: retcode = flasher.flash(build=args.input, target_id='all', platform_name=args.platform_name, target_filename=args.target_filename, method=args.method, no_reset=args.no_reset) if len(available) <= 0: msg = "Could not find any connected device" raise FlashError(message=msg, return_code=EXIT_CODE_DEVICES_MISSING) available_platforms, target_ids_to_flash = \ self.prepare_platforms_and_targets(available, args.tid, available_target_ids) if not target_ids_to_flash: self.logger.error( "Could not find given target_id from attached devices") self.logger.error("Available target_ids: %s", available_target_ids) raise FlashError(message="Could not map device", return_code=EXIT_CODE_COULD_NOT_MAP_DEVICE) elif len(available_platforms) > 1: if not args.platform_name: self.logger.error( "More than one platform detected for given target_id") self.logger.error( "Please specify the platform with -t <PLATFORM_NAME>") self.logger.error("Found platforms: %s", available_platforms) raise FlashError( message= "More than one platform detected for given target id", return_code=EXIT_CODE_PLATFORM_REQUIRED) else: retcode = flasher.flash(build=args.input, target_id=target_ids_to_flash, target_filename=args.target_filename, platform_name=available_platforms[0], method=args.method, no_reset=args.no_reset) return retcode
def subcmd_flash_handler(self, args): """ flash command handler """ flasher = Flash() available = flasher.get_available_device_mapping() available_target_ids = [] retcode = 0 #print(args) if args.input: if not isfile(args.input): print("Could not find given file: %s" % args.input) return EXIT_CODE_FILE_MISSING else: print("File is missing") return EXIT_CODE_FILE_MISSING if args.platform_name: if args.platform_name not in flasher.get_supported_targets(): print("Not supported platform: %s" % args.platform_name) print("Supported platforms: %s" % flasher.get_supported_targets()) return EXIT_CODE_NOT_SUPPORTED_PLATFORM if not args.tid: print("Target_id is missing") return EXIT_CODE_NO_TARGET_ID if 'all' in args.tid: retcode = flasher.flash(build=args.input, target_id='all', platform_name=args.platform_name, method=args.method, no_reset=args.no_reset) if len(available) <= 0: print("Could not find any connected device") return EXIT_CODE_DEVICES_MISSING available_platforms, target_ids_to_flash = \ self.prepare_platforms_and_targets(available, args.tid, available_target_ids) if not target_ids_to_flash: print("Could not find given target_id from attached devices") print("Available target_ids:") print(available_target_ids) return EXIT_CODE_COULD_NOT_MAP_DEVICE elif len(available_platforms) > 1: if not args.platform_name: print("More than one platform detected for given target_id") print("Please specify the platform with -t <PLATFORM_NAME>") print("Found platforms:") print(available_platforms) return EXIT_CODE_PLATFORM_REQUIRED else: #print(target_ids_to_flash) retcode = flasher.flash(build=args.input, target_id=target_ids_to_flash, platform_name=available_platforms[0], method=args.method, no_reset=args.no_reset) return retcode