Esempio n. 1
0
    def open_program(self, text, lang, prefix):
        command = text

        new_command = self.get_matching_command(text, lang, prefix)
        if new_command != "":
            command = new_command

        logging.debug("Command " + command)
        ret = self.run_command(command)
        if (ret == True):
            reporter.report_success(text)
        return ret
Esempio n. 2
0
  def open_program(self, text, lang, prefix):
    command = text

    new_command = self.get_matching_command(text, lang, prefix)
    if new_command!="":
      command = new_command
    
    logging.debug( "Command " + command )
    ret = self.run_command(command)
    if (ret == True):
      reporter.report_success(text)
    return ret
Esempio n. 3
0
    def process_text(self, text, lang):

        if len(text) == 1:
            if self.is_grid_running == True:
                if '0' <= text[:1] <= '9':
                    #send command to grid
                    self.grid.select_cell(text)
                    reporter.report_success(text)
                    return True
            else:
                self.insert_text(text, lang)
                return True

        if text == "grid" or text == "griglia":
            if self.grid != None and self.is_grid_running == True:
                self.grid.stop()
            if (self.grid == None):
                self.grid = grid.Grid()
            self.grid.start()
            self.is_grid_running = True
            reporter.report_success(text)
            return True

        # Ignore some token in initial position
        if text.startswith('open ') or text.startswith(
                'run ') or text.startswith('apri '):
            startpos = text.find(" ") + 1
            t = text[startpos:]
            return self.open_program(t, lang, text.split(" ")[0].strip())
        # Keyword in order to go to a web page
        elif text.startswith('vai su ') or text.startswith('go to '):
            startpos = text.find(" ") + 1
            t = text[startpos:]
            startpos = t.find(" ") + 1
            t = t[startpos:]
            self.google_search(t)
            return True
        # Keyword in order to write with vocal keyboard
        elif text.startswith('scrivi ') or text.startswith('write '):
            startpos = text.find(" ") + 1
            t = text[startpos:]
            self.insert_text(t, lang)
            return True
        else:
            status = self.open_program(text, lang, "")
            if self.is_grid_running == True and status == True:
                self.grid.stop()
            if (status == False):
                t = text
                if text.startswith('chi è ') or text.startswith('cosa è '):
                    startpos = text.find("è ") + 1
                    t = text[startpos:]
                if text.startswith('who is') or text.startswith('what is'):
                    startpos = text.find("is ") + 1
                    t = text[startpos:]
                status = self.sparql.run(t, lang[:2])
                if (status == True):
                    reporter.report_success(text)
            return status
        reporter.report_failure(text)
Esempio n. 4
0
 def process_text(self, text, lang):
 
   if len(text)==1:
     if self.is_grid_running == True:
       if '0' <= text[:1] <= '9':
         #send command to grid
         self.grid.select_cell(text)
         reporter.report_success(text)
         return True;
     else:
       self.insert_text(text, lang)
       return True
 
   if text == "grid" or text == "griglia":
     if self.grid!=None and self.is_grid_running == True:
        self.grid.stop()
     if (self.grid == None):
       self.grid = grid.Grid()
     self.grid.start()
     self.is_grid_running = True
     reporter.report_success(text)
     return True
       
   # Ignore some token in initial position
   if text.startswith('open ') or text.startswith('run ') or text.startswith('apri '):
     startpos = text.find(" ") + 1
     t = text[startpos:]
     return self.open_program(t, lang, text.split(" ")[0].strip())
   # Keyword in order to go to a web page
   elif text.startswith('vai su ') or text.startswith('go to '):
     startpos = text.find(" ") + 1
     t = text[startpos:]
     startpos = t.find(" ") + 1
     t = t[startpos:]
     self.google_search(t);
     return True
   # Keyword in order to write with vocal keyboard
   elif text.startswith('scrivi ') or text.startswith('write '):
     startpos = text.find(" ") + 1
     t = text[startpos:]
     self.insert_text(t, lang)
     return True
   else:
     status = self.open_program(text, lang, "")
     if self.is_grid_running == True and status == True:
       self.grid.stop()
     if (status == False):
       t = text
       if text.startswith('chi è ') or text.startswith('cosa è '):
         startpos = text.find("è ") + 1
         t = text[startpos:]
       if text.startswith('who is') or text.startswith('what is'):
         startpos = text.find("is ") + 1
         t = text[startpos:]
       status = self.sparql.run(t, lang[:2])
       if (status == True):
         reporter.report_success(text)
     return status
   reporter.report_failure(text)
Esempio n. 5
0
 def google_search(self, t):
     command = "xdg-open \"https://www.google.com/search?q=" + t + "&btnI\""
     ret = self.run_command(command)
     if (ret == True):
         reporter.report_success(t)
Esempio n. 6
0
 def insert_text(self, t, lang):
     command = "xte \"str " + t + "\""
     ret = self.run_command(command)
     if (ret == True):
         reporter.report_success(t)
Esempio n. 7
0
 def google_search(self, t):
   command = "xdg-open \"https://www.google.com/search?q=" + t + "&btnI\""
   ret = self.run_command(command)
   if (ret == True):
     reporter.report_success(t)
Esempio n. 8
0
 def insert_text(self, t, lang):
   command =  "xte \"str " + t + "\""  
   ret = self.run_command(command)
   if (ret == True):
     reporter.report_success(t)