本文整理汇总了Python中myppy.util.cd函数的典型用法代码示例。如果您正苦于以下问题:Python cd函数的具体用法?Python cd怎么用?Python cd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cd函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: install
def install(self):
updir = self._unpack()
for nm in os.listdir(updir):
if nm.endswith(".rpm"):
fpath = os.path.join(updir, nm)
with open(fpath+".cpio", "w+") as stdout:
self.target.do("rpm2cpio", fpath, stdout=stdout)
stdout.seek(0)
with cd(self.INSTALL_PREFIX):
self.target.do("cpio", "-duvi", stdin=stdout)
def hackily_define_TIOCSWINSZ(lines):
for ln in lines:
yield ln
if ln.strip().startswith("#define TIOCGWINSZ"):
yield "#define TIOCSWINSZ 0x5414\n"
ioctl_header = os.path.join(self.INSTALL_PREFIX,
"opt/lsb/include/sys/ioctl.h")
self._patch_file(ioctl_header, hackily_define_TIOCSWINSZ)
# Check if we can actually compile something
with tempdir() as workdir:
with open(os.path.join(workdir, "test.c"), "w") as f:
f.write("""
#include <stdio.h>
int main(void) { printf("hello world"); return 0; }
""")
with cd(workdir):
try:
self.target.do("lsbcc", "-m32", "-o", "test", "test.c")
self.target.do("./test")
except Exception, e:
msg = "Failed to compile a test executable:\n"
msg += " " + str(e) + "\n"
msg += "Please make sure you can compile 32-bit "
msg += "LSB applications on your system"
raise RuntimeError(msg)
示例2: _generic_cmake
def _generic_cmake(self,relpath=".",args=[],env={}):
"""Do a generic "cmake" on the given source tarball."""
archflags = " ".join("-arch "+arch for arch in self.TARGET_ARCHS)
workdir = self._get_builddir()
cmd = ["cmake"]
cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.PREFIX,))
cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON")
cmd.append("-DCMAKE_OSX_SYSROOT="+self.MACOSX_SYSROOT)
cmd.append("-DCMAKE_OSX_ARCHITECTURES="+";".join(self.TARGET_ARCHS))
cmd.append("-DBUILD_TESTS=False")
cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel")
for arg in args:
cmd.append(arg)
libdir = os.path.join(self.PREFIX,"lib")
incdir = os.path.join(self.PREFIX,"include")
env = env.copy()
env.setdefault("LDFLAGS",self.LDFLAGS)
env.setdefault("CFLAGS","-Os %s %s -mmacosx-version-min=%s -isysroot %s" % (archflags,self.INCFLAGS,self.MACOSX_DEPLOYMENT_TARGET,self.MACOSX_SYSROOT,))
env.setdefault("CXXFLAGS","-Os %s %s -mmacosx-version-min=%s -isysroot %s" % (archflags,self.INCFLAGS,self.MACOSX_DEPLOYMENT_TARGET,self.MACOSX_SYSROOT,))
# Do an out-of-source build, required by some recipes.
builddir = os.path.join(self._get_builddir(), "MYPPY-BUILD")
if not os.path.exists(builddir):
os.makedirs(builddir)
cmd.append("..")
with cd(builddir):
self.target.do(*cmd,env=env)
示例3: build
def build(self, relpath="", args=[], env={}):
super(py_m2crypto, self).build()
workdir = self._get_builddir()
cmd = [self.target.PYTHON_EXECUTABLE, "setup.py", "build", "build_ext", "--openssl=%s" % self.target.PREFIX]
cmd.extend(args)
with cd(os.path.join(workdir, relpath)):
self.target.do(*cmd, env=env)
示例4: _nway_configure
def _nway_configure(self,script=None,vars=None,args=None,env={}):
"""Do a "./configure" for each architecure in a separate dir."""
workdir = self._get_builddir()
# Create work dir for each additional arch.
archdirs = []
for arch in self.TARGET_ARCHS:
if arch == self.LOCAL_ARCH:
archdirs.append((arch,workdir))
else:
archdir = os.path.join(os.path.dirname(workdir),arch)
if os.path.exists(archdir):
shutil.rmtree(archdir)
shutil.copytree(workdir,archdir)
archdirs.append((arch,archdir))
# Now run the appropriate ./configure in each arch dir.
for (arch,archdir) in archdirs:
if os.path.exists(os.path.join(archdir,"Makefile")):
with cd(archdir):
try:
self.target.do("make","clean")
except subprocess.CalledProcessError:
pass
self.TARGET_ARCH = arch
self.CONFIGURE_DIR = archdir
self._generic_configure(script,vars,args,env)
self.TARGET_ARCH = None
示例5: _generic_pyinstall
def _generic_pyinstall(self,relpath="",args=[],env={}):
"""Do a generic "python setup.py install" for this recipe."""
workdir = self._get_builddir()
cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install"]
cmd.extend(args)
with cd(os.path.join(workdir,relpath)):
self.target.do(*cmd,env=env)
示例6: find_new_files
def find_new_files(self):
# os.walk has a bad habit of choking on unicode errors, so
# we do it by hand and get it right. Anything that can't
# be decoded properly gets deleted.
todo = [self.rootdir]
while todo:
dirpath = todo.pop(0)
try:
names = os.listdir(dirpath)
except OSError, e:
if e.errno not in (errno.ENOENT,):
raise
continue
if not names:
if not self._is_oldfile(dirpath + os.sep):
yield dirpath + os.sep
else:
for nm in names:
try:
fpath = os.path.join(dirpath,nm)
except UnicodeDecodeError:
with util.cd(dirpath):
if util.isrealdir(nm):
shutil.rmtree(nm)
else:
os.unlink(nm)
else:
if not self._is_tempfile(fpath):
if util.isrealdir(fpath):
todo.append(fpath)
else:
if not self._is_oldfile(fpath):
yield fpath
示例7: install
def install(self, relpath="", args=[], env={}):
workdir = self._get_builddir()
# link statically with libmysqlclient_r.so
cmd_conf = [
self.target.PYTHON_EXECUTABLE,
"setup.py",
"setopt",
"-c",
"options",
"-o",
"static",
"-s",
"True",
"-f",
"site.cfg",
]
cmd_conf2 = [
self.target.PYTHON_EXECUTABLE,
"setup.py",
"setopt",
"-c",
"options",
"-o",
"mysql_config",
"-s",
os.path.join(self.target.PREFIX, "bin", "mysql_config"),
"-f",
"site.cfg",
]
cmd = [self.target.PYTHON_EXECUTABLE, "setup.py", "install_lib"]
cmd.extend(args)
with cd(os.path.join(workdir, relpath)):
self.target.do(*cmd_conf, env=env)
self.target.do(*cmd_conf2, env=env)
self.target.do(*cmd, env=env)
示例8: install
def install(self):
updir = self._unpack()
for nm in os.listdir(updir):
if nm.endswith(".rpm"):
fpath = os.path.join(updir, nm)
with open(fpath+".cpio", "w+") as stdout:
self.target.do("rpm2cpio", fpath, stdout=stdout)
stdout.seek(0)
with cd(self.INSTALL_PREFIX):
self.target.do("cpio", "-duvi", stdin=stdout)
示例9: install
def install(self,relpath="",args=[],env={}):
workdir = self._get_builddir()
# link statically with libpg.so
cmd = [self.target.PYTHON_EXECUTABLE,"setup.py","install_lib"]
cmd.extend(args)
with cd(os.path.join(workdir,relpath)):
f = open('setup.cfg', 'w')
f.write(self.SETUP_CFG % self.target.PREFIX)
f.close()
self.target.do(*cmd,env=env)
示例10: _generic_cmake
def _generic_cmake(self, relpath=".", args=[], env={}):
cmd = ["cmake"]
cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.INSTALL_PREFIX,))
cmd.append("-DCMAKE_MODULE_PATH=%s" % (os.path.join(self.PREFIX, "share", "cmake"),))
cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON")
cmd.append("-DBUILD_TESTS=False")
cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel")
for arg in args:
cmd.append(arg)
with cd(self._get_builddir()):
self.target.do(*cmd, env=env)
示例11: _generic_cmake
def _generic_cmake(self,relpath=".",args=[],env={}):
cmd = ["cmake"]
cmd.append("-DCMAKE_INSTALL_PREFIX=%s" % (self.INSTALL_PREFIX,))
cmd.append("-DCMAKE_MODULE_PATH=%s" % (os.path.join(self.PREFIX,"share","cmake"),))
cmd.append("-DCMAKE_VERBOSE_MAKEFILE=ON")
cmd.append("-DBUILD_TESTS=False")
cmd.append("-DCMAKE_BUILD_TYPE=MinSizeRel")
for arg in args:
cmd.append(arg)
# Do an out-of-source build, required by some recipes.
builddir = os.path.join(self._get_builddir(), "MYPPY-BUILD")
os.makedirs(builddir)
cmd.append("..")
with cd(builddir):
self.target.do(*cmd,env=env)
示例12: build
def build(self):
# fetch and upnpack source
src = self.target.fetch(self.SOURCE_URL)
self._unpack_tarball(src,self.target.builddir)
self.workdir = os.path.join(self.target.builddir, 'p4python-2012.1.442152')
# fetch P4API
src = self.target.fetch(self.P4API_URL)
self._unpack_tarball(src,self.workdir)
p4api_dir = os.path.join(self.workdir, 'p4api-2012.1.442152')
# Generate the setup.cfg file.
with cd(self.workdir):
f = open("setup.cfg", "w")
f.write("[p4python_config]\n")
f.write("p4_api=%s" % p4api_dir)
f.close()
示例13: install
def install(self):
updir = self._unpack()
for nm in os.listdir(updir):
if nm.endswith(".rpm"):
fpath = os.path.join(updir, nm)
with open(fpath+".cpio", "w+") as stdout:
self.target.do("rpm2cpio", fpath, stdout=stdout)
stdout.seek(0)
with cd(self.INSTALL_PREFIX):
self.target.do("cpio", "-duvi", stdin=stdout)
def hackily_define_TIOCSWINSZ(lines):
for ln in lines:
yield ln
if ln.strip().startswith("#define TIOCGWINSZ"):
yield "#define TIOCSWINSZ 0x5414\n"
ioctl_header = os.path.join(self.INSTALL_PREFIX,
"opt/lsb/include/sys/ioctl.h")
self._patch_file(ioctl_header, hackily_define_TIOCSWINSZ)
示例14: _generic_configure
def _generic_configure(self,script=None,vars=None,args=None,env={}):
"""Do a generic "./configure" for this recipe."""
if script is None:
script = self.CONFIGURE_SCRIPT
if vars is None:
vars = self.CONFIGURE_VARS
if args is None:
args = self.CONFIGURE_ARGS
if isinstance(script,basestring):
cmd = [script]
else:
cmd = list(script)
cmd.append("--prefix=%s" % (self.INSTALL_PREFIX,))
for arg in args:
cmd.append(arg)
if vars is not None:
for var in vars:
cmd.append(var)
workdir = self._get_builddir()
workdir = os.path.join(workdir,self.CONFIGURE_DIR)
with cd(workdir):
self.target.do(*cmd,env=env)
示例15: _patch
def _patch(self):
workdir = self._get_builddir()
patchfile = os.path.join(os.path.dirname(__file__),"_py2app.patch")
with open(patchfile,"rb") as fin:
with cd(os.path.join(workdir,"py2app")):
self.target.do("patch",stdin=fin)