Exemple #1
0
 def __init__(self, name, emitter=None):
     self.name = name
     self.bind(emitter)
     self.config = config
     self.dialog_renderer = None
     self.file_system = FileSystemAccess(join('skills', name))
     self.registered_intents = []
     self.log = getLogger(name)
Exemple #2
0
from onyx.skills.core import OnyxSkill

config = get_config('onyx')

global ws

import threading
from threading import Thread

from onyx.sockyx.client.ws import WebsocketClient
from onyx.sockyx.message import Message

skills = OnyxSkill(name="cli")

json = Json()
LOG = getLogger('Client')

def handle_speak(event):
    utterance = event.data.get('utterance')
    print(">> " + utterance)

def handle_finish(event):
    print("Finish")

def connect():
    # Once the websocket has connected, just watch it for speak events
    ws.run_forever()

ws = WebsocketClient()
ws.on('speak', handle_speak)
ws.on('finish', handle_finish)
Exemple #3
0
# -*- coding: utf-8 -*-
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Machine')
json = Json()

"""
    Allows to manage the different instances of Onyx

    Permet de gérer les différentes instances d'Onyx
"""
class Machine:

    def __init__(self):
        self.id = None
        self.name = None
        self.house = None
        self.room = None
        self.host = None
Exemple #4
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

from adapt.engine import IntentDeterminationEngine

from onyx.messagebus.message import Message
from onyx.skills.core import open_intent_envelope
from onyx.util.log import getLogger
from onyx.util.parse import normalize

__author__ = 'seanfitz'

logger = getLogger(__name__)


class IntentService(object):
    def __init__(self, emitter):
        self.engine = IntentDeterminationEngine()
        self.emitter = emitter
        self.emitter.on('register_vocab', self.handle_register_vocab)
        self.emitter.on('register_intent', self.handle_register_intent)
        self.emitter.on('recognizer_loop:utterance', self.handle_utterance)
        self.emitter.on('detach_intent', self.handle_detach_intent)
        self.emitter.on('detach_skill', self.handle_detach_skill)

    def handle_utterance(self, message):
        # Get language of the utterance
        lang = message.data.get('lang', None)
Exemple #5
0
# -*- coding: utf-8 -*-
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Room')
json = Json()

"""
    This class allows to manage the rooms of the house

    Cette classe permet de gérér les pièces de la maison
"""
class Room:

    def __init__(self):
        self.id = None
        self.name = None
        self.house = None

    """
Exemple #6
0
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

import importlib, os, onyx
from flask import current_app as app, g
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.skills.core import *
from onyx.config import get_config
from onyx.util.log import getLogger

logger = getLogger('Action')
json = Json()
config = get_config('onyx')
"""
    This class handles the possible actions of Onyx and is used by the scenario system

    Cette classe s'occupe de gérer les actions possible d'Onyx et est couplé avec le système de scénario
"""


class Action:
    def __init__(self):
        self.app = app
        self.id = None
        self.url = None
        self.param = None
Exemple #7
0
"""
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from flask_login import current_user
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Notification')
json = Json()

"""
    Manages the notification part of Onyx

    Gère la partie notification d'Onyx
"""
class Notification:

    def __init__(self):
        self.id = None
        self.text = None
        self.link = None
        self.priority = 0
        self.is_read = 0
Exemple #8
0
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

import socket
import subprocess
import tempfile

import os
import os.path
import psutil
from os.path import dirname
from onyx.util.log import getLogger
from onyx.config import get_config

LOGGER = getLogger(__name__)
config = get_config('onyx')


def play_wav(uri):
    play_cmd = config.get("Sound", "wav")
    play_wav_cmd = str(play_cmd).split(" ")
    for index, cmd in enumerate(play_wav_cmd):
        if cmd == "#1":
            play_wav_cmd[index] = (get_http(uri))
    return subprocess.Popen(play_wav_cmd)


def play_mp3(uri):
    play_cmd = config.get("Sound", "mp3")
    play_mp3_cmd = str(play_cmd).split(" ")
