def _get_target_path(self, uuid, path): bundle_path = self.get_bundle_location(uuid) try: key = (bundle_path, uuid, path) get_target_path = lambda: download_util.get_target_path(*key) return self._cached_if_stable(uuid, 'target_path', key, get_target_path) except download_util.PathException as e: raise UsageError(e.message)
def _threaded_read(self, run_state, path, stream_fn, reply_fn): """ Given a run state, a path, a stream function and a reply function, - Computes the real filesystem path to the path in the bundle - In case of error, invokes reply_fn with an http error - Otherwise starts a thread calling stream_fn on the computed final path """ try: final_path = get_target_path(run_state.bundle_path, run_state.bundle['uuid'], path) except PathException as e: reply_fn((httplib.NOT_FOUND, e.message), None, None) read_thread = threading.Thread(target=stream_fn, args=[final_path]) read_thread.start() self.read_threads.append(read_thread)
def _get_target_path(self, uuid, path): bundle_path = self._bundle_store.get_bundle_location(uuid) try: return download_util.get_target_path(bundle_path, uuid, path) except download_util.PathException as e: raise UsageError(e.message)