• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python api.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyface.api.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_prepare_bem_model_job

    def get_prepare_bem_model_job(self, subject_to):
        subjects_dir = self.mri.subjects_dir
        subject_from = self.mri.subject

        bem_name = "inner_skull-bem"
        bem_file = bem_fname.format(subjects_dir=subjects_dir, subject=subject_from, name=bem_name)
        if not os.path.exists(bem_file):
            pattern = bem_fname.format(subjects_dir=subjects_dir, subject=subject_to, name="(.+-bem)")
            bem_dir, bem_file = os.path.split(pattern)
            m = None
            bem_file_pattern = re.compile(bem_file)
            for name in os.listdir(bem_dir):
                m = bem_file_pattern.match(name)
                if m is not None:
                    break

            if m is None:
                pattern = bem_fname.format(subjects_dir=subjects_dir, subject=subject_to, name="*-bem")
                err = "No bem file found; looking for files matching " "%s" % pattern
                error(err)

            bem_name = m.group(1)

        bem_file = bem_fname.format(subjects_dir=subjects_dir, subject=subject_to, name=bem_name)

        # job
        desc = "mne_prepare_bem_model for %s" % subject_to
        func = prepare_bem_model
        args = (bem_file,)
        kwargs = {}
        return (desc, func, args, kwargs)
开发者ID:NeedlessToSay,项目名称:mne-python,代码行数:31,代码来源:_coreg_gui.py


示例2: delete

    def delete ( self, path = None ):
        """ Deletes the associated directory from the file system.
        """
        if path is None:
            path = self.path

        not_deleted = 0
        try:
            for name in listdir( path ):
                fn = join( path, name )
                if isfile( fn ):
                    if self.include_file( fn ):
                        remove( fn )
                    else:
                        not_deleted += 1
                elif isdir( fn ) and (not self.delete( fn )):
                    not_deleted += 1
            if not_deleted == 0:
                rmdir( path )
                return True
        except:
            error( self.handler.parent, "Could not delete '%s'" % fn )

        # Indicate that the directory was not deleted:
        return False
开发者ID:enthought,项目名称:etsdevtools,代码行数:25,代码来源:file_space.py


示例3: perform

    def perform(self, event):

        plot_component = self.container.component

        filter = 'PNG file (*.png)|*.png|\nTIFF file (*.tiff)|*.tiff|'
        dialog = FileDialog(action='save as', wildcard=filter)

        if dialog.open() != OK:
            return

        # Remove the toolbar before saving the plot, so the output doesn't
        # include the toolbar.
        plot_component.remove_toolbar()

        filename = dialog.path

        width, height = plot_component.outer_bounds

        gc = PlotGraphicsContext((width, height), dpi=72)
        gc.render_component(plot_component)
        try:
            gc.save(filename)
        except KeyError as e:
            errmsg = ("The filename must have an extension that matches "
                      "a graphics format, such as '.png' or '.tiff'.")
            if str(e.message) != '':
                errmsg = ("Unknown filename extension: '%s'\n" %
                          str(e.message)) + errmsg

            error(None, errmsg, title="Invalid Filename Extension")

        # Restore the toolbar.
        plot_component.add_toolbar()
开发者ID:enthought,项目名称:chaco,代码行数:33,代码来源:toolbar_buttons.py


示例4: _subject_changed

    def _subject_changed(self):
        subject = self.subject
        subjects_dir = self.subjects_dir
        if not subjects_dir or not subject:
            return

        path = None
        if self.use_high_res_head:
            path = _find_high_res_head(subjects_dir=subjects_dir,
                                       subject=subject)
            if not path:
                error(None, "No high resolution head model was found for "
                      "subject {0}, using standard head instead. In order to "
                      "generate a high resolution head model, run:\n\n"
                      "    $ mne make_scalp_surfaces -s {0}"
                      "\n\n".format(subject), "No High Resolution Head")

        if not path:
            path = head_bem_fname.format(subjects_dir=subjects_dir,
                                         subject=subject)
        self.bem.file = path

        # find fiducials file
        fid_files = _find_fiducials_files(subject, subjects_dir)
        if len(fid_files) == 0:
            self.fid.reset_traits(['file'])
            self.lock_fiducials = False
        else:
            self.fid_file = fid_files[0].format(subjects_dir=subjects_dir,
                                                subject=subject)
            self.lock_fiducials = True

        # does not seem to happen by itself ... so hard code it:
        self.reset_fiducials()
