-
Notifications
You must be signed in to change notification settings - Fork 0
/
teletext.py
63 lines (46 loc) · 1.54 KB
/
teletext.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
teletext.py
MIT License (c) Faure Systems <dev at faure dot systems>
Displays message received from MQTT server in fullscreen on main monitor and play a sound.
To switch MQTT broker, kill the program and start again with new arguments.
Use -d option to start in windowed mode instead of fullscreen.
usage: python3 teletext.py [-h] [-s SERVER] [-p PORT] [-d] [-l LOGGER]
optional arguments:
-h, --help show this help message and exit
-s SERVER, --server SERVER
change MQTT server host
-p PORT, --port PORT change MQTT server port
-d, --debug set DEBUG log level
-l LOGGER, --logger LOGGER
use logging config file
To switch MQTT broker, kill the program and start again with new arguments.
"""
import paho.mqtt.client as mqtt
import os, sys, uuid
from constants import *
from TeletextApp import TeletextApp
from Singleton import Singleton, SingletonException
me = None
try:
me = Singleton()
except SingletonException:
sys.exit(-1)
except BaseException as e:
print(e)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# translation
import gettext
try:
gettext.find(APPLICATION)
traduction = gettext.translation(APPLICATION, localedir='locale', languages=['fr'])
traduction.install()
except:
_ = gettext.gettext # cool, this hides PyLint warning Undefined name '_'
mqtt_client = mqtt.Client(uuid.uuid4().urn, clean_session=True, userdata=None)
app = TeletextApp(sys.argv, mqtt_client, debugging_mqtt=False)
# guizero event loop
app.loop()
del me
sys.exit(0)