def install(self, cleanup=True): self._verify() if self.is_installed(): return src = self.location() collision = get_bundle(self.name()) if collision is None: dst = make_bundle_install_path(self._rawname) if cleanup: comm.moveItem(src, dst) else: comm.mkdirItem(dst) comm.mergeDirs(src, dst) else: default_path = os.path.join(collision.location(), self._DEFAULT) if os.path.exists(default_path): default_path_bkup = "%s.old.%s" % ( default_path, time.strftime("%Y%m%d-%H%M%S", time.localtime())) comm.moveItem(default_path, default_path_bkup) comm.mkdirItem(default_path) self._rearrange_conf_files(self._DEFAULT) comm.mergeDirs(src, collision.location()) if cleanup: self.delete()
def install(self, cleanup=True): self._verify() if self.is_installed(): return src = self.location() collision = get_bundle(self.name()) if collision is None: dst = make_bundle_install_path(self._rawname) if cleanup: comm.moveItem(src, dst) else: comm.mkdirItem(dst) comm.mergeDirs(src, dst) else: default_path = os.path.join(collision.location(), self._DEFAULT) default_path_bkup = "%s.old.%s" % (default_path, time.strftime("%Y%m%d-%H%M%S", time.localtime())) comm.moveItem(default_path, default_path_bkup) comm.mkdirItem(default_path) self._rearrange_conf_files(self._DEFAULT) comm.mergeDirs(src, collision.location()) if cleanup: self.delete()
def _rearrange_conf_files(self, dirname): self._verify() location = self.location() subdir = os.path.join(location, dirname) if os.path.lexists(subdir): if not os.path.isdir(subdir): raise OSError("Existing file not a directory: %s" % subdir) else: comm.mkdirItem(subdir) for f in glob.glob(os.path.join(location, "*.conf")): comm.moveItem(f, subdir)