def __init__(self):
        filename = "../Setup/templates/popup.glade"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("window1")
        self.title = self.builder.get_object("lblTitle")
        self.message = self.builder.get_object("lblMessage")
        self.titleBox = self.builder.get_object("labelbox")
        self.titleBox.connect("button-release-event", self.on_clicked)
        self.exit = self.builder.get_object("exitbox")
        self.exit.connect("button-release-event", self.close_notify)
        self.icon = self.builder.get_object("imgIcon")
        self.window.set_gravity(gdk.Gravity.NORTH_WEST)
        self.display = False
        self.window.set_keep_above(True)
        self.counter = 0
        self.counter2 = 0
        self.counting = False
        self.queue = []

        self.info = lispeak.getInfo()

        gobject.timeout_add_seconds(1, self.timer)
        try:
            gobject.timeout_add_seconds(0.2, self.display_notify)
        except:
            print "Reverting to 1 second check"
            gobject.timeout_add_seconds(1, self.display_notify)
        gobject.timeout_add_seconds(30, self.message_system)
        while gtk.events_pending():
            gtk.main_iteration_do(True)
        self.message_system()
예제 #2
0
파일: notify.py 프로젝트: Abdillah/LiSpeak
    def __init__(self):
        filename = "../Setup/templates/popup.glade"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(filename)
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("window1")
        self.title = self.builder.get_object("lblTitle")
        self.message = self.builder.get_object("lblMessage")
        self.titleBox = self.builder.get_object("labelbox")
        self.titleBox.connect("button-release-event", self.on_clicked)
        self.exit = self.builder.get_object("exitbox")
        self.exit.connect("button-release-event",self.close_notify)
        self.icon = self.builder.get_object("imgIcon") 
        self.window.set_gravity(gdk.Gravity.NORTH_WEST)  
        self.display = False
        self.window.set_keep_above(True)
        self.counter = 0
        self.counter2 = 0
        self.counting = False
        self.queue = []
        
        self.info = lispeak.getInfo()

        gobject.timeout_add_seconds(1, self.timer)
        try:
            gobject.timeout_add_seconds(0.2, self.display_notify)
        except:
            print "Reverting to 1 second check"
            gobject.timeout_add_seconds(1, self.display_notify)       
        gobject.timeout_add_seconds(30, self.message_system)
        while gtk.events_pending():
            gtk.main_iteration_do(True)
        self.message_system()
예제 #3
0
파일: notify.py 프로젝트: hihihippp/LiSpeak
 def message_system(self):
     if lispeak.getInfo()['MESSAGES'] == "True":
         f = urllib2.urlopen("http://lispeak.bmandesigns.com/functions.php?f=messageUpdate")
         text = f.read()
         message = json.loads(text.replace('\r', '\\r').replace('\n', '\\n'),strict=False)
         lastId = lispeak.getSingleInfo("lastid")
         if lastId == "":
             lastId = message['id']
         try:
             go = int(message['id']) > int(lastId)
         except:
             go = True
         if go:
             if 'icon' in message:
                 urllib.urlretrieve(message['icon'], "/tmp/lsicon.png")
                 self.queue.append({'title':"LiSpeak - "+message['title'],'message':message['text'],'icon':"/tmp/lsicon.png","speech":message['text']})
             else:
                 self.queue.append({'title':"LiSpeak - "+message['title'],'message':message['text'],"speech":message['text']})
         
         lispeak.writeSingleInfo("lastid",str(int(message['id'])))
     return True
예제 #4
0
파일: notify.py 프로젝트: Abdillah/LiSpeak
from gi.repository import Gtk
from gi.repository import Gdk as gdk
from gi.repository import GdkPixbuf as pixbuf
from gi.repository import Gtk as gtk
from gi.repository import GObject as gobject

FILEFOLDER="/tmp/lispeak_" + getpass.getuser()

#ar = lispeak.getSingleInfo("ARDUINO")
#if ar == "":
#    ar = '/dev/ttyACM1'
#    lispeak.writeSingleInfo('ARDUINO','/dev/ttyACM1')
#lcd = lispeak.arduino(lispeak.getSingleInfo("ARDUINO"))
#lcd.sendText("Welcome|LiSpeak LCD;")

