def __init__(self, parent=None):
        super().__init__(parent)
        self.assistant = Assistant()
        self.textViewer = TextEdit()
        self.textViewer.setContents(
            QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.ExamplesPath) +
            "/assistant/simpletextviewer/documentation/intro.html")
        self.setCentralWidget(self.textViewer)

        self._createActions()
        self._createMenus()

        self.setWindowTitle(self.tr("Simple Text Viewer"))
        self.resize(750, 400)
Exemple #2
0
    def idle_main(self, bot, update):
        request = update.message.text.strip()
        user_id = update.message.chat_id
        does_print = bool(self.config[PrintMessages])
        user_name = update.message.from_user.username
        if does_print:
            print((USER_ASKS_PATTERN.format(user_id, user_name, request)))
        assistant: Assistant = self.__user_assistant_dict.get(user_id, None)
        if assistant is None:
            assistant: Assistant = Assistant(self.__language_model,
                                             self.message_bundle,
                                             self.__app_dict,
                                             self.config,
                                             w2v=self.__w2v,
                                             user_id=user_id)
            self.__user_assistant_dict[user_id] = assistant
        answer = assistant.process_request(request)
        message = answer.message
        if does_print:
            print(ASSISTANT_ANSWERS_PATTERN.format(user_id, user_name,
                                                   message))

        buttons = self.get_buttons(answer.dialog_step)
        bot.sendMessage(user_id, text=message, reply_markup=buttons)
        if answer.picture is not None:
            image = answer.picture
            if hasattr(image, 'read'):
                bot.sendPhoto(user_id, photo=image)
Exemple #3
0
 def __init__(self,
              name: str,
              delay: int,
              zone_id: str,
              is_muted: bool,
              vagrant_vm_name: str,
              vagrant_vm_id: str):
     Assistant.__init__(self, name, delay, zone_id, is_muted)
     self.vagrant_vm_name: str = vagrant_vm_name
     self.vagrant_vm_id: str = vagrant_vm_id
     self.POWEROFF: str = 'poweroff'
     self.RUNNING: str = 'running'
     self.SAVED: str = 'saved'
     self.SAVING: str = 'saving'
     self.RESTORING: str = 'restoring'
     self.ABORTED: str = 'aborted'
Exemple #4
0
 def __init__(self, name: str, delay: int, zone_id: str, is_muted: bool,
              chat_db_path: str, addressbook_db_path: str,
              names_criteria: List[Optional[str]], is_names_include: bool,
              groupchat_names_criteria: List[Optional[str]],
              is_groupchat_names_include: bool):
     Assistant.__init__(self, name, delay, zone_id, is_muted)
     self.chat_db_path: str = chat_db_path
     self.addressbook_db_path: str = addressbook_db_path
     self.names_criteria: List[Optional[str]] = list(
         map(lambda s: s if s is None else s.lower(), names_criteria))
     self.is_names_include: bool = is_names_include
     self.groupchat_names_criteria: List[Optional[str]] = list(
         map(lambda s: s
             if s is None else s.lower(), groupchat_names_criteria))
     self.is_groupchat_names_include: bool = is_groupchat_names_include
     self._desired_messages: List[Message] = []
     self.READ_MESSAGES: str = 'read messages'
     self.UNREAD_MESSAGES: str = 'unread messages'
    def __init__(self, bridge):

        self.bridge = bridge
        self.stop_event = threading.Event()
        self.dev = TestEquipment(self.on_dev_disconnected)

        self.exit_auto = threading.Event()

        self.message_thread = threading.Thread(target=self.handle_message)
Exemple #6
0
    def Formation_кey(self):
        l = {}
        v = []
        for x in self.character_list:
            l[x] = []
            for y in range(self.rand):
                deb = random.getrandbits(self.bit)
                if not deb in v:
                    v.append(deb)
                else:
                    deb = random.getrandbits(125)
                    v.append(deb)
                l[x].append(deb)

        with open('key.json', 'w', encoding='utf-8') as file_j:
            json.dump(l, file_j, sort_keys=False, ensure_ascii=False)

        Assistant.chek_d(self)
