class Main(object): def __init__(self): print "Init Main object..." self._mainloop = MainLoop() def run(self): self._mainloop.initialize() running = True frames = 0 print "BinaryClock Main starts running..." while running: try: self._mainloop.update() except (KeyboardInterrupt): running = False del (self._mainloop) print "User aborted..." except (Exception): running = False del (self._mainloop) e = sys.exc_info() t = time n = time.ctime()[11:13] + time.ctime()[14:16] s = str(n).rjust(4) f = file(time.asctime() + ".log", 'w') for l in e: f.write(str(l))
class Main(object): def __init__(self): print "Init Main object..." self._mainloop = MainLoop() self._log = Logger.Logger('main') def run(self): self._mainloop.initialize() running = True frames = 0 while running: try: self._mainloop.update() self._mainloop.draw() print "End of Main..." except Exception as e: running = False print str(e)
class Main(object): def __init__(self): print "Init Main object..." self._mainloop = MainLoop() self._log = Logger.Logger('main') def run(self): self._mainloop.initialize() running=True frames = 0 while running: try: self._mainloop.update() self._mainloop.draw() print "End of Main..." except Exception as e: running = False print str(e)
class Main(object): def __init__(self): print "Init Main object..." self._mainloop = MainLoop() self._log = Logger.Logger('main') def run(self): self._mainloop.initialize() running=True frames = 0 while running: try: frames = frames + 1 self._log.info("Entering main-loop....") self._mainloop.update() #Not all has to be drawn if frames%3==0: self._mainloop.draw() except Exception as e: print str(e)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from Option import Option from MainLoop import MainLoop from Color import Color if __name__ == '__main__': print( Color.pink + " ____ ________ ____ __ " + Color.red + " _____ ____ \n" + Color.pink + " / __ )__ __/ __/ __/__ _____/ __ \___ _____/ /__________ __ _____ _____" + Color.red + "/ ___// __ \\\n" + Color.pink + " / __ / / / / /_/ /_/ _ \/ ___/ / / / _ \/ ___/ __/ ___/ __ \/ / / / _ \/ ___/" + Color.red + " __ \/ /_/ /\n" + Color.pink + " / /_/ / /_/ / __/ __/ __/ / / /_/ / __(__ ) /_/ / / /_/ / /_/ / __/ / " + Color.red + "/ /_/ /\__, / \n" + Color.pink + "/_____/\__,_/_/ /_/ \___/_/ /_____/\___/____/\__/_/ \____/\__, /\___/_/ " + Color.red + "\____//____/ \n" + Color.pink + " /____/ \n" + Color.reset) option = Option mainloop = MainLoop(option)
def __init__(self): print "Init Main object..." self._mainloop = MainLoop()
from threading import Thread import time from FlaskServer import run from Device import devices from MainLoop import MainLoop if __name__ == '__main__': try: mnlp = MainLoop(1) mnlp.init() p1 = Thread(name="MainLoop", target=mnlp.run) p1.start() p2 = Thread(name="RestAPI", target=run) p2.start() p1.join() p2.join() for x in devices: devices[x].exit() except: print("Other error or exception occurred!") finally: for x in devices: devices[x].exit()
def main(): loop = MainLoop() loop.gameLoop()
def __init__(self): print "Init Main object..." self._mainloop = MainLoop() self._log = Logger.Logger('main')
ledController = None denon = None try: sys.stdout.write("Welcome to JWolf's Denon controls!\n") sys.stdout.flush() ledController = LedController(Gpio_Mode, Led_Green, Led_Red) ledController.SystemStart() denon = DenonConnection(Denon_IP, Denon_Port, ledController.ErrorCode1) commands = GetCommands(denon, ledController) translateUserInputToCommands = TranslateUserInputToCommands(commands) #If there is no commandline arguments, we will start the mainloop and be in #an "interactive mode" if len(sys.argv) == 1: userI2CInput = UserI2CInput(I2C_Bus_Number, I2C_Device_Address, ledController.ErrorCode2) mainLoop = MainLoop() mainLoop.Start(userI2CInput, translateUserInputToCommands, ledController) #If there are arguments we will execute the argument and return to the #commandline in a non-blocking way else: translateUserInputToCommands.AddInput(sys.argv[1]) if translateUserInputToCommands.IsCommand(): command = translateUserInputToCommands.GetCommand() fullUserInput = translateUserInputToCommands.GetUserInputs() try: ledController.CommandExecuted() command.Execute(fullUserInput) except (KeyboardInterrupt, SystemExit): raise