Eichhoernchen/SiriServer — Issue #12: More Snippets
Author: seabass86
Created: 2012-01-31 04:50:11+00:00
State: open

Hey,
I'm new to Python but not new to programming and would like to support your cause as a fellow German =)
It would be great to have more snippets and an example of how to use them. Especially an Answer Snippet would be great to display requests made to WolframAlpha like the US Siri does when it's been asked a question. I tried to implement it but somewhere is an error and I'm not sure yet how Python's exception handeling works to figure it out.... any thoughts?

class SiriAnswerSnippet(AceObject):
def __init__(self, answers=None, confirmationOptions=None):
super(SiriAnswerSnippet, self).__init__("Snippet", "com.apple.ace.answer")
self.answers = answers if answers != None else []
if confirmationOptions != None:
self.confirmationOptions=confirmationOptions

def to_plist(self):
self.add_property('answers')
self.add_property('confirmationOptions')
return super(SiriAnswerSnippet, self).to_plist()

class SiriAnswer(DomainObject):
def __init__(self, title=None, lines=None):
super(SiriAnswer, self).__init__("Object", "com.apple.ace.answer")
self.title = title
self.lines = lines if lines != None else []

def to_plist(self):
self.add_property('title')
self.add_property('lines')
return super(SiriAnswer, self).to_plist()

class SiriAnswerLine(DomainObject):
def __init__(self, text="", image=""):
super(SiriAnswerLine, self).__init__("ObjectLine", "com.apple.ace.answer")
self.text = text
self.image = image

def to_plist(self):
self.add_property('text')
self.add_property('image')
return super(SiriAnswerLine, self).to_plist()

####

view = AddViews(self.refId, dialogPhase="Summary")
wolfram = SiriAnswer(title="This is a test",lines=[SiriAnswerLine(text="Hallo")])
view1 = SiriAnswerSnippet(answers=[wolfram])
view.views = [view1]
self.sendRequestWithoutAnswer(view)
self.complete_request()

Thank you for all the work you have done!