def _call(self, callback, *args): try: callback(*args) except Exception as err: msg = 'Library import callback threw an unexpected exception' RideLogException(message=msg, exception=err, level='WARN').publish()
def run(self): self._initiate_database_connection() while True: try: if not self._handle_message(): break except Exception as err: msg = 'Library import handling threw an unexpected exception' RideLogException(message=msg, exception=err, level='WARN').publish() self._database.close()
def test_log_exception(self): try: 1 / 0 except Exception, err: msg = RideLogException(message='Some error text', exception=err, level='ERROR') assert_true( msg.message.startswith( 'Some error text\n\nTraceback (most recent call last):')) assert_equals(msg.level, 'ERROR') assert_true(msg.timestamp.startswith('20'))
def _execute(self, method): try: method() except Exception, err: self.SetValue(False) self.Enable(False) msg = 'Failed to %s plugin %s:\n%s'\ % (method.__name__, self._plugin.name, err) self._plugin.error = err self._plugin.doc = msg LOG.error(msg) RideLogException(message=msg, exception=err, level='ERROR').publish()
def _fetch_keywords(self, library_name, library_args): try: path = get_path( library_name.replace('/', os.sep), os.path.abspath('.')) return get_import_result(path, library_args) except Exception as err: print('FAILED', library_name, err) kws = self._spec_initializer.init_from_spec(library_name) if not kws: msg = 'Importing test library "%s" failed' % library_name RideLogException( message=msg, exception=err, level='WARN').publish() return kws