Ejemplo n.º 1
0
 def start(self):
     self.__data_accessors__ = []
     count = len(self.__files_specifications__)
     progressManager = ProgressDialogManager(self.__parent__,
                                             label_text=("Preparing data"),
                                             max_value=count)
     with progressManager as progress:
         for idx in range(count):
             if (progress.wasCanceled()):
                 break
             progress.increaseCounter()
             self.__data_accessors__.append(
                 get_data_accessor_from_file_specification(
                     self.__parent__, self.__files_specifications__[idx]))
Ejemplo n.º 2
0
 def __init__(self, _parent, _files_specifications):
     self.__data_vectors_accessor_group__ = DataVectorsAccessorGroup()
     count = len(_files_specifications)
     progressManager = ProgressDialogManager(_parent,
                                             label_text=("Preparing data"),
                                             max_value=count)
     with progressManager as progress:
         for idx in range(count):
             if (progress.wasCanceled()):
                 break
             progress.increaseCounter()
             vector_accessor = get_data_accessor_from_file_specification(
                 _parent, _files_specifications[idx])
             self.__data_vectors_accessor_group__.addDataVectorAccessor(
                 vector_accessor)
Ejemplo n.º 3
0
    def reload(self):
        self.changeEnablemend(True)
        if self.rootDirLabel.text():

            self.filesTableView.clear()
            self.changeEnablemend(False)

            iteratorFlag = QDirIterator.Subdirectories \
                            if self.recursively.isChecked() \
                            else QDirIterator.NoIteratorFlags
            nameFilters = QStringList(
                    self.filesExtension.text()) \
                    if len(self.filesExtension.text()) > 0 \
                            and not self.filesExtension.text() \
                                in ("*", "*.*", "", None) \
                    else QStringList()
            self.iterator = QDirIterator(self.rootDirLabel.text(), nameFilters,
                                         QDir.Filters(QDir.Files),
                                         iteratorFlag)

            with ProgressDialogManager(self) as progress:
                while (self.iterator.next()):
                    if (progress.wasCanceled()):
                        break
                    fileInfo = self.iterator.fileInfo()
                    if fileInfo.size() == 0 or fileInfo.isFile() == False:
                        continue
                    if self.filesExtension.text() in ("*", "*.*", "", None):
                        if (sys.platform == 'win32' \
                            and fileInfo.isExecutable() == True) \
                            or is_text_file(fileInfo.filePath(),
                                    self.onlyKnownTypes.checkState()) == False:
                            continue
                    progress.increaseCounter()

                    checkable = QStandardItem("")
                    checkable.setCheckable(True)
                    filename = QStandardItem(fileInfo.fileName())
                    progress.setLabelText(fileInfo.fileName())
                    size = QStandardItem(str(fileInfo.size()))
                    path = QStandardItem(fileInfo.path())
                    self.filesTableView.addRow(
                        (checkable, filename, size, path))  # @IgnorePep8

            self.filesTableView.resizeColumnsToContents()
            self.filesExtension.setFocus()
            self.changeEnablemend(True)
    def __showTachograms__(self, files_specifications):
        progressManager = ProgressDialogManager(
            self,
            label_text="Create tachograms",
            max_value=len(files_specifications))
        firstFocus = True
        checked = self.__allowTachogramsDuplicationButton__.isChecked()
        with progressManager as progress:
            for idx in range(progress.maximum()):
                if (progress.wasCanceled()):
                    break
                progress.increaseCounter()
                tachogram_plot = self.params.add_tachogram_plot_handler(
                    files_specifications[idx], checked, firstFocus)
                if firstFocus and tachogram_plot:
                    firstFocus = False

        self.__datasourceList__.clearSelection()
Ejemplo n.º 5
0
 def __change_selection__(self, _select):
     self.changeEnablemend(False)
     count = self.filesTableView.getRowCount()
     progressManager = ProgressDialogManager(
         self,
         label_text=("Selecting..." if _select else "Unselecting..."),
         max_value=count)
     with progressManager as progress:
         for idx in range(count):
             if (progress.wasCanceled()):
                 break
             progress.increaseCounter()
             if _select:
                 self.filesTableView.setCheckedRowState(idx, Qt.Checked)
             else:
                 self.filesTableView.setCheckedRowState(idx, Qt.Unchecked)
     self.filesTableView.changeCompleteState()
     self.changeEnablemend(True)
