def test_get_1(self): la = Calculator() config = { 'parent': self.get_fake_ion(), 'name': 'linear_adjustor', 'statement': '(x+y)/z', 'variables': [{ 'vn': 'x', 'node_reference': '1.0' }, { 'vn': 'y', 'node_reference': '2' }, { 'vn': 'z', 'node_reference': '3' }] } la.configure(config) la.start() value = la.get() if value != 1.0: self.fail( 'wrong value returned from simple get. Value returned: ' + str(value)) return
def start(self): self.STATE = {} self.STATE.update(self.__class__.STATE) if self.require_acknowledge: self.STATE[self.__class__.SENT]['clear'] = self.__class__.SENT Calculator.start(self) variables = [] self._message = '' message = self.message while '$' in message: index = message.index('$') try: if message[index + 1] == '{': end = string.find(message, '}', index) if end > -1: var = message[index:end + 1] variable = var[2:-1] if '$' not in variable and '{' not in variable: message = string.replace(message, var, '%s') variables.append(variable) except IndexError: pass self._message += message[0:index + 1] message = message[index + 1:] self._message += message self._message_vars = tuple(variables) self._change_state('start')
def start(self): self.STATE = {} self.STATE.update(self.__class__.STATE) if self.require_acknowledge: self.STATE[self.__class__.SENT]['clear'] = self.__class__.SENT Calculator.start(self) variables = [] self._message = '' message = self.message while '$' in message: index = message.index('$') try: if message[index+1] == '{': end = string.find(message,'}',index) if end > -1: var = message[index:end+1] variable = var[2:-1] if '$' not in variable and '{' not in variable: message = string.replace(message,var,'%s') variables.append(variable) except IndexError: pass self._message += message[0:index+1] message = message[index+1:] self._message += message self._message_vars = tuple(variables) self._change_state('start')
def test_get_1(self): la = Calculator() config = {'parent':self.get_fake_ion(), 'name':'linear_adjustor', 'statement':'(x+y)/z', 'variables':[{'vn':'x','node_reference':'1.0'}, {'vn':'y','node_reference':'2'}, {'vn':'z','node_reference':'3'}]} la.configure(config) la.start() value = la.get() if value != 1.0: self.fail('wrong value returned from simple get. Value returned: ' + str(value)) return
def start(self): if not self._running.isSet(): _Trigger.start(self) variables = [] self._message = '' message = self.message while '$' in message: index = message.index('$') try: if message[index+1] == '{': end = string.find(message,'}',index) if end > -1: var = message[index:end+1] variable = var[2:-1] if '$' not in variable and '{' not in variable: message = string.replace(message,var,'%s') variables.append(variable) except IndexError: pass self._message += message[0:index+1] message = message[index+1:] self._message += message self._message_vars = tuple(variables) self.state = self.STATES[self.state]['start'] self._running.set() try: Calculator.start(self) except: message = "Failed to start Trigger %r. Will retry in 30 secs." msglog.error(message % self.name) if not self._start_failed: msglog.exception(prefix="handled") self._start_failed = True else: message = "Trigger %r started. Evaluation runs in 30 seconds." msglog.inform(message % self.name) self._start_failed = False finally: self.reschedule(30)
def start(self): if not self._running.isSet(): _Trigger.start(self) variables = [] self._message = '' message = self.message while '$' in message: index = message.index('$') try: if message[index + 1] == '{': end = string.find(message, '}', index) if end > -1: var = message[index:end + 1] variable = var[2:-1] if '$' not in variable and '{' not in variable: message = string.replace(message, var, '%s') variables.append(variable) except IndexError: pass self._message += message[0:index + 1] message = message[index + 1:] self._message += message self._message_vars = tuple(variables) self.state = self.STATES[self.state]['start'] self._running.set() try: Calculator.start(self) except: message = "Failed to start Trigger %r. Will retry in 30 secs." msglog.error(message % self.name) if not self._start_failed: msglog.exception(prefix="handled") self._start_failed = True else: message = "Trigger %r started. Evaluation runs in 30 seconds." msglog.inform(message % self.name) self._start_failed = False finally: self.reschedule(30)