Пример #1
0
def run_example(name, script_output, run=False):
    os.chdir("../docs/guide/creating-content/")
    os.chdir(name)
    populate_filters_log, populate_filters_logstream = stream_logger("%s.populate.filters.log" % name)
    log, logstream = stream_logger("%s.log" % name)

    with divert_stdout() as stdout:
        Document.filter_list = dexy.introspect.filters(populate_filters_log)

        controller = Controller(args)
        controller.log = log
        controller.load_config()
        controller.process_config()
        controller.virtual_docs = []

        for doc in controller.docs:
            doc.log = log

        [doc.setup() for doc in controller.docs]
        controller.docs = [doc.run() for doc in controller.docs]
        script_output["%s-run" % name] = stdout.getvalue()
        script_output['docs'] = dict((doc.key(), doc.last_artifact.data_dict) for doc in controller.docs)
        print script_output['docs']

    script_output["%s-populate-filters" % name] = populate_filters_logstream.getvalue()
    script_output["%s-log" % name] = logstream.getvalue()
    os.chdir("..")
    os.chdir("../../../artifacts")
Пример #2
0
def run_example(name, script_output, run=False):
    log, logstream = stream_logger("%s.log" % name)
    populate_filters_log, populate_filters_logstream= stream_logger("%s.populate.filters.log" % name)
    os.chdir(name)

    with divert_stdout() as stdout:
        ### @export "controller-config"
        controller = Controller(args)
        controller.log = log
        controller.load_config()
        controller.process_config()
        controller.virtual_docs = []
        ### @end
        if run:
            for doc in controller.docs:
                doc.log = log
            ### @export "populate-filters"
            Document.filter_list = dexy.introspect.filters(populate_filters_log)
            ### @export "controller-run"
            [doc.setup() for doc in controller.docs]
            controller.docs = [doc.run() for doc in controller.docs]
            ### @end
        script_output["%s-run" % name] = stdout.getvalue()

    os.chdir("..")

    script_output["%s-depends" % name] = repr(controller.depends)
    script_output["%s-docs" % name] = print_controller_docs(controller)
    script_output["%s-log" % name] = logstream.getvalue()
    script_output["%s-populate-filters" % name] = populate_filters_logstream.getvalue()
    script_output["%s-members" % name] = print_controller_members(controller)
    script_output["%s-ordering" % name] = repr(controller.ordering)
    script_output["%s-doc-logs" % name] = dict((doc.key(), doc.logstream.getvalue()) for doc in controller.docs)
Пример #3
0
def test_run():
    with tempdir():
        fn = modargs.function_for(dexy.commands, "dexy")
        args = modargs.determine_kwargs(fn)
        args['globals'] = []
        os.mkdir(args['logsdir'])
        c = Controller(args)
        c.config = SIMPLE_PY_CONFIG
        c.process_config()
        assert c.members.has_key("simple.py|py")
        assert isinstance(c.members["simple.py|py"], Document)
Пример #4
0
def run_dexy_without_tempdir(config_dict, additional_args={}):
    if not hasattr(Document, 'filter_list'):
        Document.filter_list = dexy.introspect.filters()
    
    args = controller_args(additional_args)

    c = Controller(args)
    c.config = config_dict
    c.process_config()

    [doc.setup() for doc in c.docs]

    for doc in c.docs:
        yield(doc)

    c.persist()
Пример #5
0
def test_circular_dependencies():
    with tempdir():
        fn = modargs.function_for(dexy.commands, "dexy")
        args = modargs.determine_kwargs(fn)
        args['globals'] = []
        os.mkdir(args['logsdir'])
        args['danger'] = True
        c = Controller(args)
        c.config = CIRCULAR_CONFIG
        with divert_stdout() as stdout:
            try:
                c.process_config()
                assert False
            except CycleError:
                assert True
            stdout_text = stdout.getvalue()
        assert "abc depends on ghi" in stdout_text
        assert "def depends on abc" in stdout_text
        assert "ghi depends on def" in stdout_text
Пример #6
0
def test_docs_with_no_filters():
    with tempdir():
        fn = modargs.function_for(dexy.commands, "dexy")
        args = modargs.determine_kwargs(fn)
        args['globals'] = []
        os.mkdir(args['logsdir'])
        c = Controller(args)
        c.config = NO_FILTERS_CONFIG
        c.process_config()
        assert c.members.has_key("hello.txt")
        assert isinstance(c.members["hello.txt"], Document)
        assert sorted(c.batch_info().keys()) == [
                "args",
                "config",
                "docs",
                "elapsed",
                "finish_time",
                "id",
                "start_time",
                "timing"
                ]
Пример #7
0
def run_dexy_without_tempdir(config_dict, additional_args={}):
    if not hasattr(Document, "filter_list"):
        Document.filter_list = dexy.introspect.filters()

    fn = modargs.function_for(dexy.commands, "dexy")
    args = modargs.determine_kwargs(fn)
    args.update(additional_args)

    if not os.path.exists(args["logsdir"]):
        os.mkdir(args["logsdir"])
    if not os.path.exists(args["artifactsdir"]):
        os.mkdir(args["artifactsdir"])

    c = Controller(args)
    c.config = config_dict
    c.process_config()

    [doc.setup() for doc in c.docs]

    for doc in c.docs:
        yield (doc)

    c.persist()