开发者ID:JuliaSprenger,项目名称:mne-python,代码行数:34,代码来源:_fiducials_gui.py


示例5: _get_misc_data

    def _get_misc_data(self):
        if not self.raw:
            return
        if self.show_gui:
            # progress dialog with indefinite progress bar
            prog = ProgressDialog(title="Loading SQD data...",
                                  message="Loading stim channel data from SQD "
                                  "file ...")
            prog.open()
            prog.update(0)
        else:
            prog = None

        try:
            data, times = self.raw[self.misc_chs]
        except Exception as err:
            if self.show_gui:
                error(None, "Error reading SQD data file: %s (Check the "
                      "terminal output for details)" % str(err),
                      "Error Reading SQD File")
            raise
        finally:
            if self.show_gui:
                prog.close()
        return data
开发者ID:jhouck,项目名称:mne-python,代码行数:25,代码来源:_kit2fiff_gui.py


示例6: read_file

 def read_file(self):
     """Read the file."""
     if op.exists(self.file):
         if self.file.endswith('.fif'):
             bem = read_bem_surfaces(self.file, verbose=False)[0]
             self.points = bem['rr']
             self.norms = bem['nn']
             self.tris = bem['tris']
         else:
             try:
                 points, tris = read_surface(self.file)
                 points /= 1e3
                 self.points = points
                 self.norms = []
                 self.tris = tris
             except Exception:
                 error(message="Error loading surface from %s (see "
                               "Terminal for details).",
                       title="Error Loading Surface")
                 self.reset_traits(['file'])
                 raise
     else:
         self.points = np.empty((0, 3))
         self.norms = np.empty((0, 3))
         self.tris = np.empty((0, 3))
开发者ID:nfoti,项目名称:mne-python,代码行数:25,代码来源:_file_traits.py


示例7: _get_hsp_raw

    def _get_hsp_raw(self):
        fname = self.hsp_file
        if not fname:
            return

        try:
            pts = read_hsp(fname)

            n_pts = len(pts)
            if n_pts > KIT.DIG_POINTS:
                msg = ("The selected head shape contains {n_in} points, "
                       "which is more than the recommended maximum ({n_rec}). "
                       "The file will be automatically downsampled, which "
                       "might take a while. A better way to downsample is "
                       "using FastScan.")
                msg = msg.format(n_in=n_pts, n_rec=KIT.DIG_POINTS)
                information(None, msg, "Too Many Head Shape Points")
                pts = _decimate_points(pts, 5)

        except Exception as err:
            error(None, str(err), "Error Reading Head Shape")
            self.reset_traits(['hsp_file'])
            raise
        else:
            return pts
开发者ID:Anevar,项目名称:mne-python,代码行数:25,代码来源:_kit2fiff_gui.py


示例8: _show_open_dialog

    def _show_open_dialog(self, parent):
        """
        Show the dialog to open a project.

        """

        # Determine the starting point for browsing.  It is likely most
        # projects will be stored in the default path used when creating new
        # projects.
        default_path = self.model_service.get_default_path()
        project_class = self.model_service.factory.PROJECT_CLASS

        if self.model_service.are_projects_files():
            dialog = FileDialog(parent=parent, default_directory=default_path,
                title='Open Project')
            if dialog.open() == OK:
                path = dialog.path
            else:
                path = None
        else:
            dialog = DirectoryDialog(parent=parent, default_path=default_path,
                message='Open Project')
            if dialog.open() == OK:
                path = project_class.get_pickle_filename(dialog.path)
                if File(path).exists:
                    path = dialog.path
                else:
                    error(parent, 'Directory does not contain a recognized '
                        'project')
                    path = None
            else:
                path = None

        return path
开发者ID:enthought,项目名称:envisage,代码行数:34,代码来源:ui_service.py


示例9: convert_output

 def convert_output(self,tmp):
     a=tmp.split(" ")
     if len(a)<3:
         error(parent=None, title="error", message= "fehler: falscher string sollte Konvertiert werden: "+ str(a))
         return(tmp)
     print "Konvertiere:", a
     return(float(a[2]))