Ejemplo n.º 6
0
 def changeCheckStatForAll(self, _check):
     """
     method changes check state (True/False) for the whole table view
     """
     if not self.is_checkable:
         return
     self.setEnabled(False)
     count = self.model().rowCount()
     progressManager = ProgressDialogManager(
         self,
         label_text=("Checking..." if _check else "Unchecking..."),
         max_value=count)
     with progressManager as progress:
         for idx in range(count):
             if (progress.wasCanceled()):
                 break
             progress.increaseCounter()
             self.model().item(idx).setCheckState(
                 Qt.Checked if _check else Qt.Unchecked)
     self.setEnabled(True)
Ejemplo n.º 7
0
    def __init__(self, filesnames, parent=None):
        super(FilesPreviewDialog, self).__init__(parent)
        self.setWindowTitle('File(s) preview')
        self.setGeometry(QRect(50, 50, 1000, 600))
        self.setLayout(QVBoxLayout())
        #a list object has attribute 'insert'
        filesnames = filesnames if hasattr(filesnames, 'insert') \
                        else [filesnames]

        filesPreviewTabWidget = TabWidgetCommon(self)
        progressManager = ProgressDialogManager(self,
                                                label_text="Opening files ...",
                                                max_value=len(filesnames))
        with progressManager as progress:
            for filename in filesnames:
                if (progress.wasCanceled()):
                    break
                progress.increaseCounter()
                tab = self.__createFilePreview__(filesPreviewTabWidget,
                                                 filename)
                filesPreviewTabWidget.addTab(tab, 'File: ' + filename)

        closeButton = PushButtonWidget(self, i18n="close", i18n_def="Close")
        self.connect(closeButton, SIGNAL("clicked()"), self, SLOT("reject()"))
    def start(self):
        """
        method initiate show up of poincare progress bar
        """
        self.__interrupted__ = False

        #parameter formatted_summary_statistics is used to store
        #calculated summary statistics
        if not self.params.formatted_summary_statistics == None:
            self.params.formatted_summary_statistics[:] = []

        outcomes_exist_info = []
        progressManager = ProgressDialogManager(self.parent,
                                count=len(self.__data_vector_accessor_list__))
        for data_vector_accessor in self.__data_vector_accessor_list__:
            parameters = \
                data_vector_accessor.parameters_container.parameters.get(PoincarePlotParameters.NAME) #  alias @IgnorePep8
            parameters.prepareParameters()
            pp_generator = PoincarePlotGenerator(
                        output_file_listener=self.params.output_file_listener,
                        parameters=parameters)
            if self.params.save_csv == True:
                (ok, _) = pp_generator.precheck(
                                        data_vector_accessor.source_name)
                if ok == False:
                    if pp_generator.outcome_exists:
                        outcomes_exist_info.append(
                                        data_vector_accessor.source_name)
                    continue

            message = parameters.validateParameters(self.params.check_level)
            if message:
                ErrorWindow(message=message)
                return
            count = pp_generator.segment_count(data_vector_accessor.data_vector) # @IgnorePep8

            #add artificially 1% of the count to avoid the second show
            #of progress bar when in fact total number of segment count
            #is greater then total count calculated by segment_count method
            count = count + int(count * (1 / 100))

            #extends label text with source name (if not None)
            label_text = "{0} [{1}]".format(self.label_text,
                                    nvl(data_vector_accessor.source_name, ""))
            with progressManager.initialize(label_text=label_text,
                                            max_value=count) as progress:
                start_progress = self.__StartProgress__()
                if not self.params.progress_handler == None:
                    #give ability to pass custom progress handler
                    progress_handler = self.params.progress_handler
                elif self.params.save_csv == True:
                    progress_handler = self.__CSVProgressHandler__()
                else:
                    progress_handler = self.__ProgressHandler__()
                progress_handler.progress = progress
                if self.params.save_csv == True:
                    pp_generator.generate_CSV(data_vector_accessor.data_vector,
                                            data_vector_accessor.source_name,
                                            start_progress=start_progress,
                                            progress_handler=progress_handler)
                else:
                    pp_generator.generate(data_vector_accessor.data_vector,
                                          start_progress=start_progress,
                                          progress_handler=progress_handler)
                #store information about interrupt signal if it has happened
                self.__interrupted__ = progress_handler.interrupted

                if self.__interrupted__ == False and \
                    not self.params.formatted_summary_statistics == None:
                    self.params.formatted_summary_statistics.append(
                                  pp_generator.formatted_summary_statistics)

                #if interrupted break the whole loop
                if self.__interrupted__:
                    return
        if len(outcomes_exist_info) > 0:
            message = "For the following files, outcomes already exist:"
            for outcome in outcomes_exist_info:
                message += ("\n" + outcome)
            InformationWindow(message=message)
