def get_formats(cls): '''inits supported file formats''' if cls.installed_formats is None: cls.installed_formats = OrderedDict() formats_xml = cls.run_command( [cls.BFORMATS, '-xml'] ) if formats_xml is None: return formats = etree.fromstring( formats_xml ) codecs = formats.xpath('//format') for c in codecs: try: ext=c.xpath('tag[@name="extensions"]')[0].get('value', '').split('|') name = c.get('name') cls.installed_formats[name.lower()] = Format( name=name, fullname=c.get('name'), ext=ext, reading=len(c.xpath('tag[@name="support" and @value="reading"]'))>0, writing=len(c.xpath('tag[@name="support" and @value="writing"]'))>0, multipage=len(c.xpath('tag[@name="support" and @value="writing multiple pages"]'))>0, metadata=True, ) except IndexError: continue
def load_default_drivers(): stores = OrderedDict() store_list = [ x.strip() for x in config.get('bisque.blob_service.stores', '').split(',') ] log.debug('requested stores = %s', store_list) for store in store_list: # pull out store related params from config params = dict((x[0].replace('bisque.stores.%s.' % store, ''), x[1]) for x in config.items() if x[0].startswith('bisque.stores.%s.' % store)) if 'mounturl' not in params: if 'path' in params: path = params.pop('path') params['mounturl'] = string.Template(path).safe_substitute( OLDPARMS) log.warn( "Use of deprecated path (%s) in %s driver . Please change to mounturl and remove any from %s", path, store, OLDPARMS.keys()) log.info("using mounturl = %s", params['mounturl']) else: log.error('cannot configure %s without the mounturl parameter', store) continue #if 'top' not in params: # params['top'] = params['mounturl'].split ('$user')[0] # log.warn ("top for %s was not set. Using %s", params['mounturl'], params['top']) log.debug("params = %s", params) #driver = make_storage_driver(params.pop('path'), **params) #if driver is None: # log.error ("failed to configure %s. Please check log for errors " , str(store)) # continue stores[store] = params return stores
def get_formats(cls): '''inits supported file formats''' if cls.installed_formats is None: formats_xml = cls.run_command([cls.CONVERTERCOMMAND, '-fmtxml']) formats = etree.fromstring('<formats>%s</formats>' % formats_xml) cls.installed_formats = OrderedDict() codecs = formats.xpath('//codec') for c in codecs: try: name = c.get('name') fullname = c.xpath('tag[@name="fullname"]')[0].get( 'value', '') exts = c.xpath('tag[@name="extensions"]')[0].get( 'value', '').split('|') reading = len( c.xpath( 'tag[@name="support" and @value="reading"]')) > 0 writing = len( c.xpath( 'tag[@name="support" and @value="writing"]')) > 0 multipage = len( c.xpath( 'tag[@name="support" and @value="writing multiple pages"]' )) > 0 metadata = len( c.xpath( 'tag[@name="support" and @value="reading metadata"]' ) ) > 0 or len( c.xpath( 'tag[@name="support" and @value="writing metadata"]' )) > 0 samples_min = misc.safeint( c.xpath('tag[@name="min-samples-per-pixel"]')[0].get( 'value', '0')) samples_max = misc.safeint( c.xpath('tag[@name="max-samples-per-pixel"]')[0].get( 'value', '0')) bits_min = misc.safeint( c.xpath('tag[@name="min-bits-per-sample"]')[0].get( 'value', '0')) bits_max = misc.safeint( c.xpath('tag[@name="max-bits-per-sample"]')[0].get( 'value', '0')) except IndexError: continue cls.installed_formats[name.lower()] = Format( name=name, fullname=fullname, ext=exts, reading=reading, writing=writing, multipage=multipage, metadata=metadata, samples=(samples_min, samples_max), bits=(bits_min, bits_max))
def load_storage_drivers(): stores = OrderedDict() store_list = [ x.strip() for x in config.get('bisque.blob_service.stores','').split(',') ] log.debug ('requested stores = %s' , store_list) for store in store_list: # pull out store related params from config params = dict ( (x[0].replace('bisque.stores.%s.' % store, ''), x[1]) for x in config.items() if x[0].startswith('bisque.stores.%s.' % store)) if 'path' not in params: log.error ('cannot configure %s without the path parameter' , store) continue log.debug("params = %s" , str(params)) driver = make_storage_driver(params.pop('path'), **params) if driver is None: log.error ("failed to configure %s. Please check log for errors " , str(store)) continue stores[store] = driver return stores
def _get_stores(self): "Return an OrderedDict of store resources in the users ordering" #root = self._create_root_mount() root = self._load_root_mount() store_order = get_tag (root, 'order') if store_order is None: store_order = config.get('bisque.blob_service.stores','') else: store_order = store_order[0].get ('value') log.debug ("using store order %s", store_order) stores = OrderedDict() for store_name in (x.strip() for x in store_order.split(',')): store_el = root.xpath('./store[@name="%s"]' % store_name) if not store_el or len(store_el) > 1: log.warn ("store %s does not exist in %s", store_name, etree.tostring(root)) continue store = store_el[0] stores[store_name] = store log.debug ("adding store '%s' at %s", store_name, len(stores)) return stores
def get_formats(cls): '''inits supported file formats''' if cls.installed_formats is not None: return fs = cls.run_command( [cls.CONVERTERCOMMAND, '-h'] ) if fs is None: return '' ins = [f.strip(' ') for f in misc.between('Input File Formats are:%s' % (os.linesep*2) , 'Output File Formats are:', fs).split(os.linesep) if f != ''] # version 8.0.0 if 'Exit Codes:' in fs: ous = [f.strip(' ') for f in misc.between('Output File Formats are:%s' % (os.linesep*2), 'Exit Codes:', fs).split(os.linesep) if f != ''] else: # version 7.X ous = [f.strip(' ') for f in misc.between('Output File Formats are:%s' % (os.linesep*2), 'Examples:', fs).split(os.linesep) if f != ''] ins = [parse_format(f) for f in ins] ous = [parse_format(f) for f in ous] # join lists cls.installed_formats = OrderedDict() for name,longname,ext in ins: cls.installed_formats[name.lower()] = Format(name=name, fullname=longname, ext=ext, reading=True, multipage=True, metadata=True) for name,longname,ext in ous: cls.installed_formats[name.lower()] = Format(name=name, fullname=longname, ext=ext, reading=True, writing=True, multipage=True, metadata=True )
#log.debug("loading %s -> name/type (%s/%s)(%s) " , uri, name, str(dbcls), ida) #resource = DBSession.query(dbcls).get (int (ida)) resource = DBSession.query(dbcls).filter(dbcls.id == int(ida)) if not query: resource = resource.first() #log.debug ("loaded %s" % resource) return resource except Exception: log.exception("Failed to load uri %s", uri) return None converters = OrderedDict(( ('object', load_uri), ('integer', int), ('float', float), ('number', float), ('string', unicode_safe), )) def try_converters(value): for ty_, converter in converters.items(): try: v = converter(value) if v is not None: return v except ValueError: pass # we should never get here raise ValueError
def get_formats(cls): '''inits supported file formats''' if cls.installed_formats is not None: return cls.extensions = [ '.svs', '.ndpi', '.vms', '.vmu', '.scn', '.mrxs', '.svslide', '.bif' ] # Many extensions may unfortunately be .tif, we'll have to deal with that later cls.installed_formats = OrderedDict() cls.installed_formats['aperio'] = Format(name='aperio', fullname='Aperio', ext=['svs', 'tif', 'tiff'], reading=True, multipage=False, metadata=True) # tif cls.installed_formats['hamamatsu'] = Format(name='hamamatsu', fullname='Hamamatsu', ext=['ndpi', 'vms', 'vmu'], reading=True, multipage=False, metadata=True) cls.installed_formats['leica'] = Format(name='leica', fullname='Leica', ext=['scn'], reading=True, multipage=False, metadata=True) cls.installed_formats['mirax'] = Format(name='mirax', fullname='MIRAX', ext=['mrxs'], reading=True, multipage=False, metadata=True) cls.installed_formats['philips'] = Format(name='philips', fullname='Philips', ext=['tiff'], reading=True, multipage=False, metadata=True) cls.installed_formats['sakura'] = Format(name='sakura', fullname='Sakura', ext=['svslide'], reading=True, multipage=False, metadata=True) cls.installed_formats['trestle'] = Format(name='trestle', fullname='Trestle', ext=['tif'], reading=True, multipage=False, metadata=True) cls.installed_formats['ventana'] = Format(name='ventana', fullname='Ventana', ext=['bif', 'tif'], reading=True, multipage=False, metadata=True) cls.installed_formats['tiff'] = Format(name='tiff', fullname='Generic tiled TIFF', ext=['tif', 'tiff'], reading=True, multipage=False, metadata=True)
def get_formats(cls): '''inits supported file formats''' if cls.installed_formats is None: cls.installed_formats = OrderedDict() # OrderedDict containing Format and keyed by format name