Exemple #7
0
 def get_assistant_via_assistant_id(self, tr_id):
     with dbapi2.connect(self.dbfile) as connection:
         cursor = connection.cursor()
         query = "select * from assistant where (assistant_id = %s)"
         cursor.execute(query, (tr_id, ))
         if (cursor.rowcount == 0):
             return None
     assistant_ = Assistant(
         *cursor.fetchone()[:])  # Inline unpacking of a tuple
     return assistant_
Exemple #8
0
 def get_assistants(self):
     assistants = []
     with dbapi2.connect(self.dbfile) as connection:
         cursor = connection.cursor()
         query = "select * from assistant order by assistant_id"
         cursor.execute(query)
         for row in cursor:
             assistant = Assistant(*row[:])
             assistants.append((assistant.tr_id, assistant))
     return assistants
Exemple #9
0
    def __init__(self, userID, customers, bankTellers, assistants):
        """
        Creates the variables associated with this class

        :type userID: string
        :param userID: the owner of the account

        :type customers: list
        :param customers: all customers that can be accessed

        :type bankTellers: list
        :param bankTellers: all bank tellers that can be accessed

        :type assistants: list
        :param assistants: all assistants that can be accessed
        """

        Assistant.__init__(self, userID, customers, bankTellers)
        self.__assistants = assistants
Exemple #10
0
    def execute_command(self):
        for command in Assistant.commands():
            if re.search(command[0], self.phrase, re.I):
                matched = True
                args = re.search(command[0], self.phrase, re.I).groups()

                if len(args) > 0:
                    command[1](args)
                else:
                    command[1]()

                return

        raise ValueError("Unknown command was heard")
