comparison sat_frontends/bridge/dbus_bridge.py @ 3066:2cc2f65379f7

core: added imageCheck and imageResize methods: imageCheck will give a report on image, notably it will tell if it's too big and needs to be resized before a transfer. imageResize will create a new image with the requested size and return a path to it.
author Goffi <goffi@goffi.org>
date Tue, 29 Oct 2019 20:38:39 +0100
parents 964abd07dc03
children 7574f795bd1e
comparison
equal deleted inserted replaced
3065:f8e3789912d0 3066:2cc2f65379f7
466 else: 466 else:
467 if errback is None: 467 if errback is None:
468 errback = log.error 468 errback = log.error
469 error_handler = lambda err:errback(dbus_to_bridge_exception(err)) 469 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
470 return self.db_core_iface.historyGet(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler) 470 return self.db_core_iface.historyGet(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler)
471
472 def imageCheck(self, arg_0, callback=None, errback=None):
473 if callback is None:
474 error_handler = None
475 else:
476 if errback is None:
477 errback = log.error
478 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
479 kwargs={}
480 if callback is not None:
481 kwargs['timeout'] = const_TIMEOUT
482 kwargs['reply_handler'] = callback
483 kwargs['error_handler'] = error_handler
484 return str(self.db_core_iface.imageCheck(arg_0, **kwargs))
485
486 def imageResize(self, image_path, width, height, callback=None, errback=None):
487 if callback is None:
488 error_handler = None
489 else:
490 if errback is None:
491 errback = log.error
492 error_handler = lambda err:errback(dbus_to_bridge_exception(err))
493 return str(self.db_core_iface.imageResize(image_path, width, height, timeout=const_TIMEOUT, reply_handler=callback, error_handler=error_handler))
471 494
472 def isConnected(self, profile_key="@DEFAULT@", callback=None, errback=None): 495 def isConnected(self, profile_key="@DEFAULT@", callback=None, errback=None):
473 if callback is None: 496 if callback is None:
474 error_handler = None 497 error_handler = None
475 else: 498 else:
1083 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) 1106 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1084 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) 1107 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1085 self.db_core_iface.historyGet(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler) 1108 self.db_core_iface.historyGet(from_jid, to_jid, limit, between, filters, profile, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1086 return fut 1109 return fut
1087 1110
1111 def imageCheck(self, arg_0):
1112 loop = asyncio.get_running_loop()
1113 fut = loop.create_future()
1114 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1115 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1116 self.db_core_iface.imageCheck(arg_0, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1117 return fut
1118
1119 def imageResize(self, image_path, width, height):
1120 loop = asyncio.get_running_loop()
1121 fut = loop.create_future()
1122 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1123 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))
1124 self.db_core_iface.imageResize(image_path, width, height, timeout=const_TIMEOUT, reply_handler=reply_handler, error_handler=error_handler)
1125 return fut
1126
1088 def isConnected(self, profile_key="@DEFAULT@"): 1127 def isConnected(self, profile_key="@DEFAULT@"):
1089 loop = asyncio.get_running_loop() 1128 loop = asyncio.get_running_loop()
1090 fut = loop.create_future() 1129 fut = loop.create_future()
1091 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret) 1130 reply_handler = lambda ret=None: loop.call_soon_threadsafe(fut.set_result, ret)
1092 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err)) 1131 error_handler = lambda err: loop.call_soon_threadsafe(fut.set_exception, dbus_to_bridge_exception(err))