Пример #1
0
    def run(self, *args, **kwargs):
        from django.conf import settings
        dist = kwargs.get("dist", False)
        buildpath = "dist" if dist else "build"
        less_dir = os.path.join(self.site.paths['static'], "less")
        css_dir = os.path.join(self.site.paths[buildpath], settings.STATIC_URL_REL, 'css')
        if not os.path.isdir(less_dir) or not os.listdir(less_dir):
            return

        main_file_less = self.config.get("main_file_less", "main.less")
        main_file_css = self.config.get("main_file_css", "main.css")
        sass = self.config.get(
            "command",
            "lessc {input} {output}"
        )

        cmd = sass.format(
            input=shell_escape(
                os.path.realpath(
                    os.path.join(less_dir, main_file_less)
                )
            ),
            output=shell_escape(
                os.path.realpath(
                    os.path.join(css_dir, main_file_css)
                )
            ),
            )

        os.chdir(less_dir)
        if os.name == "nt":
            run_subprocess(cmd)
        else:
            os.system(cmd)
Пример #2
0
def appsRunning(l):
    if os.name == "nt":
        psdata = run_subprocess(
            ['wmic', 'process', 'get', 'description']
        )
    else:
        psdata = run_subprocess(['ps aux'])
    retval = {}
    for app in l:
        retval[app] = app in psdata
    return retval
Пример #3
0
def applescript(input):
    # Bail if we're not on mac os for now
    if platform.system() != "Darwin":
        return

    command = "osascript<<END%sEND" % input
    return run_subprocess(command)
Пример #4
0
    def run(self, *args, **kwargs):
        from django.conf import settings
        s_type = self.config.get("type", "sass")
        if s_type != "sass" and s_type != "scss":
            s_type = "sass"

        dist = kwargs.get("dist", False)
        buildpath = "dist" if dist else "build"
        sass_dir = os.path.join(self.site.paths['static'], s_type)
        css_dir = os.path.join(self.site.paths[buildpath], settings.STATIC_URL_REL, 'css')
        if not os.path.isdir(sass_dir) or not os.listdir(sass_dir):
            return

        if not os.path.exists(css_dir):
            os.makedirs(css_dir)

        main_file_sass = self.config.get("main_file_sass", "main.sass")
        if s_type == "scss":
            main_file_sass = self.config.get("main_file_scss", "main.scss")
        main_file_css = self.config.get("main_file_css", "main.css")
        sass = self.config.get(
            "command",
            "%s -t compressed {input} {output}" % s_type
        )

        cmd = sass.format(
            input=shell_escape(
                os.path.realpath(
                    os.path.join(sass_dir, main_file_sass)
                )
            ),
            output=shell_escape(
                os.path.realpath(
                    os.path.join(css_dir, main_file_css)
                )
            ),
        )

        os.chdir(sass_dir)
        if os.name == "nt":
            run_subprocess(cmd)
        else:
            os.system(cmd)
    def run(self, *args, **kwargs):
        from django.conf import settings
        dist = kwargs.get("dist", False)

        coffeepath = os.path.realpath(
            os.path.join(
                self.site.paths['static'], 'coffee'
            )
        )
        if not os.path.isdir(coffeepath) or not os.listdir(coffeepath):
            return

        def sort_by_buildorder(a, b):
            return 0
        try:
            build_order = self.config.get("build_order")
            if build_order:
                def sort_by_buildorder(a, b):
                    a = self._path_to_url(a, coffeepath)
                    b = self._path_to_url(b, coffeepath)

                    idx_a = 9999999
                    idx_b = 9999999
                    if a in build_order:
                        idx_a = build_order.index(a)

                    if b in build_order:
                        idx_b = build_order.index(b)

                    if idx_a == idx_b:
                        return 0

                    return cmp(idx_a, idx_b)
        except:
            pass

        files = fileList(coffeepath)
        files.sort(sort_by_buildorder)
        files = " ".join(map(lambda x: shell_escape(x), files))

        output_filename = self.config.get(
            "output_filename",
            "main.js"
        )

        temp_output_filename = ".tmp.main.js"

        coffee = self.config.get(
            "command",
            "coffee --join {output_filename} --compile --output {dir_js} {files}"
        )

        dir_js = os.path.abspath(
            os.path.join(
                self.site.paths["dist" if dist else "build"],
                settings.STATIC_URL_REL, "js"
            )
        )

        cmd = coffee.format(
            output_filename=temp_output_filename,
            dir_js=shell_escape(dir_js),
            files=files,
        )

        result = 0
        if os.name == "nt":
            run_subprocess(cmd)
            # TODO: take return code into account on windows
        else:
            print cmd
            result = os.system(cmd)

        if result == 0:
            shutil.move(
                os.path.abspath(os.path.join(dir_js, temp_output_filename)),
                os.path.abspath(os.path.join(dir_js, output_filename)),
            )
        else:
            try:
                os.remove(os.path.join(dir_js, temp_output_filename))
            except OSError:
                pass