Beispiel #1
0
    def remove_program(self, index):
        if 0 <= index < len(self._programs):
            del self._programs[index]

        for i in range(index, len(self._programs)):
            options.save(self._programs[i], i)  # Save programs using new indices

        options.erase(_Program, len(self._programs))  # Remove info in last index
Beispiel #2
0
    def remove_program(self, index):
        if 0 <= index < len(self._programs):
            del self._programs[index]

        for i in range(index, len(self._programs)):
            options.save(self._programs[i], i)  # Save programs using new indices

        options.erase(_Program, len(self._programs))  # Remove info in last index
Beispiel #3
0
    def __setattr__(self, key, value):
        try:
            super(_Station, self).__setattr__(key, value)
            if not key.startswith('_') and key not in self.SAVE_EXCLUDE:
                options.save(self, self.index)
        except ValueError:  # No index available yet
            pass

        if key == 'usage' and value > options.max_usage:
            logging.warning('The usage of %s is more than the maximum allowed usage, '
                            'scheduling it will be impossible.', self.name)
Beispiel #4
0
    def __setattr__(self, key, value):
        try:
            super(_Station, self).__setattr__(key, value)
            if not key.startswith('_') and key not in self.SAVE_EXCLUDE:
                options.save(self, self.index)
        except ValueError:  # No index available yet
            pass

        if key == 'usage' and value > options.max_usage:
            logging.warning('The usage of %s is more than the maximum allowed usage, '
                            'scheduling it will be impossible.', self.name)
Beispiel #5
0
 def __setattr__(self, key, value):
     if key == 'modulo':
         self._modulo = value
         if not self._loading:
             self.schedule = self._schedule  # Convert to custom sequence
     elif key == 'manual':
         self._manual = value
         if not self._loading and value:
             self.schedule = self._schedule  # Convert to custom sequence
     elif key == 'start':
         if self._loading:  # Update start date to most recent possible
             while value <= datetime.datetime.today():
                 value += datetime.timedelta(minutes=self._modulo)
             self._start = value
         else:
             self._start = value
             self.schedule = self._schedule  # Convert to custom sequence
     else:
         super(_Program, self).__setattr__(key, value)
         if key not in self.SAVE_EXCLUDE:
             if not self._loading and self.index >= 0:
                 options.save(self, self.index)
Beispiel #6
0
 def __setattr__(self, key, value):
     if key == 'modulo':
         self._modulo = value
         if not self._loading:
             self.schedule = self._schedule  # Convert to custom sequence
     elif key == 'manual':
         self._manual = value
         if not self._loading and value:
             self.schedule = self._schedule  # Convert to custom sequence
     elif key == 'start':
         if self._loading:  # Update start date to most recent possible
             while value <= datetime.datetime.today():
                 value += datetime.timedelta(minutes=self._modulo)
             self._start = value
         else:
             self._start = value
             self.schedule = self._schedule  # Convert to custom sequence
     else:
         super(_Program, self).__setattr__(key, value)
         if key not in self.SAVE_EXCLUDE:
             if not self._loading and self.index >= 0:
                 options.save(self, self.index)
Beispiel #7
0
 def __setattr__(self, key, value):
     super(_BaseStations, self).__setattr__(key, value)
     if not key.startswith('_') and not self._loading:
         options.save(self)
Beispiel #8
0
 def __setattr__(self, key, value):
     super(_BaseStations, self).__setattr__(key, value)
     if not key.startswith('_') and not self._loading:
         options.save(self)
Beispiel #9
0
 def add_program(self, program=None):
     if program is None:
         program = _Program(self, len(self._programs))
     self._programs.append(program)
     options.save(program, program.index)
Beispiel #10
0
 def add_program(self, program=None):
     if program is None:
         program = _Program(self, len(self._programs))
     self._programs.append(program)
     options.save(program, program.index)