예제 #1
0
 def _print_error(self, msg):
     ''' Publish error message.
     '''
     try:
         publish('console_errors', msg)
     except:
         logger.error('publishing of message failed')
예제 #2
0
    def load_macro(self, macro_name):
        fpath = os.path.join(self.macrodir, macro_name)
        self._recorded_cmds = []
        with open(fpath, 'r') as f:
            content = f.read()
            
        # fix missing newline at end of file to avoid issues later when
        # we append to it
        if not content.endswith('\n'): 
            with open(fpath, 'a') as f:
                f.write('\n')

        lines = content.split('\n')
            
        errors = []
        for i, line in enumerate(lines):
            try:
                self.command(line, save=False)
            except Exception as err:
                msg = str(err)
                logger.error("%s" % ''.join(traceback.format_tb(sys.exc_info()[2])))
                try:
                    publish('console_errors', msg)
                except:
                    logger.error("publishing of error failed")
 def _print_error(self, msg):
     ''' Publish error message.
     '''
     try:
         publish('console_errors', msg)
     except:
         logger.error('publishing of message failed')
예제 #4
0
    def load_macro(self, macro_name):
        fpath = os.path.join(self.macrodir, macro_name)
        self._recorded_cmds = []
        with open(fpath, 'r') as f:
            content = f.read()

        # fix missing newline at end of file to avoid issues later when
        # we append to it
        if not content.endswith('\n'):
            with open(fpath, 'a') as f:
                f.write('\n')

        lines = content.split('\n')

        errors = []
        for i, line in enumerate(lines):
            try:
                self.command(line, save=False)
            except Exception as err:
                msg = str(err)
                logger.error("%s",
                             ''.join(traceback.format_tb(sys.exc_info()[2])))
                try:
                    publish('console_errors', msg)
                except:
                    logger.error("publishing of error failed")
예제 #5
0
 def publish_updates(self, added_set, changed_set, deleted_set):
     types = get_available_types()
     try:
         publish('types', [
             packagedict(types),
             list(added_set),
             list(changed_set),
             list(deleted_set),
         ])
     except:
         logger.error("publish of types failed")
예제 #6
0
 def publish_updates(self, added_set, changed_set, deleted_set):
     types = get_available_types()
     try:
         publish('types',
                 [
                     packagedict(types),
                     list(added_set),
                     list(changed_set),
                     list(deleted_set),
                 ])
     except:
         logger.error("publish of types failed")
예제 #7
0
 def load_macro(self, macro_name):
     fpath = os.path.join(self.macrodir, macro_name)
     self._recorded_cmds = []
     with open(fpath, 'r') as f:
         lines = f.readlines()
         
     errors = []
     for i, line in enumerate(lines):
         try:
             self.command(line.rstrip('\n'), save=False)
         except Exception as err:
             msg = str(err)
             logger.error("%s" % ''.join(traceback.format_tb(sys.exc_info()[2])))
             try:
                 publish('console_errors', msg)
             except:
                 logger.error("publishing of error failed")
 def publish_components(self):
     ''' Publish the current component tree and subscribed components.
     '''
     try:
         publish('components', self.get_components())
         publish('', {'Dataflow': self.get_dataflow('')})
         publish('', {'Workflow': self.get_workflow('')})
     except Exception as err:
         self._error(err, sys.exc_info())
     else:
         comps = self._publish_comps.keys()
         for pathname in comps:
             comp, root = self.get_object(pathname, report=False)
             if comp is None:
                 del self._publish_comps[pathname]
                 publish(pathname, {})
             else:
                 publish(pathname, comp.get_attributes(io_only=False))
예제 #9
0
    def load_macro(self, macro_name):
        fpath = os.path.join(self.macrodir, macro_name)
        self._recorded_cmds = []
        with open(fpath, 'r') as f:
            lines = f.readlines()

        errors = []
        for i, line in enumerate(lines):
            try:
                self.command(line.rstrip('\n'), save=False)
            except Exception as err:
                msg = str(err)
                logger.error("%s" %
                             ''.join(traceback.format_tb(sys.exc_info()[2])))
                try:
                    publish('console_errors', msg)
                except:
                    logger.error("publishing of error failed")
