Exemplo n.º 1
0
 def getTime(self):
     """
     @description: a function that let google2ubuntu read and display
     the current timme
     """
     var=time.strftime('%H:%M',time.localtime())
     hour=var.split(':')[0]
     minute=var.split(':')[1]
     
     message = _('it is')+' '+hour+' '+_('hour')+' '+minute+' '+_('minute')
     os.system('echo "'+var+'" > /tmp/g2u_display_'+self.pid)
     tts(message)
Exemplo n.º 2
0
    def read_clipboard(self):
        """
        @description: A function to make google2ubuntu reads the selected
        text
        """
        clipboard = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY)

        text = clipboard.wait_for_text()
        if text != None:
            text=text.replace("'",' ')
            print text
            tts(text)
        else:
            tts(_('Nothing in the clipboard'))
Exemplo n.º 3
0
 def getPower(self):
     """
     @description: a function that let google2ubuntu read and display
     the current power state
     """
     command = "acpi -b"
     process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     output,error  = process.communicate()
     #parsing output
     if output.count('Battery') > 0:
         pcent = output.split(' ')[3]
         rtime = output.split(' ')[4]
         
         if output.count('Charging') > 0:
             message = _('Charging')+': '+pcent+'\n'+rtime+' '+_('before charging')
         else:
             message = _('Discharging')+': '+pcent+'\n'+rtime+' '+_('remaining')
     else:
         message = _('battery is not plugged')
     
     os.system('echo "'+message+'" > /tmp/g2u_display_'+self.pid)
     tts(message)
Exemplo n.º 4
0
from subprocess import *
from os.path import expanduser
import sys, subprocess, os, json, unicodedata, time, locale
from urllib2 import urlopen

locale.setlocale(locale.LC_ALL, '')
lang = locale.getdefaultlocale()[0]
lang=lang.split('_')[0]

sys.path.append('/usr/share/google2ubuntu/librairy')
from Googletts import tts

if len(sys.argv) >= 2:
    null = None
    keyword = sys.argv[1]
    #keyword = keyword.replace(' ','+')
    print keyword
    data = urlopen("http://www.google.com/dictionary/json?callback=dict_api.callbacks.id100&q="+keyword+"&sl="+lang+"&tl="+lang+"&restrict=pr%2Cde&client=te").read()[25:-1]
 
    d = eval('('+data+')')
    if d[1] == 200:
        result = d[0]
          
        if 'webDefinitions' in result:
            webd = result.get('webDefinitions')[0]
            entries = webd.get('entries')
            entry=entries[0]
            for term in entry.get('terms'):
                if term.get('type') == 'text':
                    tts(term.get('text'))