def execute(self): self.start_sockets() logger.info("PROXY SOCKETS STARTED") while self.flag: data = self.receive_sock.recv( 30 * 1024 ) # buffer size is 30 * 1024 bytes self.send_sock.sendto( data, (PROXY_UDP_IP, PROXY_SENDING_PORT_ONE) ) if is_app_running(): self.send_sock.sendto( data, (PROXY_UDP_IP, PROXY_SENDING_PORT_TWO) )
def execute(self): self.start_sockets() logger.info("PROXY SOCKETS STARTED") while self.flag: data = self.receive_sock.recv( 30 * 1024) # buffer size is 30 * 1024 bytes self.send_sock.sendto(data, (PROXY_UDP_IP, PROXY_SENDING_PORT_ONE)) if is_app_running(): self.send_sock.sendto(data, (PROXY_UDP_IP, PROXY_SENDING_PORT_TWO))
def on_gesture(self, gesture, touch): logger.debug("PROJECTORS STATE: %d" % self.activity_checker.projectors_on) if not self.activity_checker.projectors_on: logger.info('Turning Projectors On') self.activity_checker.turn_projectors_power(1) self.activity_checker.set_last_activity() logger.debug('gesture: %d' % self.counter) self.counter += 1 #print self.gestures.gesture_to_str(gesture) # gesture recognition if self.gestures.find(gesture, GESTURE_ACCEPTANCE_MARGIN) and is_app_running(): logger.debug("gesture recognized") kill_app_running()
def test_terminate_application(self): """ Kills the running application (if none runnig, it starts it) """ import time if not is_app_running(): self.tetris.execute() time.sleep(5) app = get_app_running() # guarantee the application is running self.assertNotEqual(app, None) kill_app_running() time.sleep(5) self.assertNotEqual(app.poll(), None)
def manage_screensaver(self, control, minutes): inactivity_time = self.get_minutes( self.cast_time_to_timedelta( control.inactivity_time ) ) application = ApplicationProxy.objects.filter(id = control.application.id)[0] if minutes > inactivity_time and not is_app_running() and application: logger.info('Launching Screensaver') application.execute(True)
def _execute(self, is_screensaver): """Tries to execute application's batch file. While is executing all process output (stdout/stderr) is catched and handled later on when the application is terminated. This method blocks until the application exits. Use run() instead. Returns: True if application is successfuly executed. False is returned whether there is no boot file or another application is already running. Raises: An Exception is raised in case something goes wrong during process execution""" #hide scatter logger.info('running application: %s' % self.name) if (is_app_running()): get_app_mutex().unlock() return False app_boot_file = self.get_boot_file() success = False if app_boot_file: try: from mtmenu import cover_window cover_window.show() self.start_run() command = self.build_command(app_boot_file) # Starts application process and waits for it to terminate process = Popen(command, stdout = PIPE, stderr = PIPE, cwd = self.get_extraction_fullpath(), shell = False) # defines the application that is running set_app_running(process) from utils import bring_window_to_front bring_window_to_front(True) # Concatenate output output = StringIO() for line in process.communicate(): output.write(line) remove_app_running() cover_window.resume(self, is_screensaver) self.end_run() # Save output to database self.add_log_entry(output.getvalue()) success = True logger.info("Application %s terminated" % self.name) except Exception, e: #Pokemon logger.error("EXCEPTION RUNNING APPLICATION:\n%s" % e)
def _execute(self, is_screensaver): """Tries to execute application's batch file. While is executing all process output (stdout/stderr) is catched and handled later on when the application is terminated. This method blocks until the application exits. Use run() instead. Returns: True if application is successfuly executed. False is returned whether there is no boot file or another application is already running. Raises: An Exception is raised in case something goes wrong during process execution""" #hide scatter logger.info('running application: %s' % self.name) if (is_app_running()): get_app_mutex().unlock() return False app_boot_file = self.get_boot_file() success = False if app_boot_file: try: from mtmenu import cover_window cover_window.show() self.start_run() command = self.build_command(app_boot_file) # Starts application process and waits for it to terminate process = Popen(command, stdout=PIPE, stderr=PIPE, cwd=self.get_extraction_fullpath(), shell=False) # defines the application that is running set_app_running(process) from utils import bring_window_to_front bring_window_to_front(True) # Concatenate output output = StringIO() for line in process.communicate(): output.write(line) remove_app_running() cover_window.resume(self, is_screensaver) self.end_run() # Save output to database self.add_log_entry(output.getvalue()) success = True logger.info("Application %s terminated" % self.name) except Exception, e: #Pokemon logger.error("EXCEPTION RUNNING APPLICATION:\n%s" % e)