Exemple #1
0
def repl(config, user_identifier, device_identifier):
    """Starts a client REPL to communicate with a broker instance.
    """
    if config:
        CONFIG.load_from_file(config)

    with MQTTChannel() as mqtt:
        client = ReplClient(device_identifier, user_identifier, mqtt)
        client.cmdloop()
Exemple #2
0
def main(config_file, skills_dir, language, repo_url,
         **kwargs):  # pragma: no cover
    """An open-source 🤖 assistant library built for people and made to be super
    easy to setup and understand.
    """
    if os.path.isfile(config_file):
        CONFIG.load_from_file(config_file)

    # Sets default settings value if not given in args or config file
    CONFIG.set(LANGUAGE, language or CONFIG.get(LANGUAGE, 'en'))
    CONFIG.set(SKILLS_DIR, skills_dir or CONFIG.get(SKILLS_DIR, os.getcwd()))
    CONFIG.set(REPO_URL, repo_url
               or CONFIG.get(REPO_URL, 'https://github.com/'))

    install_logs(CONFIG.get(VERBOSE), CONFIG.get(DEBUG))
Exemple #3
0
def serve(data_dir, default):
    """Starts the server.
    """
    agents_factory = FromFile(data_dir, default)

    # Let's load the configuration and load the skills
    CONFIG.load_from_file(agents_factory._default_conf_path)  # pylint: disable=protected-access
    import_skills(CONFIG.getpath(SKILLS_DIR, os.path.join(data_dir, 'skills')),
                  CONFIG.getbool(WATCH))

    server = Server(agents_factory)

    with MQTTChannel() as mqtt:
        mqtt.attach(server)
        input('Press any key, anytime to stop the broker')
Exemple #4
0
 def setup(self):
     CONFIG.load_from_file(
         os.path.join(os.path.dirname(__file__),
                      '../../__settings/default/pytlas.ini'))
https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

import os
from datetime import timedelta
from pytlas.cli import DEBUG
from pytlas.settings import CONFIG

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Read the configuration file
CONFIG.load_from_file(os.path.join(BASE_DIR, 'pytlas.ini'))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = CONFIG.get('secret', section='web')

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = CONFIG.getbool(DEBUG, section='web') # Must be set to an empty string to turn it off

ALLOWED_HOSTS = [CONFIG.get('allowed_host', '*', section='web')]

CORS_ORIGIN_ALLOW_ALL = True # Since the API is exposed to anyone

# Application definition