Example #1
0
def workshop():

    # List of input files to compile into a single presentation
    files = [
        'input/cover.i',
        'input/overview.i',
        'input/example01.i',
        'input/moose_object.i',
        'input/input_parameters.i',
        'input/kernels.i',
        'input/example02.i',
        'input/mesh.i',
        'input/outputs.i',
        'input/bcs.i',
        'input/adapt.i',
        'input/coupling.i',
        'input/example03.i',
        'input/materials.i',
        'input/auxkernels.i',
        'input/auxvariables.i',
        'input/functions.i',
        'input/postprocessors.i',
        'input/executioners.i',
        'input/time_steppers.i',
        'input/ics.i',
        'input/multiapps.i',
        'input/transfers.i',
        'input/mesh_modifiers.i',
        'input/mooseapp.i',
        #'input/code_verification.i',
        #'input/preconditioning.i',
        #'input/debugging.i',
        #'input/vis_tools.i',
        #'input/testing.i',
        #'input/mesh_modifiers.i',
        'input/oversampling.i',
        'input/random.i',
        'input/action.i',
        'input/dirac.i',
        'input/scalar_kernels.i',
        'input/geom_search.i',
        'input/dampers.i',
        'input/dg.i',
        'input/user_objects.i',
        'input/restart.i'
    ]

    # Create the presentation containing the entire moose workshop
    print utils.colorText('Building MOOSE Workshop', 'MAGENTA')
    merger = base.PresentationMerger(
        'moose.i',
        files,
        style='inl',
        title="TMS2016 MOOSE/Phase-field Workshop")
    merger.write()
Example #2
0
def workshop():

  # List of input files to compile into a single presentation
  files = ['input/cover.i',
           'input/overview.i',
           'input/example01.i',
           'input/moose_object.i',
           'input/input_parameters.i',
           'input/kernels.i',
           'input/example02.i',
           'input/mesh.i',
           'input/outputs.i',
           'input/bcs.i',
           'input/adapt.i',
           'input/coupling.i',
           'input/example03.i',
           'input/materials.i',
           'input/auxkernels.i',
           'input/auxvariables.i',
           'input/functions.i',
           'input/postprocessors.i',
           'input/executioners.i',
           'input/time_steppers.i',
           'input/ics.i',
           'input/multiapps.i',
           'input/transfers.i',
           'input/mesh_modifiers.i',
           'input/mooseapp.i',
           #'input/code_verification.i',
           #'input/preconditioning.i',
           #'input/debugging.i',
           #'input/vis_tools.i',
           #'input/testing.i',
           #'input/mesh_modifiers.i',
           'input/oversampling.i',
           'input/random.i',
           'input/action.i',
           'input/dirac.i',
           'input/scalar_kernels.i',
           'input/geom_search.i',
           'input/dampers.i',
           'input/dg.i',
           'input/user_objects.i',
           'input/restart.i'
           ]

  # Create the presentation containing the entire moose workshop
  print utils.colorText('Building MOOSE Workshop', 'MAGENTA')
  merger = base.PresentationMerger('moose.i', files, style='inl', title="TMS2016 MOOSE/Phase-field Workshop")
  merger.write()
Example #3
0
  def __init__(self, input_file, **kwargs):

    # Determine the format
    self._format = kwargs.pop('format', 'remark')

    self._reveal_dir = None
    if self._format == 'reveal':
      self._reveal_dir = os.getenv('REVEAL_JS_DIR', os.path.join(os.getenv('HOME'), 'projects', 'reveal.js'))

      if not os.path.exists(self._reveal_dir):
        print 'ERROR: Attempted to output in Reveal.js format, but Reveal.js directory was not found, set the REAVEL_JS_DIR enviornmental variable or clone the repository into your ~/projects directory.'
        sys.exit()


    # Create the Factory and Warehouse
    self.factory = Factory()
    self.warehouse = SlideSetWarehouse(format=self._format)

    # Set the location of PresentationBuilder directory
    self._source_dir = os.path.abspath(os.path.join(os.path.split(inspect.getfile(self.__class__))[0], '..'))

    # Extract input/output file names
    f, ext = os.path.splitext(input_file)
    self._input_file = input_file
    self._output_file = f + '.html'

    # Register the objects to be created
    self.factory.loadPlugins('.', 'slidesets', MooseObject)
    self.factory.loadPlugins('.', 'slides', MooseObject)
    self.factory.loadPlugins('.', 'images', MooseObject)

    # Build the Parser object
    self.parser = Parser(self.factory, self.warehouse)

    # Create SlideSet objects via the Parser object by parsing the input file
    print colorText('Parsing input...', 'CYAN')
    err = self.parser.parse(input_file)
    if err:
      sys.exit()
    print ''

    # Store the top-level 'presentation' level parameters
    self._params = self.parser.root.children["presentation"].params

    # Extract CSS style
    self._style()

    # Build the slides
    self.warehouse.execute()