Exemple #11
0
class Console(BaseInterface):
    def __init__(self, language_model, app_dict, w2v, message_bundle, config):
        super().__init__(message_bundle, config)
        self.__assistant = Assistant(language_model,
                                     message_bundle,
                                     app_dict,
                                     config,
                                     w2v=w2v)
        self.__START_MESSAGE_KEY = self.config[StartMessageKey]

    def start(self):
        print(self.message_bundle[self.__START_MESSAGE_KEY])
        request = input("User: "******"exit":
            try:
                answer = self.__assistant.process_request(request)
                print("Masha: " + answer.message)
            except Exception:
                logging.error(traceback.print_exc())
            request = input("User: ")

    def stop(self):
        self.__assistant.stop()
Exemple #12
0
def init(canvas, stop):
    print('Listening... Press Ctrl+C to exit')

    global stop_id
    global gen_canvas
    global detector
    global assist
    detector = snowboydecoder.HotwordDetector(models, sensitivity=sensitivity)

    # capture SIGINT signal, e.g., Ctrl+C
    assist = Assistant()

    stop_id = stop
    gen_canvas = canvas
    detector.start(detected_callback=detect_callback,
                   interrupt_check=interrupt_callback,
                   sleep_time=0.03)
Exemple #13
0
    def createAssistant(self, userID, customers, bankTellers):
        """
        Creates an assistant object

        :type userID: string
        :param userID: the userID of the assistant

        :type customers: list
        :param customers: all customers that assistant can access

        :type bankTellers: list
        :param bankTellers: all bank tellers that assistant can access
        """

        assistant = Assistant(userID, customers, bankTellers)
        self.__assistants.append(assistant)

        return assistant
Exemple #14
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging
from Snap7Light import Snap7Light
from Snap7Shutter import Snap7Shutter
from Snap7Temperature import Snap7Temperature
from assistant import Assistant
from utilitys import catchErrors, getSlotValue, lg, configureLogger
#hermes: 'publish_continue_session', 'publish_end_session', 'publish_start_session_action', 'publish_start_session_notification',

# ======================================================================================================================

assist = Assistant()
lights = Snap7Light(assist.get_config())
shutter = Snap7Shutter(assist.get_config())
temp = Snap7Temperature(assist.get_config())

# ======================================================================================================================
#@catchErrors
#def activateObject(hermes, intent_message):
#  location = getSlotValue(intent_message.slots, "deviceLocation", intent_message.site_id if intent_message.site_id != "default" else "wohnzimmer")
#  device = getSlotValue(intent_message.slots, "device", "")
#  deviceType = getSlotValue(intent_message.slots, "deviceType", "default")
#  lg.debug("activateObject:    location: {}, device: {}, deviceType: {}".format(location, device, deviceType))
#  if device.upper() == "Licht".upper():
#    deviceType = deviceType if deviceType != "default" else "decke"
#    lights.turnOn(location, deviceType)
#    hermes.publish_end_session(intent_message.session_id, "Licht im {} wird angeschalten".format(location))
#  elif device.upper() == "Rollo".upper():
#    deviceType = deviceType if deviceType != "default" else "fenster"
#    shutter.open(location, deviceType)
class TPlanMessageHandler():
    """
     This class handle messages from UI
    """

    def __init__(self, bridge):

        self.bridge = bridge
        self.stop_event = threading.Event()
        self.dev = TestEquipment(self.on_dev_disconnected)

        self.exit_auto = threading.Event()

        self.message_thread = threading.Thread(target=self.handle_message)

    def run_auto_test(self):

        while not self.exit_auto.is_set():
            targets = self.dev.wait_for_target(2)
            if not targets:
                continue

            board = self.bridge.getBoard()
            target = TARGET[board](self.dev)
            self.bridge.log('\n============= search target =============')
            start_time = datetime.datetime.now()
            mask = 0
            for i in range(4):
                if targets & (1 << i):
                    self.bridge.log('find target %d' % (i + 1))
                    self.bridge.setBoardState(i, 1)
                else:
                    self.bridge.setBoardState(i, 0)

            mask = targets
            for i in range(4):
                if mask & (1 << i) == 0:
                    continue

                self.dev.select_target(i)

                time.sleep(0.1)
                # To do

                self.bridge.log('----------- test target %d -----------' % (i + 1))
                print('......... test target %d .........' % (i + 1))

                try:
                    has_error = False
                    while True:
                        if target.find_device():
                            self.bridge.log('skip writing interface firmware')
                        else:
                            self.bridge.log('write interface firmware...')
                            if target.write_interface():
                                has_error = True
                                break

                        self.bridge.log('write bootloader...')
                        if target.write_bootloader():
                            has_error = True
                            break

                        self.bridge.log('write test program...')
                        if target.write_test():
                            has_error = True
                            break

                        self.bridge.log('ok')
                        time.sleep(2)
                        self.bridge.log('read test result...')
                        io_result, io_result_description, voltage_result, voltage_result_description = target.test()
                        if io_result:
                            self.bridge.log('IO test: ok')
                        else:
                            self.bridge.log('IO test: failed')
                            self.bridge.log(io_result_description)

                            has_error = True
                            break

                        if voltage_result:
                            self.bridge.log('Voltage test: ok')
                        else:
                            self.bridge.log('Voltage test: failed')
                            self.bridge.log(voltage_result_description)

                            has_error = True
                            break

                        # self.bridge.log('write product program...')
                        # target.write_product()

                        break

                    if has_error:
                        self.bridge.log('failed')
                        self.bridge.setBoardState(i, 3)
                    else:
                        self.bridge.log('......... test target %d done .........' % (i + 1))
                        self.bridge.setBoardState(i, 2)
                except subprocess.CalledProcessError as e:
                    self.bridge.log('failed')
                    self.bridge.log(e)
                    self.bridge.setBoardState(i, 3)

                self.dev.power_off_targets(i)

            end_time = datetime.datetime.now()
            self.bridge.log('\ntime lapsed: %d' % (end_time - start_time).seconds)

    def handle_message(self):
        while True:
            message = self.bridge.get()
            print(message)
            if message == 'start':
                if self.dev.connect():
                    self.auto_test_thread = threading.Thread(target=self.run_auto_test)
                    self.exit_auto.clear()
                    self.auto_test_thread.start()
            elif message == 'stop':
                self.exit_auto.set()
            elif message == 'quit':
                self.exit_auto.set()
                self.stop_event.set()
                break
            else:
                if self.dev.connect():
                    board = self.bridge.getBoard()
                    target = TARGET[board](self.dev)
                    index = self.bridge.getBoardId() - 1
                    self.dev.select_target(index)
                    time.sleep(3)
                    self.bridge.log('-------- %s --------' % message)
                    try:
                        has_error = False
                        if message == 'write interface':
                            if target.write_interface():
                                has_error = True
                        elif message == 'write bootloader':
                            if target.write_bootloader():
                                has_error = True
                        elif message == 'write program':
                            if target.write_test():
                                has_error = True
                        elif message == 'test target':
                            io_result, io_result_description, voltage_result, voltage_result_description = target.test()
                            if not io_result:
                                self.bridge.log('IO test: failed')
                                self.bridge.log(io_result_description)

                                has_error = True

                            if not voltage_result:
                                self.bridge.log('Voltage test: failed')
                                self.bridge.log(voltage_result_description)

                                has_error = True
                        elif message == 'write product':
                            target.write_product()

                        if has_error:
                            self.bridge.log('failed')
                        else:
                            self.bridge.log('ok')
                    except subprocess.CalledProcessError as e:
                        self.bridge.log('failed')
                        self.bridge.log(e)

                        # self.dev.deselect_target(index)

    def start(self):
        self.message_thread.start()

    def join(self):
        self.exit_auto.set()
        self.stop_event.set()
        self.dev.disconnect()
        self.message_thread.join()

    def on_dev_disconnected(self):
        self.exit_auto.set()
        self.bridge.disconnect('device is disconnected')
Exemple #16
0
            add_local_preposition(spoken_room))
    elif intent_name == user_intent("nextMedia"):
        command = "NEXT"
        response = "Die aktuelle Wiedergabe wird {} übersprungen".format(
            add_local_preposition(spoken_room))
    else:
        command = "PREVIOUS"
        response = "{} geht es zurück zur vorherigen Wiedergabe".format(
            add_local_preposition(spoken_room))

    openhab.send_command_to_devices(items, command)
    return True, response