preInfo = lispeak.getInfo()
if "NOTIFICATIONS" not in preInfo:
    lispeak.writeSingleInfo("NOTIFICATIONS","LiSpeak")
if "NOTIFYX" not in preInfo:
    lispeak.writeSingleInfo("NOTIFYX","50")
if "NOTIFYY" not in preInfo:
    lispeak.writeSingleInfo("NOTIFYY","50")
if "MESSAGES" not in preInfo:
    lispeak.writeSingleInfo("MESSAGES","False")


try:
    os.chdir("Microphone")
except:
    print "Currently in",os.getcwd()
from gi.repository import Gtk
from gi.repository import Gdk as gdk
from gi.repository import GdkPixbuf as pixbuf
from gi.repository import Gtk as gtk
from gi.repository import GObject as gobject

FILEFOLDER = "/tmp/lispeak_" + getpass.getuser()

#ar = lispeak.getSingleInfo("ARDUINO")
#if ar == "":
#    ar = '/dev/ttyACM1'
#    lispeak.writeSingleInfo('ARDUINO','/dev/ttyACM1')
#lcd = lispeak.arduino(lispeak.getSingleInfo("ARDUINO"))
#lcd.sendText("Welcome|LiSpeak LCD;")

preInfo = lispeak.getInfo()
if "NOTIFICATIONS" not in preInfo:
    lispeak.writeSingleInfo("NOTIFICATIONS", "LiSpeak")
if "NOTIFYX" not in preInfo:
    lispeak.writeSingleInfo("NOTIFYX", "50")
if "NOTIFYY" not in preInfo:
    lispeak.writeSingleInfo("NOTIFYY", "50")
if "MESSAGES" not in preInfo:
    lispeak.writeSingleInfo("MESSAGES", "False")

try:
    os.chdir("Microphone")
except:
    print "Currently in", os.getcwd()

try:
예제 #6
0
파일: wolf.py 프로젝트: Coco2233/LiSpeak
    def handle_starttag(self, tag, attrs):
        if tag == "pod":
            self.podIndex = self.podIndex + 1
        elif tag == "plaintext":
            if self.podIndex == 2 and self.go == True:
                self.next = True
    def handle_endtag(self, tag):
        pass
    def handle_data(self, data):
        if self.next == True:
            self.output = data
            self.next = False
            self.go = False

try:
    appid = lispeak.getInfo()['WOLF']
except:
    appid = ""
if appid != "":
    q = sys.argv[1]
    response = urllib2.urlopen("http://api.wolframalpha.com/v1/query?input="+q.replace(" ","%20")+"&appid="+appid)

    html = response.read() 
    data = open("data.html",'w')
    data.write(html)
    data.close()
    parser = MyHTMLParser()
    parser.podIndex = 0
    parser.go = True
    parser.next = False
    parser.feed(html)