开发者ID:ottodietz,项目名称:qdsearch,代码行数:7,代码来源:spectrometer.py


示例10: _children_items_changed

    def _children_items_changed ( self, event ):
        """ Handles changes to the 'children' trait.
        """
        for child in event.added:
            if not isinstance( child, DirectoryNode ):
                continue

            new_path = join( self.path, child.dir_name )
            if isfile( new_path ):
                error( self.handler.parent,
                       ("Cannot create the directory '%s'.\nThere is already a "
                        "file with that name.") % child.dir_name )
                return

            if not isdir( new_path ):
                try:
                    mkdir( new_path )
                except:
                    error( self.handler.parent, ("An error occurred creating "
                           "the directory '%s'") % child.dir_name )
                    return

            child.set( path = new_path, file_space = self.file_space )

            self.initialized = False
开发者ID:enthought,项目名称:etsdevtools,代码行数:25,代码来源:file_space.py


示例11: _save_as_fired

    def _save_as_fired(self):
        # create raw
        try:
            raw = self.model.get_raw()
        except Exception as err:
            error(None, str(err), "Error Creating KIT Raw")
            raise

        # find default path
        stem, _ = os.path.splitext(self.sqd_file)
        if not stem.endswith('raw'):
            stem += '-raw'
        default_path = stem + '.fif'

        # save as dialog
        dlg = FileDialog(action="save as",
                         wildcard="fiff raw file (*.fif)|*.fif",
                         default_path=default_path)
        dlg.open()
        if dlg.return_code != OK:
            return

        fname = dlg.path
        if not fname.endswith('.fif'):
            fname += '.fif'
            if os.path.exists(fname):
                answer = confirm(None, "The file %r already exists. Should it "
                                 "be replaced?", "Overwrite File?")
                if answer != YES:
                    return

        self.queue.put((raw, fname))
        self.queue_len += 1
开发者ID:Anevar,项目名称:mne-python,代码行数:33,代码来源:_kit2fiff_gui.py


示例12: display_message

    def display_message(self, msg, title=None, is_error=False):
        """
        Display the specified message to the user.

        """

        # Ensure we record any reasons this method doesn't work.  Especially
        # since it's critical in displaying errors to users!
        try:

            # Attempt to identify the current application window.
            parent_window = None
            workbench = self.application.get_service('envisage.'
                'workbench.IWorkbench')
            if workbench is not None:
                parent_window = workbench.active_window.control

            # Display the requested message
            if is_error:
                error(parent_window, msg, title=title)
            else:
                information(parent_window, msg, title=title)

        except:
            logger.exception('Unable to display pop-up message')

        return
开发者ID:LRFrank,项目名称:envisage,代码行数:27,代码来源:ui_service.py


示例13: _update_points

    def _update_points(self):
        """Update the location of the plotted points"""
        if not hasattr(self.src, "data"):
            return

        trans = self.trans
        if np.any(trans):
            if trans.ndim == 0 or trans.shape == (3,) or trans.shape == (1, 3):
                pts = self.points * trans
            elif trans.shape == (3, 3):
                pts = np.dot(self.points, trans.T)
            elif trans.shape == (4, 4):
                pts = apply_trans(trans, self.points)
            else:
                err = (
                    "trans must be a scalar, a length 3 sequence, or an "
                    "array of shape (1,3), (3, 3) or (4, 4). "
                    "Got %s" % str(trans)
                )
                error(None, err, "Display Error")
                raise ValueError(err)
        else:
            pts = self.points

        self.src.data.points = pts
开发者ID:jasmainak,项目名称:mne-python,代码行数:25,代码来源:_viewer.py


示例14: _inner

 def _inner(self, info, *args, **kw):
     if not self.object_valid(info):
         mesg = 'Unable to save the data due to the following problem(s)\n'
         mesg += self.object_messages(info)
         error(info.ui.control, mesg)
         return False
     return func(self, info, *args, **kw)
开发者ID:bburan,项目名称:NeuroBehavior,代码行数:7,代码来源:file_handler.py


示例15: edit_function_call