if __name__ == "__main__":
    with Assistant() as a:
        a.add_callback(user_intent("switchDeviceOn"), switch_on_off_callback)
        a.add_callback(user_intent("switchDeviceOff"), switch_on_off_callback)

        a.add_callback(user_intent("getTemperature"), get_temperature_callback)

        a.add_callback(user_intent("increaseItem"), increase_decrease_callback)
        a.add_callback(user_intent("decreaseItem"), increase_decrease_callback)

        a.add_callback(user_intent("setValue"), set_value_callback)

        a.add_callback(user_intent("playMedia"), player_callback)
        a.add_callback(user_intent("pauseMedia"), player_callback)
        a.add_callback(user_intent("nextMedia"), player_callback)
        a.add_callback(user_intent("previousMedia"), player_callback)
Exemple #17
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import random

from assistant import Assistant

# ======================================================================================================================

assist = Assistant()
jokes = None
file_path = os.path.dirname(os.path.realpath(__file__)) + "/"

# ======================================================================================================================


def load_jokes(lang, safe_only=False):
    if (safe_only):
        path = file_path + "jokes/" + lang.lower() + "_safe_only.txt"
    else:
        path = file_path + "jokes/" + lang.lower() + ".txt"

    with open(path, encoding="utf-8") as file:
        # Read line by line and remove whitespace characters at the end of each line
        content = file.readlines()
        content = [x.strip() for x in content]

    random.shuffle(content)
    return content