Example #4
0
    def __init__(self, input_file, **kwargs):

        # Determine the format
        self._format = kwargs.pop("format", "remark")

        self._reveal_dir = None
        if self._format == "reveal":
            self._reveal_dir = os.getenv("REVEAL_JS_DIR", os.path.join(os.getenv("HOME"), "projects", "reveal.js"))

            if not os.path.exists(self._reveal_dir):
                print "ERROR: Attempted to output in Reveal.js format, but Reveal.js directory was not found, set the REAVEL_JS_DIR enviornmental variable or clone the repository into your ~/projects directory."
                sys.exit()

        # Create the Factory and Warehouse
        self.factory = Factory()
        self.warehouse = SlideSetWarehouse(format=self._format)

        # Set the location of PresentationBuilder directory
        self._source_dir = os.path.abspath(os.path.join(os.path.split(inspect.getfile(self.__class__))[0], ".."))

        # Extract input/output file names
        f, ext = os.path.splitext(input_file)
        self._input_file = input_file
        self._output_file = f + ".html"

        # Register the objects to be created
        self.factory.loadPlugins(".", "slidesets", MooseObject)
        self.factory.loadPlugins(".", "slides", MooseObject)
        self.factory.loadPlugins(".", "images", MooseObject)

        # Build the Parser object
        self.parser = Parser(self.factory, self.warehouse)

        # Create SlideSet objects via the Parser object by parsing the input file
        print colorText("Parsing input...", "CYAN")
        err = self.parser.parse(input_file)
        if err:
            sys.exit()
        print ""

        # Store the top-level 'presentation' level parameters
        self._params = self.parser.root.children["presentation"].params

        # Extract CSS style
        self._style()

        # Build the slides
        self.warehouse.execute()
Example #5
0
  def markdown(self):

    # Extract all the slide set content
    output = []
    print colorText('\nRetrieving Markdown', 'CYAN')
    for obj in self.objects:
      md = obj.markdown()
      if not md:
        print 'Warning: The slide set, ' + obj.name() +', does not contain content.'
      else:
        output.append(md)

    if self.format == 'remark':
      return '\n\n---\n\n'.join(output)
    elif self.format == 'reveal':
      return '\n\n'.join(output)
Example #6
0
    def format(self, record):
        msg = logging.Formatter.format(self, record)

        if record.name.endswith('Item'):
            level = 3
        elif record.name.endswith('Database'):
            level = 2
        elif record.name.endswith(
                'MooseApplicationSyntax') or record.name.endswith(
                    'MooseCommonFunctions'):
            level = 1
        else:
            level = 0

        if record.levelname in ['DEBUG', 'WARNING', 'ERROR', 'CRITICAL']:
            msg = '{}{}: {}'.format(' ' * 4 * level, record.levelname, msg)
        else:
            msg = '{}{}'.format(' ' * 4 * level, msg)

        if record.levelname in self.COLOR:
            msg = utils.colorText(msg, self.COLOR[record.levelname])

        # Increment counts
        self.COUNTS[record.levelname] += 1

        return msg
Example #7
0
    def format(self, record):
        msg = logging.Formatter.format(self, record)

        if record.name.endswith('Item'):
            level = 4
        elif record.name.endswith('Database'):
            level = 3
        elif record.name.endswith('MooseInformationBase') or record.name.endswith('MooseObjectInformation') or record.name.endswith('MooseApplicationSyntax') or record.name.endswith('MooseSystemInformation'):
            level = 2
        elif record.name.endswith('MooseSubApplicationDocGenerator'):
            level = 1
        else:
            level = 0

        if record.levelname in ['DEBUG', 'WARNING', 'ERROR', 'CRITICAL']:
            msg = '{}{}: {}'.format(' '*4*level, record.levelname, msg)
        else:
            msg = '{}{}'.format(' '*4*level, msg)

        if record.levelname in self.COLOR:
            msg = utils.colorText(msg, self.COLOR[record.levelname])

        # Increment counts
        self.COUNTS[record.levelname] += 1

        return msg
Example #8
0
    def markdown(self):

        # Extract all the slide set content
        output = []
        print colorText('\nRetrieving Markdown', 'CYAN')
        for obj in self.objects:
            md = obj.markdown()
            if not md:
                print 'Warning: The slide set, ' + obj.name(
                ) + ', does not contain content.'
            else:
                output.append(md)

        if self.format == 'remark':
            return '\n\n---\n\n'.join(output)
        elif self.format == 'reveal':
            return '\n\n'.join(output)
