Exemplo n.º 1
0
    def threaded_code(config=config, snarks=snarks, keep_alive_func=None, sleep_func=None):
      try:
        snarkutils.gui_postprocess_snarks(config, snarks)
        if (len(snarks) == 0):
          raise common.CompileSubsException("After postprocessing, no messages were left.")

        logging.info("Calling %s exporter..." % config.exporter_name)
        wx.GetApp().invoke_later(wx.GetApp().ACTION_WARN, {"message":"Calling %s exporter..." % config.exporter_name})
        snarkutils.export_snarks(config, snarks, keep_alive_func=None, sleep_func=None)

        logging.info("Export succeeded.")
        wx.GetApp().invoke_later(wx.GetApp().ACTION_WARN, {"message":"Export succeeded."})

      except (common.CompileSubsException) as err:
        # Exporter failed in an uninteresting way.
        logging.error(str(err))
        wx.GetApp().invoke_later(wx.GetApp().ACTION_WARN, {"message":"Error: %s" % str(err)})

      except (Exception) as err:
        logging.exception(err)
        wx.GetApp().invoke_later(wx.GetApp().ACTION_WARN, {"message":"Error: The exporter failed in an unexpected way."})
Exemplo n.º 2
0
def main_cli():
  config = None
  snarks = []

  try:
    # If common's backend prompt funcs were to be replaced
    # (i.e., for GUI popups), that'd happen here.

    # Import the config module as an object that can
    # be passed around, and suppress creation of pyc clutter.
    #
    sys.dont_write_bytecode = True
    config = __import__("config")
    sys.dont_write_bytecode = False
    config = common.Changeling(config)  # A copy w/o module baggage.

    logging.info("Calling %s parser..." % config.parser_name)
    snarks = snarkutils.parse_snarks(config)
    if (len(snarks) == 0):
      raise common.CompileSubsException("No messages were parsed.")

    snarkutils.process_snarks(config, snarks)
    if (len(snarks) == 0):
      raise common.CompileSubsException("After processing, no messages were left.")

    logging.info("Calling %s exporter..." % config.exporter_name)
    snarkutils.export_snarks(config, snarks)

    logging.info("Done.")

  except (common.CompileSubsException) as err:
    # Parser or Exporter failed in an uninteresting way.
    logging.error(str(err))
    sys.exit(1)

  except (Exception) as err:
    logging.exception(err)
    sys.exit(1)