from os.path import join as p_join
from assistant import Assistant
from utils import *
import json

app = flask.Flask(__name__)


@app.route('/personal_assistan', methods=['GET', 'POST'])
def find_navigation():
    """
    :return:
    """
    """addresses = flask.request.values        # returns a dictionary (Map class in Java)
    start_address = addresses.get("from_address")"""
    event_list = assistant.read_today_events()
    print(event_list)

    json_events = json.dumps(event_list)

    return json_events


if __name__ == "__main__":
    config = read_config(yaml_path="../../personal_assistant_config.yaml")

    calendar_url = config["calendar_url"]
    assistant = Assistant(calendar_url)

    app.run(host=get_ip_address(), port=5000, debug=False)
 def __init__(self, name: str, delay: int, zone_id: str, is_muted: bool):
     Assistant.__init__(self, name, delay, zone_id, is_muted)
     self.example_state: str = 'example state'
Exemple #20
0
    def __init__(self):
        super(Shish, self).__init__()

        self.character_list = a
        self.bit = 10
        self.rand = 5

        self.Windows = tkinter.Tk()
        self.Windows.geometry('666x380')

        self.bat1 = tkinter.Button(self.Windows,
                                   width=5,
                                   text='Создать ключ',
                                   command=self.Formation_кey,
                                   fg='#ffffff',
                                   bg='#4b5463')
        self.frame0 = tkinter.Frame(self.Windows)
        self.text0_1 = tkinter.Text(self.frame0,
                                    width=5,
                                    height=1,
                                    bg='#ffffff')
        self.text0_2 = tkinter.Text(self.frame0,
                                    width=5,
                                    height=1,
                                    bg='#ffffff')
        self.frame4 = tkinter.Frame(self.Windows)
        self.frame2_1 = tkinter.Frame(self.frame4)
        self.bat2 = tkinter.Button(self.frame2_1,
                                   width=5,
                                   height=5,
                                   text='Закодировать',
                                   command=self.Encryption,
                                   fg='#ffffff',
                                   bg='#4b5463')

        self.text1 = tkinter.scrolledtext.ScrolledText(self.frame2_1,
                                                       width=10,
                                                       height=11)
        self.frame1 = tkinter.Frame(self.frame2_1)
        self.bat2_1 = tkinter.Button(self.frame1,
                                     width=5,
                                     text='COPY',
                                     command=lambda: Assistant.copy0(self),
                                     bg='#fade55')
        self.bat2_2 = tkinter.Button(self.frame1,
                                     width=5,
                                     text='PAST',
                                     command=lambda: Assistant.paste0(self),
                                     bg='#c3f229')
        self.frame3_1 = tkinter.Frame(self.frame4)
        self.bat3 = tkinter.Button(self.frame3_1,
                                   width=5,
                                   height=5,
                                   text='Декодировать',
                                   command=self.Decryption,
                                   fg='#ffffff',
                                   bg='#4b5463')

        self.text2 = tkinter.scrolledtext.ScrolledText(self.frame3_1,
                                                       width=10,
                                                       height=11)
        self.frame2 = tkinter.Frame(self.frame3_1)
        self.bat3_1 = tkinter.Button(self.frame2,
                                     width=5,
                                     text='COPY',
                                     command=lambda: Assistant.copy1(self),
                                     bg='#fade55')
        self.bat3_2 = tkinter.Button(self.frame2,
                                     width=5,
                                     text='PAST',
                                     command=lambda: Assistant.paste1(self),
                                     bg='#c3f229')

        self.bat_clear = tkinter.Button(self.Windows,
                                        width=5,
                                        height=3,
                                        text='X_X',
                                        command=lambda: Assistant.clear(self),
                                        fg='#ffffff',
                                        bg='#4b5463')

        Assistant.pack(self)

        Assistant.chek_d(self)

        self.Windows.mainloop()
