예제 #1
0
파일: __init__.py 프로젝트: hchen139/moose
def moosedocs():

  # Options
  options = vars(command_line_options())

  # Initialize logging
  formatter = init_logging(options.pop('verbose'))
  log = logging.getLogger('MooseDocs')

  # Remove moose.svg files (these get generated via dot)
  log.info('Removing *.moose.svg files from {}'.format(os.getcwd()))
  purge(['svg'])

  # Execute command
  cmd = options.pop('command')
  if cmd == 'check':
    commands.generate(stubs=False, pages_stubs=False, **options)
  elif cmd == 'generate':
    commands.generate(**options)
  elif cmd == 'serve':
    commands.serve(**options)
  elif cmd == 'build':
    commands.build(**options)
  elif cmd == 'latex':
    commands.latex(**options)

  # Display logging results
  print 'WARNINGS: {}  ERRORS: {}'.format(formatter.COUNTS['WARNING'], formatter.COUNTS['ERROR'])
  return formatter.COUNTS['ERROR'] > 0
예제 #2
0
def moosedocs():

    # Options
    options = command_line_options()

    # Initialize logging
    formatter = init_logging(options.verbose)
    log = logging.getLogger('MooseDocs')

    # Remove moose.svg files (these get generated via dot)
    log.info('Removing *.moose.svg files from {}'.format(os.getcwd()))
    purge(['svg'])

    # Execute command
    if options.command == 'check':
        commands.generate(config_file=options.config_file, stubs=False, pages_stubs=False)
    elif options.command == 'generate':
        commands.generate(config_file=options.config_file, stubs=options.stubs, pages_stubs=options.pages_stubs)
    elif options.command == 'serve':
        commands.serve(config_file=options.config_file, strict=options.strict, livereload=options.livereload, clean=options.clean, theme=options.theme, pages=options.pages, page_keys=options.page_keys)
    elif options.command == 'build':
        commands.build(config_file=options.config_file, theme=options.theme, pages=options.pages, page_keys=options.page_keys)

    # Display logging results
    print 'WARNINGS: {}  ERRORS: {}'.format(formatter.COUNTS['WARNING'], formatter.COUNTS['ERROR'])
    return formatter.COUNTS['ERROR'] > 0
예제 #3
0
def moosedocs():

    # Options
    options = vars(command_line_options())

    # Initialize logging
    formatter = init_logging(options.pop('verbose'))
    log = logging.getLogger('MooseDocs')

    # Remove moose.svg files (these get generated via dot)
    log.info('Removing *.moose.svg files from {}'.format(os.getcwd()))
    purge(['svg'])

    # Execute command
    cmd = options.pop('command')
    if cmd == 'check':
        commands.generate(stubs=False, pages_stubs=False, **options)
    elif cmd == 'generate':
        commands.generate(**options)
    elif cmd == 'serve':
        commands.serve(**options)
    elif cmd == 'build':
        commands.build(**options)
    elif cmd == 'latex':
        commands.latex(**options)

    # Display logging results
    print 'WARNINGS: {}  ERRORS: {}'.format(formatter.COUNTS['WARNING'],
                                            formatter.COUNTS['ERROR'])
    return formatter.COUNTS['ERROR'] > 0
예제 #4
0
def moosedocs():

    # Options
    options = command_line_options()

    # Initialize logging
    formatter = init_logging(options.verbose)

    # Execute command
    if options.command == 'generate':
        commands.generate(config_file=options.moosedocs_config_file,
                          purge=options.purge)
    elif options.command == 'serve':
        commands.serve(config_file=options.mkdocs_config_file,
                       strict=options.strict,
                       livereload=options.livereload,
                       clean=options.clean,
                       theme=options.theme,
                       pages=options.pages)
    elif options.command == 'build':
        commands.build(config_file=options.mkdocs_config_file,
                       theme=options.theme,
                       pages=options.pages)

    # Display logging results
    print 'WARNINGS: {}  ERRORS: {}'.format(formatter.COUNTS['WARNING'],
                                            formatter.COUNTS['ERROR'])
    return formatter.COUNTS['ERROR'] > 0
예제 #5
0
파일: __init__.py 프로젝트: garvct/Moose
def moosedocs():

    # Options
    options = command_line_options()

    # Initialize logging
    formatter = init_logging(options.verbose)
    log = logging.getLogger('MooseDocs')

    # Remove moose.svg files (these get generated via dot)
    log.info('Removing *.moose.svg files from {}'.format(os.getcwd()))
    purge(['svg'])

    # Execute command
    if options.command == 'check':
        commands.generate(config_file=options.config_file, stubs=False, pages_stubs=False)
    elif options.command == 'generate':
        commands.generate(config_file=options.config_file, stubs=options.stubs, pages_stubs=options.pages_stubs)
    elif options.command == 'serve':
        commands.serve(config_file=options.config_file, strict=options.strict, livereload=options.livereload, clean=options.clean, theme=options.theme, pages=options.pages, page_keys=options.page_keys)
    elif options.command == 'build':
        commands.build(config_file=options.config_file, theme=options.theme, pages=options.pages, page_keys=options.page_keys)

    # Display logging results
    print 'WARNINGS: {}  ERRORS: {}'.format(formatter.COUNTS['WARNING'], formatter.COUNTS['ERROR'])
    return formatter.COUNTS['ERROR'] > 0
예제 #6
0
    def test_whitelist(self):
        args = parse_args(["dev", "build", "--whitelist", self.BLANK_WL, "--dry"])
        cmd, dfile, pipfile = build(args)
        with open("src/build/core.requirements.txt", "r") as f:
            core_deps = f.readlines()
        self.assertListEqual(core_deps, pipfile)

        args = parse_args(["dev", "build", "--whitelist", self.SELECTOR_WL, "--dry"])
        cmd, dfile, pipfile = build(args)
        self.assertListEqual(
            pipfile, core_deps + read_deps("youtube") + read_deps("twitter")
        )
예제 #7
0
파일: main.py 프로젝트: qing3peng/moose
def run():
    """
    Main MooseDocs command.
    """

    # Options
    options = vars(command_line_options())

    # Initialize logging
    formatter = init_logging(options.pop('verbose'))

    # Create cache directory.
    # This needs to be done hear rather than in MooseDocs/__init__.py to avoid race condition
    # when multiple processes are loading the MooseDocs module.
    if not os.path.exists(MooseDocs.TEMP_DIR):
        os.makedirs(MooseDocs.TEMP_DIR)

    # Remove moose.svg files (these get generated via dot)
    LOG.debug('Removing *.moose.svg files from %s', os.getcwd())
    purge(['svg'])

    # Pull LFS image files
    try:
        subprocess.check_output(['git', 'lfs', 'pull'], cwd=MooseDocs.ROOT_DIR)
    except subprocess.CalledProcessError:
        LOG.error(
            "Unable to run 'git lfs', it is likely not installed but required for "
            "the MOOSE documentation system.")
        sys.exit(1)

    # Execute command
    cmd = options.pop('command')
    if cmd == 'test':
        retcode = 0
        LOG.error('Deprecated command, please used "~/projects/moose/python/run_tests ' \
                  '-j8 --re=MooseDocs" instead.')
    elif cmd == 'check':
        retcode = commands.check(**options)
    elif cmd == 'generate':
        retcode = 0
        LOG.error(
            'Deprecated command, please used "check --generate" instead.')
    elif cmd == 'serve':
        retcode = 0
        LOG.error('Deprecated command, please used "build --serve" instead.')
    elif cmd == 'build':
        retcode = commands.build(**options)
    elif cmd == 'latex':
        retcode = commands.latex(**options)
    elif cmd == 'presentation':
        retcode = commands.presentation(**options)

    # Check retcode
    if retcode:
        return retcode

    # Display logging results
    warn, err = formatter.counts()
    print 'WARNINGS: {}  ERRORS: {}'.format(warn, err)
    return err > 0
예제 #8
0
 def test_default_build(self):
     args = parse_args(["dev", "build", "--dry"])
     cmd, dfile, pipfile = build(args)
     self.assertTrue(
         dockerimage_tag_matches(cmd, "forensicarchitecture/mtriage:dev")
     )
     self.assertTrue(builds_from_cpu_dockerfile(dfile))
예제 #9
0
    def test_whitelist(self):
        args = parse_args(
            ["dev", "build", "--whitelist", self.BLANK_WL, "--dry"])
        cmd, dfile, pipfile = build(args)
        with open("src/build/core.requirements.txt", "r") as f:
            core_deps = f.readlines()
        self.assertListEqual(core_deps, pipfile)

        args = parse_args(
            ["dev", "build", "--whitelist", self.SELECTOR_WL, "--dry"])
        cmd, dfile, pipfile = build(args)
        expected_pipfile = core_deps + read_deps("Youtube") + read_deps(
            "Twitter")
        expected_pipfile = [x for x in expected_pipfile if x != '\n']
        pipfile = [x for x in pipfile if x != '\n']
        self.assertListEqual(pipfile, expected_pipfile)
예제 #10
0
    def test_custom_tags(self):
        args = parse_args(["dev", "build", "--tag", "CUSTOM_TAG", "--dry"])
        cmd, dfile, pipfile = build(args)
        self.assertTrue(
            dockerimage_tag_matches(cmd,
                                    "forensicarchitecture/mtriage:CUSTOM_TAG"))

        args = parse_args(
            ["run", "docs/tutorial/1/1a.yaml", "--tag", "CUSTOM_TAG", "--dry"])
        cmd = run(args)
        self.assertTrue(cmd[-1] == "forensicarchitecture/mtriage:CUSTOM_TAG")
예제 #11
0
파일: main.py 프로젝트: zachmprince/moose
def run():
    """
    Main MooseDocs command.
    """

    # Options
    options = vars(command_line_options())

    # Initialize logging
    formatter = init_logging(options.pop('verbose'))

    # Create cache directory.
    # This needs to be done hear rather than in MooseDocs/__init__.py to avoid race condition
    # when multiple processes are loading the MooseDocs module.
    if not os.path.exists(MooseDocs.TEMP_DIR):
        os.makedirs(MooseDocs.TEMP_DIR)

    # Remove moose.svg files (these get generated via dot)
    LOG.debug('Removing *.moose.svg files from %s', os.getcwd())
    purge(['svg'])

    # Execute command
    cmd = options.pop('command')
    if cmd == 'test':
        retcode = 0
        LOG.error('Deprecated command, please used "~/projects/moose/python/run_tests ' \
                  '-j8 --re=MooseDocs" instead.')
    elif cmd == 'check':
        retcode = commands.check(**options)
    elif cmd == 'generate':
        retcode = 0
        LOG.error('Deprecated command, please used "check --generate" instead.')
    elif cmd == 'serve':
        retcode = 0
        LOG.error('Deprecated command, please used "build --serve" instead.')
    elif cmd == 'build':
        retcode = commands.build(**options)
    elif cmd == 'latex':
        retcode = commands.latex(**options)
    elif cmd == 'presentation':
        retcode = commands.presentation(**options)

    # Check retcode
    if retcode:
        return retcode

    # Display logging results
    warn, err = formatter.counts()
    print 'WARNINGS: {}  ERRORS: {}'.format(warn, err)
    return err > 0
예제 #12
0
def moosedocs():

    # Options
    options = vars(command_line_options())

    # Initialize logging
    formatter = init_logging(options.pop('verbose'))
    log = logging.getLogger('MooseDocs')

    # Remove moose.svg files (these get generated via dot)
    log.debug('Removing *.moose.svg files from {}'.format(os.getcwd()))
    purge(['svg'])

    # Pull LFS image files
    try:
        subprocess.check_output(['git', 'lfs', 'pull'])
    except subprocess.CalledProcessError:
        print "ERROR: Unable to run 'git lfs', it is likely not installed but required for the MOOSE documentation system."
        sys.exit(1)

    # Execute command
    cmd = options.pop('command')
    if cmd == 'test':
        retcode = commands.test(**options)
    elif cmd == 'check':
        retcode = commands.check(**options)
    elif cmd == 'generate':
        retcode = commands.generate(**options)
    elif cmd == 'serve':
        retcode = commands.serve(**options)
    elif cmd == 'build':
        retcode = commands.build(**options)
    elif cmd == 'latex':
        retcode = commands.latex(**options)

    # Check retcode
    if retcode is not None:
        return retcode

    # Display logging results
    warn, err = formatter.counts()
    print 'WARNINGS: {}  ERRORS: {}'.format(warn, err)
    return err > 0
예제 #13
0
 def test_gpu_build(self):
     args = parse_args(["dev", "build", "--gpu", "--dry"])
     cmd, dfile, pipfile = build(args)
     self.assertTrue(builds_from_gpu_dockerfile(dfile))