Exemplo n.º 1
0
    def test_file_open_close(self, tmp_path, backend):
        bck = H5Backend(backend)
        title = 'this is a test file'
        start_path = get_temp_path(tmp_path, backend)
        h5_file = bck.open_file(start_path.joinpath('h5file.h5'), 'w', title)
        if backend != 'h5pyd':
            assert start_path.joinpath('h5file.h5').exists()
            assert start_path.joinpath('h5file.h5').is_file()

        assert bck.isopen() is True
        assert bck.root().attrs['TITLE'] == title
        assert bck.root().attrs['pymodaq_version'] == get_version()
        bck.close_file()
        assert bck.isopen() is False
Exemplo n.º 2
0
#['pyqtgraph.'+x for x in helpers.listAllPackages(pkgroot='examples')])


def get_packages():

    packages = find_packages()
    for pkg in packages:
        if 'hardware.' in pkg:
            packages.pop(packages.index(pkg))
    return packages


allPackages = get_packages()

setup(
    version=get_version(),
    #cmdclass={'build': Build,},
    #           'install': Install,
    #           'deb': helpers.DebCommand,
    #           'test': helpers.TestCommand,
    #           'debug': helpers.DebugCommand,
    #           'mergetest': helpers.MergeTestCommand,
    #           'style': helpers.StyleCommand},
    packages=allPackages,
    #package_dir={'examples': 'examples'},  ## install examples along with the rest of the source
    package_data={},
    entry_points={
        'console_scripts': [
            'pymodaq_scan=pymodaq.pymodaq_exec:scan',
            'pymodaq_move=pymodaq.pymodaq_exec:move',
            'pymodaq_viewer=pymodaq.pymodaq_exec:viewer',
Exemplo n.º 3
0
    def init_file(self,
                  update_h5=False,
                  custom_naming=False,
                  addhoc_file_path=None):
        """Initializes a new h5 file.
        Could set the h5_file attributes as:

        * a file with a name following a template if ``custom_naming`` is ``False`` and ``addhoc_file_path`` is ``None``
        * a file within a name set using a file dialog popup if ``custom_naming`` is ``True``
        * a file with a custom name if ``addhoc_file_path`` is a ``Path`` object or a path string

        Parameters
        ----------
        update_h5: bool
                   create a new h5 file with name specified by other parameters
                   if false try to open an existing file and will append new data to it
        custom_naming: bool
                       if True, a selection file dialog opens to set a new file name
        addhoc_file_path: Path or str
                          supplied name by the user for the new file

        Returns
        -------
        update_h5: bool
                   True if new file has been created, False otherwise
        """
        date = datetime.datetime.now()

        if addhoc_file_path is None:
            if not os.path.isdir(self.settings.child(('base_path')).value()):
                os.mkdir(self.settings.child(('base_path')).value())

            # set the filename and path
            base_name = self.settings.child(('base_name')).value()

            if not custom_naming:
                custom_naming = self.settings.child(('custom_name')).value()

            if not custom_naming:
                scan_type = self.settings.child(
                    ('save_type')).value() == 'scan'
                scan_path, current_scan_name, save_path = self.update_file_paths(
                    update_h5)
                self.current_scan_name = current_scan_name
                self.settings.child(
                    ('current_scan_name')).setValue(current_scan_name)
                self.settings.child(
                    ('current_scan_path')).setValue(str(scan_path))

                if not scan_type:
                    self.h5_file_path = save_path  #will remove the dataset part used for DAQ_scan datas
                    self.h5_file_name = base_name + date.strftime(
                        '_%Y%m%d_%H_%M_%S.h5')
                else:
                    self.h5_file_path = save_path
                    self.h5_file_name = save_path.name + ".h5"
            else:
                self.h5_file_name = utils.select_file(start_path=base_name,
                                                      save=True,
                                                      ext='h5')
                self.h5_file_path = self.h5_file_name.parent

        else:
            if isinstance(addhoc_file_path, str):
                addhoc_file_path = Path(addhoc_file_path)
            self.h5_file_path = addhoc_file_path.parent
            self.h5_file_name = addhoc_file_path.name

        fullpathname = str(self.h5_file_path.joinpath(self.h5_file_name))
        self.settings.child(('current_h5_file')).setValue(fullpathname)

        if update_h5:
            self.current_scan_group = None

        scan_group = None
        if self.current_scan_group is not None:
            scan_group = self.current_scan_group._v_name

        if update_h5:
            self.close_file()
            self.h5_file = tables.open_file(fullpathname,
                                            'w',
                                            title='PyMoDAQ file')
            self.h5_file.root._v_attrs['pymodaq_version'] = get_version()
        else:
            self.close_file()
            self.h5_file = tables.open_file(fullpathname,
                                            'a',
                                            title='PyMoDAQ file')

        self.raw_group = self.get_set_group(self.h5_file.root,
                                            'Raw_datas',
                                            title='Data from PyMoDAQ modules')
        self.get_set_logger(self.raw_group)
        if scan_group is not None:
            self.current_scan_group = self.get_set_group(
                self.raw_group, scan_group)
        else:
            self.current_scan_group = self.get_last_scan()

        self.raw_group._v_attrs['type'] = self.settings.child(
            ('save_type')).value()
        self.h5_file.root._v_attrs['file'] = date.strftime(self.h5_file_name)
        if update_h5:
            self.h5_file.root._v_attrs['date'] = date.strftime('%Y%m%d')
            self.h5_file.root._v_attrs['time'] = date.strftime('%H:%M:%S')

        return update_h5
Exemplo n.º 4
0
copyright = u'%d, Weber Sébastien' % year

author = 'Weber Sebastien'

# 'releases' (changelog) settings
releases_issue_uri = "https://github.com/CEMES-CNRS/PyMoDAQ/issues/%s"
releases_release_uri = "https://github.com/CEMES-CNRS/PyMoDAQ/tree/%s"

sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), '..')))
from pymodaq.version import get_version