Exemple #9
0
# -*- coding: utf-8 -*-
"""
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Geolocalisation')
json = Json()
"""
    This class allows you to retrieve the different information on geolocation

    Cette classe permet de récupérer les différentes informations sur la géolocalisation
"""


class Geolocalisation:
    def __init__(self):
        self.latitude = None
        self.longitude = None

    """
        This function gets latitude and longitude

        Cette fonction récupère la latitude et la longitude
Exemple #10
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.api.assets import Json
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.action import *
from flask import g, current_app as app
import os, onyx
from onyx.api.exceptions import *
from onyx.config import get_config
from onyx.util.log import getLogger

logger = getLogger('Event')
action = Action()
json = Json()
config = get_config('onyx')
"""
    This class allows to manage the event part of Onyx

    Cette classe permet de gérer la partie évenement d'Onyx
"""


class Event:
    def init(self):
        self.app = app
        self.id = None
        self.code = None
Exemple #11
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.api.assets import Json
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.action import *
from flask import g, current_app as app
import os, onyx
from onyx.api.exceptions import *
from onyx.config import get_config
from onyx.util.log import getLogger

logger = getLogger('Event')
action = Action()
json = Json()
config = get_config('onyx')

"""
    This class allows to manage the event part of Onyx

    Cette classe permet de gérer la partie évenement d'Onyx
"""
class Event:

    def init(self):
        self.app = app
        self.id = None
        self.code = None
Exemple #12
0
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

import pystache
import os
import random
import codecs
from onyx.util import log

__author__ = 'seanfitz'
logger = log.getLogger(__name__)

__doc__ = """

"""

class MustacheDialogRenderer(object):
    """
    A dialog template renderer based on the mustache templating language.
    """
    def __init__(self):
        self.templates = {}

    def load_template_file(self, template_name, filename):
        """
        Load a template by file name into the templates cache.
Exemple #13
0
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

from flask_login import current_user
from time import strftime
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Calendar')
json = Json()

"""
    This class allows to manage the Calendar and the Events in Onyx

    Cette classe permet de gérer le Calendrier et les Evenements dans Onyx
"""
class Calendar:

    def __init__(self):
        self.user = None
        self.id = None
        self.title = 'Undefined'
        self.notes = 'Undefined'
        self.lieu = 'Home'
Exemple #14
0
# -*- coding: utf-8 -*-
"""
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import RoomModel
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import RoomException
from onyx.util.log import getLogger

logger = getLogger('Room')
json = Json()
"""
    This class allows to manage the rooms of the house

    Cette classe permet de gérér les pièces de la maison
"""


class Room:
    def __init__(self):
        self.id = None
        self.name = None
        self.house = None

    """
Exemple #15
0
# -*- coding: utf-8 -*-
"""
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('House')
json = Json()
"""
    This class allows to manage the house of the user

    Cette classe permet de gérer le domicile de l'utilisateur
"""


class House:
    def __init__(self):
        self.id = None
        self.name = None
        self.address = None
        self.city = None
        self.postal = None
Exemple #16
0
from flask import json
from flask_script import Manager, Command, Option
from flask_migrate import Migrate, MigrateCommand
from onyx.extensions import db
from onyx.api.server import *
from onyx.app_config import *
from onyx.util.log import getLogger
from onyx import *

app = create_app()

migrate = Migrate(app, db)
manager = Manager(app, with_default_commands=False)
server = Server()

LOG = getLogger(__name__)

class Run(Command):

    option_list = (
        Option('--host', '-h', dest='host', default="0.0.0.0"),
        Option('--port', '-p', dest='port', default=8080),
        Option('--debug', '-d', dest='debug', default=False, action="store_true"),
        Option('--reload', '-r', dest='reload', default=False, action="store_true")
    )

    def run(self, host='0.0.0.0', port=8080, debug=False, reload=False):
        self.runserver(host, port, debug, reload)

    def runserver(self, host, port, debug, reload):
        print(' _____   __   _  __    __ __    __ ')