예제 #10
0
 def publish_components(self):
     ''' Publish the current component tree and subscribed components.
     '''
     try:
         publish('components', self.get_components())
         publish('', {'Dataflow': self.get_dataflow('')})
         publish('', {'Workflow': self.get_workflow('')})
     except Exception as err:
         self._error(err, sys.exc_info())
     else:
         comps = self._publish_comps.keys()
         for pathname in comps:
             comp, root = self.get_object(pathname, report=False)
             if comp is None:
                 del self._publish_comps[pathname]
                 publish(pathname, {})
             else:
                 publish(pathname, comp.get_attributes(io_only=False))
    def _start_log_msgs(self, topic):
        """ Start sending log messages. """
        # Need to lock access while we capture state.
        logging._acquireLock()
        try:
            # Flush output.
            for handler in logging.getLogger().handlers:
                handler.flush()

            # Grab previously logged messages.
            log_path = os.path.join(self._log_directory, 'openmdao_log.txt')
            with open(log_path, 'r') as inp:
                line = True  # Just to get things started.
                while line:
                    lines = []
                    for i in range(100):  # Process in chunks.
                        line = inp.readline()
                        if line:
                            lines.append(line)
                        else:
                            break
                    if lines:
                        publish('log_msgs',
                                dict(active=False, text=''.join(lines)))
            # End of historical messages.
            publish('log_msgs', dict(active=False, text=''))

            # Add handler to get any new messages.
            if self._log_handler is None:
                self._log_handler = _LogHandler()
                logging.getLogger().addHandler(self._log_handler)
        except Exception:
            print "Can't initiate logging:"
            traceback.print_exc()
        finally:
            logging._releaseLock()
        self._log_subscribers += 1
예제 #12
0
    def _start_log_msgs(self, topic):
        """ Start sending log messages. """
        # Need to lock access while we capture state.
        logging._acquireLock()
        try:
            # Flush output.
            for handler in logging.getLogger().handlers:
                handler.flush()

            # Grab previously logged messages.
            log_path = os.path.join(self._log_directory, 'openmdao_log.txt')
            with open(log_path, 'r') as inp:
                line = True  # Just to get things started.
                while line:
                    lines = []
                    for i in range(100):  # Process in chunks.
                        line = inp.readline()
                        if line:
                            lines.append(line)
                        else:
                            break
                    if lines:
                        publish('log_msgs',
                                dict(active=False, text=''.join(lines)))
            # End of historical messages.
            publish('log_msgs', dict(active=False, text=''))

            # Add handler to get any new messages.
            if self._log_handler is None:
                self._log_handler = _LogHandler()
                logging.getLogger().addHandler(self._log_handler)
        except Exception:
            print "Can't initiate logging:"
            traceback.print_exc()
        finally:
            logging._releaseLock()
        self._log_subscribers += 1
예제 #13
0
 def _error(self, msg):
     logger.error(msg)
     publish('console_errors', msg)
     publish('file_errors', msg)
예제 #14
0
 def write(self, msg):
     publish('log_msgs', dict(active=True, text=msg))
예제 #15
0
 def _error(self, msg):
     logger.error(msg)
     print msg
     publish('console_errors', msg)
예제 #16
0
 def send_pub_msg(self, msg, topic):
     ''' Publish the given message with the given topic.
     '''
     publish(topic, msg)
 def _error(self, msg):
     logger.error(msg)
     print msg
     publish('console_errors', msg)
 def send_pub_msg(self, msg, topic):
     ''' Publish the given message with the given topic.
     '''
     publish(topic, msg)
예제 #19
0
 def _error(self, msg):
     logger.error(msg)
     publish('console_errors', msg)
     publish('file_errors', msg)
 def write(self, msg):
     publish('log_msgs', dict(active=True, text=msg))