コード例 #1
0
 def _iterate_until_blocking(self, generator_method, *args):
     """Helper calling for generator methods.  The decorated method iterates
     the generator until the generator yields an :class:`ActionStep` object that
     is blocking.  If a non blocking :class:`ActionStep` object is yielded, then
     send it to the GUI thread for execution through the signal slot mechanism.
     
     :param generator_method: the method of the generator to be called
     :param *args: the arguments to use when calling the generator method.
     """
     try:
         result = generator_method(*args)
         while True:
             if isinstance(result, (ActionStep, )):
                 if result.blocking:
                     LOGGER.debug('blocking step, yield it')
                     return result
                 else:
                     LOGGER.debug('non blocking step, use signal slot')
                     self.non_blocking_action_step_signal.emit(result)
             #
             # Cancel requests can arrive asynchronously through non
             # blocking ActionSteps such as UpdateProgress
             #
             if self._non_blocking_cancel_request == True:
                 LOGGER.debug('asynchronous cancel, raise request')
                 result = self._generator.throw(CancelRequest())
             else:
                 LOGGER.debug('move iterator forward')
                 result = self._generator.next()
     except CancelRequest, e:
         LOGGER.debug('iterator raised cancel request, pass it')
         return e
コード例 #2
0
ファイル: backup.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     dialog = self.render()
     with hide_progress_dialog(gui_context):
         result = dialog.exec_()
         if result == QtWidgets.QDialog.Rejected:
             raise CancelRequest()
         return (dialog.label, dialog.storage)
コード例 #3
0
ファイル: update_progress.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     """This method will update the progress dialog, if such dialog exists
     within the GuiContext
     
     :param gui_context: a :class:`camelot.admin.action.GuiContext` instance
     """
     progress_dialog = gui_context.progress_dialog
     if progress_dialog:
         if self._maximum is not None:
             progress_dialog.setMaximum(self._maximum)
         if self._value is not None:
             progress_dialog.setValue(self._value)
         progress_dialog.set_cancel_hidden(not self.cancelable)
         if self._text is not None:
             progress_dialog.setLabelText(six.text_type(self._text))
         if self._clear_details is True:
             progress_dialog.clear_details()
         if self._detail is not None:
             progress_dialog.add_detail(self._detail)
         if self._title is not None:
             progress_dialog.title = self._title
         if self.enlarge:
             progress_dialog.enlarge()
         if self.blocking:
             progress_dialog.set_ok_hidden(False)
             progress_dialog.exec_()
             progress_dialog.set_ok_hidden(True)
         if progress_dialog.wasCanceled():
             progress_dialog.reset()
             raise CancelRequest()
コード例 #4
0
ファイル: gui.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     if not len(self.subclass_tree):
         return self.admin
     dialog = self.render()
     result = dialog.exec_()
     if result == QtWidgets.QDialog.Rejected:
         raise CancelRequest()
     return dialog.selected_subclass
コード例 #5
0
 def _was_canceled(self, gui_context):
     """raise a :class:`camelot.core.exception.CancelRequest` if the
     user pressed the cancel button of the progress dialog in the
     gui_context.
     """
     if gui_context.progress_dialog:
         if gui_context.progress_dialog.wasCanceled():
             LOGGER.debug('progress dialog was canceled, raise request')
             raise CancelRequest()
コード例 #6
0
 def gui_run(self, gui_context):
     settings = QtCore.QSettings()
     directory = settings.value('datasource').toString()
     dialog = self.render(directory)
     if dialog.exec_() == QtGui.QDialog.Rejected:
         raise CancelRequest()
     file_names = [unicode(fn) for fn in dialog.selectedFiles()]
     if file_names:
         settings.setValue('datasource', QtCore.QVariant(file_names[0]))
     return file_names
コード例 #7
0
 def gui_run(self, gui_context):
     """This method will update the progress dialog, if such dialog exists
     within the GuiContext
     
     :param gui_context: a :class:`camelot.admin.action.GuiContext` instance
     """
     progress_dialog = gui_context.progress_dialog
     if progress_dialog:
         if progress_dialog.wasCanceled():
             progress_dialog.reset()
             raise CancelRequest()
         progress_dialog.setMaximum(self._maximum)
         progress_dialog.setValue(self._value)
         if self._text != None:
             progress_dialog.setLabelText(unicode(self._text))
コード例 #8
0
ファイル: select_file.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     settings = QtCore.QSettings()
     directory = six.text_type(variant_to_py(settings.value('datasource')))
     directory = os.path.dirname(directory)
     if self.file_name is not None:
         directory = os.path.join(directory, self.file_name)
     get_filename = QtGui.QFileDialog.getSaveFileName
     with hide_progress_dialog( gui_context ):
         selected = get_filename(parent=gui_context.workspace,
                                 caption=six.text_type(self.caption),
                                 directory=directory,
                                 filter=self.file_name_filter)
         if selected:
             settings.setValue('datasource', py_to_variant(selected))
             return six.text_type(selected)
         else:
             raise CancelRequest()
コード例 #9
0
ファイル: select_file.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     settings = QtCore.QSettings()
     directory = six.text_type(variant_to_py(settings.value('datasource')))
     directory = os.path.dirname(directory)
     if self.single:
         get_filename = QtGui.QFileDialog.getOpenFileName
     else:
         get_filename = QtGui.QFileDialog.getOpenFileNames
     with hide_progress_dialog( gui_context ):
         selected = get_filename(parent=gui_context.workspace,
                                 caption=six.text_type(self.caption),
                                 directory=directory,
                                 filter=self.file_name_filter)
         if selected:
             if self.single:
                 settings.setValue( 'datasource', py_to_variant(selected))
                 return [six.text_type(selected)]
             else:
                 settings.setValue( 'datasource', py_to_variant(selected[0]))
                 return [six.text_type(fn) for fn in selected]
         else:
             raise CancelRequest()
コード例 #10
0
ファイル: gui.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     message_box = self.render()
     result = message_box.exec_()
     if result == QtWidgets.QMessageBox.Cancel:
         raise CancelRequest()
     return result
コード例 #11
0
ファイル: gui.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     dialog = self.render()
     result = dialog.exec_()
     if result == QtWidgets.QDialog.Rejected:
         raise CancelRequest()
     return dialog.get_value()
コード例 #12
0
ファイル: select_object.py プロジェクト: vortexR2/camelot
 def gui_run(self, gui_context):
     dialog = self.render(gui_context)
     with hide_progress_dialog(gui_context):
         if dialog.exec_() == QtWidgets.QDialog.Rejected:
             raise CancelRequest()
         return dialog.objects
コード例 #13
0
 def gui_run( self, gui_context ):
     dialog = self.render()
     result = dialog.exec_()
     if result == QtGui.QDialog.Rejected:
         raise CancelRequest()
     return ( dialog.label, dialog.storage )
コード例 #14
0
 def gui_run( self, gui_context ):
     dialog = self.render( gui_context )
     result = dialog.exec_()
     if result == QtGui.QDialog.Rejected:
         raise CancelRequest()
     return self._obj
コード例 #15
0
 def gui_run(self, gui_context):
     select_dialog = SelectDialog(self.admin, self.query)
     select_dialog.exec_()
     if select_dialog.object_getter:
         return select_dialog.object_getter
     raise CancelRequest()