def edit_function_call(func_def):

    if func_def.code is None:
        msg = "Perhaps your python path is not set correctly or\n" \
              "there is an error in the file (or one it imports).\n"
        error(None, msg, "Error loading function")

        return None

    # If it is a user-defined function, one would want to edit it
    # else it can remain un-editable.
    path_dir = os.path.dirname(func_def.filename)
    usr_path = os.path.join(ETSConfig.user_data, USER_MODULE_NAME)

    if path_dir == usr_path:
        # This is a user function

        is_ok = edit_user_function(func_def)

        if is_ok:
            if func_def.dirty:
                func_def.write(overwrite = True)

            return func_def
    else:
        is_ok = edit_sys_function(func_def)

        if is_ok:
            if func_def.dirty:
                func_def.write(overwrite = False)
            return func_def
开发者ID:BabeNovelty,项目名称:blockcanvas,代码行数:31,代码来源:function_call_tools.py


示例16: select_plugin

 def select_plugin(self, plugin_obj):
     # Set up image capturing
     self.camera = plugin_obj()
     try:
         self.camera.open()
     except CameraError:
         error(None, 'No camera was detected. Did you forget to plug it in?')
         sys.exit()
开发者ID:UltracoldAtomsLab,项目名称:Beams,代码行数:8,代码来源:MainWindow.py


示例17: _us_error

    def _us_error(e):
        """Display a message to the user after a UserStorageError exception has
        been raised.  If the message is empty then we assume the user has
        already been informed."""

        msg = str(e)
        if msg:
            error(None, msg)
开发者ID:enthought,项目名称:apptools,代码行数:8,代码来源:user_database.py


示例18: init_model

    def init_model(self, op):
        
        dtype_to_trait = {"category" : Str,
                          "float" : Float,
                          "bool" : Bool,
                          "int" : Int}
        
        for op_tube in op.tubes:
            tube = Tube(file = op_tube.file,
                        parent = self)
            
            # first load the tube's metadata and set special columns
            try:
                tube_meta = fcsparser.parse(op_tube.file, 
                                            meta_data_only = True, 
                                            reformat_meta = True)
                #tube_channels = tube_meta["_channels_"].set_index("$PnN")
            except Exception as e:
                error(None, "FCS reader threw an error on tube {0}: {1}"\
                            .format(op_tube.file, e.value),
                      "Error reading FCS file")
                return
            
            # if we're the first tube loaded, create a dummy experiment
            if not self.dummy_experiment:
                self.dummy_experiment = ImportOp(tubes = [op_tube],
                                                 conditions = op.conditions,
                                                 coarse_events = 1).apply()
                
            if '$SRC' in tube_meta:    
                self.tube_traits["$SRC"] = Str(condition = False)
                tube.add_trait("$SRC", Str(condition = False))
                tube.trait_set(**{"$SRC" : tube_meta['$SRC']})
                
            if 'TUBE NAME' in tube_meta:
                #self._add_metadata("TUBE NAME", "TUBE NAME", Str(condition = False))
                self.tube_traits["TUBE NAME"] = Str(condition = False)
                tube.add_trait("TUBE NAME", Str(condition = False))
                tube.trait_set(**{"TUBE NAME" : tube_meta['TUBE NAME']})
                
            if '$SMNO' in tube_meta:
                #self._add_metadata("$SMNO", "$SMNO", Str(condition = False))
                self.tube_traits["$SMNO"] = Str(condition = False)
                tube.add_trait("$SMNO", Str(condition = False))
                tube.trait_set(**{"$SMNO" : tube_meta['SMNO']})

            # next set conditions
            for condition in op_tube.conditions:
                condition_dtype = op.conditions[condition]
                condition_trait = \
                    dtype_to_trait[condition_dtype](condition = True)
                tube.add_trait(condition, condition_trait)
                if not condition in self.tube_traits:
                    self.tube_traits[condition] = condition_trait
            tube.trait_set(**op_tube.conditions)
            
            self.tubes.append(tube)
开发者ID:adam-urbanczyk,项目名称:cytoflow,代码行数:57,代码来源:import_dialog.py