Exemple #17
0
@author :: Cassim Khouani
"""
import onyx
from flask import current_app as app

from onyx.api.assets import Json
from onyx.util.log import getLogger
from onyx.api.exceptions import *
from onyx.config import get_config

from onyx.skills.core import *

#from chatterbot import ChatBot
#from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer

LOG = getLogger('Kernel')
config = get_config('onyx')
json = Json()
"""
class Kernel:

    def __init__(self):
        self.kernel = self.set()
        self.app = app
        self.id = None
        self.text = None
        self.label = None
        self.kwargs = None
        self.url = None
        self.type_event = None
Exemple #18
0
from onyx.util.log import getLogger
from onyx.api.exceptions import *
from onyx.config import get_config

from onyx.skills.core import *

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer, ListTrainer


from onyx.messagebus.client.ws import WebsocketClient
from onyx.messagebus.message import Message

from onyx import *

LOG = getLogger('Kernel')
config = get_config('onyx')
json = Json()

class Kernel:

    def __init__(self):
        self.kernel = self.set()
        self.app = app
        self.id = None
        self.text = None
        self.label = None
        self.kwargs = None
        self.url = None
        self.type_event = None
Exemple #19
0
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
import os
from onyx.util.log import getLogger
from flask import request, render_template, redirect, url_for, flash
from onyxbabel import gettext
from onyx.api.assets import Json
from onyx.api.exceptions import *
from bs4 import BeautifulSoup
try:
	import urllib.request
except ImportError:
	import urllib

logger = getLogger('Transport')
json = Json()

"""
	Get information of RATP service

	Informations sur les différents services de la RATP
"""
class Ratp:

	def __init__(self):
		self.url = None
		self.line = None
		self.station = None
		self.direction = None
Exemple #20
0
# -*- coding: utf-8 -*-
"""
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.util.lang.format_common import convert_to_mixed_fraction
from onyx.util.log import getLogger
from onyx.util.lang.common_data_en import _NUM_STRING_EN, \
    _FRACTION_STRING_EN, _LONG_SCALE_EN, _SHORT_SCALE_EN

LOG = getLogger(__name__)


def nice_number_en(number, speech, denominators=range(1, 21)):
    """ English helper for nice_number

    This function formats a float to human understandable functions. Like
    4.5 becomes "4 and a half" for speech and "4 1/2" for text

    Args:
        number (int or float): the float to format
        speech (bool): format for speech (True) or display (False)
        denominators (iter of ints): denominators to use, default [1 .. 20]
    Returns:
        (str): The formatted string.
    """
Exemple #21
0
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from flask_login import current_user
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Notification')
json = Json()

"""
    Manages the notification part of Onyx

    Gère la partie notification d'Onyx
"""
class Notification:

    def __init__(self):
        self.id = None
        self.text = None
        self.link = None
        self.priority = 0
        self.is_read = 0
Exemple #22
0
from shutil import copyfile
from subprocess import Popen, PIPE
from threading import Thread
from time import sleep

from pyric import pyw
from wifi import Cell

from onyx.sockyx.client.ws import WebsocketClient
from onyx.sockyx.message import Message
from onyx.util import connected
from onyx.util.log import getLogger

__author__ = 'aatchison and penrods'

LOG = getLogger("WiFiClient")

SCRIPT_DIR = dirname(realpath(__file__))


def cli_no_output(*args):
    ''' Invoke a command line and return result '''
    LOG.info("Command: %s" % list(args))
    proc = Popen(args=args, stdout=PIPE, stderr=PIPE)
    stdout, stderr = proc.communicate()
    return {'code': proc.returncode, 'stdout': stdout, 'stderr': stderr}


def cli(*args):
    ''' Invoke a command line, then log and return result '''
    LOG.info("Command: %s" % list(args))
Exemple #23
0
from onyx.extensions import db, login_manager
from onyx.api.assets import Json
from onyx.api.navbar import *
from onyx.api.exceptions import *
from onyx.api.events import *
from onyx.util.log import getLogger
from flask_jwt_extended import (create_access_token, create_refresh_token,
                                jwt_required, jwt_refresh_token_required,
                                get_jwt_identity, get_raw_jwt)
from passlib.hash import sha256_crypt
import onyx
import datetime

event = Event()
navbars = Navbar()
logger = getLogger('User')
json = Json()


class User:
    def __init__(self):
        self.id = None
        self.username = None
        self.password = None
        self.verifpassword = None
        self.lastpassword = None
        self.email = None
        self.admin = None
        self.tutorial = 0
        self.background_color = '#efefef'
        self.color = 'indigo darken-1'
Exemple #24
0
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from flask.ext.login import current_user
from onyxbabel import gettext
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.exceptions import *
from onyx.api.assets import Json
from onyx.config import get_config , get_path
from flask import current_app as app
from onyxbabel import refresh
from onyx.util.log import getLogger

logger = getLogger('Options')
json = Json()

"""
    Cette class can change option of Onyx

    Cette classe permet de gérer les options d'Onyx
