@@ -219,10 +219,11 @@ def filename(self):
219219 def _getStats (self ):
220220 """ return info on storage usage """
221221 self ._verifyOpen ()
222- if self .id .db .writer :
223- stats = self .id .db .writer .getStats ()
224- elif self .id .db .reader :
222+
223+ if self .id .db .reader :
225224 stats = self .id .db .reader .getStats ()
225+ elif self .id .db .writer :
226+ stats = self .id .db .writer .getStats ()
226227 else :
227228 stats = {"created" : 0 , "lastModified" : 0 , "owner" : 0 }
228229 return stats
@@ -272,13 +273,13 @@ def created(self):
272273 """Creation time of the domain"""
273274 self ._verifyOpen ()
274275 stats = self ._getStats ()
275- return stats [ "created" ]
276+ return stats . get ( "created" )
276277
277278 @property
278279 def owner (self ):
279280 """Username of the owner of the domain"""
280281 stats = self ._getStats ()
281- return stats [ "owner" ]
282+ return stats . get ( "owner" )
282283
283284 @property
284285 def limits (self ):
@@ -315,15 +316,14 @@ def _init_db(self,
315316 bucket = None ,
316317 api_key = None ,
317318 swmr = False ,
319+ track_order = None ,
318320 getobjs = True ,
319321 retries = 10 ,
320322 timeout = 180 ,
321323 ** kwds ,
322324 ):
323325 # initialize h5db using domain path
324326
325- cfg = config .get_config () # pulls in state from a .hscfg file (if found).
326-
327327 # accept domain values in the form:
328328 # http://server:port/home/user/myfile.h5
329329 # or
@@ -359,31 +359,10 @@ def _init_db(self,
359359 if domain [0 ] != "/" :
360360 raise IOError (400 , "relative paths are not valid" )
361361
362- if endpoint is None :
363- if "hs_endpoint" in cfg :
364- endpoint = cfg ["hs_endpoint" ]
365-
366362 # remove the trailing slash on endpoint if it exists
367363 if endpoint and endpoint .endswith ('/' ):
368364 endpoint = endpoint .strip ('/' )
369365
370- if username is None :
371- if "hs_username" in cfg :
372- username = cfg ["hs_username" ]
373-
374- if password is None :
375- if "hs_password" in cfg :
376- password = cfg ["hs_password" ]
377-
378- if api_key is None and "hs_api_key" in cfg :
379- api_key = cfg ["hs_api_key" ]
380-
381- if bucket is None :
382- if "HS_BUCKET" in os .environ :
383- bucket = os .environ ["HS_BUCKET" ]
384- elif "hs_bucket" in cfg :
385- bucket = cfg ["hs_bucket" ]
386-
387366 db = Hdf5db (app_logger = self .log ) # initialize hdf5 db
388367
389368 kwargs = {"app_logger" : self .log }
@@ -403,6 +382,8 @@ def _init_db(self,
403382 kwargs ["retries" ] = retries
404383 if timeout :
405384 kwargs ["timeout" ] = timeout
385+ if track_order :
386+ kwargs ["track_order" ] = track_order
406387
407388 root_id = None
408389
@@ -503,8 +484,11 @@ def __init__(
503484 """
504485
505486 self .log = logging .getLogger ()
487+ cfg = config .get_config () # pulls in state from a .hscfg file (if found).
506488
507489 self .log .setLevel (logging .ERROR )
490+ if track_order is None :
491+ track_order = cfg .track_order
508492
509493 # if we're passed a GroupId as domain, just initialize the file object
510494 # with that. This will be faster and enable the File object to share the same http connection.
@@ -538,12 +522,14 @@ def __init__(
538522 kwargs ["swmr" ] = swmr
539523 if bucket :
540524 kwargs ["bucket" ] = bucket
525+ if track_order is not None :
526+ kwargs ["track_order" ] = track_order
541527 kwargs ["getobjs" ] = True # TBD: disable this optionally?
542528
543529 db = self ._init_db (domain , ** kwargs )
544530
545531 root_id = db .root_id
546- root_json = db .getObjectById (root_id )
532+ root_json = db .getObjectById (root_id , refresh = True )
547533
548534 if "limits" in root_json :
549535 self ._limits = root_json ["limits" ]
@@ -564,6 +550,9 @@ def __init__(
564550 self ._lastScan = None # when summary stats where last updated by server
565551 self ._swmr_mode = swmr
566552
553+ if track_order is None :
554+ track_order = cfg .track_order
555+
567556 Group .__init__ (self , self ._id , track_order = track_order )
568557
569558 def _getVerboseInfo (self ):
@@ -715,31 +704,6 @@ def compressors(self):
715704 compressors = []
716705 return compressors
717706
718- # override base implemention of ACL methods to use the domain rather than update root group
719- def getACL (self , username ):
720- req = "/acls/" + username
721- rsp_json = self .GET (req )
722- acl_json = rsp_json ["acl" ]
723- return acl_json
724-
725- def getACLs (self ):
726- req = "/acls"
727- rsp_json = self .GET (req )
728- acls_json = rsp_json ["acls" ]
729- return acls_json
730-
731- def putACL (self , acl ):
732- if "userName" not in acl :
733- raise IOError (404 , "ACL has no 'userName' key" )
734- perm = {}
735- for k in ("create" , "read" , "update" , "delete" , "readACL" , "updateACL" ):
736- if k not in acl :
737- raise IOError (404 , "Missing ACL field: {}" .format (k ))
738- perm [k ] = acl [k ]
739-
740- req = "/acls/" + acl ["userName" ]
741- self .PUT (req , body = perm )
742-
743707 def run_scan (self ):
744708 MAX_WAIT = 10
745709 self ._getVerboseInfo ()
0 commit comments