本文整理汇总了Python中common_py.system.filesystem.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Python FileSystem类的具体用法?Python FileSystem怎么用?Python FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileSystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_checktest
def run_checktest(option):
checktest_quiet = 'yes'
if os.getenv('TRAVIS') == "true":
checktest_quiet = 'no'
# iot.js executable
iotjs = fs.join(build_root, 'iotjs', 'iotjs')
fs.chdir(path.PROJECT_ROOT)
code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH,
'--',
'quiet='+checktest_quiet])
if code != 0:
ex.fail('Failed to pass unit tests')
if not option.no_check_valgrind:
code = ex.run_cmd('valgrind', ['--leak-check=full',
'--error-exitcode=5',
'--undef-value-errors=no',
iotjs,
path.CHECKTEST_PATH,
'--',
'quiet='+checktest_quiet])
if code == 5:
ex.fail('Failed to pass valgrind test')
if code != 0:
ex.fail('Failed to pass unit tests in valgrind environment')
return True
示例2: get_snapshot_contents
def get_snapshot_contents(js_path, snapshot_tool):
""" Convert the given module with the snapshot generator
and return the resulting bytes.
"""
wrapped_path = js_path + ".wrapped"
snapshot_path = js_path + ".snapshot"
module_name = os.path.splitext(os.path.basename(js_path))[0]
with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
if module_name != "iotjs":
fwrapped.write("(function(exports, require, module, native) {\n")
fwrapped.write(fmodule.read())
if module_name != "iotjs":
fwrapped.write("});\n")
ret = subprocess.call([snapshot_tool,
"generate",
"--context", "eval",
"-o", snapshot_path,
wrapped_path])
fs.remove(wrapped_path)
if ret != 0:
msg = "Failed to dump %s: - %d" % (js_path, ret)
print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
fs.remove(snapshot_path)
exit(1)
return snapshot_path
示例3: get_snapshot_contents
def get_snapshot_contents(module_name, snapshot_generator):
""" Convert the given module with the snapshot generator
and return the resulting bytes.
"""
js_path = fs.join(path.SRC_ROOT, 'js', module_name + '.js')
wrapped_path = js_path + ".wrapped"
snapshot_path = js_path + ".snapshot"
with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
if module_name != "iotjs":
fwrapped.write("(function(exports, require, module) {\n")
fwrapped.write(fmodule.read())
if module_name != "iotjs":
fwrapped.write("});\n")
ret = subprocess.call([snapshot_generator,
"--save-snapshot-for-eval",
snapshot_path,
wrapped_path])
if ret != 0:
msg = "Failed to dump %s: - %d" % (js_path, ret)
print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
exit(1)
with open(snapshot_path, 'rb') as snapshot:
code = snapshot.read()
fs.remove(wrapped_path)
fs.remove(snapshot_path)
return code
示例4: get_snapshot_contents
def get_snapshot_contents(js_path, snapshot_tool, literals=None):
""" Convert the given module with the snapshot generator
and return the resulting bytes.
"""
wrapped_path = js_path + ".wrapped"
snapshot_path = js_path + ".snapshot"
module_name = os.path.splitext(os.path.basename(js_path))[0]
with open(wrapped_path, 'w') as fwrapped, open(js_path, "r") as fmodule:
if module_name != "iotjs":
fwrapped.write("(function(exports, require, module, native) {\n")
fwrapped.write(fmodule.read())
if module_name != "iotjs":
fwrapped.write("});\n")
cmd = [snapshot_tool, "generate", "-o", snapshot_path]
if literals:
cmd.extend(["--static", "--load-literals-list-format", literals])
ret = subprocess.call(cmd + [wrapped_path])
fs.remove(wrapped_path)
if ret != 0:
if literals == None:
msg = "Failed to dump %s: - %d" % (js_path, ret)
print("%s%s%s" % ("\033[1;31m", msg, "\033[0m"))
exit(1)
else:
print("Unable to create static snapshot from '%s'. Falling back "
"to normal snapshot." % js_path)
return snapshot_path
示例5: configure_trizenrt
def configure_trizenrt(tizenrt_root, buildtype):
# TODO: handle buildtype (build vs release) for tizenrt build
tizenrt_tools = fs.join(tizenrt_root, 'os/tools')
fs.chdir(tizenrt_tools)
ex.check_run_cmd('./configure.sh', ['artik053/iotjs'])
fs.chdir('..')
ex.check_run_cmd('make', ['context'])
示例6: run_checktest
def run_checktest(options):
checktest_quiet = 'yes'
if os.getenv('TRAVIS') == "true":
checktest_quiet = 'no'
# iot.js executable
iotjs = fs.join(options.build_root, 'bin', 'iotjs')
build_args = ['--', 'quiet=' + checktest_quiet]
if options.iotjs_exclude_module:
skip_module = ','.join(options.iotjs_exclude_module)
build_args.append('skip-module=' + skip_module)
# experimental
if options.experimental:
build_args.append('experimental=' + 'yes');
fs.chdir(path.PROJECT_ROOT)
code = ex.run_cmd(iotjs, [path.CHECKTEST_PATH] + build_args)
if code != 0:
ex.fail('Failed to pass unit tests')
if not options.no_check_valgrind:
code = ex.run_cmd('valgrind', ['--leak-check=full',
'--error-exitcode=5',
'--undef-value-errors=no',
iotjs,
path.CHECKTEST_PATH] + build_args)
if code == 5:
ex.fail('Failed to pass valgrind test')
if code != 0:
ex.fail('Failed to pass unit tests in valgrind environment')
示例7: test_cpp
def test_cpp():
test_dir = fs.join(os.path.dirname(__file__), 'test_cpp')
test_cpp = fs.join(test_dir, 'test.cpp')
# Compile test.c and make a static library
print_blue('Compile C++ test module.')
ex.check_run_cmd_output('c++', ['-c', test_cpp, '-o', test_dir + '/test.o'])
ex.check_run_cmd_output('ar', ['-cr', test_dir + '/libtest.a',
test_dir + '/test.o'])
# Generate test_module
print_blue('Generate binding for C++ test module.')
ex.check_run_cmd_output(generator_script, [test_dir, 'c++'])
# Build iotjs
print_blue('Build IoT.js.')
module_dir = fs.join(module_generator_dir, 'output', 'test_cpp_module')
args = [
'--external-module=' + module_dir,
'--cmake-param=-DENABLE_MODULE_TEST_CPP_MODULE=ON',
'--jerry-profile=es2015-subset',
'--clean'
]
ex.check_run_cmd_output(build_script, args)
run_test_js(test_dir)
print_green('C++ test succeeded.')
示例8: set_config_tizenrt
def set_config_tizenrt(buildtype):
exec_docker(DOCKER_ROOT_PATH, [
'cp',
fs.join(DOCKER_IOTJS_PATH,
'config/tizenrt/artik05x/configs/',
buildtype, 'defconfig'),
fs.join(DOCKER_TIZENRT_OS_PATH, '.config')])
示例9: build_nuttx
def build_nuttx(nuttx_root, buildtype, maketarget):
fs.chdir(fs.join(nuttx_root, 'nuttx'))
if buildtype == "release":
rflag = 'R=1'
else:
rflag = 'R=0'
ex.check_run_cmd('make',
[maketarget, 'IOTJS_ROOT_DIR=' + path.PROJECT_ROOT, rflag])
示例10: setup_tizen_root
def setup_tizen_root(tizen_root):
if fs.exists(tizen_root):
fs.chdir(tizen_root)
ex.check_run_cmd('git', ['pull'])
fs.chdir(path.PROJECT_ROOT)
else:
ex.check_run_cmd('git', ['clone',
'https://github.com/pmarcinkiew/tizen3.0_rootstrap.git',
tizen_root])
示例11: build_napi_test_module
def build_napi_test_module(is_debug):
node_gyp = fs.join(path.PROJECT_ROOT,
'node_modules',
'.bin',
'node-gyp')
print('==> Build N-API test module with node-gyp\n')
project_root = fs.join(path.PROJECT_ROOT, 'test', 'napi')
debug_cmd = '--debug' if is_debug else '--release'
Executor.check_run_cmd(node_gyp, ['configure', debug_cmd ,'rebuild'],
cwd=project_root)
示例12: copy_tiznert_stuff
def copy_tiznert_stuff(tizenrt_root, iotjs_dir):
tizenrt_iotjsapp_dir = fs.join(tizenrt_root, 'apps/system/iotjs')
tizenrt_config_dir = fs.join(tizenrt_root, 'build/configs/artik053/iotjs')
iotjs_tizenrt_appdir = fs.join(iotjs_dir,
'config/tizenrt/artik05x/app')
iotjs_config_dir = \
fs.join(iotjs_dir, 'config/tizenrt/artik05x/configs')
ex.check_run_cmd('cp',
['-rfu', iotjs_tizenrt_appdir, tizenrt_iotjsapp_dir])
ex.check_run_cmd('cp',
['-rfu', iotjs_config_dir, tizenrt_config_dir])
示例13: setup_tizenrt_repo
def setup_tizenrt_repo(tizenrt_root):
if fs.exists(tizenrt_root):
fs.chdir(tizenrt_root)
ex.check_run_cmd('git', ['fetch', 'origin'])
fs.chdir(path.PROJECT_ROOT)
else:
ex.check_run_cmd('git', ['clone',
'https://github.com/Samsung/TizenRT.git',
tizenrt_root])
ex.check_run_cmd('git', ['--git-dir', tizenrt_root + '/.git/',
'--work-tree', tizenrt_root,
'checkout', TIZENRT_COMMIT])
copy_tiznert_stuff(tizenrt_root, path.PROJECT_ROOT)
示例14: build_jerry
def build_jerry(option):
# Check if JerryScript submodule exists.
if not fs.exists(path.JERRY_ROOT):
ex.fail('JerryScript submodule not exists!')
# Move working directory to JerryScript build directory.
build_home = fs.join(host_build_root, 'deps', 'jerry')
fs.maybe_make_directory(build_home)
fs.chdir(build_home)
# Set JerryScript cmake option.
cmake_opt = [path.JERRY_ROOT]
cmake_opt.append('-DCMAKE_TOOLCHAIN_FILE=' + host_cmake_toolchain_file)
if option.buildtype == 'debug':
cmake_opt.append('-DCMAKE_BUILD_TYPE=Debug')
# Turn off LTO for jerry bin to save build time.
cmake_opt.append('-DENABLE_LTO=OFF')
# Turn on snapshot
if not option.no_snapshot:
cmake_opt.append('-DFEATURE_SNAPSHOT_SAVE=ON')
# Run cmake.
ex.check_run_cmd('cmake', cmake_opt)
target_jerry = {
'target_name': 'jerry',
'output_path': fs.join(build_home, 'bin/jerry')
}
# Make option.
make_opt = ['-C', build_home]
if not option.no_parallel_build:
make_opt.append('-j')
# Run make for a target.
ex.check_run_cmd('make', make_opt)
# Check output
output = target_jerry['output_path']
if not fs.exists(output):
print output
ex.fail('JerryScript build failed - target not produced.')
# copy
fs.copy(output, jerry_output_path)
return True
示例15: __init__
def __init__(self, options):
self._process_pool = multiprocessing.Pool(processes=1)
self.iotjs = fs.abspath(options.iotjs)
self.quiet = options.quiet
self.platform = options.platform
self.timeout = options.timeout
self.valgrind = options.valgrind
self.coverage = options.coverage
self.n_api = options.n_api
self.skip_modules = []
self.results = {}
self._msg_queue = multiprocessing.Queue(1)
if options.skip_modules:
self.skip_modules = options.skip_modules.split(",")
# Process the iotjs build information.
iotjs_output = Executor.check_run_cmd_output(self.iotjs,
[path.BUILD_INFO_PATH])
build_info = json.loads(iotjs_output)
self.builtins = set(build_info["builtins"])
self.features = set(build_info["features"])
self.stability = build_info["stability"]
self.debug = build_info["debug"]
if options.n_api:
build_napi_test_module(self.debug)