def run_command(self, options, args): if args: # Uninstall pythons for arg in args: pkg = Package(arg) pkgname = pkg.name pkgpath = os.path.join(PATH_PYTHONS, pkgname) venvpath = os.path.join(PATH_VENVS, pkgname) if not is_installed(pkgname): logger.error("`%s` is not installed." % pkgname) continue if get_using_python_pkgname() == pkgname: off() for d in os.listdir(PATH_BIN): # remove symlink path = os.path.join(PATH_BIN, d) if os.path.islink(path): basename = os.path.basename(os.path.realpath(path)) tgtpath = os.path.join(pkgpath, 'bin', basename) if os.path.isfile(tgtpath) and os.path.samefile( path, tgtpath): unlink(path) rm_r(pkgpath) rm_r(venvpath) else: self.parser.print_help()
def symlink(self): install_dir = os.path.realpath(self.install_dir) 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)
def symlink(self): install_dir = os.path.realpath(self.install_dir) 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)
def run_command(self, options, args): if args: # Uninstall pythonidae for arg in args: pkg = Package(arg) pkgname = pkg.name pkgpath = os.path.join(PATH_PYTHONS, pkgname) venvpath = os.path.join(PATH_VENVS, pkgname) if not is_installed(pkgname): logger.error("`%s` is not installed." % pkgname) continue if get_using_python_pkgname() == pkgname: off() for d in os.listdir(PATH_BIN): # remove symlink path = os.path.join(PATH_BIN, d) if os.path.islink(path): basename = os.path.basename(os.path.realpath(path)) tgtpath = os.path.join(pkgpath, "bin", basename) if os.path.isfile(tgtpath) and os.path.samefile(path, tgtpath): unlink(path) rm_r(pkgpath) rm_r(venvpath) else: self.parser.print_help()
def install(self): if os.path.isdir(self.install_dir): logger.info("You are already installed `%s`" % self.pkg.name) sys.exit() self.ensure() self.download() logger.info("") logger.info("This could take a while. You can run the following command on another shell to track the status:") logger.info(" tail -f %s" % self.logfile) logger.info("") self.unpack() self.patch() logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) try: self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile)) logger.info(" pythonbrew install --force %s" % self.pkg.version) sys.exit(1) self.install_setuptools() logger.info("Installed %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname":self.pkg.name}) logger.info("") logger.info(" pythonbrew switch %s" % self.pkg.version)
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_VENVS) makedirs(PATH_HOME_ETC) # create script directories rm_r(PATH_SCRIPTS) makedirs(PATH_SCRIPTS) makedirs(PATH_SCRIPTS_PYTHONBREW) makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS) makedirs(PATH_SCRIPTS_PYTHONBREW_INSTALLER) # copy all .py files for path in glob.glob(os.path.join(installer_root, "*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW) for path in glob.glob(os.path.join(installer_root, "commands", "*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS) for path in glob.glob(os.path.join(installer_root, "installer", "*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_INSTALLER) # create patches direcotry rm_r(PATH_PATCHES) shutil.copytree(os.path.join(installer_root, "patches"), PATH_PATCHES) # create a main file fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w") fp.write("""import pythonbrew if __name__ == "__main__": pythonbrew.main() """) fp.close() # create entry point file fp = open(PATH_BIN_PYTHONBREW, "w") fp.write("""#!/usr/bin/env bash %s "%s/pythonbrew_main.py" "$@" """ % (sys.executable, PATH_SCRIPTS)) fp.close() # mode 0755 os.chmod( PATH_BIN_PYTHONBREW, 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 pythonbrew 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)
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_VENVS) makedirs(PATH_HOME_ETC) # create script directories rm_r(PATH_SCRIPTS) makedirs(PATH_SCRIPTS) makedirs(PATH_SCRIPTS_PYTHONBREW) makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS) makedirs(PATH_SCRIPTS_PYTHONBREW_INSTALLER) # copy all .py files for path in glob.glob(os.path.join(installer_root,"*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW) for path in glob.glob(os.path.join(installer_root,"commands","*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS) for path in glob.glob(os.path.join(installer_root,"installer","*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_INSTALLER) # create patches direcotry rm_r(PATH_PATCHES) shutil.copytree(os.path.join(installer_root,"patches"), PATH_PATCHES) # create a main file fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w") fp.write("""import pythonbrew if __name__ == "__main__": pythonbrew.main() """) fp.close() # create entry point file fp = open(PATH_BIN_PYTHONBREW, "w") fp.write("""#!/usr/bin/env bash %s "%s/pythonbrew_main.py" "$@" """ % (sys.executable, PATH_SCRIPTS)) fp.close() # mode 0755 os.chmod(PATH_BIN_PYTHONBREW, 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 pythonbrew shutil.copy(os.path.join(installer_root,'etc','bashrc'), os.path.join(PATH_ETC,'bashrc')) #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 ) # copy config.cfg shutil.copy(os.path.join(installer_root,'etc','config.cfg'), PATH_ETC_CONFIG)
def install(self, installer_root): # create directories makedirs(PATH_PYTHONS) makedirs(PATH_BUILD) makedirs(PATH_DISTS) makedirs(PATH_ETC) makedirs(PATH_BIN) makedirs(PATH_LOG) # create script directories rm_r(PATH_SCRIPTS) makedirs(PATH_SCRIPTS) makedirs(PATH_SCRIPTS_PYTHONBREW) makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS) makedirs(PATH_SCRIPTS_PYTHONBREW_INSTALLER) # copy all .py files for path in glob.glob(os.path.join(installer_root,"*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW) for path in glob.glob(os.path.join(installer_root,"commands","*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS) for path in glob.glob(os.path.join(installer_root,"installer","*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_INSTALLER) # create patches direcotry rm_r(PATH_PATCHES) shutil.copytree(os.path.join(installer_root,"patches"), PATH_PATCHES) # create a main file fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w") fp.write("""import pythonbrew if __name__ == "__main__": pythonbrew.main() """) fp.close() # create entry point file fp = open(PATH_BIN_PYTHONBREW, "w") fp.write("""#!/usr/bin/env bash %s %s/pythonbrew_main.py "$@" """ % (sys.executable, PATH_SCRIPTS)) fp.close() # mode 0755 os.chmod(PATH_BIN_PYTHONBREW, 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 pythonbrew fp = open(os.path.join(PATH_ETC,'bashrc'), 'w') for line in open(os.path.join(installer_root,'etc','bashrc')): line = line.replace('@ROOT@', ROOT) fp.write(line) fp.close() # copy config.cfg shutil.copy(os.path.join(installer_root,'etc','config.cfg'), PATH_ETC_CONFIG)
def run_command_delete(self, options, args): for arg in args[1:]: target_dir = os.path.join(self._workon_home, arg) if not os.path.isdir(target_dir): logger.error('%s already does not exist.' % target_dir) else: if not os.access(target_dir, os.W_OK): logger.error("Can not delete %s.\nPermission denied." % target_dir) continue logger.info('Deleting `%s` environment in %s' % (arg, self._workon_home)) # make command rm_r(target_dir)
def _update_pythonbrew(self, options, args): if options.master: version = 'master' elif options.develop: version = 'develop' else: version = get_stable_version() # check for version if not options.force and Version(version) <= VERSION: logger.info( "You are already running the installed latest version of pythonbrew." ) return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`pythonbrew-%s` was not found in pypi." % version) sys.exit(1) headinfo = get_headerinfo_from_url(download_url) content_type = headinfo['content-type'] if not options.master and not options.develop: if not is_gzip(content_type, Link(download_url).filename): logger.error("content type should be gzip. content-type:`%s`" % content_type) sys.exit(1) filename = "pythonbrew-%s" % version distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) 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, 'pythonbrew_install.py'), '--upgrade' ]) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
def run_command(self, options, args): if args: pkg = Package(args[0]) pkgname = pkg.name pkgpath = os.path.join(PATH_PYTHONS, pkgname) if not os.path.isdir(pkgpath): logger.info("`%s` is not installed." % pkgname) sys.exit(1) if get_current_python_path() == os.path.join(pkgpath,'bin','python'): off() rm_r(pkgpath) else: self.parser.print_help()
def run_command(self, options, args): if args: pkg = Package(args[0]) pkgname = pkg.name pkgpath = "%s/%s" % (PATH_PYTHONS, pkgname) if not os.path.isdir(pkgpath): logger.info("`%s` is not installed." % pkgname) sys.exit(1) if os.path.islink("%s/current" % PATH_PYTHONS): curpath = os.path.realpath("%s/current" % PATH_PYTHONS) if pkgpath == curpath: off() rm_r(pkgpath) else: self.parser.print_help()
def run_command_delete(self, options, args): if not self._pkgname: logger.error("Unknown python version: ( 'pythonbrew venv delete <project> -p VERSION' )") sys.exit(1) for arg in args[1:]: target_dir = os.path.join(self._workon_home, arg) if not os.path.isdir(target_dir): logger.error('%s does not exist.' % target_dir) else: if not os.access(target_dir, os.W_OK): logger.error("Can not delete %s.\nPermission denied." % target_dir) continue logger.info('Deleting `%s` environment in %s' % (arg, self._workon_home)) # make command rm_r(target_dir)
def _update_pythonbrew(self, options, args): if options.master: version = "master" elif options.develop: version = "develop" else: version = get_stable_version() # check for version if not options.force and Version(version) <= VERSION: logger.info("You are already running the installed latest version of pythonbrew.") return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`pythonbrew-%s` was not found in pypi." % version) sys.exit(1) headinfo = get_headerinfo_from_url(download_url) content_type = headinfo["content-type"] if not options.master and not options.develop: if not is_gzip(content_type, Link(download_url).filename): logger.error("content type should be gzip. content-type:`%s`" % content_type) sys.exit(1) filename = "pythonbrew-%s" % version distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) 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, "pythonbrew_install.py"), "--upgrade"]) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
def _update_pythonbrew(self, options, args): # pythonbrew update if options.head: version = 'head' else: version = get_stable_version() # check for version if not options.force and version <= VERSION: logger.info("You are already running the installed latest version of pythonbrew.") return download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`%s` of pythonbrew not found." % version) sys.exit(1) headinfo = get_headerinfo_from_url(download_url) content_type = headinfo['content-type'] # head is only for gzip. if not options.head and not is_gzip(content_type, Link(download_url).filename): logger.error("Invalid content-type: `%s`" % content_type) sys.exit(1) filename = "pythonbrew-%s" % version distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) 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 unpack_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('%s %s/pythonbrew_install.py --upgrade' % (sys.executable, extract_dir)) except: logger.error("Failed to update pythonbrew.") sys.exit(1) logger.info("The pythonbrew has been updated.")
def install(self): # cleanup if os.path.isdir(self.build_dir): shutil.rmtree(self.build_dir) # 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 = get_headerinfo_from_url(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 are 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) self.patch() logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) try: self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile)) logger.log(" pythonbrew install --force %s" % self.pkg.version) sys.exit(1) self.symlink() self.install_setuptools() logger.info( "\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname": self.pkg.name}) logger.info(" pythonbrew switch %s" % self.pkg.alias)
def run_command(self, options, args): if args: version = args[0] else: version = get_stable_version() # check for latest version if version <= VERSION: logger.info("You are already running the installed latest version of pythonbrew.") sys.exit() download_url = get_pythonbrew_update_url(version) if not download_url: logger.error("`%s` of pythonbrew not found." % version) sys.exit(1) resp = get_response_from_url(download_url) content_type = resp.info()['content-type'] if not is_gzip(content_type, Link(download_url).filename): logger.error("Invalid content-type: `%s`" % content_type) sys.exit(1) filename = "pythonbrew-%s" % version distname = "%s.tgz" % filename download_file = os.path.join(PATH_DISTS, distname) 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 unpack_downloadfile(content_type, download_file, extract_dir): sys.exit(1) try: installer_path = "%s/pythonbrew" % (extract_dir) logger.info("Installing %s into %s" % (extract_dir, ROOT)) PythonbrewInstaller().install(installer_path) except: logger.error("Failed to update pythonbrew.") raise sys.exit(1) logger.info("The pythonbrew has been updated.")
def install(self): # cleanup if os.path.isdir(self.build_dir): shutil.rmtree(self.build_dir) # 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 = get_headerinfo_from_url(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 are 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) self.patch() logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) try: self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile)) logger.log(" pythonbrew install --force %s" % self.pkg.version) sys.exit(1) self.symlink() self.install_setuptools() logger.info( "\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname": self.pkg.name} ) logger.info(" pythonbrew switch %s" % self.pkg.alias)
def install(self, installer_root): makedirs(PATH_PYTHONS) makedirs(PATH_BUILD) makedirs(PATH_DISTS) makedirs(PATH_ETC) makedirs(PATH_BIN) makedirs(PATH_LOG) rm_r(PATH_SCRIPTS) makedirs(PATH_SCRIPTS) makedirs(PATH_SCRIPTS_PYTHONBREW) makedirs(PATH_SCRIPTS_PYTHONBREW_COMMANDS) for path in glob.glob(os.path.join(installer_root,"*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW) for path in glob.glob(os.path.join(installer_root,"commands","*.py")): shutil.copy(path, PATH_SCRIPTS_PYTHONBREW_COMMANDS) rm_r(PATH_PATCHES) shutil.copytree(os.path.join(installer_root,"patches"), PATH_PATCHES) fp = open("%s/pythonbrew_main.py" % PATH_SCRIPTS, "w") fp.write("""import pythonbrew if __name__ == "__main__": pythonbrew.main() """) fp.close() fp = open(PATH_BIN_PYTHONBREW, "w") fp.write("""#!/usr/bin/env bash %s %s/pythonbrew_main.py "$@" """ % (sys.executable, PATH_SCRIPTS)) fp.close() os.chmod(PATH_BIN_PYTHONBREW, 0755) symlink(PATH_BIN_PYTHONBREW, PATH_BIN_PYBREW) # pybrew is symbolic pythonbrew fp = open(os.path.join(PATH_ETC,'bashrc'), 'w') for line in open(os.path.join(installer_root,'scripts','bashrc')): line = line.replace('@ROOT@', ROOT) fp.write(line) fp.close() os.system("echo 'setenv PATH %s/bin:%s/current/bin:$PATH' > %s/cshrc" % (ROOT, PATH_PYTHONS, PATH_ETC))
def run_command_init(self): if os.path.exists(self._venv): logger.info('Remove virtualenv. (%s)' % self._venv_dir) rm_r(self._venv_dir) if os.path.exists(self._venv_clone): logger.info('Remove virtualenv-clone. (%s)' % self._venv_clone_dir) rm_r(self._venv_clone_dir) if not os.access(PATH_DISTS, os.W_OK): logger.error("Can not initialize venv command: Permission denied.") sys.exit(1) d = Downloader() download_file = os.path.join(PATH_DISTS, 'virtualenv.tar.gz') d.download('virtualenv.tar.gz', VIRTUALENV_DLSITE, download_file) logger.info('Extracting virtualenv into %s' % self._venv_dir) untar_file(download_file, self._venv_dir) download_file = os.path.join(PATH_DISTS, 'virtualenv-clone.tar.gz') d.download('virtualenv-clone.tar.gz', VIRTUALENV_CLONE_DLSITE, download_file) logger.info('Extracting virtualenv-clone into %s' % self._venv_clone_dir) untar_file(download_file, self._venv_clone_dir)
def symlink(self): install_dir = os.path.realpath(self.install_dir) 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)
def run_command(self, options, args): if args: # Uninstall pythons for arg in args: pkg = Package(arg) pkgname = pkg.name pkgpath = os.path.join(PATH_PYTHONS, pkgname) if not os.path.isdir(pkgpath): logger.info("`%s` is not installed." % pkgname) continue if get_current_python_path() == os.path.join(pkgpath,'bin','python'): off() for d in os.listdir(PATH_BIN): # remove symlink path = os.path.join(PATH_BIN, d) if os.path.islink(path): basename = os.path.basename(os.path.realpath(path)) tgtpath = os.path.join(pkgpath, 'bin', basename) if os.path.isfile(tgtpath) and os.path.samefile(path, tgtpath): unlink(path) rm_r(pkgpath) else: self.parser.print_help()
def _clean(self, root): for dir in os.listdir(root): rm_r("%s/%s" % (root, dir))
def _cleanup(self, root): for dir in os.listdir(root): rm_r(os.path.join(root, dir))