core, bridge: new imageGeneratePreview helped method to generate a thumbnail

This commit is contained in:
Goffi 2020-03-01 18:48:06 +01:00
commit 3686d7e036
2 changed files with 90 additions and 0 deletions

View file

@ -489,6 +489,15 @@ class Bridge:
kwargs['error_handler'] = error_handler
return str(self.db_core_iface.imageCheck(arg_0, **kwargs))
def imageGeneratePreview(self, image_path, profile_key, callback=None, errback=None):
if callback is None:
error_handler = None
else:
if errback is None:
errback = log.error
error_handler = lambda err:errback(dbus_to_bridge_exception(err))
return str(self.db_core_iface.imageGeneratePreview(image_path, profile_key, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
def imageResize(self, image_path, width, height, callback=None, errback=None):
if callback is None:
error_handler = None
@ -1149,6 +1158,14 @@ class AIOBridge(Bridge):
self.db_core_iface.imageCheck(arg_0, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
return fut
def imageGeneratePreview(self, image_path, profile_key):
loop = asyncio.get_running_loop()
fut = loop.create_future()
reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
self.db_core_iface.imageGeneratePreview(image_path, profile_key, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
return fut
def imageResize(self, image_path, width, height):
loop = asyncio.get_running_loop()
fut = loop.create_future()

View file

@ -383,6 +383,14 @@ class Bridge(object):
errback = self._generic_errback
d.addErrback(errback)
def imageGeneratePreview(self, image_path, profile_key, callback=None, errback=None):
d = self.root.callRemote("imageGeneratePreview", image_path, profile_key)
if callback is not None:
d.addCallback(callback)
if errback is None:
errback = self._generic_errback
d.addErrback(errback)
def imageResize(self, image_path, width, height, callback=None, errback=None):
d = self.root.callRemote("imageResize", image_path, width, height)
if callback is not None:
@ -818,6 +826,11 @@ class AIOBridge(Bridge):
d.addErrback(self._errback)
return d.asFuture(asyncio.get_event_loop())
def imageGeneratePreview(self, image_path, profile_key):
d = self.root.callRemote("imageGeneratePreview", image_path, profile_key)
d.addErrback(self._errback)
return d.asFuture(asyncio.get_event_loop())
def imageResize(self, image_path, width, height):
d = self.root.callRemote("imageResize", image_path, width, height)
d.addErrback(self._errback)