本文整理汇总了Python中utils.chdir函数的典型用法代码示例。如果您正苦于以下问题:Python chdir函数的具体用法?Python chdir怎么用?Python chdir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chdir函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: helper
def helper(tree=None, source='src', options=lambda _: []):
"""Run main in clean environments, with various '--source' options.
Each invocation is done against a separate, temporary directory.
main is currently run 3 times:
- from the current working directory, with `--source tmpdir/src`;
- from `tmpdir`, with `--source src`;
- from `tmpdir/src`, without --source argument.
"""
homedir = Path(tempfile.mkdtemp())
with home(homedir):
with chdir(homedir):
with directory_tree(tree) as tmpdir:
main('--source', tmpdir / source, *options(tmpdir))
yield tmpdir
with directory_tree(tree) as tmpdir:
with chdir(tmpdir):
main('--source', source, *options(tmpdir))
yield tmpdir
with directory_tree(tree) as tmpdir:
with chdir(tmpdir / source):
main(*options(tmpdir))
yield tmpdir
# Implicitely asserts that `homedir` == `cwd` is empty
homedir.rmdir()
开发者ID:ritlew,项目名称:emanate,代码行数:28,代码来源:test_integration.py
示例2: test_utils_chdir
def test_utils_chdir(self):
oldcwd = os.getcwd()
with utils.chdir('/tmp'):
self.assertEqual(os.getcwd(), '/tmp')
self.assertEqual(os.getcwd(), oldcwd)
with self.assertRaises(ValueError):
with utils.chdir(os.devnull):
pass # pragma: no cover
开发者ID:vincent-legoll,项目名称:glancing,代码行数:8,代码来源:test_utils.py
示例3: update
def update(self, rev = None):
assert rev == None
with chdir(self.path()):
Run(['git', 'pull', 'origin', 'master'])
env = os.environ.copy()
with chdir(self.path()):
Run(['gclient', 'sync'], self.make_env())
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:9,代码来源:puller.py
示例4: install
def install(should_identify=True):
# Based on ideas from https://github.com/harvimt/quamash/blob/master/.travis.yml
if should_identify:
system_identify()
td = Travis_Dispatcher()
xqt(
# Cached Downloads
'sudo mkdir -p /downloads',
'sudo chmod a+rw /downloads')
sip_ver = 'sip-4.17'
if not isfile('/downloads/sip.tar.gz'):
wget('http://downloads.sourceforge.net/project/pyqt/sip/{}/{}'.
format(sip_ver, _gz(sip_ver)), '/downloads/sip.tar.gz')
# _`pyqt_ver`: Select a PyQt version. See also qt5_Linux_ and qt5_OS_X_.
pyqt_ver = '5.5.1'
pyqt_gpl_ver = 'PyQt-gpl-' + pyqt_ver
if not isfile('/downloads/pyqt5.tar.gz'):
wget('http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-{}/{}'.
format(pyqt_ver, _gz(pyqt_gpl_ver)), '/downloads/pyqt5.tar.gz')
# Builds
xqt('sudo mkdir -p /builds',
'sudo chmod a+rw /builds')
# Qt5
td.qt5()
# SIP. With Linux or OS_X, don't use the package manager to install these,
# since they're installed for the system python, not the pyenv version
# we're testing with.
with pushd('/builds'):
xqt('tar xzf /downloads/sip.tar.gz --keep-newer-files')
chdir(sip_ver)
xqt('python configure.py',
'make',
'sudo make install')
# PyQt5
with pushd('/builds'):
xqt('tar xzf /downloads/pyqt5.tar.gz --keep-newer-files')
chdir(pyqt_gpl_ver)
td.pyqt5_configure()
xqt('make',
'sudo make install')
# PCRE
td.pcre()
# Qutepart
if build_os == 'Linux':
set_display()
xqt('sh -e /etc/init.d/xvfb start')
# Install, which also builds Python C extensions. Use this instead of
# ``build_ext`` so that Enki will have an already-installed qutepart,
# rather than needing to regenrate the command below.
xqt('python setup.py install')
开发者ID:Aldenis2112,项目名称:qutepart,代码行数:55,代码来源:qutepart_travis.py
示例5: get_jobs
def get_jobs(repo):
"""Obtain the list of jobs from the given repo."""
# Maintain a copy of the repo in the temp dir.
if not os.path.isdir(TMP_DIR):
os.mkdir(TMP_DIR)
with utils.chdir(TMP_DIR):
dirname = repo.split('/')[-1]
if not os.path.isdir(dirname):
subprocess.check_call([
utils.GIT, 'clone', '--mirror', repo, dirname])
with utils.chdir(dirname):
subprocess.check_call([utils.GIT, 'remote', 'update'])
jobs = json.loads(subprocess.check_output([
utils.GIT, 'show', 'master:infra/bots/jobs.json']))
return (BUCKET_SKIA_INTERNAL, jobs)
开发者ID:HalCanary,项目名称:skia-hc,代码行数:15,代码来源:try.py
示例6: gen_toolchain
def gen_toolchain(chrome_path, msvs_version, isolate_file):
"""Update the VS toolchain, isolate it, and return the isolated hash."""
with utils.chdir(chrome_path):
subprocess.check_call([utils.GCLIENT, 'sync'])
depot_tools = subprocess.check_output([
'python', os.path.join('build', 'find_depot_tools.py')]).rstrip()
with utils.git_branch():
vs_toolchain_py = os.path.join('build', 'vs_toolchain.py')
env = os.environ.copy()
env['GYP_MSVS_VERSION'] = msvs_version
subprocess.check_call(['python', vs_toolchain_py, 'update'], env=env)
output = subprocess.check_output(['python', vs_toolchain_py,
'get_toolchain_dir'], env=env).rstrip()
src_dir = get_toolchain_dir(output)
# Mock out absolute paths in win_toolchain.json.
win_toolchain_utils.abstract(os.path.join('build', 'win_toolchain.json'),
os.path.dirname(depot_tools))
# Isolate the toolchain. Assumes we're running on Windows, since the above
# would fail otherwise.
isolate_file_dirname = os.path.dirname(isolate_file)
toolchain_relpath = os.path.relpath(src_dir, isolate_file_dirname)
chrome_relpath = os.path.relpath(os.getcwd(), isolate_file_dirname)
depot_tools_relpath = os.path.relpath(depot_tools, isolate_file_dirname)
isolate = os.path.join(
os.curdir, 'tools', 'luci-go', 'win64', 'isolate.exe')
isolate_cmd = [isolate, 'archive', '--quiet',
'--isolate-server', 'https://isolateserver.appspot.com',
'-i', isolate_file,
'-s', 'win_toolchain_%s.isolated' % msvs_version,
'--extra-variable', 'WIN_TOOLCHAIN_DIR=%s' % toolchain_relpath,
'--extra-variable', 'DEPOT_TOOLS_DIR=%s' % depot_tools_relpath,
'--extra-variable', 'CHROME_DIR=%s' % chrome_relpath]
isolate_out = subprocess.check_output(isolate_cmd).rstrip()
return shlex.split(isolate_out)[0]
开发者ID:AHPlankton,项目名称:skia,代码行数:35,代码来源:isolate_win_toolchain.py
示例7: identify
def identify(self):
with chdir(self.path()):
output = Run(['git', 'log', '-1'])
m = re.match("commit ([0-9a-z]+)\s*", output)
if m == None:
raise Exception('unknown output from git: ' + output)
return m.group(1)
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:7,代码来源:puller.py
示例8: build_valgrind
def build_valgrind():
if os.path.isfile(os.path.join(INSTALL_DIR, 'bin', 'valgrind')):
return
with utils.chdir(os.path.join(TEMP_DIR, VALGRIND)):
subprocess.check_call(['./configure', '--prefix=%s' % INSTALL_DIR])
subprocess.check_call(['make'])
subprocess.check_call(['make', 'install'])
开发者ID:android,项目名称:platform_external_skia,代码行数:7,代码来源:create.py
示例9: make
def make(self):
if self.config == "android":
target_cpu = "arm"
elif self.config == "32bit":
target_cpu = "x86"
elif self.config == "64bit":
target_cpu = "x64"
else:
raise Exception("Unknown config in V8Builder.make!")
objdir = os.path.realpath(self.objdir())
if not os.path.isdir(objdir):
out_dir = os.path.join(self.folder, 'v8', 'out')
if not os.path.isdir(out_dir):
os.mkdir(out_dir)
os.mkdir(objdir)
with utils.chdir(os.path.join(self.folder, 'v8')):
config = [
'is_debug = false',
'target_cpu = "{}"'.format(target_cpu)
]
if self.config == "arm":
config += [
'symbol_level = 1',
'v8_android_log_stdout = true',
'target_os = "android"'
]
args = 'gn gen ' + objdir + ' --args=\'' + " ".join(config) + '\''
Run(args, self.env.get(), shell=True)
Run(["ninja", "-C", objdir, "d8"], self.env.get())
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:34,代码来源:build.py
示例10: create_asset
def create_asset(target_dir):
"""Create the asset."""
with utils.chdir(target_dir):
tarball = 'clang.tgz'
subprocess.check_call(['wget', '-O', tarball, GS_URL])
subprocess.check_call(['tar', 'zxvf', tarball])
os.remove(tarball)
开发者ID:molikto,项目名称:Skia,代码行数:7,代码来源:create.py
示例11: benchmark
def benchmark(self, shell, env, args):
with utils.chdir("/tmp/"):
full_args = [shell]
if args:
full_args.extend(args)
full_args.append('build/ts/shell.js')
if "WebKit" in shell:
full_args.append('--')
if "v8" in shell:
full_args.append('--')
full_args.append('-x')
tests = []
totalscore = 0
bench_path = os.path.join(utils.config.BenchmarkPath, self.folder)
for name in ["crypto", "deltablue", "raytrace", "richards", "splay"]:
output = utils.RunTimedCheckOutput(full_args +
[os.path.join(bench_path, name+".swf")], env=env)
lines = output.splitlines()
for x in lines:
m = re.search("NotifyScore (\d+)", x)
if not m:
continue
score = m.group(1)
totalscore += int(score)
tests.append({ 'name': name, 'time': score})
print(score + ' - ' + name)
if len(tests) > 0:
tests.append({ 'name': '__total__', 'time': totalscore / len(tests)})
return tests
开发者ID:Timvde,项目名称:arewefastyet,代码行数:33,代码来源:benchmarks.py
示例12: run
def run(self, benchmark, config):
env = os.environ.copy()
env.update(config.env())
env.update(self.engineInfo["env"])
args = config.args() + self.engineInfo["args"]
with utils.chdir(os.path.join(utils.config.BenchmarkPath, benchmark.folder)):
return benchmark.benchmark(self.engineInfo["binary"], env, args)
开发者ID:dhananjay92,项目名称:arewefastyet,代码行数:8,代码来源:executors.py
示例13: retrieveInfo
def retrieveInfo(self):
with utils.chdir(os.path.join(self.folder)):
objdir = os.path.abspath(os.path.join('WebKitBuild', 'Release'))
info = {}
info["engine_type"] = "webkit"
info["env"] = {'DYLD_FRAMEWORK_PATH': objdir}
return info
开发者ID:dminor,项目名称:arewefastyet,代码行数:8,代码来源:build.py
示例14: clone
def clone(self):
os.mkdir(self.folder)
with chdir(self.folder):
# get depot_tools
Run(['git', 'clone', 'https://chromium.googlesource.com/chromium/tools/depot_tools.git'])
# get actual v8 source
Run(['fetch', 'v8'], env=self.make_env())
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:8,代码来源:puller.py
示例15: extract
def extract(self, filename):
if "tar.bz2" in filename:
tar = tarfile.open(self.folder + filename)
tar.extractall(self.folder)
tar.close()
elif "zip" in filename:
with utils.chdir(self.folder):
utils.Run(["unzip", filename], silent=True)
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:8,代码来源:download.py
示例16: clean
def clean(self):
with utils.chdir(self.folder):
Run(["svn","revert","Tools/Scripts/check-for-weak-vtables-and-externals"])
Run(["svn","revert","Source/JavaScriptCore/Configurations/Base.xcconfig"])
Run(["svn","revert","Source/bmalloc/Configurations/Base.xcconfig"])
Run(["svn","revert","Source/WTF/Configurations/Base.xcconfig"])
Run(["svn","revert","Source/bmalloc/bmalloc/SmallLine.h"])
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:8,代码来源:build.py
示例17: install
def install(should_identify=True):
if should_identify:
system_identify()
# Create a place to store downloads.
if not isdir(DOWNLOADS):
mkdir(DOWNLOADS)
# Download and install PyQt5. Only download if we don't have a cached copy
# available.
install_PyQt5 = os.path.join(DOWNLOADS, 'install-PyQt5.exe')
if not isfile(install_PyQt5):
wget('http://downloads.sourceforge.net/project/pyqt/PyQt5/PyQt-5.5.1/'
'PyQt5-5.5.1-gpl-Py3.4-Qt5.5.1-x32.exe',
install_PyQt5)
# See https://github.com/appveyor/ci/issues/363#issuecomment-148915001.
xqt('REG ADD HKCU\\Software\\Python\\PythonCore\\3.4\\InstallPath /f /ve '
'/t REG_SZ /d C:\\Python34',
install_PyQt5 + ' /S')
# Download and compile PCRE.
pcre_ver = 'pcre-8.38'
pcre_zip = pcre_ver + '.zip'
pcre_zip_path = os.path.join(DOWNLOADS, pcre_zip)
if not isfile(pcre_zip_path):
# Note: Don't use ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/,
# because this sometimes hangs during download, causing the build to
# fail. Instead, use the more reliable SourceForge mirror.
wget('http://downloads.sourceforge.net/project/pcre/pcre/8.38/' +
pcre_zip, pcre_zip_path)
# See https://sevenzip.osdn.jp/chm/cmdline/commands/extract_full.htm.
xqt('7z x {} > nul'.format(pcre_zip_path))
with pushd(pcre_ver):
mkdir('build')
chdir('build')
xqt('cmake .. -DBUILD_SHARED_LIBS:BOOL=OFF -DPCRE_SUPPORT_UTF:BOOL=ON '
'-DPCRE_SUPPORT_JIT:BOOL=ON -G "Visual Studio 10 2010"',
'cmake --build . --config Release')
# Install, which also builds Python C extensions. Use this instead of
# ``build_ext`` so that Enki will have an already-installed qutepart,
# rather than needing to regenrate the command below.
xqt('python setup.py install --include-dir={}/build '
'--lib-dir={}/build/Release --force'.format(pcre_ver, pcre_ver))
开发者ID:Aldenis2112,项目名称:qutepart,代码行数:44,代码来源:qutepart_appveyor.py
示例18: update_sdk_file
def update_sdk_file(skia_path, isolated_hash):
"""Edit the android_sdk_hash file, upload a CL."""
with utils.chdir(skia_path):
with utils.git_branch():
hash_file = os.path.join('infra', 'bots', 'android_sdk_hash')
with open(hash_file, 'w') as f:
f.write(isolated_hash)
subprocess.check_call([utils.GIT, 'add', hash_file])
subprocess.check_call([utils.GIT, 'commit', '-m', 'Update Android SDK'])
subprocess.check_call([utils.GIT, 'cl', 'upload', '--bypass-hooks'])
开发者ID:RobertoMalatesta,项目名称:skia,代码行数:10,代码来源:isolate_android_sdk.py
示例19: reconf
def reconf(self):
# Step 0. install ndk if needed.
if self.config.startswith("android"):
self.env.remove("CC")
self.env.remove("CXX")
self.env.remove("LINK")
self.installNdk()
# Step 1. autoconf.
with utils.chdir(os.path.join(self.folder, 'js', 'src')):
if platform.system() == "Darwin":
utils.run_realtime("autoconf213", shell=True)
elif platform.system() == "Linux":
utils.run_realtime("autoconf2.13", shell=True)
elif platform.system() == "Windows":
utils.run_realtime("autoconf-2.13", shell=True)
# Step 2. configure
if os.path.exists(os.path.join(self.folder, 'js', 'src', 'Opt')):
shutil.rmtree(os.path.join(self.folder, 'js', 'src', 'Opt'))
os.mkdir(os.path.join(self.folder, 'js', 'src', 'Opt'))
args = ['--enable-optimize', '--disable-debug']
if self.config == "android":
args.append("--target=arm-linux-androideabi")
args.append("--with-android-ndk="+os.path.abspath(self.folder)+"/android-ndk-r12/")
args.append("--with-android-version=24")
args.append("--enable-pie")
if self.config == "android64":
args.append("--target=aarch64-linux-androideabi")
args.append("--with-android-ndk="+os.path.abspath(self.folder)+"/android-ndk-r12/")
args.append("--with-android-version=24")
args.append("--enable-pie")
if platform.architecture()[0] == "64bit" and self.config == "32bit":
if platform.system() == "Darwin":
args.append("--target=i686-apple-darwin10.0.0")
elif platform.system() == "Linux":
args.append("--target=i686-pc-linux-gnu")
else:
assert False
with utils.chdir(os.path.join(self.folder, 'js', 'src', 'Opt')):
Run(['../configure'] + args, self.env.get())
return True
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:43,代码来源:build.py
示例20: __init__
def __init__(self, folder, suite=None):
if folder.endswith("/"):
folder = folder[:-1]
self.suite = suite if suite is not None else self.name()
self.folder_ = folder
with utils.chdir(os.path.join(utils.config.BenchmarkPath, self.folder_)):
fp = open("VERSION", 'r')
self.version = self.suite + " " + fp.read().strip("\r\n\r\n \t")
fp.close()
开发者ID:bnjbvr,项目名称:arewefastyet,代码行数:11,代码来源:benchmarks_shell.py
注:本文中的utils.chdir函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论