def approve_rereview(theme): """Replace original theme with pending theme on filesystem.""" # If reuploaded theme, replace old theme design. storage = LocalFileStorage() rereview = theme.rereviewqueuetheme_set.all() reupload = rereview[0] if reupload.header_path != reupload.theme.header_path: move_stored_file(reupload.header_path, reupload.theme.header_path, storage=storage) if reupload.footer_path != reupload.theme.footer_path: move_stored_file(reupload.footer_path, reupload.theme.footer_path, storage=storage) create_persona_preview_images( src=reupload.theme.header_path, full_dst=[ reupload.theme.header_path.replace('header', 'preview'), reupload.theme.header_path.replace('header', 'icon') ], set_modified_on=[reupload.theme.addon]) rereview.delete() theme.addon.increment_version()
def approve_rereview(theme): """Replace original theme with pending theme on filesystem.""" # If reuploaded theme, replace old theme design. storage = LocalFileStorage() rereview = theme.rereviewqueuetheme_set.all() reupload = rereview[0] if reupload.header_path != reupload.theme.header_path: create_persona_preview_images( src=reupload.header_path, full_dst=[reupload.theme.thumb_path, reupload.theme.icon_path], set_modified_on=[reupload.theme.addon]) if not reupload.theme.is_new(): # Legacy themes also need a preview_large.jpg. # Modern themes use preview.png for both thumb and preview so there # is no problem there. copy_stored_file(reupload.theme.thumb_path, reupload.theme.preview_path, storage=storage) move_stored_file(reupload.header_path, reupload.theme.header_path, storage=storage) if reupload.footer_path != reupload.theme.footer_path: move_stored_file(reupload.footer_path, reupload.theme.footer_path, storage=storage) rereview.delete() theme.addon.increment_version()
def calc_checksum(theme_id, **kw): """For migration 596.""" lfs = LocalFileStorage() theme = Persona.objects.get(id=theme_id) header = theme.header_path footer = theme.footer_path # Delete invalid themes that are not images (e.g. PDF, EXE). try: Image.open(header) Image.open(footer) except IOError: log.info('Deleting invalid theme [%s] (header: %s) (footer: %s)' % (theme.addon.id, header, footer)) theme.addon.delete() theme.delete() rm_stored_dir(header.replace('header.png', ''), storage=lfs) return # Calculate checksum and save. try: theme.checksum = make_checksum(header, footer) theme.save() except IOError as e: log.error(str(e))
def reject_rereview(theme): """Delete pending theme from filesystem.""" storage = LocalFileStorage() rereview = theme.rereviewqueuetheme_set.all() reupload = rereview[0] storage.delete(reupload.header_path) storage.delete(reupload.footer_path) rereview.delete()
def reject_rereview(theme): """Replace original theme with pending theme on filesystem.""" storage = LocalFileStorage() rereview = theme.rereviewqueuetheme_set.all() reupload = rereview[0] storage.delete(reupload.header_path) storage.delete(reupload.footer_path) rereview.delete()
def make_checksum(header_path, footer_path): ls = LocalFileStorage() footer = footer_path and ls._open(footer_path).read() or '' raw_checksum = ls._open(header_path).read() + footer return hashlib.sha224(raw_checksum).hexdigest()
def setUp(self): self.tmp = tempfile.mkdtemp() self.stor = LocalFileStorage()
def setUp(self): super(TestLocalFileStorage, self).setUp() self.tmp = tempfile.mkdtemp() self.stor = LocalFileStorage()