Esempio n. 1
0
def main():
    logging.info("Generating sample images...")

    app = create_app(ProdConfig)

    for template in app.template_service.all():
        app.image_service.create(template, template.sample_text)
Esempio n. 2
0
def run(loop=True):
    logging.info("Generating sample images...")

    app = create_app(ProdConfig)

    for template in app.template_service.all():
        app.image_service.create(template, template.sample_text)
Esempio n. 3
0
def main():
    logging.info("Generating sample images...")

    app = create_app(ProdConfig)

    with app.app_context():

        for template in app.template_service.all():
            app.image_service.create(template, template.sample_text)
            MemeModel(key=template.key).save()
Esempio n. 4
0
def main():
    logging.info("Generating sample images...")

    app = create_app(ProdConfig)

    with app.app_context():

        for template in app.template_service.all():
            app.image_service.create(template, Text("_"))
            app.image_service.create(template, Text("_/_"))
            app.image_service.create(template, template.sample_text)
Esempio n. 5
0
    def test_prod(self):
        _app = app.create_app(settings.ProdConfig)

        assert False is _app.config["DEBUG"]
        assert False is _app.config["TESTING"]
Esempio n. 6
0
    def test_dev(self):
        _app = app.create_app(settings.DevConfig)

        assert True is _app.config["DEBUG"]
        assert False is _app.config["TESTING"]
Esempio n. 7
0
    def test_test(self):
        _app = app.create_app(settings.TestConfig)

        assert True is _app.config["DEBUG"]
        assert True is _app.config["TESTING"]
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Esempio n. 9
0
def app():
    app = create_app(get_config('test'))
    yield app
Esempio n. 10
0
            log.info("Engery threshold: %s", self.recognizer.energy_threshold)

    def listen(self):
        log.info("Listening for audio...")
        audio = None
        with self.microphone as source:
            try:
                audio = self.recognizer.listen(source, timeout=0.5)
            except speech_recognition.WaitTimeoutError:
                log.debug("No audio detected")
            else:
                log.debug("Audio detected: %s", audio)
        return audio

    def recognize(self, audio):
        log.info("Recognizing speech...")
        speech = None
        try:
            speech = self.recognizer.recognize_google(audio)
        except speech_recognition.UnknownValueError:
            log.warning("No speech detected")
        else:
            log.debug("Detected speech: %s", speech)
        return speech


if __name__ == '__main__':
    api = create_app(ProdConfig)
    with api.app_context():
        Application(api)
Esempio n. 11
0
def app():
    return create_app(get_config('test'))
Esempio n. 12
0
    def test_prod(self):
        _app = app.create_app(settings.ProdConfig)

        assert False is _app.config['DEBUG']
        assert False is _app.config['TESTING']
Esempio n. 13
0
    def test_dev(self):
        _app = app.create_app(settings.DevConfig)

        assert True is _app.config['DEBUG']
        assert False is _app.config['TESTING']
Esempio n. 14
0
    def test_test(self):
        _app = app.create_app(settings.TestConfig)

        assert True is _app.config['DEBUG']
        assert True is _app.config['TESTING']
Esempio n. 15
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Esempio n. 16
0
 def test_dev(self):
     dev_app = app.create_app(settings.DevConfig)
     assert True is dev_app.config["DEBUG"]
Esempio n. 17
0
def app():
    app = create_app(get_config('test'))
    yield app
Esempio n. 18
0
    def run(self):
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_CONFIG', 'dev'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(host='0.0.0.0', extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
Esempio n. 19
0
 def test_dev(self):
     dev_app = app.create_app(settings.DevConfig)
     assert True is dev_app.config['DEBUG']
Esempio n. 20
0
 def app():
     app = create_app(get_config("test"))
     app.config["GOOGLE_ANALYTICS_TID"] = "my_tid"
     return app
Esempio n. 21
0
            log.info("Engery threshold: %s", self.recognizer.energy_threshold)

    def listen(self):
        log.info("Listening for audio...")
        audio = None
        with self.microphone as source:
            try:
                audio = self.recognizer.listen(source, timeout=0.5)
            except speech_recognition.WaitTimeoutError:
                log.debug("No audio detected")
            else:
                log.debug("Audio detected: %s", audio)
        return audio

    def recognize(self, audio):
        log.info("Recognizing speech...")
        speech = None
        try:
            speech = self.recognizer.recognize_google(audio)
        except speech_recognition.UnknownValueError:
            log.warning("No speech detected")
        else:
            log.debug("Detected speech: %s", speech)
        return speech


if __name__ == '__main__':
    api = create_app(ProdConfig)
    with api.app_context():
        Application(api)
Esempio n. 22
0
import subprocess
import logging

from flask_script import Manager, Server
from flask_migrate import Migrate, MigrateCommand
from whitenoise import WhiteNoise

from memegen.settings import get_config
from memegen.app import create_app


# Select app configuration from the environment
config = get_config(os.getenv('CONFIG', 'dev'))

# Build the app using configuration from the environment
_app = create_app(config)

# Populate unset environment variables
for name, command in [
    ('DEPLOY_DATE', "TZ=America/Detroit date '+%F %T'"),
]:
    output = subprocess.run(command, shell=True, stdout=subprocess.PIPE,
                            universal_newlines=True).stdout.strip() or "???"
    os.environ[name] = os.getenv(name, output)

# Configure the command-line interface
manager = Manager(_app)


@manager.command
def validate():
Esempio n. 23
0
            image = Image.open(domain.path)
            old_size = image.size
            max_size = self.root.winfo_width(), self.root.winfo_height()
            ratio = min(max_size[0] / old_size[0], max_size[1] / old_size[1])
            new_size = [int(s * ratio * 0.9) for s in old_size]
            image = image.resize(new_size, Image.ANTIALIAS)
            self._image = ImageTk.PhotoImage(image)
            self.label.configure(image=self._image)

            self.clear()

        self.restart(update=True, clear=False)

    def clear(self, *_):
        self.text.delete(0, tk.END)
        self.restart()

    def restart(self, *_, update=True, clear=True):
        if update:
            if self._update_event:
                self.root.after_cancel(self._update_event)
            self._update_event = self.root.after(1000, self.update)
        if clear:
            if self._clear_event:
                self.root.after_cancel(self._clear_event)
            self._clear_event = self.root.after(5000, self.clear)


if __name__ == '__main__':
    Application(create_app(ProdConfig))
Esempio n. 24
0
def app(postgres):
    app = create_app(get_config('test'))
    app.config['SQLALCHEMY_DATABASE_URI'] = postgres.url()
    yield app