本文整理汇总了Python中utils.tmp_dir函数的典型用法代码示例。如果您正苦于以下问题:Python tmp_dir函数的具体用法?Python tmp_dir怎么用?Python tmp_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tmp_dir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--msvs_version', required=True)
parser.add_argument('--chrome_path')
parser.add_argument('--skia_path')
args = parser.parse_args()
isolate_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'win_toolchain.isolate')
with utils.print_timings():
with utils.tmp_dir() as tmp_dir:
chrome_path = args.chrome_path
if not chrome_path:
print ('Syncing Chrome from scratch. If you already have a checkout, '
'specify --chrome_path to save time.')
chrome_path = os.path.join(tmp_dir.name, 'src')
if not os.path.isdir(chrome_path):
utils.git_clone(REPO_CHROME, chrome_path)
skia_path = args.skia_path
if not skia_path:
print ('Syncing Skia from scratch. If you already have a checkout, '
'specify --chrome_path to save time.')
skia_path = os.path.join(tmp_dir.name, 'skia')
if not os.path.isdir(skia_path):
utils.git_clone(REPO_SKIA, skia_path)
isolated_hash = gen_toolchain(chrome_path, args.msvs_version,
isolate_file)
update_toolchain_file(skia_path, args.msvs_version, isolated_hash)
开发者ID:AHPlankton,项目名称:skia,代码行数:31,代码来源:isolate_win_toolchain.py
示例2: create_asset
def create_asset(target_dir):
"""Create the asset."""
with utils.tmp_dir():
subprocess.check_call(['wget', URL, '--output-document=cmake.tar.gz'])
subprocess.check_call(['tar', '--extract', '--gunzip', '--file',
'cmake.tar.gz', '--directory', target_dir,
'--strip-components', '1'])
开发者ID:google,项目名称:skia,代码行数:7,代码来源:create.py
示例3: main
def main():
if sys.platform != 'win32':
print >> sys.stderr, 'This script only runs on Windows.'
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument('--gsutil')
parser.add_argument('--sdk_path', '-s', required=True)
parser.add_argument('--runtime_path', '-r',
default=os.path.join("C:","System32","vulkan-1.dll"),
required=True)
args = parser.parse_args()
with utils.tmp_dir():
cwd = os.getcwd()
create_script = os.path.join(common.FILE_DIR, 'create.py')
upload_script = os.path.join(common.FILE_DIR, 'upload.py')
try:
cmd = ['python', create_script,
'-t', cwd,
'--sdk_path', args.sdk_path,
'--runtime_path', args.runtime_path]
subprocess.check_call(cmd)
cmd = ['python', upload_script, '-t', cwd]
if args.gsutil:
cmd.extend(['--gsutil', args.gsutil])
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Trap exceptions to avoid printing two stacktraces.
sys.exit(1)
开发者ID:03050903,项目名称:skia,代码行数:30,代码来源:create_and_upload.py
示例4: main
def main():
if 'linux' not in sys.platform:
print >> sys.stderr, 'This script only runs on Linux.'
sys.exit(1)
parser = argparse.ArgumentParser()
parser.add_argument('--gsutil')
parser.add_argument('--lib_path', '-l', required=True)
args = parser.parse_args()
with utils.tmp_dir():
cwd = os.getcwd()
create_script = os.path.join(common.FILE_DIR, 'create.py')
upload_script = os.path.join(common.FILE_DIR, 'upload.py')
try:
subprocess.check_call(['python', create_script,
'-t', cwd,
'-l', args.lib_path])
cmd = ['python', upload_script, '-t', cwd]
if args.gsutil:
cmd.extend(['--gsutil', args.gsutil])
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Trap exceptions to avoid printing two stacktraces.
sys.exit(1)
开发者ID:MIPS,项目名称:external-skia,代码行数:25,代码来源:create_and_upload.py
示例5: download_version
def download_version(self, version, target_dir):
"""Download the specified version of the asset."""
gs_path = GS_PATH_TMPL % (self._gs_subdir, str(version))
target_dir = os.path.abspath(target_dir)
with utils.tmp_dir():
zip_file = os.path.join(os.getcwd(), '%d.zip' % version)
self._gs.copy(gs_path, zip_file)
zip_utils.unzip(zip_file, target_dir)
开发者ID:luzhenrong45,项目名称:skia,代码行数:8,代码来源:asset_utils.py
示例6: download
def download(self, name, version, target_dir):
"""Download from GS."""
gs_path = GS_PATH_TMPL % (GS_SUBDIR_TMPL % (self._gs_bucket, name), str(version))
target_dir = os.path.abspath(target_dir)
with utils.tmp_dir():
zip_file = os.path.join(os.getcwd(), "%d.zip" % version)
self.copy(gs_path, zip_file)
zip_utils.unzip(zip_file, target_dir)
开发者ID:ROM-PacMe,项目名称:skia,代码行数:8,代码来源:asset_utils.py
示例7: upload
def upload(self, name, version, target_dir):
"""Upload to GS."""
target_dir = os.path.abspath(target_dir)
with utils.tmp_dir():
zip_file = os.path.join(os.getcwd(), "%d.zip" % version)
zip_utils.zip(target_dir, zip_file, blacklist=ZIP_BLACKLIST)
gs_path = GS_PATH_TMPL % (GS_SUBDIR_TMPL % (self._gs_bucket, name), str(version))
self.copy(zip_file, gs_path)
开发者ID:ROM-PacMe,项目名称:skia,代码行数:8,代码来源:asset_utils.py
示例8: _json_output
def _json_output(self, cmd):
"""Run the given command, return the JSON output."""
with utils.tmp_dir():
json_output = os.path.join(os.getcwd(), 'output.json')
self._run(cmd + ['--json-output', json_output])
with open(json_output) as f:
parsed = json.load(f)
return parsed.get('result', [])
开发者ID:android,项目名称:platform_external_skia,代码行数:8,代码来源:asset_utils.py
示例9: _write_to_storage
def _write_to_storage(task):
"""Writes the specified compile task to Google storage."""
with utils.tmp_dir():
json_file = os.path.join(os.getcwd(), _get_task_file_name(task))
with open(json_file, 'w') as f:
json.dump(task, f)
subprocess.check_call(['gsutil', 'cp', json_file, '%s/' % _get_gs_bucket()])
print 'Created %s/%s' % (_get_gs_bucket(), os.path.basename(json_file))
开发者ID:google,项目名称:skia,代码行数:8,代码来源:trigger_wait_g3_task.py
示例10: create_asset
def create_asset(chrome_src_path, browser_executable, target_dir,
upload_to_partner_bucket):
"""Create the asset."""
browser_executable = os.path.realpath(browser_executable)
chrome_src_path = os.path.realpath(chrome_src_path)
target_dir = os.path.realpath(target_dir)
if not os.path.exists(target_dir):
os.makedirs(target_dir)
with utils.tmp_dir():
if os.environ.get('CHROME_HEADLESS'):
# Start Xvfb if running on a bot.
try:
subprocess.Popen(['sudo', 'Xvfb', ':0', '-screen', '0', '1280x1024x24'])
except Exception:
# It is ok if the above command fails, it just means that DISPLAY=:0
# is already up.
pass
webpages_playback_cmd = [
'python', os.path.join(SKIA_TOOLS, 'skp', 'webpages_playback.py'),
'--page_sets', 'all',
'--browser_executable', browser_executable,
'--non-interactive',
'--output_dir', os.getcwd(),
'--chrome_src_path', chrome_src_path,
]
if upload_to_partner_bucket:
webpages_playback_cmd.append('--upload_to_partner_bucket')
print 'Running webpages_playback command:\n$ %s' % (
' '.join(webpages_playback_cmd))
try:
subprocess.check_call(webpages_playback_cmd)
finally:
# Clean up any leftover browser instances. This can happen if there are
# telemetry crashes, processes are not always cleaned up appropriately by
# the webpagereplay and telemetry frameworks.
procs = subprocess.check_output(['ps', 'ax'])
for line in procs.splitlines():
if browser_executable in line:
pid = line.strip().split(' ')[0]
if pid != str(os.getpid()) and not 'python' in line:
try:
subprocess.check_call(['kill', '-9', pid])
except subprocess.CalledProcessError as e:
print e
else:
print 'Refusing to kill self.'
src = os.path.join(os.getcwd(), 'playback', 'skps')
for f in os.listdir(src):
if f.endswith('.skp'):
shutil.copyfile(os.path.join(src, f), os.path.join(target_dir, f))
# Copy over private SKPs from Google storage into the target_dir.
subprocess.check_call([
'gsutil', 'cp', os.path.join(PRIVATE_SKPS_GS, '*'), target_dir])
开发者ID:MIPS,项目名称:external-skia,代码行数:57,代码来源:create.py
示例11: _test_versions
def _test_versions(self, store):
with utils.tmp_dir():
# Create input files and directories.
input_dir = os.path.join(os.getcwd(), 'input')
_write_stuff(input_dir)
self.assertEqual(store.get_available_versions(self.asset_name), [])
store.upload(self.asset_name, 0, input_dir)
self.assertEqual(store.get_available_versions(self.asset_name), [0])
store.upload(self.asset_name, 1, input_dir)
self.assertEqual(store.get_available_versions(self.asset_name), [0, 1])
store.delete_contents(self.asset_name)
self.assertEqual(store.get_available_versions(self.asset_name), [])
开发者ID:03050903,项目名称:skia,代码行数:12,代码来源:asset_utils_test.py
示例12: _test_upload_download
def _test_upload_download(self, store):
with utils.tmp_dir():
# Create input files and directories.
input_dir = os.path.join(os.getcwd(), 'input')
_write_stuff(input_dir)
# Upload a version, download it again.
store.upload(self.asset_name, 0, input_dir)
output_dir = os.path.join(os.getcwd(), 'output')
store.download(self.asset_name, 0, output_dir)
# Compare.
test_utils.compare_trees(self, input_dir, output_dir)
开发者ID:03050903,项目名称:skia,代码行数:13,代码来源:asset_utils_test.py
示例13: test_upload_download
def test_upload_download(self):
with utils.tmp_dir():
# Create input files and directories.
input_dir = os.path.join(os.getcwd(), 'input')
_write_stuff(input_dir)
# Upload a version, download it again.
self.a.upload_new_version(input_dir)
output_dir = os.path.join(os.getcwd(), 'output')
self.a.download_current_version(output_dir)
# Compare.
test_utils.compare_trees(self, input_dir, output_dir)
开发者ID:03050903,项目名称:skia,代码行数:13,代码来源:asset_utils_test.py
示例14: download
def download(self, name, version, target_dir):
"""Download a CIPD package."""
pkg_name = CIPD_PACKAGE_NAME_TMPL % name
version_tag = TAG_VERSION_TMPL % version
target_dir = os.path.abspath(target_dir)
with utils.tmp_dir():
infile = os.path.join(os.getcwd(), 'input')
with open(infile, 'w') as f:
f.write('%s %s' % (pkg_name, version_tag))
self._run([
'ensure',
'--root', target_dir,
'--list', infile,
])
开发者ID:android,项目名称:platform_external_skia,代码行数:14,代码来源:asset_utils.py
示例15: create_asset
def create_asset(target_dir, msvs_version, chrome_path=None):
"""Create the asset."""
if not os.path.isdir(target_dir):
os.makedirs(target_dir)
with utils.tmp_dir() as tmp_dir:
if not chrome_path:
print ('Syncing Chrome from scratch. If you already have a checkout, '
'specify --chrome_path to save time.')
chrome_path = os.path.join(tmp_dir.name, 'src')
if not os.path.isdir(chrome_path):
subprocess.check_call([utils.GCLIENT, 'config', REPO_CHROME, '--managed'])
subprocess.check_call([utils.GCLIENT, 'sync'])
gen_toolchain(chrome_path, msvs_version, target_dir)
开发者ID:03050903,项目名称:skia,代码行数:14,代码来源:create.py
示例16: test_zip_unzip
def test_zip_unzip(self):
with utils.tmp_dir():
fw = test_utils.FileWriter(os.path.join(os.getcwd(), 'input'))
# Create input files and directories.
fw.mkdir('mydir')
fw.mkdir('anotherdir', 0666)
fw.mkdir('dir3', 0600)
fw.mkdir('subdir')
fw.write('a.txt', 0777)
fw.write('b.txt', 0751)
fw.write('c.txt', 0640)
fw.write(os.path.join('subdir', 'd.txt'), 0640)
# Zip, unzip.
zip_utils.zip('input', 'test.zip')
zip_utils.unzip('test.zip', 'output')
# Compare the inputs and outputs.
test_utils.compare_trees(self, 'input', 'output')
开发者ID:android,项目名称:platform_external_skia,代码行数:19,代码来源:zip_utils_test.py
示例17: test_versions
def test_versions(self):
with utils.tmp_dir():
# Create input files and directories.
input_dir = os.path.join(os.getcwd(), 'input')
_write_stuff(input_dir)
self.assertEqual(self.a.get_current_version(), -1)
self.assertEqual(self.a.get_available_versions(), [])
self.assertEqual(self.a.get_next_version(), 0)
self.a.upload_new_version(input_dir)
self.assertEqual(self.a.get_current_version(), 0)
self.assertEqual(self.a.get_available_versions(), [0])
self.assertEqual(self.a.get_next_version(), 1)
self.a.upload_new_version(input_dir)
self.assertEqual(self.a.get_current_version(), 1)
self.assertEqual(self.a.get_available_versions(), [0, 1])
self.assertEqual(self.a.get_next_version(), 2)
开发者ID:03050903,项目名称:skia,代码行数:21,代码来源:asset_utils_test.py
示例18: isolate_android_sdk
def isolate_android_sdk(android_sdk_root):
"""Isolate the Android SDK and return the isolated hash."""
repo_isolate_file = os.path.join(INFRA_BOTS_DIR, ISOLATE_FILE_NAME)
with utils.tmp_dir():
# Copy the SDK dir contents into a directory with a known name.
sdk_dir = os.path.join(os.getcwd(), SDK_DIR_NAME)
shutil.copytree(android_sdk_root, sdk_dir)
isolate_file = os.path.join(os.getcwd(), ISOLATE_FILE_NAME)
shutil.copyfile(repo_isolate_file, isolate_file)
# Isolate the SDK.
isolate = get_isolate_binary()
check_isolate_auth(isolate)
android_sdk_relpath = os.path.relpath(
sdk_dir, os.path.dirname(isolate_file))
isolate_cmd = [isolate, 'archive', '--quiet',
'--isolate-server', 'https://isolateserver.appspot.com',
'-i', isolate_file,
'-s', 'android_sdk.isolated',
'--extra-variable', 'ANDROID_SDK_DIR=%s' % android_sdk_relpath]
isolate_out = subprocess.check_output(isolate_cmd).rstrip()
return shlex.split(isolate_out)[0]
开发者ID:RobertoMalatesta,项目名称:skia,代码行数:22,代码来源:isolate_android_sdk.py
示例19: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--local_svgs_dir", "-l", default="", help="Directory containing additional SVGs we want to upload."
)
parser.add_argument("--gsutil")
args = parser.parse_args()
with utils.tmp_dir():
cwd = os.getcwd()
create_script = os.path.join(common.FILE_DIR, "create.py")
upload_script = os.path.join(common.FILE_DIR, "upload.py")
try:
subprocess.check_call(["python", create_script, "-t", cwd, "-l", args.local_svgs_dir])
cmd = ["python", upload_script, "-t", cwd]
if args.gsutil:
cmd.extend(["--gsutil", args.gsutil])
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Trap exceptions to avoid printing two stacktraces.
sys.exit(1)
开发者ID:aseprite,项目名称:skia,代码行数:22,代码来源:create_and_upload.py
示例20: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--gsutil")
parser.add_argument("--chrome_path")
parser.add_argument("--msvs_version", required=True)
args = parser.parse_args()
with utils.tmp_dir():
cwd = os.getcwd()
create_script = os.path.join(common.FILE_DIR, "create.py")
upload_script = os.path.join(common.FILE_DIR, "upload.py")
try:
cmd = ["python", create_script, "-t", cwd, "--msvs_version", args.msvs_version]
if args.chrome_path:
cmd.extend(["--chrome_path", args.chrome_path])
subprocess.check_call(cmd)
cmd = ["python", upload_script, "-t", cwd]
if args.gsutil:
cmd.extend(["--gsutil", args.gsutil])
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
# Trap exceptions to avoid printing two stacktraces.
sys.exit(1)
开发者ID:rlugojr,项目名称:skia,代码行数:24,代码来源:create_and_upload.py
注:本文中的utils.tmp_dir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论