Пример #1
0
 def build_execution_plan (self, task_names):
     self.assert_dependencies_resolved()
             
     execution_plan = []
     for name in as_list(task_names):
         self.enqueue_task(execution_plan, name)
     return execution_plan
Пример #2
0
def execute_tool_on_source_files (project, name, command_and_arguments):
    source_dir = project.expand_path("$dir_source_main_python")
    files = discover_files(source_dir, ".py")
    command = as_list(command_and_arguments) + [f for f in files]

    report_file = project.expand_path("$dir_reports/%s" % name)

    return execute_command(command, report_file), report_file
Пример #3
0
def as_task_name_list (mixed):
    result = []
    for d in as_list(mixed):
        if isinstance(d, types.FunctionType):
            result.append(d.__name__)
        else:
            result.append(str(d))
    return result
Пример #4
0
def execute_tool_on_modules (project, name, command_and_arguments, extend_pythonpath=True):
    source_dir = project.expand_path("$dir_source_main_python")
    modules = discover_modules(source_dir)
    command = as_list(command_and_arguments) + modules

    report_file = project.expand_path("$dir_reports/%s" % name)

    env = os.environ
    if extend_pythonpath:
        env["PYTHONPATH"] = source_dir
    return execute_command(command, report_file, env=env), report_file
Пример #5
0
    def build(self, tasks=[], environments=[]):
        Reactor._current_instance = self

        if environments:
            self.logger.info("Activated environments: %s", ", ".join(environments))

        self.execution_manager.execute_initializers(environments, logger=self.logger, project=self.project)

        self.log_project_properties()

        self.validate_project()

        tasks = as_list(tasks)

        if not len(tasks):
            if self.project.default_task:
                tasks += as_list(self.project.default_task)
            else:
                raise PythonbuilderException("No default task given.")

        execution_plan = self.execution_manager.build_execution_plan(tasks)
        self.logger.debug("Execution plan is %s", ", ".join([task.name for task in execution_plan]))

        self.logger.info("Building %s version %s", self.project.name, self.project.version)
        self.logger.info("Executing build in %s", self.project.basedir)
        self.logger.info("Going to execute task%s %s",
            "s" if len(tasks) != 1 else "",
            ", ".join(tasks))

        task_execution_summaries =\
        self.execution_manager.execute_execution_plan(execution_plan,
            logger=self.logger,
            project=self.project,
            reactor=self)

        return BuildSummary(self.project, task_execution_summaries)
Пример #6
0
def build_binary_distribution(project, logger):
    reports_dir = project.expand_path("$dir_reports/distutils")
    if not os.path.exists(reports_dir):
        os.mkdir(reports_dir)

    setup_script = project.expand_path("$dir_dist/setup.py")

    logger.info("Building binary distribution in %s", project.expand_path("$dir_dist"))

    commands = as_list(project.get_property("distutils_commands"))

    for command in commands:
        logger.debug("Executing distutils command %s", command)
        with open(os.path.join(reports_dir, command), "w") as output_file:
            process = subprocess.Popen((sys.executable, setup_script, command),
                cwd=project.expand_path("$dir_dist"),
                stdout=output_file,
                stderr=output_file,
                shell=False)
            return_code = process.wait()
            if return_code != 0:
                raise BuildFailedException("Error while executing setup command %s", command)
Пример #7
0
 def test_should_wrap_single_string_as_list (self):
     self.assertEquals(["spam"], as_list("spam"))
Пример #8
0
 def is_applicable (self, environments=None):
     if not self.environments:
         return True
     for environment in as_list(environments):
         if environment in self.environments:
             return True
Пример #9
0
 def test_should_unwrap_multiple_tuples (self):
     self.assertEquals(["spam", "eggs", "foo", "bar"], as_list(("spam", "eggs"), ("foo", "bar")))
Пример #10
0
 def test_should_unwrap_mixed_tuples_and_lists_and_strings (self):
     self.assertEquals(["spam", "eggs", "foo", "bar", "foobar"], as_list(("spam", "eggs"), ["foo", "bar"], "foobar"))
Пример #11
0
 def test_should_unwrap_multiple_lists (self):
     self.assertEquals(["spam", "eggs", "foo", "bar"], as_list(["spam", "eggs"], ["foo", "bar"]))
Пример #12
0
 def test_should_unwrap_single_tuple (self):
     self.assertEquals(["spam", "eggs"], as_list(("spam", "eggs")))
Пример #13
0
 def test_should_wrap_two_strings_as_list (self):
     self.assertEquals(["spam", "eggs"], as_list("spam", "eggs"))
Пример #14
0
 def test_should_unwrap_mixed_tuples_and_lists_and_strings_and_ignore_none_values (self):
     self.assertEquals(["spam", "eggs", "foo", "bar", "foobar"], as_list(None, ("spam", "eggs"),
                                                                         None, ["foo", "bar"],
                                                                         None, "foobar", None))
Пример #15
0
 def test_should_return_empty_list_when_none_is_given (self):
     self.assertEquals([], as_list(None))
Пример #16
0
 def test_should_return_empty_list_when_no_argument_is_given (self):
     self.assertEquals([], as_list())
Пример #17
0
 def test_should_return_list_of_function (self):
     def foo (): pass
     self.assertEquals([foo], as_list(foo))