def __init__(self, prefix, description, config_file): super().__init__(command_prefix=prefix, description=description, pm_help=None, help_attrs=dict(hidden=True)) self.config = Configuration(config_file) self.add_command(self.ping) self.add_command(self.uptime) self.remove_command("help") self.add_command(self.help) self.add_command(self.create) self.add_command(self.select) self.add_command(self.destroy) self.add_command(self.index) self.add_command(self.join) self.add_command(self.bracket) self.start_time = 0 self.selected_tournament = "" self.session = aiohttp.ClientSession(loop=self.loop)
def on_message(client, userdata, msg): """ Defines action what to do if event receives """ #Subscriber.on_message(client, userdata, msg) logging.info((msg.topic + " " + str(msg.payload))) from config.Configuration import Configuration config = Configuration() influxdb_client = InfluxDbClient( str(config.read_config("influxdb", "host")), int(config.read_config("influxdb", "port")), str(config.read_config("influxdb", "username")), str(config.read_config("influxdb", "password")), str(config.read_config("influxdb", "database"))) influxdb_client.write_entry("postbox", { "value": msg.payload, "topic": msg.topic })
def on_message(client, userdata, msg): """ Defines action what to do if event receives """ #Subscriber.on_message(client, userdata, msg) logging.info((msg.topic + " " + str(msg.payload))) from config.Configuration import Configuration config = Configuration() mail = EmailMessage() mail['Subject'] = "Sie haben Post ..." mail['From'] = config.read_config("mail", "sender") mail['To'] = config.read_config("mail", "recipient") if config.read_config("mail", "ssl_ca") is not None: server = smtplib.SMTP_SSL( host=str(config.read_config("mail", "host")), port=int(config.read_config("mail", "port")), certfile=str(config.read_config("mail", "ssl_ca"))) else: server = smtplib.SMTP_SSL(host=str( config.read_config("mail", "host")), port=config.read_config("mail", "port")) try: server.ehlo() server.login(str(config.read_config("mail", "username")), str(config.read_config("mail", "password"))) server.send_message(mail, str(config.read_config("mail", "sender")), str(config.read_config("mail", "recipient"))) finally: server.quit()
if has_signal: has_signal = False event_handler.publish("postbox_open") logging.info("Published event to queue") publish_signal() logging.basicConfig( filename='postbox.log', level=logging.INFO, datefmt='%Y-%m-%d %H:%M:%S', format='%(asctime)-15s - [%(levelname)s] %(module)s: %(message)s', ) config = Configuration() rf_client = RfClient(config.read_config("rf", "pin")) event_handler = Publisher(str(config.read_config("mqtt", "host")), int(config.read_config("mqtt", "port")), str(config.read_config("mqtt", "topic")), str(config.read_config("mqtt", "user")), str(config.read_config("mqtt", "password")), str(config.read_config("mqtt", "ssl_ca"))) while True: result = rf_client.read() if result is not None: logging.info("Received event '%s'" % result) if config.read_config("rf", "filter") is None or result == int( config.read_config("rf", "filter")):