示例19: _get__info

    def _get__info(self):
        if self.file:
            info = None
            fid, tree, _ = fiff_open(self.file)
            fid.close()
            if len(dir_tree_find(tree, FIFF.FIFFB_MEAS_INFO)) > 0:
                info = read_info(self.file, verbose=False)
            elif len(dir_tree_find(tree, FIFF.FIFFB_ISOTRAK)) > 0:
                info = read_dig_montage(fif=self.file)

            if isinstance(info, DigMontage):
                info.transform_to_head()
                digs = list()
                _append_fiducials(digs, info.lpa, info.nasion, info.rpa)
                for idx, pos in enumerate(info.hsp):
                    dig = {'coord_frame': FIFF.FIFFV_COORD_HEAD,
                           'ident': idx,
                           'kind': FIFF.FIFFV_POINT_EXTRA,
                           'r': pos}
                    digs.append(dig)
                info = _empty_info(1)
                info['dig'] = digs
            elif info is None or info['dig'] is None:
                error(None, "The selected FIFF file does not contain "
                      "digitizer information. Please select a different "
                      "file.", "Error Reading FIFF File")
                self.reset_traits(['file'])
                return
            else:
                # check that all fiducial points are present
                has_point = {FIFF.FIFFV_POINT_LPA: False,
                             FIFF.FIFFV_POINT_NASION: False,
                             FIFF.FIFFV_POINT_RPA: False}
                for d in info['dig']:
                    if d['kind'] == FIFF.FIFFV_POINT_CARDINAL:
                        has_point[d['ident']] = True
                if not all(has_point.values()):
                    points = _fiducial_coords(info['dig'])
                    if len(points) == 3:
                        _append_fiducials(info['dig'], *points.T)
                    else:
                        missing = []
                        if not has_point[FIFF.FIFFV_POINT_LPA]:
                            missing.append('LPA')
                        if not has_point[FIFF.FIFFV_POINT_NASION]:
                            missing.append('Nasion')
                        if not has_point[FIFF.FIFFV_POINT_RPA]:
                            missing.append('RPA')
                        error(None, "The selected FIFF file does not contain "
                              "all cardinal points (missing: %s). Please "
                              "select a different file." % ', '.join(missing),
                              "Error Reading FIFF File")
                        self.reset_traits(['file'])
                        return

            return info
开发者ID:Eric89GXL,项目名称:mne-python,代码行数:56,代码来源:_file_traits.py


示例20: _on_add_condition

    def _on_add_condition(self):
        """
        Add a new condition.  Use TraitsUI to make a simple dialog box.
        """
        
        class ValidPythonIdentifier(BaseCStr):
    
            info_text = 'a valid python identifier'
    
            def validate(self, obj, name, value):
                value = super(ValidPythonIdentifier, self).validate(obj, name, value)
                if util.sanitize_identifier(value) == value:
                    return value 
                
                self.error(obj, name, value)
        
        class NewTrait(HasTraits):    
            condition_name = ValidPythonIdentifier()
            condition_type = Enum(["Category", "Number", "True/False"])
    
            view = View(Item(name = 'condition_name'),
                        Item(name = 'condition_type'),
                        buttons = OKCancelButtons,
                        title = "Add a condition",
                        close_result = False)
            
            def _validate_condition_name(self, x):
                return util.sanitize_identifier(x)
            
        
        new_trait = NewTrait()
        new_trait.edit_traits(kind = 'modal')
        
        if not new_trait.condition_name: 
            return

        name = new_trait.condition_name
        
        if name in self.model.dummy_experiment.channels:
            error(None, 
                  "Condition \"{0}\" conflicts with a channel name.".format(name),
                  "Error adding condition")
            return
        
        if name in self.model.tube_traits:
            error(None,
                  "The experiment already has a condition named \"{0}\".".format(name),
                  "Error adding condition")
            return
        
        if new_trait.condition_type == "Category":
            self._add_metadata(name, name + " (Category)", Str(condition = True))
        elif new_trait.condition_type == "Number":
            self._add_metadata(name, name + " (Number)", Float(condition = True))
        else:
            self._add_metadata(name, name + " (T/F)", Bool(condition = True))       
开发者ID:adam-urbanczyk,项目名称:cytoflow,代码行数:56,代码来源:import_dialog.py



注:本文中的pyface.api.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python api.information函数代码示例发布时间:2022-05-25
下一篇:
Python api.confirm函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap