示例#1
0
    def __init__(self, path=None, file_types=None, activate=False):
        """
        :param path: path to folder which will be watched
        :param file_types: list of file types which will be watched for, e.g. ['.tif', '.jpeg]
        :param activate: whether or not the Watcher will already emit signals
        """
        super(NewFileInDirectoryWatcher, self).__init__()

        self._file_system_watcher = QtCore.QFileSystemWatcher()
        if path is None:
            path = os.getcwd()
        self._file_system_watcher.addPath(path)
        self._files_in_path = os.listdir(path)

        self._file_system_watcher.directoryChanged.connect(
            self._directory_changed)
        self._file_system_watcher.blockSignals(~activate)

        self._file_changed_watcher = QtCore.QFileSystemWatcher()
        self._file_changed_watcher.fileChanged.connect(self._file_changed)

        if file_types is None:
            self.file_types = set([])
        else:
            self.file_types = set(file_types)
示例#2
0
    def __init__(self, filename=None):
        super(FileNameIterator, self).__init__()
        self.acceptable_file_endings = []
        self.directory_watcher = QtCore.QFileSystemWatcher()
        self.directory_watcher.directoryChanged.connect(
            self.add_new_files_to_list)
        self.create_timed_file_list = False

        if filename is None:
            self.complete_path = None
            self.directory = None
            self.filename = None
            self.file_list = []
            self.ordered_file_list = []
            self.filename_list = []
        else:
            self.complete_path = os.path.abspath(filename)
            self.directory, self.filename = os.path.split(self.complete_path)
            self.acceptable_file_endings.append(self.filename.split('.')[-1])
示例#3
0
    def __init__(self, parent, path):
        self.parent = parent
        self.loading_dir_file = False

        parent.path = path
        parent.path['graphics'] = parent.path['main'] / 'UI' / 'graphics'
        self.config = configparser.RawConfigParser()

        # Specify yaml files
        parent.path[
            'default_config'] = parent.path['appdata'] / 'default_config.yaml'
        parent.path[
            'Cantera_Mech'] = parent.path['appdata'] / 'generated_mech.yaml'
        for key in ['default_config', 'Cantera_Mech']:
            if parent.path[key].exists(
            ):  # Check that file is readable and writable
                if not os.access(parent.path[key], os.R_OK) or not os.access(
                        parent.path[key], os.W_OK):
                    os.chmod(parent.path[key], stat.S_IRUSR | stat.S_IWUSR
                             | stat.S_IRGRP)  # try to change if not

        # Create file watcher
        self.fs_watcher = QtCore.QFileSystemWatcher()
        self.fs_watcher.directoryChanged.connect(self.mech)