예제 #1
0
    def selectImageFromAlbum(self,
                             destinationDir,
                             supportedMimeTypes,
                             displaySize,
                             randomize,
                             retry=1):
        result = BaseService.selectImageFromAlbum(self, destinationDir,
                                                  supportedMimeTypes,
                                                  displaySize, randomize)
        if result is None:
            return None
        # catch broken urls
        if result.error is not None and result.source is not None:
            logging.warning(
                "broken url detected. You should remove '.../%s' from keywords"
                % (self.getUrlFilename(result.source)))
        # catch unsupported mimetypes (can only be done after downloading the image)
        elif result.error is None and result.mimetype not in supportedMimeTypes:
            logging.warning(
                "unsupported mimetype '%s'. You should remove '.../%s' from keywords"
                % (result.mimetype, self.getUrlFilename(result.source)))
        else:
            return result

        # track broken urls / unsupported mimetypes and display warning message on web interface
        self.brokenUrls.append(result["source"])
        # retry (with another image)
        if retry > 0:
            return self.selectImageFromAlbum(destinationDir,
                                             supportedMimeTypes,
                                             displaySize,
                                             randomize,
                                             retry=retry - 1)
        return BaseService.createImageHolder(self).setError(
            '%s uses broken urls / unsupported images!' % self.SERVICE_NAME)
예제 #2
0
    def selectImageFromAlbum(self, destinationDir, supportedMimeTypes,
                             displaySize, randomize):
        result = BaseService.selectImageFromAlbum(self, destinationDir,
                                                  supportedMimeTypes,
                                                  displaySize, randomize)
        if result is not None:
            return result

        if not self.isGooglePhotosEnabled():
            return {
                'id':
                None,
                'mimetype':
                None,
                'source':
                None,
                'error':
                '"Photos Library API" is not enabled on\nhttps://console.developers.google.com\n\nCheck the Photoframe Wiki for details'
            }
        else:
            return {
                'id':
                None,
                'mimetype':
                None,
                'source':
                None,
                'error':
                'No (new) images could be found.\nCheck spelling or make sure you have added albums'
            }
예제 #3
0
  def selectImageFromAlbum(self, destinationDir, supportedMimeTypes, displaySize, randomize):
    result = BaseService.selectImageFromAlbum(self, destinationDir, supportedMimeTypes, displaySize, randomize)
    if result is not None:
      return result

    if os.path.exists(self.usbDir):
      return {'id': None, 'mimetype': None, 'error': 'No images could be found on storage device "%s"!\n\nPlease place albums inside /photoframe/{album_name} directory and add each {album_name} as keyword.\n\nAlternatively, put images directly inside the "/photoframe/"-directory on your storage device.' % self.device}
    else:
      return {'id': None, 'mimetype': None, 'error': 'No external storage device detected! Please connect a USB-stick!\n\n Place albums inside /photoframe/{album_name} directory and add each {album_name} as keyword.\n\nAlternatively, put images directly inside the "/photoframe/"-directory on your storage device.'}