"""
class Options:

    def __init__(self):
        self.user = None
        self.color = None
        self.background = '#efefef'
        self.lang = 'en-US'
Exemple #25
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from flask import current_app as app
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.exceptions import *
from onyx.api.assets import Json
from onyx.util.log import getLogger
from onyx.config import get_config
import onyx

json = Json()
logger = getLogger('Scenario')

config = get_config('onyx')


class Scenario:
    def __init__(self):
        self.id = None
        self.template = None
        self.name = None
        self.house = None
        self.user = None
        self.event = None
        self.action = None
        self.action_param = None
        self.plugin_name = None
Exemple #26
0
from onyx.skills.core import OnyxSkill

config = get_config('onyx')

global ws

import threading
from threading import Thread

from onyx.messagebus.client.ws import WebsocketClient
from onyx.messagebus.message import Message

skills = OnyxSkill(name="cli")

json = Json()
LOG = getLogger('CliClient')

def handle_speak(event):
    utterance = event.data.get('utterance')
    print(">> " + utterance)

def handle_finish(event):
    print("Finish")

def connect():
    # Once the websocket has connected, just watch it for speak events
    ws.run_forever()

ws = WebsocketClient()
ws.on('speak', handle_speak)
ws.on('finish', handle_finish)
Exemple #27
0
config = get_config('onyx')

import threading
from threading import Thread

from onyx.sockyx.client.ws import WebsocketClient
from onyx.sockyx.message import Message

skills = OnyxSkill(name="speech")

stt = STTFactory.create()
tts = TTSFactory.create()

json = Json()
LOG = getLogger('SpeechClient')
import speech_recognition as sr


class Detector:

	def __init__(self):
		self.lang = config.get('Base', 'lang')

	def detected_callback(self):

		def create_ws_detect():
				def onConnected(event=None):
					ws.emit(Message('onyx_detect'))
					t.close()
Exemple #28
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

from onyx.extensions import db
from onyx.core.models import *
from onyx.api.assets import Json
from onyx.api.exceptions import *
#from onyx.api.kernel import Kernel
from onyx.util.log import getLogger
from passlib.hash import sha256_crypt
import git, onyx

logger = getLogger('Install')
json = Json()
#kernel = Kernel()
"""
    Make the Onyx installation done

    Classe qui fait l'installation d'Onyx
"""


class Install:
    def __init__(self):
        self.password = None
        self.username = None
        self.email = None
Exemple #29
0
from onyx.config import get_config
from onyx.api.assets import Json
from onyx.api.server import *
from onyx.util.log import getLogger
from onyx.skills.core import *
import threading

#from onyx.api.kernel import Kernel

from onyx.sockyx.client.ws import WebsocketClient
from onyx.sockyx.message import Message

from onyx.core.models import ConfigModel, RevokedTokenModel

server = Server()
LOG = getLogger("App")
json = Json()
#kernel = Kernel()

to_reload = False

from onyx.app_config import ProdConfig, Config

__all__ = ('create_app', 'create_db', 'blueprints_fabrics', 'get_blueprints',
           'error_pages', 'ws', 'AppReloader')


class AppReloader(object):
    def __init__(self, create):
        self.create = create
        self.app = create()
Exemple #30
0
@author :: Cassim Khouani
"""

