def _create_citem(self, size, force=False): this_method_version = '0.1.0' if self._citem_info is None: try: with open(self.prop_citem_path(), 'r') as fh: self._citem_info = json.loads(fh.read()) except: self._citem_info = dict() VERSION = '__module_version_citem_creation_%d__' % size WATERMARK = '__watermark_uid_citem_creation_%d__' % size watermark_path = os.path.join(os.path.join(os.path.dirname(__file__), '..'), 'theme', 'static', 'common', 'img', 'thumbnail_movie.png') if force or not os.path.exists(self._cimage_item_path(size)) or self._citem_info.get(VERSION) != __version__ + this_method_version or self._citem_info.get(WATERMARK) != fstools.uid(watermark_path): logger.info('creating citem (%d) for %s', size, self.name()) try: p = video_picture_edit(self.raw_path(), logger=logger) p.resize(size) movie_icon = picture_edit(watermark_path) p.join(movie_icon, p.JOIN_TOP_RIGHT, 0.75) except IOError: logger.error('error creating citem (%d) for %s', size, self.name()) else: try: p.save(self._cimage_item_path(size)) except IOError: logger.error('error creating citem (%d) for %s', size, self.name()) else: self._citem_info[VERSION] = __version__ + this_method_version self._citem_info[WATERMARK] = fstools.uid(watermark_path) try: with open(self.prop_citem_path(), 'w') as fh: fh.write(json.dumps(self._citem_info, sort_keys=True, indent=4)) except IOError: logger.warning('Error while writing cache file (%s)', self._cache_filename)
def uid(self): """ Returns the uid of the source file. :returns: unique id :rtype: str """ return fstools.uid(self.filename)
def uid(self): return fstools.uid(self.raw_path())
def get_rights_uid(self): filename = user_permission_file % self.get_session_user() if os.path.isfile(filename): return fstools.uid(filename) return 'no_rights_uid'
def uid(self): return fstools.uid(self.raw_path()) + '_' + pygal_user.get_rights_uid()