当前位置: 首页>>代码示例>>Python>>正文


Python api.error函数代码示例

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


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


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