def start(self, rq={'request':'play'}): print "STARTING USER PROCESSES" # Add user events #print "ADDING USER EVENTS" for key in weioUserApi.attach.events: #print weioUserApi.attach.events[key].handler weioParser.addUserEvent(weioUserApi.attach.events[key].event, weioUserApi.attach.events[key].handler) if (weioIO.gpio != None): if (weioRunnerGlobals.WEIO_SERIAL_LINKED == False): try : weioIO.gpio = weioGpio.WeioGpio() # Initialize globals for the user Tornado weioRunnerGlobals.DECLARED_PINS = weioIO.gpio.declaredPins except : print "LPC coprocessor is not present" weioIO.gpio = None # Launching threads for key in weioUserApi.attach.procs : #print key p = multiprocessing.Process(target=weioUserApi.attach.procs[key].procFnc, args=weioUserApi.attach.procs[key].procArgs) p.daemon = True # Add it to the global list of user processes self.userProcessList.append(p) # Start it p.start()
def launcher(self): print "======>>> LAUNCHING..." # Re-load user main (in case it changed) confFile = weioConfig.getConfiguration() # Get the last name of project and run it projectModule = confFile["last_opened_project"].replace("/", ".") + ".main" print "CALL", projectModule # Init GPIO object for uper communication if weioRunnerGlobals.WEIO_SERIAL_LINKED == False: try: weioIO.gpio = weioGpio.WeioGpio() # Initialize globals for the user Tornado weioRunnerGlobals.DECLARED_PINS = weioIO.gpio.declaredPins except: print "LPC coprocessor is not present" weioIO.gpio = None # Import userMain from local module try: userMain = __import__(projectModule, fromlist=[""]) except: print "MODULE CAN'T BE LOADED" result = None # Calling user setup() if present if "setup" in vars(userMain): userMain.setup() # Add user events print "ADDING USER EVENTS" for key in weioUserApi.attach.events: # print weioUserApi.attach.events[key].handler weioParser.addUserEvent(weioUserApi.attach.events[key].event, weioUserApi.attach.events[key].handler) # Launching threads for key in weioUserApi.attach.procs: # print key t = threading.Thread( target=weioUserApi.attach.procs[key].procFnc, args=weioUserApi.attach.procs[key].procArgs ) t.daemon = True # Start it t.start() # print "STARTING PROCESS PID", t.pid while True: # Get the command from userTornado (blocking) msg = self.qIn.get() print "*** GOT THE COMMAND: ", msg.req # Execute the command msg.res = None if msg.req in weioParser.weioSpells or msg.req in weioParser.weioUserSpells: if msg.req in weioParser.weioSpells: msg.res = weioParser.weioSpells[msg.req](msg.data) elif msg.req in weioParser.weioUserSpells: msg.res = weioParser.weioUserSpells[msg.req](msg.data) else: msg.res = None # Send back the result self.qOut.put(msg)
def launcher(self): #print "======>>> LAUNCHING..." # Re-load user main (in case it changed) confFile = weioConfig.getConfiguration() # Get the last name of project and run it projectModule = confFile["last_opened_project"].replace('/', '.') + ".main" #print "CALL", projectModule # Init GPIO object for uper communication if (weioRunnerGlobals.WEIO_SERIAL_LINKED == False): try : weioIO.gpio = weioGpio.WeioGpio() except: print "LPC coprocessor is not present" weioIO.gpio = None # Import userMain from local module try : userMain = __import__(projectModule, fromlist=['']) except : print "MODULE CAN'T BE LOADED. Maybe you have some errors in modules that you wish to import?" result = None # Calling user setup() if present if "setup" in vars(userMain): userMain.setup() # Add user events #print "ADDING USER EVENTS" for key in weioUserApi.attach.events: #print weioUserApi.attach.events[key].handler weioParser.addUserEvent(weioUserApi.attach.events[key].event, weioUserApi.attach.events[key].handler) # Launching threads for key in weioUserApi.attach.procs: #print key t = threading.Thread(target=weioUserApi.attach.procs[key].procFnc, args=weioUserApi.attach.procs[key].procArgs) t.daemon = True # Start it t.start() #print "STARTING PROCESS PID", t.pid weioRunnerGlobals.running = True fRunning = open('/weio/running.p', 'wb') pickle.dump(weioRunnerGlobals.running, fRunning) fRunning.close() while (True): # Get the command from userTornado (blocking) msg = self.qIn.get() #print "*** GOT THE COMMAND: ", msg.req # Execute the command msg.res = None if msg.req in weioParser.weioSpells or msg.req in weioParser.weioUserSpells: if msg.req in weioParser.weioSpells: msg.res = weioParser.weioSpells[msg.req](msg.data) elif msg.req in weioParser.weioUserSpells: msg.res = weioParser.weioUserSpells[msg.req](msg.data) else: msg.res = None # Send back the result self.qOut.put(msg)
def launcher(self): #print "======>>> LAUNCHING..." # get configuration from file confFile = weioConfig.getConfiguration() # get location of last opened project lp = confFile["last_opened_project"] # check if main.py exists in current user project if (weioFiles.checkIfFileExists(lp+"/main.py")): # set the location of current project main.py projectModule = lp.replace('/', '.') + ".main" else : # Use the location of default www/defaultMain/main.py projectModule = "www.defaultMain.main" #print "CALL", projectModule # Init GPIO object for uper communication if (weioRunnerGlobals.WEIO_SERIAL_LINKED == False): try : weioIO.gpio = weioGpio.WeioGpio() except: print "LPC coprocessor is not present" weioIO.gpio = None # Import userMain from local module try : self.userMain = __import__(projectModule, fromlist=['']) # Calling user setup() if present if "setup" in vars(self.userMain): self.userMain.setup() except : print "MODULE CAN'T BE LOADED. Maybe you have some errors in modules that you wish to import?" print traceback.format_exc() result = None # Add user events #print "ADDING USER EVENTS" for key in weioUserApi.attach.events: #print weioUserApi.attach.events[key].handler weioParser.addUserEvent(weioUserApi.attach.events[key].event, weioUserApi.attach.events[key].handler) # Launching threads for key in weioUserApi.attach.procs: #print key t = threading.Thread(target=weioUserApi.attach.procs[key].procFnc, args=weioUserApi.attach.procs[key].procArgs) t.daemon = True # Start it t.start() #print "STARTING PROCESS PID", t.pid weioRunnerGlobals.running.value = True while (True): # Get the command from userTornado (blocking) msg = self.qIn.get() #print "*** GOT THE COMMAND: ", msg.req # Execute the command msg.res = None if msg.req in weioParser.weioSpells or msg.req in weioParser.weioUserSpells: if msg.req in weioParser.weioSpells: msg.res = weioParser.weioSpells[msg.req](msg.data) elif msg.req in weioParser.weioUserSpells: msg.res = weioParser.weioUserSpells[msg.req](msg.data) else: msg.res = None # Send back the result self.qOut.put(msg)
def launcher(self): print "======>>> LAUNCHING..." # Re-load user main (in case it changed) confFile = weioConfig.getConfiguration() # Get the last name of project and run it projectModule = confFile["last_opened_project"].replace('/', '.') + ".main" print "CALL", projectModule # Init GPIO object for uper communication if (weioRunnerGlobals.WEIO_SERIAL_LINKED == False): try: weioIO.gpio = weioGpio.WeioGpio() # Initialize globals for the user Tornado weioRunnerGlobals.DECLARED_PINS = weioIO.gpio.declaredPins except: print "LPC coprocessor is not present" weioIO.gpio = None # Import userMain from local module try: userMain = __import__(projectModule, fromlist=['']) except: print "MODULE CAN'T BE LOADED" result = None # Calling user setup() if present if "setup" in vars(userMain): userMain.setup() # Add user events print "ADDING USER EVENTS" for key in weioUserApi.attach.events: #print weioUserApi.attach.events[key].handler weioParser.addUserEvent(weioUserApi.attach.events[key].event, weioUserApi.attach.events[key].handler) # Launching threads for key in weioUserApi.attach.procs: #print key t = threading.Thread(target=weioUserApi.attach.procs[key].procFnc, args=weioUserApi.attach.procs[key].procArgs) t.daemon = True # Start it t.start() #print "STARTING PROCESS PID", t.pid while (True): # Get the command from userTornado (blocking) msg = self.qIn.get() print "*** GOT THE COMMAND: ", msg.req # Execute the command msg.res = None if msg.req in weioParser.weioSpells or msg.req in weioParser.weioUserSpells: if msg.req in weioParser.weioSpells: msg.res = weioParser.weioSpells[msg.req](msg.data) elif msg.req in weioParser.weioUserSpells: msg.res = weioParser.weioUserSpells[msg.req](msg.data) else: msg.res = None # Send back the result self.qOut.put(msg)