comparison sat/core/sat_main.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 fee60f17ebac
children d1464548055a
comparison
equal deleted inserted replaced
3065:f8e3789912d0 3066:2cc2f65379f7
38 from sat.memory import memory 38 from sat.memory import memory
39 from sat.memory import cache 39 from sat.memory import cache
40 from sat.memory import encryption 40 from sat.memory import encryption
41 from sat.tools import async_trigger as trigger 41 from sat.tools import async_trigger as trigger
42 from sat.tools import utils 42 from sat.tools import utils
43 from sat.tools import images
43 from sat.tools.common import dynamic_import 44 from sat.tools.common import dynamic_import
44 from sat.tools.common import regex 45 from sat.tools.common import regex
46 from sat.tools.common import data_format
45 from sat.stdui import ui_contact_list, ui_profile_manager 47 from sat.stdui import ui_contact_list, ui_profile_manager
46 import sat.plugins 48 import sat.plugins
47 49
48 50
49 try: 51 try:
159 self.bridge.register_method("discoFindByFeatures", self._findByFeatures) 161 self.bridge.register_method("discoFindByFeatures", self._findByFeatures)
160 self.bridge.register_method("saveParamsTemplate", self.memory.save_xml) 162 self.bridge.register_method("saveParamsTemplate", self.memory.save_xml)
161 self.bridge.register_method("loadParamsTemplate", self.memory.load_xml) 163 self.bridge.register_method("loadParamsTemplate", self.memory.load_xml)
162 self.bridge.register_method("sessionInfosGet", self.getSessionInfos) 164 self.bridge.register_method("sessionInfosGet", self.getSessionInfos)
163 self.bridge.register_method("namespacesGet", self.getNamespaces) 165 self.bridge.register_method("namespacesGet", self.getNamespaces)
166 self.bridge.register_method("imageCheck", self._imageCheck)
167 self.bridge.register_method("imageResize", self._imageResize)
164 168
165 self.memory.initialized.addCallback(self._postMemoryInit) 169 self.memory.initialized.addCallback(self._postMemoryInit)
166 170
167 @property 171 @property
168 def version(self): 172 def version(self):
630 "jid": client.jid.full(), 634 "jid": client.jid.full(),
631 "started": str(int(client.started)) 635 "started": str(int(client.started))
632 } 636 }
633 return defer.succeed(data) 637 return defer.succeed(data)
634 638
639 # images
640
641 def _imageCheck(self, path):
642 report = images.checkImage(self, path)
643 return data_format.serialise(report)
644
645 def _imageResize(self, path, width, height):
646 d = images.resizeImage(path, (width, height))
647 d.addCallback(lambda new_image_path: str(new_image_path))
648 return d
649
635 # local dirs 650 # local dirs
636 651
637 def getLocalPath(self, client, dir_name, *extra_path, **kwargs): 652 def getLocalPath(self, client, dir_name, *extra_path, **kwargs):
638 """retrieve path for local data 653 """retrieve path for local data
639 654