本文整理汇总了Python中pythonz.util.rm_r函数的典型用法代码示例。如果您正苦于以下问题:Python rm_r函数的具体用法?Python rm_r怎么用?Python rm_r使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rm_r函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: symlink
def symlink(self):
install_dir = os.path.realpath(self.install_dir)
if self.pkg.type == 'pypy':
bin_dir = os.path.join(install_dir, 'bin')
symlink(os.path.join(bin_dir, 'pypy'), os.path.join(bin_dir, 'python'))
return
if self.options.framework:
# create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
bin_dir = os.path.join(install_dir, 'bin')
if os.path.exists(bin_dir):
rm_r(bin_dir)
m = re.match(r'\d\.\d', self.pkg.version)
if m:
version = m.group(0)
symlink(os.path.join(install_dir, 'Frameworks', 'Python.framework', 'Versions', version, 'bin'), os.path.join(bin_dir))
path_python = os.path.join(install_dir, 'bin', 'python')
if not os.path.isfile(path_python):
src = None
for d in os.listdir(os.path.join(install_dir, 'bin')):
if re.match(r'python\d\.\d', d):
src = d
break
if src:
path_src = os.path.join(install_dir, 'bin', src)
symlink(path_src, path_python)
开发者ID:davidszotten,项目名称:pythonz,代码行数:25,代码来源:pythoninstaller.py
示例2: install
def install(self):
# get content type.
if is_file(self.download_url):
path = fileurl_to_path(self.download_url)
self.content_type = mimetypes.guess_type(path)[0]
else:
headerinfo = Downloader.read_head_info(self.download_url)
self.content_type = headerinfo['content-type']
if is_html(self.content_type):
# note: maybe got 404 or 503 http status code.
logger.error("Invalid content-type: `%s`" % self.content_type)
return
if os.path.isdir(self.install_dir):
logger.info("You have already installed `%s`" % self.pkg.name)
return
self.download_and_extract()
logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
logger.info(" tail -f %s\n" % self.logfile)
logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
try:
self.patch()
self.configure()
self.make()
self.make_install()
except Exception:
import traceback
traceback.print_exc()
rm_r(self.install_dir)
logger.error("Failed to install %s. Check %s to see why." % (self.pkg.name, self.logfile))
sys.exit(1)
self.symlink()
logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
开发者ID:totakke,项目名称:pythonz,代码行数:34,代码来源:pythoninstaller.py
示例3: symlink
def symlink(self):
install_dir = os.path.realpath(self.install_dir)
if self.pkg.type == "pypy":
bin_dir = os.path.join(install_dir, "bin")
symlink(os.path.join(bin_dir, "pypy"), os.path.join(bin_dir, "python"))
return
if self.options.framework:
# create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
bin_dir = os.path.join(install_dir, "bin")
if os.path.exists(bin_dir):
rm_r(bin_dir)
m = re.match(r"\d\.\d", self.pkg.version)
if m:
version = m.group(0)
symlink(
os.path.join(install_dir, "Frameworks", "Python.framework", "Versions", version, "bin"),
os.path.join(bin_dir),
)
path_python = os.path.join(install_dir, "bin", "python")
if not os.path.isfile(path_python):
src = None
for d in os.listdir(os.path.join(install_dir, "bin")):
if re.match(r"python\d\.\d", d):
src = d
break
if src:
path_src = os.path.join(install_dir, "bin", src)
symlink(path_src, path_python)
开发者ID:rayleyva,项目名称:pythonz,代码行数:28,代码来源:pythoninstaller.py
示例4: run_command
def run_command(self, options, args):
headinfo = Downloader.read_head_info(PYTHONZ_UPDATE_URL)
content_type = headinfo["content-type"]
filename = "pythonz-latest"
distname = "%s.tgz" % filename
download_file = os.path.join(PATH_DISTS, distname)
# Remove old tarball
unlink(download_file)
logger.info("Downloading %s as %s" % (distname, download_file))
try:
Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
except DownloadError:
unlink(download_file)
logger.error("Failed to download. `%s`" % PYTHONZ_UPDATE_URL)
sys.exit(1)
except:
unlink(download_file)
raise
extract_dir = os.path.join(PATH_BUILD, filename)
rm_r(extract_dir)
if not extract_downloadfile(content_type, download_file, extract_dir):
sys.exit(1)
try:
logger.info("Installing %s into %s" % (extract_dir, ROOT))
s = Subprocess()
s.check_call([sys.executable, os.path.join(extract_dir, "pythonz_install.py"), "--upgrade"])
except:
logger.error("Failed to update pythonz.")
sys.exit(1)
logger.info("pythonz has been updated.")
开发者ID:simudream,项目名称:pythonz,代码行数:32,代码来源:update.py
示例5: _update_pythonz
def _update_pythonz(self, options, args):
download_url = PYTHONZ_UPDATE_URL
headinfo = get_headerinfo_from_url(download_url)
content_type = headinfo['content-type']
filename = "pythonz-latest"
distname = "%s.tgz" % filename
download_file = os.path.join(PATH_DISTS, distname)
# Remove old tarball
unlink(download_file)
try:
d = Downloader()
d.download(distname, download_url, download_file)
except:
logger.error("Failed to download. `%s`" % download_url)
sys.exit(1)
extract_dir = os.path.join(PATH_BUILD, filename)
rm_r(extract_dir)
if not extract_downloadfile(content_type, download_file, extract_dir):
sys.exit(1)
try:
logger.info("Installing %s into %s" % (extract_dir, ROOT))
s = Subprocess()
s.check_call([sys.executable, os.path.join(extract_dir,'pythonz_install.py'), '--upgrade'])
except:
logger.error("Failed to update pythonz.")
sys.exit(1)
logger.info("The pythonz has been updated.")
开发者ID:Epictetus,项目名称:pythonz,代码行数:29,代码来源:update.py
示例6: install
def install(installer_root):
# create directories
makedirs(PATH_PYTHONS)
makedirs(PATH_BUILD)
makedirs(PATH_DISTS)
makedirs(PATH_ETC)
makedirs(PATH_BIN)
makedirs(PATH_LOG)
makedirs(PATH_HOME_ETC)
# create script directories
rm_r(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS_PYTHONZ)
makedirs(PATH_SCRIPTS_PYTHONZ_COMMANDS)
makedirs(PATH_SCRIPTS_PYTHONZ_INSTALLER)
# copy all .py files
for path in glob.glob(os.path.join(installer_root, "*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ)
for path in glob.glob(os.path.join(installer_root, "commands", "*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ_COMMANDS)
for path in glob.glob(os.path.join(installer_root, "installer", "*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ_INSTALLER)
# create patches direcotry
rm_r(PATH_PATCHES)
shutil.copytree(os.path.join(installer_root, "patches"), PATH_PATCHES)
# create a main file
with open("%s/pythonz_main.py" % PATH_SCRIPTS, "w") as f:
f.write(
"""import pythonz
if __name__ == "__main__":
pythonz.main()
"""
)
# create entry point file
with open(PATH_BIN_PYTHONZ, "w") as f:
f.write(
"""#!/usr/bin/env bash
%s %s/pythonz_main.py "[email protected]"
"""
% (sys.executable, PATH_SCRIPTS)
)
# mode 0755
os.chmod(
PATH_BIN_PYTHONZ,
stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH,
)
# create a bashrc for pythonz
shutil.copy(os.path.join(installer_root, "etc", "bashrc"), os.path.join(PATH_ETC, "bashrc"))
# copy config.cfg
shutil.copy(os.path.join(installer_root, "etc", "config.cfg"), PATH_ETC_CONFIG)
开发者ID:Epictetus,项目名称:pythonz,代码行数:58,代码来源:pythonzinstaller.py
示例7: install
def install(installer_root):
# create directories
makedirs(PATH_PYTHONS)
makedirs(PATH_BUILD)
makedirs(PATH_DISTS)
makedirs(PATH_ETC)
makedirs(PATH_BASH_COMPLETION)
makedirs(PATH_BIN)
makedirs(PATH_LOG)
makedirs(PATH_HOME_ETC)
# create script directories
rm_r(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS)
makedirs(PATH_SCRIPTS_PYTHONZ)
makedirs(PATH_SCRIPTS_PYTHONZ_COMMANDS)
makedirs(PATH_SCRIPTS_PYTHONZ_INSTALLER)
# copy all .py files
for path in glob.glob(os.path.join(installer_root,"*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ)
for path in glob.glob(os.path.join(installer_root,"commands","*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ_COMMANDS)
for path in glob.glob(os.path.join(installer_root,"installer","*.py")):
shutil.copy(path, PATH_SCRIPTS_PYTHONZ_INSTALLER)
# create patches direcotry
rm_r(PATH_PATCHES)
shutil.copytree(os.path.join(installer_root,"patches"), PATH_PATCHES)
# create a main file
with open("%s/pythonz_main.py" % PATH_SCRIPTS, "w") as f:
f.write("""import pythonz
if __name__ == "__main__":
pythonz.main()
""")
# create entry point file
with open(PATH_BIN_PYTHONZ, "w") as f:
f.write("""#!/usr/bin/env bash
python %s/pythonz_main.py "[email protected]"
""" % PATH_SCRIPTS)
# mode 0755
os.chmod(PATH_BIN_PYTHONZ, stat.S_IRUSR|stat.S_IWUSR|stat.S_IXUSR|stat.S_IRGRP|stat.S_IXGRP|stat.S_IROTH|stat.S_IXOTH)
# create a bashrc for pythonz
shutil.copy(os.path.join(installer_root,'etc','bashrc'), os.path.join(PATH_ETC,'bashrc'))
# create a fish file for pythonz
shutil.copy(os.path.join(installer_root, 'etc', 'pythonz.fish'), os.path.join(PATH_ETC, 'pythonz.fish'))
#copy all *.sh files to bash_completion.d directory
for path in glob.glob(os.path.join(installer_root,"etc","bash_completion.d","*.sh")):
shutil.copy( path, PATH_BASH_COMPLETION )
开发者ID:Kaemka,项目名称:pythonz,代码行数:55,代码来源:pythonzinstaller.py
示例8: run_command
def run_command(self, options, args):
if args:
# Uninstall pythons
for arg in args:
pkg = Package(arg, options.type)
pkgname = pkg.name
if not is_installed(pkg):
logger.error("`%s` is not installed." % pkgname)
continue
rm_r(os.path.join(PATH_PYTHONS, pkgname))
else:
self.parser.print_help()
开发者ID:EvertonSilva,项目名称:pythonz,代码行数:12,代码来源:uninstall.py
示例9: symlink
def symlink(self):
install_dir = os.path.realpath(self.install_dir)
bin_dir = os.path.join(install_dir, 'bin')
if self.options.framework:
# create symlink bin -> /path/to/Frameworks/Python.framework/Versions/?.?/bin
if os.path.exists(bin_dir):
rm_r(bin_dir)
m = re.match(r'\d\.\d', self.pkg.version)
if m:
version = m.group(0)
symlink(os.path.join(install_dir, 'Frameworks', 'Python.framework', 'Versions', version, 'bin'), os.path.join(bin_dir))
path_python = os.path.join(bin_dir, 'python')
if not os.path.isfile(path_python):
for f in os.listdir(bin_dir):
if re.match(r'python\d\.\d$', f):
symlink(os.path.join(bin_dir, f), path_python)
break
开发者ID:totakke,项目名称:pythonz,代码行数:17,代码来源:pythoninstaller.py
示例10: _cleanup
def _cleanup(self, root):
for dir in os.listdir(root):
rm_r(os.path.join(root, dir))
开发者ID:EvertonSilva,项目名称:pythonz,代码行数:3,代码来源:cleanup.py
注:本文中的pythonz.util.rm_r函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论