(self)
Run periodic command on master node.

        We keep time using .walshipping.last file, so this has to be run before
        set_last_complete()
Run periodic command on master node.
Run periodic command on master node .
def master_periodic(self):
        """
        Run periodic command on master node.

        We keep time using .walshipping.last file, so this has to be run before
        set_last_complete()
        """

        self.assert_is_master(True)

        try:
            command_interval = self.cf.getint("command_interval", 0)
            periodic_command = self.cf.get("periodic_command", "")

            if periodic_command:
                check_file = os.path.join(self.cf.getfile("master_data"), ".walshipping.periodic")

                elapsed = 0
                if os.path.isfile(check_file):
                    elapsed = time.time() - os.stat(check_file).st_mtime

                self.log.info("Running periodic command: %s", periodic_command)
                if not elapsed or elapsed > command_interval:
                    if not self.not_really:
                        rc = os.WEXITSTATUS(self.exec_system(periodic_command))
                        if rc != 0:
                            self.log.error("Periodic command exited with status %d", rc)
                            # dont update timestamp - try again next time
                        else:
                            open(check_file,"w").write("1")
                else:
                    self.log.debug("%d seconds elapsed, not enough to run periodic.", elapsed)
        except Exception, det:
            self.log.error("Failed to run periodic command: %s", det)
def master_periodic ( self ) : self . assert_is_master ( True ) try : command_interval = self . cf . getint ( "command_interval" , 0 ) periodic_command = self . cf . get ( "periodic_command" , "" ) if periodic_command : check_file = os . path . join ( self . cf . getfile ( "master_data" ) , ".walshipping.periodic" ) elapsed = 0 if os . path . isfile ( check_file ) : elapsed = time . time ( ) - os . stat ( check_file ) . st_mtime self . log . info ( "Running periodic command: %s" , periodic_command ) if not elapsed or elapsed > command_interval : if not self . not_really : rc = os . WEXITSTATUS ( self . exec_system ( periodic_command ) ) if rc != 0 : self . log . error ( "Periodic command exited with status %d" , rc ) # dont update timestamp - try again next time else : open ( check_file , "w" ) . write ( "1" ) else : self . log . debug ( "%d seconds elapsed, not enough to run periodic." , elapsed ) except Exception , det : self . log . error ( "Failed to run periodic command: %s" , det )