本文整理汇总了Python中static_precompiler.utils.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compile_file
def compile_file(self, source_path):
full_source_path = self.get_full_source_path(source_path)
full_output_path = self.get_full_output_path(source_path)
args = [
self.executable,
]
if self.is_sourcemap_enabled:
args.append("-m")
args.extend([
full_source_path,
"-o", os.path.dirname(full_output_path),
])
full_output_dirname = os.path.dirname(full_output_path)
if not os.path.exists(full_output_dirname):
os.makedirs(full_output_dirname)
# `cwd` is a directory containing `source_path`.
# Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
out, errors = utils.run_command(args, cwd=cwd)
if errors:
raise exceptions.StaticCompilationError(errors)
utils.convert_urls(full_output_path, source_path)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例2: compile_file
def compile_file(self, source_path):
full_source_path = self.get_full_source_path(source_path)
full_output_path = self.get_full_output_path(source_path)
# `cwd` is a directory containing `source_path`.
# Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
args = [self.executable]
if self.is_sourcemap_enabled:
args.extend(["--source-map"])
if self.global_vars:
for variable_name, variable_value in self.global_vars.items():
args.extend(["--global-var={}={}".format(variable_name, variable_value)])
args.extend([self.get_full_source_path(source_path), full_output_path])
out, errors = utils.run_command(args, cwd=cwd)
if errors:
raise exceptions.StaticCompilationError(errors)
utils.convert_urls(full_output_path, source_path)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例3: compile_file
def compile_file(self, source_path):
full_output_path = self.get_full_output_path(source_path)
# LiveScript bug with source map if the folder isn't already present
if not os.path.exists(os.path.dirname(full_output_path)):
os.makedirs(os.path.dirname(full_output_path))
args = [
self.executable,
"-c",
]
if self.is_sourcemap_enabled:
args.append("-m")
args.append("linked")
args.extend([
"-o", os.path.dirname(full_output_path),
self.get_full_source_path(source_path),
])
return_code, out, errors = utils.run_command(args)
if return_code:
raise exceptions.StaticCompilationError(errors)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例4: compile_file
def compile_file(self, source_path):
full_output_path = self.get_full_output_path(source_path)
output_dir = os.path.dirname(full_output_path)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
template_extension = os.path.splitext(source_path)[1].lstrip(".")
args = [
self.executable,
self.get_full_source_path(source_path),
"-e", template_extension,
"-f", full_output_path,
] + self.get_extra_args()
if self.is_sourcemap_enabled:
args += ["--map", full_output_path + ".map"]
return_code, out, errors = utils.run_command(args)
if return_code:
raise exceptions.StaticCompilationError(errors)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例5: compile_file
def compile_file(self, source_path):
args = [
self.executable,
] + self.get_extra_args()
if self.is_sourcemap_enabled:
args.append("-s")
full_output_path = self.get_full_output_path(source_path)
full_output_dirname = os.path.dirname(full_output_path)
if not os.path.exists(full_output_dirname):
os.makedirs(full_output_dirname)
args.extend(["-o", full_output_path])
args.append(self.get_full_source_path(source_path))
return_code, out, errors = utils.run_command(args)
if return_code:
raise exceptions.StaticCompilationError(errors)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例6: compile_file
def compile_file(self, source_path):
full_source_path = self.get_full_source_path(source_path)
full_output_path = self.get_full_output_path(source_path)
args = [
self.executable,
"--sourcemap={}".format("auto" if self.is_sourcemap_enabled else "none"),
] + self.get_extra_args()
args.extend([
self.get_full_source_path(source_path),
full_output_path,
])
full_output_dirname = os.path.dirname(full_output_path)
if not os.path.exists(full_output_dirname):
os.makedirs(full_output_dirname)
# `cwd` is a directory containing `source_path`.
# Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
out, errors = utils.run_command(args, None, cwd=cwd)
if errors:
if os.path.exists(full_output_path):
os.remove(full_output_path)
raise exceptions.StaticCompilationError(errors)
utils.convert_urls(full_output_path, source_path)
if self.is_sourcemap_enabled:
utils.fix_sourcemap(full_output_path + ".map", source_path, full_output_path)
return self.get_output_path(source_path)
示例7: compile_source
def compile_source(self, source):
args = [self.executable] + self.get_extra_args()
out, errors = utils.run_command(args, source)
if errors:
raise exceptions.StaticCompilationError(errors)
return out
示例8: compile_file
def compile_file(self, source_path):
command = "{0} {1}".format(LESS_EXECUTABLE, self.get_full_source_path(source_path))
out, errors = run_command(command, None, STATIC_ROOT)
if errors:
raise StaticCompilationError(errors)
return out
示例9: compile_source
def compile_source(self, source):
command = "{0} -".format(LESS_EXECUTABLE)
out, errors = run_command(command, source)
if errors:
raise StaticCompilationError(errors)
return out
示例10: compile_source
def compile_source(self, source):
args = [LESS_EXECUTABLE, "-"]
out, errors = run_command(args, source)
if errors:
raise StaticCompilationError(errors)
return out
示例11: compile_source
def compile_source(self, source):
args = [
self.executable
]
out, errors = run_command(args, source)
if errors:
raise StaticCompilationError(errors)
return out
示例12: compile_file
def compile_file(self, source_path):
full_source_path = self.get_full_source_path(source_path)
args = [LESS_EXECUTABLE, full_source_path]
# `cwd` is a directory containing `source_path`. Ex: source_path = '1/2/3', full_source_path = '/abc/1/2/3' -> cwd = '/abc'
cwd = os.path.normpath(os.path.join(full_source_path, *([".."] * len(source_path.split("/")))))
out, errors = run_command(args, None, cwd=cwd)
if errors:
raise StaticCompilationError(errors)
return out
示例13: compile_source
def compile_source(self, source):
command = "{0} -s --scss -C".format(SCSS_EXECUTABLE)
if SCSS_USE_COMPASS:
command += " --compass"
out, errors = run_command(command, source, STATIC_ROOT)
if errors:
raise StaticCompilationError(errors)
return out
示例14: compile_source
def compile_source(self, source):
args = [
self.executable,
"-p",
]
out, errors = utils.run_command(args, input=source)
if errors:
raise exceptions.StaticCompilationError(errors)
return out
示例15: compile_file
def compile_file(self, source_path):
command = "{0} -C {1}".format(SCSS_EXECUTABLE, self.get_full_source_path(source_path))
if SCSS_USE_COMPASS:
command += " --compass"
out, errors = run_command(command, None, STATIC_ROOT)
if errors:
raise StaticCompilationError(errors)
return out