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)
def reindex(self, args, config): self.check_access(config=config) import omero.java server_dir = self.ctx.dir / "lib" / "server" log4j = "-Dlog4j.configuration=log4j-cli.properties" classpath = [file.abspath() for file in server_dir.files("*.jar")] xargs = [log4j, "-Xmx1024M", "-cp", os.pathsep.join(classpath)] cfg = config.as_map() config.close() # Early close. See #9800 for x in ("name", "user", "host", "port"): # NOT passing password on command-line k = "omero.db.%s" % x if k in cfg: v = cfg[k] xargs.append("-D%s=%s" % (k, v)) if "omero.data.dir" in cfg: xargs.append("-Domero.data.dir=%s" % cfg["omero.data.dir"]) for k, v in cfg.items(): if k.startswith("omero.search"): xargs.append("-D%s=%s" % (k, cfg[k])) cmd = ["ome.services.fulltext.Main"] if args.full: cmd.append("full") elif args.events: cmd.append("events") elif getattr(args, "class"): cmd.append("reindex") cmd.extend(getattr(args, "class")) else: self.ctx.die(502, "No valid action: %s" % args) debug = False if getattr(args, "jdwp"): debug = True self.ctx.dbg("Launching Java: %s, debug=%s, xargs=%s" % (cmd, debug, xargs)) p = omero.java.popen( cmd, debug=debug, xargs=xargs, stdout=sys.stdout, stderr=sys.stderr) # FIXME. Shouldn't use std{out,err} self.ctx.rv = p.wait()
def reindex(self, args, config): self.check_access(config=config) import omero.java server_dir = self.ctx.dir / "lib" / "server" log_config_file = self.ctx.dir / "etc" / "logback-indexing-cli.xml" logback = "-Dlogback.configurationFile=%s" % log_config_file classpath = [file.abspath() for file in server_dir.files("*.jar")] xargs = [logback, "-Xmx1024M", "-cp", os.pathsep.join(classpath)] cfg = config.as_map() config.close() # Early close. See #9800 for x in ("name", "user", "host", "port"): # NOT passing password on command-line k = "omero.db.%s" % x if k in cfg: v = cfg[k] xargs.append("-D%s=%s" % (k, v)) if "omero.data.dir" in cfg: xargs.append("-Domero.data.dir=%s" % cfg["omero.data.dir"]) for k, v in cfg.items(): if k.startswith("omero.search"): xargs.append("-D%s=%s" % (k, cfg[k])) cmd = ["ome.services.fulltext.Main"] if args.full: cmd.append("full") elif args.events: cmd.append("events") elif getattr(args, "class"): cmd.append("reindex") cmd.extend(getattr(args, "class")) else: self.ctx.die(502, "No valid action: %s" % args) debug = False if getattr(args, "jdwp"): debug = True self.ctx.dbg( "Launching Java: %s, debug=%s, xargs=%s" % (cmd, debug, xargs)) p = omero.java.popen( cmd, debug=debug, xargs=xargs, stdout=sys.stdout, stderr=sys.stderr) # FIXME. Shouldn't use std{out,err} self.ctx.rv = p.wait()
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) except portalocker.LockException: try: config.close() except: pass self.ctx.die(111, "Could not acquire lock on %s" % cfg_xml) return config @with_config def reindex(self, args, config): self.check_access(config=config) import omero.java server_dir = self.ctx.dir / "lib" / "server" log_config_file = self.ctx.dir / "etc" / "logback-indexing-cli.xml" logback = "-Dlogback.configurationFile=%s" % log_config_file classpath = [file.abspath() for file in server_dir.files("*.jar")] xargs = [logback, "-Xmx1024M", "-cp", os.pathsep.join(classpath)]
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) except portalocker.LockException: try: config.close() except: pass self.ctx.die(111, "Could not acquire lock on %s" % cfg_xml) return config @with_config def reindex(self, args, config): self.check_access(config=config) import omero.java server_dir = self.ctx.dir / "lib" / "server" log4j = "-Dlog4j.configuration=log4j-cli.properties" classpath = [file.abspath() for file in server_dir.files("*.jar")] xargs = [log4j, "-Xmx1024M", "-cp", os.pathsep.join(classpath)]