def repack_themes_for_69(addon_ids, **kw): log.info( '[%s@%s] Repacking themes to use 69+ properties starting at id: %s...' % (len(addon_ids), recreate_theme_previews.rate_limit, addon_ids[0])) addons = Addon.objects.filter(pk__in=addon_ids).no_transforms() olympia.core.set_user(UserProfile.objects.get(pk=settings.TASK_USER_ID)) for addon in addons: version = addon.current_version log.info('[CHECK] theme [%r] for deprecated properties' % addon) if not version: log.info('[INVALID] theme [%r] has no current_version' % addon) continue pause_all_tasks() try: timer = StopWatch('addons.tasks.repack_themes_for_69') timer.start() old_xpi = get_filepath(version.all_files[0]) old_data = parse_addon(old_xpi, minimal=True) new_data = new_69_theme_properties_from_old(old_data) if new_data != old_data: # if the manifest isn't the same let's repack new_version = new_theme_version_with_69_properties(version) log.info('[SUCCESS] Theme [%r], version [%r] updated to [%r]' % (addon, version, new_version)) else: log.info('[SKIP] No need for theme repack [%s]' % addon.id) timer.log_interval('') except (IOError, ValidationError, JSONDecodeError, SigningError) as ex: log.debug('[FAIL] Theme repack for [%r]:', addon, exc_info=ex) finally: resume_all_tasks()
def migrate_lwts_to_static_themes(ids, **kw): """With the specified ids, create new static themes based on an existing lightweight themes (personas), and delete the lightweight themes after.""" mlog = olympia.core.logger.getLogger('z.task.lwtmigrate') mlog.info( '[Info] Migrating LWT to static theme %d-%d [%d].', ids[0], ids[-1], len(ids)) # Incoming ids should already by type=persona only lwts = Addon.objects.filter(id__in=ids) pause_all_tasks() for lwt in lwts: static = None try: with translation.override(lwt.default_locale): static = add_static_theme_from_lwt(lwt) mlog.info( '[Success] Static theme %r created from LWT %r', static, lwt) except Exception as e: # If something went wrong, don't migrate - we need to debug. mlog.debug('[Fail] LWT %r:', lwt, exc_info=e) if not static: continue MigratedLWT.objects.create( lightweight_theme=lwt, getpersonas_id=lwt.persona.persona_id, static_theme=static) # Steal the lwt's slug after it's deleted. slug = lwt.slug lwt.delete() static.update(slug=slug) resume_all_tasks()
def migrate_lwts_to_static_themes(ids, **kw): """With the specified ids, create new static themes based on an existing lightweight themes (personas), and delete the lightweight themes after.""" mlog = olympia.core.logger.getLogger('z.task.lwtmigrate') mlog.info('[Info] Migrating LWT to static theme %d-%d [%d].', ids[0], ids[-1], len(ids)) # Incoming ids should already by type=persona only lwts = Addon.objects.filter(id__in=ids) pause_all_tasks() for lwt in lwts: static = None try: with translation.override(lwt.default_locale): static = add_static_theme_from_lwt(lwt) mlog.info('[Success] Static theme %r created from LWT %r', static, lwt) except Exception as e: # If something went wrong, don't migrate - we need to debug. mlog.debug('[Fail] LWT %r:', lwt, exc_info=e) if not static: continue MigratedLWT.objects.create(lightweight_theme=lwt, getpersonas_id=lwt.persona.persona_id, static_theme=static) # Steal the lwt's slug after it's deleted. slug = lwt.slug lwt.delete() static.update(slug=slug) resume_all_tasks()