예제 #7
0
파일: notify.py 프로젝트: hihihippp/LiSpeak
 def timer(self):
     try:
         if lispeak.getInfo()['NOTIFICATIONS'] == "LiSpeak":
             if self.counting:
                 if self.counter == 0:
                     self.display = True
                     for each in range(0,10):
                         if self.counting:
                             self.window.set_opacity(float("0."+str(each)))
                             while gtk.events_pending():
                                 gtk.main_iteration_do(True)
                             self.window.show_all()
                             self.window.move(100,150)
                             self.icon.set_visible(not self.image_hide)
                     self.speak(self.speech)
                 if self.counter == 5:
                     if self.window.get_opacity() != 0.0:
                         for each in range(9,-1,-1):
                             self.window.set_opacity(float("0."+str(each)))
                             while gtk.events_pending():
                                 gtk.main_iteration_do(True)
                             time.sleep(0.02)
                         self.window.hide()
                         self.display = False
                         self.counting = False
                 self.counter += 1
         if not self.counting and len(self.queue) > 0 and self.display == False:
             data = self.queue[0]
             try:
                 self.message.set_text("")
                 self.message.set_text(data['message'].replace("\\n","\n"))
             except:
                 pass
             self.title.set_text(data['title'])
             if 'icon' in data:
                 if data['icon'].startswith("http"):
                     f2 = urllib2.urlopen(data['icon'])
                     output = open('/tmp/lispeak-image','wb')
                     output.write(f2.read())
                     output.close()
                     buf = pixbuf.Pixbuf.new_from_file_at_size("/tmp/lispeak-image",75,75)
                     self.icon.set_from_pixbuf(buf)
                 else:
                     try:
                         buf = pixbuf.Pixbuf.new_from_file_at_size(data['icon'].replace("file://",""),75,75)
                         self.icon.set_from_pixbuf(buf)
                     except:
                         print "Invalid Image:",data['icon']
                 self.image_hide = False
             else:
                 self.image_hide = True
             if "speech" in data:
                 print data['speech']
                 if data["speech"] != True:
                     self.speech = data['speech']
                 else:
                     self.speech = data['title']
             else:
                 self.speech = data['title']
             if lispeak.getInfo()['NOTIFICATIONS'] == "LiSpeak":
                 self.counter = 0
                 self.counting = True
             elif lispeak.getInfo()['NOTIFICATIONS'] == "System":
                 try:
                     if "icon" in data:
                         if data['icon'].startswith("http"):
                             f2 = urllib2.urlopen(data['icon'])
                             output = open('/tmp/lispeak-image','wb')
                             output.write(f2.read())
                             output.close()
                             notify(summary=data['title'],body=data['message'].replace("\\n","\n"),app_icon='/tmp/lispeak-image')
                         else:
                             notify(summary=data['title'],body=data['message'].replace("\\n","\n"),app_icon=data['icon'])
                     else:
                         notify(summary=data['title'],body=data['message'].replace("\\n","\n"))
                 except:
                     notify(summary=data['title'])
                 self.speak(self.speech)
             self.queue.pop(0)
             #lcd.sendText(self.title.get_text()+"|"+self.message.get_text()+";")
         return True
     except:
         print "AN ERROR OCCURED!", sys.exc_info()
         return True
예제 #8
0
파일: notify.py 프로젝트: hihihippp/LiSpeak
from gi.repository import Gtk
from gi.repository import Gdk as gdk
from gi.repository import GdkPixbuf as pixbuf
from gi.repository import Gtk as gtk
from gi.repository import GObject as gobject

FILEFOLDER="/tmp/lispeak_" + getpass.getuser()

#ar = lispeak.getSingleInfo("ARDUINO")
#if ar == "":
#    ar = '/dev/ttyACM1'
#    lispeak.writeSingleInfo('ARDUINO','/dev/ttyACM1')
#lcd = lispeak.arduino(lispeak.getSingleInfo("ARDUINO"))
#lcd.sendText("Welcome|LiSpeak LCD;")

if "NOTIFICATIONS" not in lispeak.getInfo():
    lispeak.writeSingleInfo("NOTIFICATIONS","LiSpeak")

try:
    os.chdir("Microphone")
except:
    print "Currently in",os.getcwd()

try:
    from dbus.mainloop.glib import DBusGMainLoop
except ImportError:
    from dbus.mainloop.qt.DBusQtMainLoop import DBusGMainLoop
    #if none exists, an ImportError will be throw
DBusGMainLoop(set_as_default=True)

class MyDBUSService(dbus.service.Object):
예제 #9
0
파일: wolf.py 프로젝트: luchfilip/LiSpeak
        elif tag == "plaintext":
            if self.podIndex == 2 and self.go == True:
                self.next = True

    def handle_endtag(self, tag):
        pass

    def handle_data(self, data):
        if self.next == True:
            self.output = data
            self.next = False
            self.go = False


try:
    appid = lispeak.getInfo()['WOLF']
except:
    appid = ""
if appid != "":
    q = sys.argv[1]
    response = urllib2.urlopen("http://api.wolframalpha.com/v1/query?input=" +
                               q.replace(" ", "%20") + "&appid=" + appid)

    html = response.read()
    data = open("data.html", 'w')
    data.write(html)
    data.close()
    parser = MyHTMLParser()
    parser.podIndex = 0
    parser.go = True
    parser.next = False