def open_config(self, unused): """ Callers are responsible for closing the returned ConfigXml object. """ cfg_xml = self.ctx.dir / "etc" / "grid" / "config.xml" cfg_tmp = self.ctx.dir / "etc" / "grid" / "config.xml.tmp" grid_dir = self.ctx.dir / "etc" / "grid" if not cfg_xml.exists() and self.can_access(grid_dir): if cfg_tmp.exists() and self.can_access(cfg_tmp): self.ctx.dbg("Removing old config.xml.tmp") cfg_tmp.remove() config = omero.config.ConfigXml(str(cfg_tmp)) try: self.ctx.controls["config"].upgrade(None, config) finally: config.close() self.ctx.err("Creating %s" % cfg_xml) cfg_tmp.rename(str(cfg_xml)) try: config = omero.config.ConfigXml(str(cfg_xml)) config.save() except portalocker.LockException: self.ctx.die(111, "Could not acquire lock on %s" % cfg_xml) return config
def open_config(self, unused): """ Callers are responsible for closing the returned ConfigXml object. """ cfg_xml = self.ctx.dir / "etc" / "grid" / "config.xml" cfg_tmp = self.ctx.dir / "etc" / "grid" / "config.xml.tmp" grid_dir = self.ctx.dir / "etc" / "grid" if not cfg_xml.exists() and self.can_access(grid_dir): if cfg_tmp.exists() and self.can_access(cfg_tmp): self.ctx.dbg("Removing old config.xml.tmp") cfg_tmp.remove() config = omero.config.ConfigXml(str(cfg_tmp)) try: self.ctx.controls["config"].upgrade(None, config) finally: config.close() self.ctx.err("Creating %s" % cfg_xml) cfg_tmp.rename(str(cfg_xml)) try: try: config = omero.config.ConfigXml(str(cfg_xml)) except Exception, e: self.ctx.die(577, str(e)) if config.save_on_close: config.save() else: self.ctx.err("%s read-only" % cfg_xml)