Better code organization

parent f4087849
...@@ -941,7 +941,7 @@ def getVoiceCommandList(): ...@@ -941,7 +941,7 @@ def getVoiceCommandList():
def getScreenshotUri(target): def getScreenshotUri(target):
qstring="select screenshot from mediasources where button_name LIKE '"+target+"%' limit 1" qstring="select screenshot from mediasources where button_name LIKE '"+target+"%'"
return runQuery(qstring) return runQuery(qstring)
def getClimaUniques(): def getClimaUniques():
......
...@@ -2455,13 +2455,16 @@ class domotikaService(service.Service): ...@@ -2455,13 +2455,16 @@ class domotikaService(service.Service):
def web_on_getScreenshotList(self, screenshot=True): def web_on_getScreenshotList(self, screenshot=True):
return dmdb.getScreenshotList(screenshot=screenshot) return dmdb.getScreenshotList(screenshot=screenshot)
def web_on_getScreenshot(self, target): def web_on_getScreenshot(self, target, callback=None):
def imageReturn(img): def imageReturn(img):
return img return img
def prepareScreenshot(res): def prepareScreenshot(res):
if res: if callback == None:
return wu.getPage(res[0][0]).addCallback(imageReturn) if res:
return False return wu.getPage(res[0][0]).addCallback(imageReturn)
return False
for r in res:
wu.getPage(r[0]).addCallback(callback)
return dmdb.getScreenshotUri(target).addCallback(prepareScreenshot) return dmdb.getScreenshotUri(target).addCallback(prepareScreenshot)
def web_on_getClimaUniques(self): def web_on_getClimaUniques(self):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment