Example #1
0
 def dump(self, filename=CONFIGURED_STATE_DUMP):
     # Write into tmp file and atomtically rename the file to avoid
     # corruption
     f = open(filename + ".tmp", 'wb')
     try:
         s = dumps(self)
         f.write(s)
     finally:
         f.close()
     rename(filename + ".tmp", filename)
Example #2
0
    def run(self, ctx):
        pprint('BLUE', "Distcheck...")
        bentomaker_script = os.path.abspath(sys.argv[0])
        if sys.platform == "win32":
            bentomaker_script = [sys.executable, bentomaker_script]
        else:
            bentomaker_script = [bentomaker_script]

        pprint('PINK', "\t-> Running sdist...")
        sdist = get_command("sdist")()
        sdist.run(ctx)
        tarname = sdist.tarname
        tardir = sdist.topdir

        saved = os.getcwd()
        if os.path.exists(DISTCHECK_DIR):
            shutil.rmtree(DISTCHECK_DIR)
        os.makedirs(DISTCHECK_DIR)
        target = os.path.join(DISTCHECK_DIR,
                              os.path.basename(tarname))
        rename(tarname, target)
        tarname = os.path.basename(target)

        os.chdir(DISTCHECK_DIR)
        try:
            pprint('PINK', "\t-> Extracting sdist...")
            tarball = tarfile.TarFile.gzopen(tarname)
            tarball.extractall()
            os.chdir(tardir)

            pprint('PINK', "\t-> Configuring from sdist...")
            check_call(bentomaker_script + ["configure", "--prefix=%s" % os.path.abspath("tmp")])

            pprint('PINK', "\t-> Building from sdist...")
            check_call(bentomaker_script + ["build", "-i"])

            pprint('PINK', "\t-> Building egg from sdist...")
            check_call(bentomaker_script + ["build_egg"])

            if sys.platform == "win32":
                pprint('PINK', "\t-> Building wininst from sdist...")
                check_call(bentomaker_script + ["build_wininst"])

            if "test" in get_command_names():
                pprint('PINK', "\t-> Testing from sdist...")
                try:
                    check_call(bentomaker_script + ["test"])
                except CalledProcessError, e:
                    raise CommandExecutionFailure(
                            "test command failed")
            else:
Example #3
0
 def safe_write(self, data, flags='w'):
     tmp = self.parent.make_node([self.name + ".tmp"])
     tmp.write(data, flags)
     rename(tmp.abspath(), self.abspath())
Example #4
0
    def run(self, ctx):
        pprint('BLUE', "Distcheck...")
        pprint('PINK', "\t-> Running sdist...")

        sdist = run_sdist(ctx)
        tarname = sdist.tarname
        tardir = sdist.topdir

        saved = os.getcwd()

        distcheck_dir = ctx.build_node.make_node(DISTCHECK_DIR)
        if os.path.exists(distcheck_dir.abspath()):
            shutil.rmtree(distcheck_dir.abspath())
        distcheck_dir.mkdir()
        target = distcheck_dir.make_node(os.path.basename(tarname))
        rename(tarname, target.abspath())
        tarname = os.path.basename(target.abspath())

        os.chdir(distcheck_dir.abspath())
        try:
            pprint('PINK', "\t-> Extracting sdist...")
            tarball = TarFile.gzopen(tarname)
            tarball.extractall()
            os.chdir(tardir)

            def _call(cmd):
                p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
                stdout, stderr = p.communicate()
                stdout = stdout.strip()
                stderr = stderr.strip()
                if stdout:
                    print stdout.decode()
                if stderr:
                    print stderr.decode()
                if p.returncode != 0:
                    raise CalledProcessError(p.returncode, cmd)

            if sys.version_info[0] < 3:
                bentomaker_script = _BENTOMAKER_SCRIPT
            else:
                bentomaker_script = [sys.executable, "-m", "bentomakerlib.bentomaker"]

            pprint('PINK', "\t-> Configuring from sdist...")
            _call(bentomaker_script + ["configure", "--prefix=%s" % os.path.abspath("tmp")])

            pprint('PINK', "\t-> Building from sdist...")
            _call(bentomaker_script + ["build", "-i"])

            pprint('PINK', "\t-> Building egg from sdist...")
            _call(bentomaker_script + ["build_egg"])

            if sys.platform == "win32":
                pprint('PINK', "\t-> Building wininst from sdist...")
                _call(bentomaker_script + ["build_wininst"])

            if "test" in COMMANDS_REGISTRY.get_command_names():
                pprint('PINK', "\t-> Testing from sdist...")
                try:
                    _call(bentomaker_script + ["test"])
                except CalledProcessError, e:
                    raise CommandExecutionFailure(
                            "test command failed")
            else:
Example #5
0
 def safe_write(self, data, flags='w'):
     tmp = self.parent.make_node([self.name + ".tmp"])
     tmp.write(data, flags)
     rename(tmp.abspath(), self.abspath())