def testConfigNoVersionPropertyParser(self, tmpdir): cfg = tmpdir.join("test-noversion.properties") s = "omero.version=5.6.1\na.1=a\nomero.db.version=5.4.0" cfg.write(s) pp = PropertyParser() props = pp.parse_file(str(cfg)) # Fails, the last two properties are parsed as one: # 'd.e' = 'line1line2f.g=\\n' assert len(props) == 2 assert props[0].key == 'a.1' assert props[0].val == 'a' assert props[1].key == 'omero.db.version' assert props[1].val == '5.4.0'
def _db_profile(self): from omero.install.config_parser import PropertyParser property_lines = self.ctx.get_config_property_lines(self.dir) for property in PropertyParser().parse_lines(property_lines): if property.key == 'omero.db.profile': return property.val raise KeyError('Configuration key not set: omero.db.profile')
def testConfigPropertyParser(self, tmpdir): cfg = tmpdir.join("test.properties") s = "a=1\nb.c=a b <!> c\nd.e=line1\\\nline2\nf.g=\\n\n" cfg.write(s) pp = PropertyParser() props = pp.parse_file(str(cfg)) # Fails, the last two properties are parsed as one: # 'd.e' = 'line1line2f.g=\\n' assert len(props) == 4 assert props[0].key == 'a' assert props[0].val == '1' assert props[1].key == 'b.c' assert props[1].val == 'a b <!> c' assert props[2].key == 'd.e' assert props[2].val == 'line1line2' assert props[3].key == 'f.g' assert props[3].val == '\\n'
def parse(self, args): from omero.install.config_parser import PropertyParser pp = PropertyParser() if args.file: args.file.close() pp.parse_file(str(path(args.file.name).abspath())) else: pp.parse_lines(self.ctx.get_config_property_lines(self.dir)) # Parse PSQL profile file for p in pp: if p.key == "omero.db.profile": psql_file = self.dir / "etc" / "profiles" / p.val pp.parse_file(str(psql_file.abspath())) break # Parse OMERO.web configuration properties if not args.no_web: pp.parse_module('omeroweb.settings') # Display options if args.headers: pp.print_headers() elif args.keys: pp.print_keys() elif args.rst: pp.print_rst() else: pp.print_defaults()
def get_mmp(sqlfile): m = re.search(r'.*/?OMERO(\d+)\.(\d+)(\w*)__(\d+)', sqlfile) if m is None: return None mmp = (int(m.group(1)), int(m.group(2)), m.group(3), int(m.group(4))) return mmp serverdir = path(sys.argv[1]) required = {'omero.db.version': None, 'omero.db.patch': None} cli = CLI() property_lines = cli.get_config_property_lines(serverdir) for property in PropertyParser().parse_lines(property_lines): if property.key in required: required[property.key] = property.val current_dbver = '%s__%s' % (required['omero.db.version'], required['omero.db.patch']) # Check dir current_mmp = get_mmp(current_dbver) if current_mmp is None: current_version = None directory = os.path.join(serverdir, 'sql', 'psql') subfolders = [f.path for f in os.scandir(directory) if f.is_dir()] for f in subfolders: ver = os.path.basename(os.path.normpath(f)) ver = ver.replace("OMERO", "")
def parse(self, args): if args.file: args.file.close() cfg = path(args.file.name) else: cfg = self.dir / "etc" / "omero.properties" from omero.install.config_parser import PropertyParser pp = PropertyParser() pp.parse_file(str(cfg.abspath())) # Parse PSQL profile file for p in pp: if p.key == "omero.db.profile": psql_file = self.dir / "etc" / "profiles" / p.val pp.parse_file(str(psql_file.abspath())) break # Parse OMERO.web configuration properties if not args.no_web: pp.parse_module('omeroweb.settings') # Display options if args.headers: pp.print_headers() elif args.keys: pp.print_keys() elif args.rst: pp.print_rst() else: pp.print_defaults()
def parse(self, args): if args.file: args.file.close() cfg = path(args.file.name) else: cfg = self.dir / "etc" / "omero.properties" from omero.install.config_parser import PropertyParser pp = PropertyParser() pp.parse(str(cfg.abspath())) if args.headers: pp.print_headers() elif args.keys: pp.print_keys() elif args.rst: pp.print_rst() else: pp.print_defaults()