Exemple #21
0
from assistant import Assistant
from assistant.gui.messageBox import MessageBox
from infi.systray import SysTrayIcon 
import time
import os 


icon = "images/icon.ico"
trayIcon_title = "Virtual Assistant"
va_settingsPath = "data"

# Cria uma intância de MessageBox para enviar mensagens para o usuário.
messageBox = MessageBox(icon)

# Obtém uma instância de Assistant e um objeto responsável pelas suas ações.
assistant = Assistant(messageBox,va_settingsPath,icon=icon)
assistantCommands = assistant.getAssistantCommands()

# Obtém um tradutor.
translator = assistant.getTranslator()


def changeLanguage(systray):
    """
    Função para trocar o idioma do assistente.
    """

    language = assistantCommands.changeLanguage()
    trayIcon.update(hover_text=trayIcon_title+" (%s)"%language)

def enable_sounds(systray):
Exemple #22
0
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.assistant = Assistant()
        self.textViewer = TextEdit()
        self.textViewer.setContents(
            QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.ExamplesPath) +
            "/assistant/simpletextviewer/documentation/intro.html")
        self.setCentralWidget(self.textViewer)

        self._createActions()
        self._createMenus()

        self.setWindowTitle(self.tr("Simple Text Viewer"))
        self.resize(750, 400)

    def _showDocumentation(self):
        self.assistant.showDocumentation("index.html")

    @QtCore.Slot()
    def _about(self):
        QtWidgets.QMessageBox.about(
            self,
            self.tr("About Simple Text Viewer"),
            self.tr("This example demonstrates how to use\n"
                    "Qt Assistant as help system for your\n"
                    "own application."),
        )

    @QtCore.Slot()
    def _open(self):
        dialog = FindFileDialog(self.textViewer, self.assistant)
        dialog.exec_()

    def _createActions(self):
        self.assistantAct = QtWidgets.QAction(
            self.tr("Help Contents"),
            self,
            shortcut=QtGui.QKeySequence.HelpContents,
            triggered=self._showDocumentation,
        )
        self.openAct = QtWidgets.QAction(
            self.tr("&Open..."),
            self,
            shortcut=QtGui.QKeySequence.Open,
            triggered=self._open,
        )
        self.clearAct = QtWidgets.QAction(
            self.tr("&Clear"),
            self,
            shortcut=self.tr("Ctrl+C"),
            triggered=self.textViewer.clear,
        )
        self.exitAct = QtWidgets.QAction(
            self.tr("E&xit"),
            self,
            shortcut=QtGui.QKeySequence.Quit,
            triggered=self.close,
        )
        self.aboutAct = QtWidgets.QAction(self.tr("&About"),
                                          self,
                                          triggered=self._about)
        self.aboutQtAct = QtWidgets.QAction(
            self.tr("About &Qt"),
            self,
            triggered=QtWidgets.QApplication.aboutQt)

    def _createMenus(self):
        fileMenu = QtWidgets.QMenu(self.tr("&File"), self)
        fileMenu.addAction(self.openAct)
        fileMenu.addAction(self.clearAct)
        fileMenu.addSeparator()
        fileMenu.addAction(self.exitAct)

        helpMenu = QtWidgets.QMenu(self.tr("&Help"), self)
        helpMenu.addAction(self.assistantAct)
        helpMenu.addSeparator()
        helpMenu.addAction(self.aboutAct)
        helpMenu.addAction(self.aboutQtAct)

        self.menuBar().addMenu(fileMenu)
        self.menuBar().addMenu(helpMenu)
Exemple #23
0
from os import listdir
import requests

from assistant import Assistant
import recommend
import recommends_control
import config.config as conf

tomato_time = 1
# filename = 'test_data.json'

# if filename not in listdir():
#     with open(filename, 'w') as file:
#         json.dump({}, file)

assistant = Assistant()
assistant.load_from_json(conf.DATA_PATH)

bot = telebot.TeleBot(conf.TOKEN)
keyboard_start_tomat = telebot.types.ReplyKeyboardMarkup(True, True)
keyboard_start_tomat.row('Начнем!')

personal_reccomendation = recommend.KNNRec()


def register_id(user_id):
    try:
        assistant.add_user(str(user_id))
    except ValueError:
        print('Пользователь уже существует')
    if str(user_id) + '.json' not in listdir(conf.DATA_PATH):
Exemple #24
0
 def __init__(self, name: str, delay: int, zone_id: str, is_muted: bool,
              job_name: str, server_url: str):
     Assistant.__init__(self, name, delay, zone_id, is_muted)
     self.job_name: str = job_name
     self.server_url: str = server_url
Exemple #25
0
    global interrupted
    interrupted = True


def interrupt_callback():
    global interrupted
    return interrupted


model = sys.argv[1]

# capture SIGINT signal, e.g., Ctrl+C
signal.signal(signal.SIGINT, signal_handler)

detector = snowboydecoder.HotwordDetector(model, sensitivity=0.7)
assistant = Assistant()


def snowboy_detect_controller():
    def detect_callback():
        detector.terminate()
        snowboydecoder.play_audio_file(snowboydecoder.DETECT_DING)
        globalmodule.assistantcontroller = True
        globalmodule.hotworddetected = False
        while True:
            if globalmodule.snowboycontroller:
                globalmodule.snowboycontroller = False
                logger.info('Listening... Press Ctrl+C to exit')
                detector.start(detected_callback=detect_callback,
                               interrupt_check=interrupt_callback,
                               sleep_time=0.03)
Exemple #26
0
from Snap7Connection import Snap7Connection as s7con
from assistant import Assistant
from Snap7Light import Snap7Light
from utilitys import configureLogger

assist = Assistant()

if __name__ == "__main__":
    configureLogger()
    client = s7con(assist.get_config())
    print(client.readBit(951, 5))
    client.setBit(951, 0)
    print(client.readBit(951, 0))
    client.writeInt(951, 0, 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256)
    print(client.readInt(951, 0))
    client.closeConnection()
    exit
    lights = Snap7Light(assist.get_config())
    print(lights.getStatus("Wohnzimmer", "decke"))
    try:
        lights.turnOff("Wohnzimmer2", "decke")
    except Exception as err:
        pass
    print(lights.getStatus("Wohnzimmer", "decke"))
    lights.turnOn("Wohnzimmer", "decke")
    print(lights.getStatus("schlafzimmer", "alle"))
    s7con().closeConnection()
Exemple #27
0
#       "If you have to enter a point you can use the keyboard "
#       "(typing \"(0, 0)\", for example) but it is often easier to "
#       "use the mouse, clicking on the output view.")
#       #"If you want to contribute to the project try: menu \"Help\" "
#       #"--> \"How to contribute...\"")
#main_help = \
#  Mode("Main help",
#       tooltip="Get general help about this button bar",
#       button=Button("Help", "help.png"),
#       enter_actions=HelpAct(msg))

main_mode = \
  Mode("Main", submodes=[exit, color, gradient, style, poly, curve,
                         circle, line, text])

if __name__ == "__main__":
    import sys

    from assistant import Assistant
    assistant = Assistant(main_mode)
    assistant.start()

    while True:
        sys.stdout.write(assistant.get_available_mode_names() + '\n')
        sys.stdout.write("Select mode (or write esc):")
        new_mode = raw_input()
        if new_mode.strip().lower() == "esc":
            assistant.exit_mode()
        else:
            assistant.choose(new_mode)
Exemple #28
0
    target = wordnet.synsets(word)

    for synonyms in target:
        new_list = [str(x) for x in synonyms.lemma_names()]

        if any(i in new_list for i in verblist):
            return True

    return False


if __name__ == '__main__':
    use_speech = False
    nlp_debug = False

    jarvis = Assistant(use_speech)

    jarvis.say('I have been fully loaded')

    input = ''

    while (input != 'Goodbye JARVIS'):
        try:
            input = jarvis.get_input()

            if not input == '':
                words = nltk.word_tokenize(input)
                tagged = nltk.pos_tag(words)

                verbs = []
                proper_nouns = []
import sys

from assistant import Assistant

assistant = Assistant()

while True:
    print('Press ENTER to start a conversation, Ctrl+C to terminate')

    try:
        sys.stdin.readline()
    except KeyboardInterrupt:
        print('\nExiting the assistant')
        break

    interactions = assistant.start_conversation()
    print(interactions)
    assistant.stop_conversation()
Exemple #30
0
from flask import Flask, jsonify, request
from assistant import Assistant
from shop_searcher import ShopSearcher

app = Flask(__name__)
assistant = Assistant(update_shops=True)
searcher = ShopSearcher()


@app.route('/user_imprint', methods=['POST'])
def get_user_imprint():
    args = request.json
    content = args.get('content', [])
    fav_shops = args.get('fav_shops', [])
    user_imprint = assistant.form_user_imprint(content, fav_shops)
    return jsonify({'user_imprint': user_imprint.tolist()})


@app.route('/recommendation', methods=['POST'])
def get_recommendations():
    args = request.json
    user_imprint = args.get('user_imprint')
    banned_shops = args.get('banned_shops', [])
    count = args.get('count', 3)

    items = assistant.make_recommendation(user_imprint, banned_shops, count)
    return jsonify({'items': items})


@app.route('/search', methods=['POST'])
def get_serp():
Exemple #31
0
#!/usr/bin/python
# -*- coding: latin-1 -*-
import sys
from assistant import Assistant

# If method call defined on launch, call. 'startx' = listen for commands from telegram
# @todo allow for all responders to execute concurrently depending on settings.
# Start assistant with telegram
if len(sys.argv) == 2 and sys.argv[1] == 'startx':  # pragma: no cover
    bot = Assistant(mode='telegram')
    bot.listen()
# Start with audio responder
elif len(sys.argv) == 2 and sys.argv[1] == 'audio':
    bot = Assistant(mode='audio')
    bot.listen()
# Start with console responder
elif (len(sys.argv) == 1 and 'unittest' not in sys.argv[0]) or (len(sys.argv) == 2 and sys.argv[1] != 'discover'):  # pragma: no cover
    bot = Assistant(mode='console')
    bot.listen()

Exemple #32
0
 def __init__(self, name: str, delay: int, zone_id: str, is_muted: bool,
              path_to_repo: str):
     Assistant.__init__(self, name, delay, zone_id, is_muted)
     self.path_to_repo: str = path_to_repo
     self.BRANCH_CLEAN: str = 'branch clean'
     self.BRANCH_DIRTY: str = 'branch dirty'
Exemple #33
0
	time.sleep(10)
	megan.speake('Esta función se encuentra en implementación')


def run(det, megan):
	megan.speake(megan.say_hi() + ';' + megan.say_my_name()) 
	det.initialize(cam_number=0)
	inp = megan.main_menu()
	time.sleep(10)
	if inp == '1':
		emergency(det, megan.language)
	if inp == '2':
		detection()
	if inp == '3':
		amplification()
	if inp == '4':
		gps()
	time.sleep(10)
	megan.speake('Regresando al menú principal')
	time.sleep(10)
	run(det, megan)

if __name__ == '__main__':
	lang = get_lang()
	megan = Assistant(name='Megan', user_name='Luis', language=lang)
	det = Detector(
		"models/yolo-tiny.h5", 
		"output/", language=lang, 
		translator=megan.translator)
	run(det, megan)