class Core(object): """""" pygame = None simulation = None event_manager = None statistics = None player_configuration = None configuration = None # hardcode pour test ask_draw_roads = False def start(self): self.configuration = Configuration() self.initialize_pygame() self.initialyze_event_manager() self.statistics = Statistics() self.initialyze_simulation() self.player_configuration = PlayerWindow(self) self.player_configuration.start() run_simulation = True try: while run_simulation: run_simulation = self.event_manager.listenAndPropagate() self.simulation.runCycle() except KeyboardInterrupt: pass self.player_configuration._Thread__stop() def initialize_pygame(self): self.pygame = Pygame() def initialyze_event_manager(self): self.event_manager = EventManager(self) def initialyze_simulation(self): self.simulation = SimulationManager(self) def updateDisplay(self): self.pygame.display_update() def updateConfiguration(self, player_configurations): for key in player_configurations: self.configuration.setConfiguration(self.configuration.CONFIGURATION_AND_PLAYER_WINDOW_RELATIONS[key], player_configurations[key]) self.simulation.restriction.updateRestrictions() # hardcode pour tests def drawAllRoads(self): if 'PlantPiecesRoad' in self.simulation.trace_zones: for trace_zone in self.simulation.trace_zones['PlantPiecesRoad']: for coordonate in trace_zone.coordonates: self.pygame.draw_circle((130, 130, 130), coordonate, trace_zone.width, 0)
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 __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 start(self): self.configuration = Configuration() self.initialize_pygame() self.initialyze_event_manager() self.statistics = Statistics() self.initialyze_simulation() self.player_configuration = PlayerWindow(self) self.player_configuration.start() run_simulation = True try: while run_simulation: run_simulation = self.event_manager.listenAndPropagate() self.simulation.runCycle() except KeyboardInterrupt: pass self.player_configuration._Thread__stop()
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")):
from config.Configuration import Configuration import logging from influx_db.subscriber import InfluxDBSubscriber logging.basicConfig(filename='postbox_influxdb.log', level=logging.DEBUG, datefmt='%Y-%m-%d %H:%M:%S', format='%(asctime)-15s - [%(levelname)s] %(module)s: %(message)s', ) config = Configuration() event_handler = InfluxDBSubscriber( 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"))) event_handler.subscribe()
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()
from config.Configuration import Configuration import logging from mail.subscriber import MailSubscriber logging.basicConfig( filename='postbox_mail.log', level=logging.DEBUG, datefmt='%Y-%m-%d %H:%M:%S', format='%(asctime)-15s - [%(levelname)s] %(module)s: %(message)s', ) config = Configuration() event_handler = MailSubscriber(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"))) event_handler.subscribe()
''' Created on 06/01/2013 @author: fernando ''' import sys, os sys.path.insert(0, os.path.realpath(os.path.join(os.getcwd(), "..", ".."))) from config.Configuration import Configuration config = Configuration.getInstance() f = config.load("config.ini") opt = config.getOption("dir") print opt.getValue(), "(", type(opt.getValue()), ")" opt = config.getOption("foodir") print opt.getValue(), "(", type(opt.getValue()), ")" sect = config.getSection("teste2").getSection("teste") if sect: opt = sect.getOption("galera") print opt.getValue(), "(", type(opt.getValue()), ")" opt = sect.getOption("risos") print opt.getValue(), "(", type(opt.getValue()), ")" print config.getPath("teste/risos").getValue() print f.toDict(True, True, True)