コード例 #1
0
ファイル: proxy.py プロジェクト: swarnimpandey/wallmanager
 def run(self):
     logger.info("PROXY RUNNING")
     try:
         self.execute()
         logger.info("PROXY STOPPED")
     except Exception, e:  #Pokemon
         if logger:
             logger.error("EXCEPTION ON PROXY:\n%s" % e)
         else:
             print "Exception on Proxy:", e
コード例 #2
0
ファイル: proxy.py プロジェクト: Sensebloom/wallmanager
 def run(self):
     logger.info("PROXY RUNNING")
     try:
         self.execute()
         logger.info("PROXY STOPPED")
     except Exception, e: #Pokemon
         if logger:
             logger.error("EXCEPTION ON PROXY:\n%s" % e)
         else:
             print "Exception on Proxy:", e
コード例 #3
0
 def turn_projectors_power(self, status):
     if not self.in_schedule():
         logger.info("NOT IN SCHEDULE. Projectors will remain with the previous state")
         return
     
     try:
         projectors.projectors_power(status)
         logger.info("Projectors status changed to %d" % status)
     except Exception, e:
         logger.error('Error changing projectors status:\n%s' % e)
コード例 #4
0
    def update_projectors_status(self):
        try:
            dic = projectors.projectors_status()
            for key, value in dic.items():
                if not value == 'OFF':
                    self.set_projectors_status(True)
                    return

            self.set_projectors_status(False)
        except Exception as e:
            logger.error("Projectors status error:\n%s" % e)
コード例 #5
0
ファイル: appbutton.py プロジェクト: Sensebloom/wallmanager
 def draw(self): 
     # Outside line
     style = {'bg-color': (1, 1, 1, 1), 'draw-background': 0, 'draw-border': True, 'border-radius': 10}
     set_color(*style.get('bg-color'))
     drawCSSRectangle(pos=self.pos, size=self.size,  style = style)
     
     # Icon
     try:
         image = Image( "../webmanager/media/%s" % str(self.app.icon) )
         x,y = list(self.center)
         image.size = self.get_resized_size(image)
         image.pos = x - image.width /2, y - image.height /2      
         image.draw()
     except Exception, e:
         logger.error("EXCEPTION loading icon\n%s" % e)
コード例 #6
0
    def last_activity_checker(self):
        while True:
            systemtime.sleep(TIME_TO_CHECK_PROJECTORS * 60)
            
            self.update_projectors_status()

            diff_min = self.get_minutes(datetime.now() - self.last_activity)
            screensaver_control = self.get_first_item(ScreensaverControlProxy.objects.all())        
            projector_control = self.get_first_item(ProjectorControlProxy.objects.all())

            if screensaver_control:
                self.manage_screensaver(screensaver_control, diff_min)
            else:
                logger.error("screensaver time not defined")

            if projector_control:
                self.manage_projectors(projector_control, diff_min)           
            else:
                logger.error("projectors inactivity time not defined")
コード例 #7
0
    def draw(self):
        # Outside line
        style = {
            'bg-color': (1, 1, 1, 1),
            'draw-background': 0,
            'draw-border': True,
            'border-radius': 10
        }
        set_color(*style.get('bg-color'))
        drawCSSRectangle(pos=self.pos, size=self.size, style=style)

        # Icon
        try:
            image = Image("../webmanager/media/%s" % str(self.app.icon))
            x, y = list(self.center)
            image.size = self.get_resized_size(image)
            image.pos = x - image.width / 2, y - image.height / 2
            image.draw()
        except Exception, e:
            logger.error("EXCEPTION loading icon\n%s" % e)
コード例 #8
0
ファイル: models.py プロジェクト: Sensebloom/wallmanager
    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)
コード例 #9
0
ファイル: models.py プロジェクト: Sensebloom/wallmanager
                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))
コード例 #10
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)
コード例 #11
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))