Ejemplo n.º 9
0
    def start(self):
        """
        method initiate show up of poincare progress bar
        """
        self.__interrupted__ = False

        #parameter formatted_summary_statistics is used to store
        #calculated summary statistics
        if not self.params.formatted_summary_statistics == None:
            self.params.formatted_summary_statistics[:] = []

        outcomes_exist_info = []
        progressManager = ProgressDialogManager(
            self.parent, count=len(self.__data_vector_accessor_list__))
        for data_vector_accessor in self.__data_vector_accessor_list__:
            parameters = \
                data_vector_accessor.parameters_container.parameters.get(PoincarePlotParameters.NAME) #  alias @IgnorePep8
            parameters.prepareParameters()
            pp_generator = PoincarePlotGenerator(
                output_file_listener=self.params.output_file_listener,
                parameters=parameters)
            if self.params.save_csv == True:
                (ok,
                 _) = pp_generator.precheck(data_vector_accessor.source_name)
                if ok == False:
                    if pp_generator.outcome_exists:
                        outcomes_exist_info.append(
                            data_vector_accessor.source_name)
                    continue

            message = parameters.validateParameters(self.params.check_level)
            if message:
                ErrorWindow(message=message)
                return
            count = pp_generator.segment_count(
                data_vector_accessor.data_vector)  # @IgnorePep8

            #add artificially 1% of the count to avoid the second show
            #of progress bar when in fact total number of segment count
            #is greater then total count calculated by segment_count method
            count = count + int(count * (1 / 100))

            #extends label text with source name (if not None)
            label_text = "{0} [{1}]".format(
                self.label_text, nvl(data_vector_accessor.source_name, ""))
            with progressManager.initialize(label_text=label_text,
                                            max_value=count) as progress:
                start_progress = self.__StartProgress__()
                if not self.params.progress_handler == None:
                    #give ability to pass custom progress handler
                    progress_handler = self.params.progress_handler
                elif self.params.save_csv == True:
                    progress_handler = self.__CSVProgressHandler__()
                else:
                    progress_handler = self.__ProgressHandler__()
                progress_handler.progress = progress
                if self.params.save_csv == True:
                    pp_generator.generate_CSV(
                        data_vector_accessor.data_vector,
                        data_vector_accessor.source_name,
                        start_progress=start_progress,
                        progress_handler=progress_handler)
                else:
                    pp_generator.generate(data_vector_accessor.data_vector,
                                          start_progress=start_progress,
                                          progress_handler=progress_handler)
                #store information about interrupt signal if it has happened
                self.__interrupted__ = progress_handler.interrupted

                if self.__interrupted__ == False and \
                    not self.params.formatted_summary_statistics == None:
                    self.params.formatted_summary_statistics.append(
                        pp_generator.formatted_summary_statistics)

                #if interrupted break the whole loop
                if self.__interrupted__:
                    return
        if len(outcomes_exist_info) > 0:
            message = "For the following files, outcomes already exist:"
            for outcome in outcomes_exist_info:
                message += ("\n" + outcome)
            InformationWindow(message=message)