# Get version info
#
# Branch-only name
version = get_version('branch')
# The full human readable version, including alpha/beta/rc tags.
release = get_version('normal')



# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
Exemplo n.º 5
0
    def init_file(self,
                  update_h5=False,
                  custom_naming=False,
                  addhoc_file_path=None):
        """
        init a new h5 file. Could be a file with a given name (addhoc_file_path) or following the template for scans
        (datasets) or for detectors or a box to set a custom name (custom naming)
        Parameters
        ----------
        update_h5: (bool) create a new h5 file with name specified by other parameters if false try to open an existing
        file or create it if it doesn't exists
        custom_naming: (bool) if True, a selection file dialog opens to set a new file name
        addhoc_file_path: (Path) supplied name for the file

        Returns
        -------
        bool: True if new file has been created, False otherwise
        """
        date = datetime.datetime.now()

        if addhoc_file_path is None:
            if not os.path.isdir(self.settings.child(('base_path')).value()):
                os.mkdir(self.settings.child(('base_path')).value())

            # set the filename and path
            base_name = self.settings.child(('base_name')).value()

            if not custom_naming:
                custom_naming = self.settings.child(('custom_name')).value()

            if not custom_naming:
                scan_type = self.settings.child(
                    ('save_type')).value() == 'scan'
                scan_path, current_scan_name, save_path = self.update_file_paths(
                    update_h5)
                self.current_scan_name = current_scan_name
                self.settings.child(
                    ('current_scan_name')).setValue(current_scan_name)
                self.settings.child(
                    ('current_scan_path')).setValue(str(scan_path))

                if not scan_type:
                    self.h5_file_path = save_path  #will remove the dataset part used for DAQ_scan datas
                    self.h5_file_name = base_name + date.strftime(
                        '_%Y%m%d_%H_%M_%S.h5')
                else:
                    self.h5_file_path = save_path
                    self.h5_file_name = save_path.name + ".h5"
            else:
                self.h5_file_name = utils.select_file(start_path=base_name,
                                                      save=True,
                                                      ext='h5')
                self.h5_file_path = self.h5_file_name.parent

        else:
            if isinstance(addhoc_file_path, str):
                addhoc_file_path = Path(addhoc_file_path)
            self.h5_file_path = addhoc_file_path.parent
            self.h5_file_name = addhoc_file_path.name

        fullpathname = str(self.h5_file_path.joinpath(self.h5_file_name))
        self.settings.child(('current_h5_file')).setValue(fullpathname)

        if update_h5:
            self.current_scan_group = None

        scan_group = None
        if self.current_scan_group is not None:
            scan_group = self.current_scan_group._v_name

        if update_h5:
            self.close_file()
            self.h5_file = tables.open_file(fullpathname,
                                            'w',
                                            title='PyMoDAQ file')
            self.h5_file.root._v_attrs['pymodaq_version'] = get_version()
        else:
            self.close_file()
            self.h5_file = tables.open_file(fullpathname,
                                            'a',
                                            title='PyMoDAQ file')

        self.raw_group = self.get_set_group(self.h5_file.root,
                                            'Raw_datas',
                                            title='Data from PyMoDAQ modules')
        self.get_set_logger(self.raw_group)
        if scan_group is not None:
            self.current_scan_group = self.get_set_group(
                self.raw_group, scan_group)
        else:
            self.current_scan_group = self.get_last_scan()

        self.raw_group._v_attrs['type'] = self.settings.child(
            ('save_type')).value()
        self.h5_file.root._v_attrs['file'] = date.strftime(self.h5_file_name)
        if update_h5:
            self.h5_file.root._v_attrs['date'] = date.strftime('%Y%m%d')
            self.h5_file.root._v_attrs['time'] = date.strftime('%H:%M:%S')

        return update_h5