Example #1
0
 def execute (self, is_screensaver=False):
     """Executes within a thread"""
     app_mutex = get_app_mutex()
     if app_mutex.testandset():
         t = Thread( target=self._execute, args=( is_screensaver, ) )
         t.start()
     else:
         logger.info("NOT RUNNING %s: some application is already running" % self.name)
Example #2
0
 def execute(self, is_screensaver=False):
     """Executes within a thread"""
     app_mutex = get_app_mutex()
     if app_mutex.testandset():
         t = Thread(target=self._execute, args=(is_screensaver, ))
         t.start()
     else:
         logger.info("NOT RUNNING %s: some application is already running" %
                     self.name)
Example #3
0
    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)
Example #4
0
                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)
        else:
            logger.error("Could not run app %s because no boot file" % self.name)
        get_app_mutex().unlock()
        
        return success
        
        
    def get_extraction_fullpath(self):
        """Full path to application repository.
        
        It considers the folder name as being the application's ID. The main path
        is setted on config.py

        Returns:
            Full path to application repository if exists otherwise
            returns empty string"""
        full_path = path.join(APPS_REPOSITORY_PATH, str(self.id))
        
Example #5
0
    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)
Example #6
0
                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)
        else:
            logger.error("Could not run app %s because no boot file" %
                         self.name)
        get_app_mutex().unlock()

        return success

    def get_extraction_fullpath(self):
        """Full path to application repository.
        
        It considers the folder name as being the application's ID. The main path
        is setted on config.py

        Returns:
            Full path to application repository if exists otherwise
            returns empty string"""
        full_path = path.join(APPS_REPOSITORY_PATH, str(self.id))

        if path.exists(full_path):