Permalink
Browse files

Merge pull request #392 from lukecampbell/coverage_modes

Adds access modes to Coverage Model usage
  • Loading branch information...
2 parents 5744ce4 + 2e2c8c1 commit 16cf3d3163e967fb52443d5b5ec2add0ed1e17f6 @blazetopher blazetopher committed Dec 6, 2012
@@ -156,7 +156,7 @@ def execute_retrieve(self):
as a value in lieu of publishing it on a stream
'''
try:
- coverage = DatasetManagementService._get_coverage(self.dataset_id)
+ coverage = DatasetManagementService._get_coverage(self.dataset_id,mode='r')
if coverage.num_timesteps == 0:
log.info('Reading from an empty coverage')
rdt = RecordDictionaryTool(param_dictionary=coverage.parameter_dictionary)
@@ -231,7 +231,7 @@ def get_last_granule(cls, container, dataset_id):
ts = float(doc.get('ts_create',0))
- coverage = DatasetManagementService._get_coverage(dataset_id)
+ coverage = DatasetManagementService._get_coverage(dataset_id,mode='r')
rdt = cls._coverage_to_granule(coverage,tdoa=slice(cls.get_relative_time(coverage,ts),None))
coverage.close(timeout=5)
@@ -240,7 +240,7 @@ def get_last_granule(cls, container, dataset_id):
@classmethod
def get_last_values(cls, dataset_id, number_of_points):
- coverage = DatasetManagementService._get_coverage(dataset_id)
+ coverage = DatasetManagementService._get_coverage(dataset_id,mode='r')
if coverage.num_timesteps < number_of_points:
if coverage.num_timesteps == 0:
rdt = RecordDictionaryTool(param_dictionary=coverage.parameter_dictionary)
@@ -252,7 +252,7 @@ def get_last_values(cls, dataset_id, number_of_points):
return rdt.to_granule()
def _replay(self):
- coverage = DatasetManagementService._get_coverage(self.dataset_id)
+ coverage = DatasetManagementService._get_coverage(self.dataset_id,mode='r')
rdt = self._coverage_to_granule(coverage, self.start_time, self.end_time, self.stride_time, self.parameters, self.stream_def_id)
elements = len(rdt)
@@ -331,9 +331,9 @@ def _create_coverage(self, dataset_id, description, parameter_dict, spatial_doma
return scov
@classmethod
- def _get_coverage(cls,dataset_id):
+ def _get_coverage(cls,dataset_id,mode='w'):
file_root = FileSystem.get_url(FS.CACHE,'datasets')
- coverage = SimplexCoverage(file_root, dataset_id)
+ coverage = SimplexCoverage(file_root, dataset_id,mode=mode)
return coverage
@classmethod
@@ -22,7 +22,7 @@ def __init__(self, filepath):
def parse_constraints(self, environ):
base = os.path.split(self.filepath)
- coverage = SimplexCoverage.load(base[0], base[1])
+ coverage = SimplexCoverage.load(base[0], base[1],mode='r')
last_modified = formatdate(time.mktime(time.localtime(os.stat(self.filepath)[ST_MTIME])))
environ['pydap.headers'].append(('Last-modified', last_modified))

0 comments on commit 16cf3d3

Please sign in to comment.