コード例 #1
0
    def list_h5(self, path):
        from PYME.IO import h5File
        try:
            with h5File.openH5(path.rstrip('/').rstrip('\\')) as h5f:
                f, length = self._string_to_file(json.dumps(h5f.get_listing()))

            self.send_response(200)
            encoding = sys.getfilesystemencoding()
            self.send_header("Content-type",
                             "application/json; charset=%s" % encoding)
            self.send_header("Content-Length", str(length))
            self.end_headers()
            return f

        except IOError:
            self.send_error(404,
                            "File not found - %s, [%s]" % (self.path, path))
            return None
コード例 #2
0
    def _aggregate_h5(self):
        """
        Support for results aggregation into an HDF5 file, using pytables.
        We treat any path components after the .h5r as locations within the file (ie table names).
        e.g. /path/to/data.h5r/<tablename>
        A few special cases / Table names are accommodated:

        MetaData: assumes we have sent PYME metadata in json format and saves to the file using the appropriate metadatahandler
        No table name: assumes we have a fitResults object (as returned by remFitBuf and saves to the the appropriate tables (as HDF task queue would)
        """
        import numpy as np
        from io import BytesIO
        #from six.moves import cPickle
        from PYME.IO import MetaDataHandler
        from PYME.IO import h5File

        #path = self.translate_path()
        filename, tablename = self.path.lstrip(
            '/')[len('__aggregate_h5'):].split('.h5')
        filename = self.translate_path(filename + '.h5')

        data = self._get_data()

        dirname = os.path.dirname(filename)
        #if not os.path.exists(dirname):
        #    os.makedirs(dirname)
        makedirs_safe(dirname)

        #logging.debug('opening h5r file')
        with h5File.openH5(filename, 'a') as h5f:
            tablename = tablename.lstrip('/')
            h5f.put_file(tablename, data)

        #logging.debug('left h5r file')
        if USE_DIR_CACHE:
            cl.dir_cache.update_cache(filename, int(len(data)))

        self.send_response(200)
        self.send_header("Content-Length", "0")
        self.end_headers()
        return
コード例 #3
0
    def get_h5_part(self, path):
        from PYME.IO import h5File
        ctype = self.guess_type(path)
        try:
            filename, part = path.split('.h5')
            part = part.lstrip('/').lstrip('\\')

            with h5File.openH5(filename + '.h5') as h5f:
                f, length = self._string_to_file(h5f.get_file(part))

                self.send_response(200)
                self.send_header("Content-type", ctype)
                self.send_header("Content-Length", length)
                #self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
                self.end_headers()
                return f

        except IOError:
            self.send_error(404,
                            "File not found - %s, [%s]" % (self.path, path))
            return None