Example #9
0
def workshop(**kwargs):

  # List of input files to compile into a single presentation
  files = ['input/cover.i',
           'input/overview.i',
           'input/problem.i',
           'input/problem_details.i',
           'input/tutorial_summary.i',
           'input/step01.i',
           'input/fem.i',
           'input/step02.i', # Mesh, Outputs, MooseObject, validParams, MOOSE Types, Kernels
           'input/laplace_young.i',
           'input/step03.i', # Materials
           'input/step04.i', # Aux Variables and Aux Kernels
           'input/step05.i', # Executioners, TimeSteppers, BoundaryConditions
           'input/step06.i', # Coupling, Functions
           'input/step07.i', # Adaptivity
           'input/step08.i', # Postprocessors
           'input/step09.i', # Solid Mechanics
           'input/step10.i', # MultiApps, Transfers, InitialConditions
           'input/mooseapp.i',
           'input/code_verification.i',
           'input/preconditioning.i',
           'input/debugging.i',
          # 'input/vis_tools.i', # We don't really need this, we talk about all of this throughout
           'input/testing.i',
           'input/mesh_modifiers.i',
           'input/oversampling.i',
           'input/random.i',
           'input/action.i',
           'input/dirac.i',
           'input/scalar_kernels.i',
           'input/geom_search.i',
           'input/dampers.i',
           'input/dg.i',
           'input/user_objects.i',
           'input/restart.i',
           'input/controls.i'
           ]

  # Create the presentation containing the entire moose workshop
  print utils.colorText('Building MOOSE Workshop', 'MAGENTA')
  merger = blaster.base.PresentationMerger('moose.i', files, style='inl', title='MOOSE Workshop',
                                   format=kwargs.pop('format','remark'))
  merger.write()
Example #10
0
    def format(self, record):
        msg = logging.Formatter.format(self, record)
        if record.levelname in self.COLOR:
            msg = utils.colorText(msg, self.COLOR[record.levelname])

        if record.levelname in self.COUNTS:
            with self.COUNTS[record.levelname].get_lock():
                self.COUNTS[record.levelname].value += 1

        return msg
Example #11
0
  def format(self, record):
    msg = logging.Formatter.format(self, record)
    if record.levelname in self.COLOR:
      msg = utils.colorText(msg, self.COLOR[record.levelname])

    if record.levelname in self.COUNTS:
      with self.COUNTS[record.levelname].get_lock():
        self.COUNTS[record.levelname].value += 1

    return msg
Example #12
0
  def __contents(self):

    # Initialize the table-of-contents slides
    for obj in self.objects:
      obj.initContents()

    # Initial slide index
    idx = 1
    title_slides = []

    # Loop through each object and slide and set the slide index
    print colorText('\nGenerating contents:', 'CYAN')
    for obj in self.objects:
      for slide in obj.warehouse().activeObjects():
        print '  ' + slide.name()
        slide.number = idx
        idx += 1 + len(re.findall('\n--', slide.markdown))

    # Call the contents object on each slide set
    for obj in self.objects:
      obj.contents()
Example #13
0
  def execute(self):

    # Number of slide set objects
    n = len(self.objects)

    # Read and build the slides
    for i in range(n):
      # Display the current object being executed
      obj = self.objects[i]
      name = obj.name()
      msg = ['Building Set:', name, '(' + str(i+1), 'of', str(n) + ')']
      print colorText(' '.join(msg), 'CYAN')

      # Read and build the content
      print '  Reading content...'
      raw = obj.read()
      print '  Building content...'
      obj.build(raw)

    # Build the table-of-contents
    self.__contents()
Example #14
0
    def __contents(self):

        # Initialize the table-of-contents slides
        for obj in self.objects:
            obj.initContents()

        # Initial slide index
        idx = 1
        title_slides = []

        # Loop through each object and slide and set the slide index
        print colorText('\nGenerating contents:', 'CYAN')
        for obj in self.objects:
            for slide in obj.warehouse().activeObjects():
                print '  ' + slide.name()
                slide.number = idx
                idx += 1 + len(re.findall('\n--', slide.markdown))

        # Call the contents object on each slide set
        for obj in self.objects:
            obj.contents()
Example #15
0
    def execute(self):

        # Number of slide set objects
        n = len(self.objects)

        # Read and build the slides
        for i in range(n):
            # Display the current object being executed
            obj = self.objects[i]
            name = obj.name()
            msg = ['Building Set:', name, '(' + str(i + 1), 'of', str(n) + ')']
            print colorText(' '.join(msg), 'CYAN')

            # Read and build the content
            print '  Reading content...'
            raw = obj.read()
            print '  Building content...'
            obj.build(raw)

        # Build the table-of-contents
        self.__contents()
Example #16
0
def cpp(**kwargs):
  print utils.colorText('Building C++ Presentation', 'MAGENTA')
  builder = base.PresentationBuilder('cpp.i', format=kwargs.pop('format','remark'))
  builder.write()
Example #17
0
def printResult(test_name, result, timing, start, end, options, color=True):
  f_result = ''

  cnt = (TERM_COLS-2) - len(test_name + result)
  color_opts = {'code' : options.code, 'colored' : options.colored}
  if color:
    any_match = False
    # Color leading paths
    m = re.search(r'(.*):(.*)', test_name)
    if m:
      test_name = colorText(m.group(1), 'CYAN', **color_opts) + ':' + m.group(2)
    # Color the Caveats CYAN
    m = re.search(r'(\[.*?\])', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'CYAN', **color_opts) + " "
    # Color Exodiff or CVSdiff tests YELLOW
    m = re.search('(FAILED \((?:EXODIFF|CSVDIFF)\))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'YELLOW', **color_opts)
    else:
      # Color remaining FAILED tests RED
      m = re.search('(FAILED \(.*\))', result)
      if m:
        any_match = True
        f_result += colorText(m.group(1), 'RED', **color_opts)
    # Color deleted tests RED
    m = re.search('(deleted) (\(.*\))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'RED', **color_opts) + ' ' + m.group(2)
    # Color long running tests YELLOW
    m = re.search('(RUNNING\.\.\.)', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'YELLOW', **color_opts)
    # Color PBS status CYAN
    m = re.search('((?:LAUNCHED|RUNNING(?!\.)|EXITING|QUEUED))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'CYAN', **color_opts)
    # Color Passed tests GREEN
    m = re.search('(OK|DRY_RUN)', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'GREEN', **color_opts)

    if not any_match:
      f_result = result

    f_result = test_name + '.'*cnt + ' ' + f_result
  else:
    f_result = test_name + '.'*cnt + ' ' + result

  # Tack on the timing if it exists
  if timing:
    f_result += ' [' + '%0.3f' % float(timing) + 's]'
  if options.debug_harness:
    f_result += ' Start: ' + '%0.3f' % start + ' End: ' + '%0.3f' % end
  return f_result
Example #18
0
def printResult(test_name, result, timing, start, end, options, color=True):
  f_result = ''

  cnt = (TERM_COLS-2) - len(test_name + result)
  color_opts = {'code' : options.code, 'colored' : options.colored}
  if color:
    any_match = False
    # Color leading paths
    m = re.search(r'(.*):(.*)', test_name)
    if m:
      test_name = colorText(m.group(1), 'CYAN', **color_opts) + ':' + m.group(2)
    # Color the Caveats CYAN
    m = re.search(r'(\[.*?\])', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'CYAN', **color_opts) + " "
    # Color Exodiff or CVSdiff tests YELLOW
    m = re.search('(FAILED \((?:EXODIFF|CSVDIFF)\))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'YELLOW', **color_opts)
    else:
      # Color remaining FAILED tests RED
      m = re.search('(FAILED \(.*\))', result)
      if m:
        any_match = True
        f_result += colorText(m.group(1), 'RED', **color_opts)
    # Color deleted tests RED
    m = re.search('(deleted) (\(.*\))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'RED', **color_opts) + ' ' + m.group(2)
    # Color long running tests YELLOW
    m = re.search('(RUNNING\.\.\.)', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'YELLOW', **color_opts)
    # Color PBS status CYAN
    m = re.search('((?:LAUNCHED|RUNNING(?!\.)|EXITING|QUEUED))', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'CYAN', **color_opts)
    # Color Passed tests GREEN
    m = re.search('(OK|DRY_RUN)', result)
    if m:
      any_match = True
      f_result += colorText(m.group(1), 'GREEN', **color_opts)

    if not any_match:
      f_result = result

    f_result = test_name + '.'*cnt + ' ' + f_result
  else:
    f_result = test_name + '.'*cnt + ' ' + result

  # Tack on the timing if it exists
  if timing:
    f_result += ' [' + '%0.3f' % float(timing) + 's]'
  if options.debug_harness:
    f_result += ' Start: ' + '%0.3f' % start + ' End: ' + '%0.3f' % end
  return f_result