from onyxbabel import gettext as _
from flask.ext.login import login_user, current_user, LoginManager
from onyx.extensions import db, login_manager
from onyx.core.models import *
from onyx.api.install import *
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.api.kernel import *
import git, pip, onyx, os, hashlib
from onyx.util.log import getLogger
from git import Repo

logger = getLogger('Install')
json = Json()
kernel = Kernel()

"""
    Make the Onyx installation done

    Classe qui fait l'installation d'Onyx
"""
class Install:

    def __init__(self):
        self.password = None
        self.username = None
        self.email = None
Exemple #31
0
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger
from flask_jwt_extended import create_access_token

import datetime

logger = getLogger('Token')
json = Json()


class Token:
    def __init__(self):
        self.id = None
        self.user = None
        self.name = None
        self.token = None

    def get(self):
        try:
            query = TokenModel.Token.query.all()
            tokens = []
            for fetch in query:
Exemple #32
0
import json
import os
import subprocess
import sys
import time
from os.path import exists, join
from threading import Timer

from onyx.sockyx.client.ws import WebsocketClient
from onyx.sockyx.message import Message
from onyx.skills.core import load_skill, create_skill_descriptor, MainModule, SKILLS_DIR
from onyx.skills.intent_service import IntentService
from onyx.util import connected
from onyx.util.log import getLogger

logger = getLogger("Skills")

ws = None
loaded_skills = {}
last_modified_skill = 0
skills_directories = []
skill_reload_thread = None
skills_manager_timer = None


def connect():
    global ws
    ws.run_forever()


def _load_skills():
Exemple #33
0
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from flask_login import current_user
from onyx.core.models import UsersModel, ConfigModel
from onyx.extensions import db
from onyx.api.exceptions import *
from onyx.api.assets import Json
from onyx.config import get_config, get_path
from onyxbabel import refresh
from onyx.util.log import getLogger

logger = getLogger('Options')
json = Json()
"""
    Cette class can change option of Onyx

    Cette classe permet de gérer les options d'Onyx
"""


class Options:
    def __init__(self):
        self.user = None
        self.color = None
        self.background = '#efefef'
        self.lang = 'en-US'
Exemple #34
0
from onyx.skills.media import MediaSkill
from adapt.intent import IntentBuilder
from onyx.messagebus.message import Message

import time
import threading

import requests

from onyx.util.log import getLogger

sys.path.append(abspath(dirname(__file__)))
Mopidy = __import__('mopidypost').Mopidy

logger = getLogger(abspath(__file__).split('/')[-2])
__author__ = 'forslund'


class MopidySkill(MediaSkill):
    def __init__(self):
        super(MopidySkill, self).__init__('Mopidy Skill')
        self.volume_is_low = False

    def at_run(self):
        def launch_mopidy():
            os.system('mopidy')

        t = threading.Thread(target=launch_mopidy)
        t.start()
Exemple #35
0
# -*- coding: utf-8 -*-
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('Geolocalisation')
json = Json()

"""
    This class allows you to retrieve the different information on geolocation

    Cette classe permet de récupérer les différentes informations sur la géolocalisation
"""
class Geolocalisation:

    def __init__(self):
        self.latitude = None
        self.longitude = None

    """
        This function gets latitude and longitude

        Cette fonction récupère la latitude et la longitude
Exemple #36
0
from adapt.intent import IntentBuilder
from os.path import join, dirname

from onyx.config import get_config
from onyx.messagebus.message import Message
from onyx.skills.core import OnyxSkill
from onyx.util.log import getLogger

logger = getLogger(__name__)

__author__ = 'forslund'


class MediaSkill(OnyxSkill):
    """
        The MediaSkill class is a base class for media skills containing
        vocabulary and intents for the common functions expected by a media
        skill. In addition event handlers to lower volume when onyx starts
        to speak and raise it again when (s)he stops.

        But wait there is one more thing! A small event emitter and matching
        handler to stop media currently playing when new media is started.
    """
    def __init__(self, name):
        super(MediaSkill, self).__init__(name)
        self.isPlaying = False
        config = get_config('onyx')
        self.base_conf = config

    def initialize(self):
        logger.info('Initializing MediaSkill commons')
Exemple #37
0
Onyx Project
https://onyxlabs.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.util.log import getLogger
from onyx.api.assets import Json
from onyx.api.exceptions import *
try:
    import urllib.request
except ImportError:
    import urllib

logger = getLogger('Transport')
json = Json()
"""
	Get information of RATP service

	Informations sur les différents services de la RATP
"""


class Ratp:
    def __init__(self):
        self.url = None
        self.line = None
        self.station = None
        self.direction = None
Exemple #38
0
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from flask_login import current_user
from flask import current_app as app
from onyx.core.models import *
from onyxbabel import gettext
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.extensions import db
import onyx
from onyx.util.log import getLogger

logger = getLogger('Navbar')
json = Json()
"""
    This class handles the user's navbar

    Cette classe gère la barre de navigation de l'utilisateur
"""


class Navbar:
    def __init__(self):
        self.user = None
        self.id = None
        self.fa = None
        self.url = None
        self.pourcentage = None
Exemple #39
0
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""

import importlib, os, onyx
from flask import current_app as app, g
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.skills.core import *
from onyx.config import get_config
from onyx.util.log import getLogger

logger = getLogger('Action')
json = Json()
config = get_config('onyx')

"""
    This class handles the possible actions of Onyx and is used by the scenario system

    Cette classe s'occupe de gérer les actions possible d'Onyx et est couplé avec le système de scénario
"""
class Action:

    def __init__(self):
        self.app = app
        self.id = None
        self.url = None
        self.param = None
Exemple #40
0
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
import pystache
import os
import random
import codecs
from onyx.util import log

__author__ = 'seanfitz'
logger = log.getLogger(__name__)


class MustacheDialogRenderer(object):
    """
    A dialog template renderer based on the mustache templating language.
    """
    def __init__(self):
        self.templates = {}

    def load_template_file(self, template_name, filename):
        """
        Load a template by file name into the templates cache.

        :param template_name: a unique identifier for a group of templates.
Exemple #41
0
config = get_config('onyx')

import threading
from threading import Thread

from onyx.messagebus.client.ws import WebsocketClient
from onyx.messagebus.message import Message

skills = OnyxSkill(name="speech")

stt = STTFactory.create()
tts = TTSFactory.create()

json = Json()
LOG = getLogger('SpeechClient')
import speech_recognition as sr


class Detector:

	def __init__(self):
		self.lang = config.get('Base', 'lang')

	def detected_callback(self):
		self.detector.terminate()
		play_wav(onyx.__path__[0] + "/client/speech/resources/ding.wav")

		r = sr.Recognizer()

		with sr.Microphone() as source:
Exemple #42
0
# -*- coding: utf-8 -*-
"""
Onyx Project
http://onyxproject.fr
Software under licence Creative Commons 3.0 France
http://creativecommons.org/licenses/by-nc-sa/3.0/fr/
You may not use this software for commercial purposes.
@author :: Cassim Khouani
"""
from onyx.core.models import *
from onyx.extensions import db
from onyx.api.assets import Json
from onyx.api.exceptions import *
from onyx.util.log import getLogger

logger = getLogger('House')
json = Json()

"""
    This class allows to manage the house of the user

    Cette classe permet de gérer le domicile de l'utilisateur
"""
class House:

    def __init__(self):
        self.id = None
        self.name = None
        self.address = None
        self.city = None
        self.postal = None
Exemple #43
0
from flask import request , render_template , redirect , url_for , flash, current_app as app
from onyxbabel import gettext
from onyx.core.models import *
from onyx.skills.core import *
from onyx.extensions import db, login_manager
from onyx.api.assets import Json
from onyx.api.navbar import *
from onyx.api.exceptions import *
from onyx.api.events import *
from onyx.util.log import getLogger
import hashlib
import onyx

event = Event()
navbars = Navbar()
logger = getLogger('User')
json = Json()


class User:

    def __init__(self):
        self.id = None
        self.username = None
        self.password = None
        self.verifpassword = None
        self.lastpassword = None
        self.email = None
        self.admin = None
        self.tutorial = 0
        self.background_color = '#efefef'