def get_customizations():
    """Obtains any customizations in the form of plugin `extensions`
    and `requires` that are imported from a `mayavi_custom_ui.py`
    provided by the user for customization.  This file must be placed
    inside the `~/.mayavi2` directory.  The variables `extensions`,
    and `requires` must be a list of extensions and strings
    respectively as expected by the `PluginDefinition` class.

    Note that `~/.mayavi2` is placed in `sys.path` so make sure that
    you choose your module names carefully (so as not to override any
    common module names).  The `mayavi_custom_ui.py` can be any legal
    Python code.

    This function returns two lists containing the `extensions` and
    `requires`.
    """
    home = get_home_directory()
    m2dir = join(home, '.mayavi2')
    if exists(m2dir):
        # Add ~/.mayavi2 to sys.path.
        sys.path.append(m2dir)
        # Now try and import the user defined plugin extension.
        try:
            from mayavi_custom_ui import extensions, requires
        except ImportError:
            pass
        else:
            return extensions, requires
    
    return [], []
Exemplo n.º 2
0
    from site_mayavi import get_plugins as _get_global_plugins
except ImportError:
    pass

    
# Now do any local user level customizations.
#
# The following code obtains any customizations and that are imported
# from a `user_mayavi.py` provided by the user in their  `~/.mayavi2`
# directory.
#
# Note that `~/.mayavi2` is placed in `sys.path` so make sure that you
# choose your module names carefully (so as not to override any common
# module names).

home = get_home_directory()
m2dir = join(home, '.mayavi2')
user_module = join(m2dir, 'user_mayavi.py')
if exists(user_module):
    # Add ~/.mayavi2 to sys.path.
    sys.path.append(m2dir)
    # Doing an import gives user information on any errors. 
    import user_mayavi
    try:
        # Now try and import the user defined plugin extension.
        from user_mayavi import get_plugins as _get_user_plugins
    except ImportError:
        # user_mayavi may not be adding any new plugins.
        pass

#  Now handle any contributions that the user has chosen via the
Exemplo n.º 3
0
        p = Plot()
        p.tools.append(PanTool(p))
        p.overlays.append(ZoomTool(p))
        return p

    view_traits = View( HSplit( VGroup( Item('open_exdesign', 
                                             style = 'simple' ),
                                        Item('exdesign', 
                                             editor = exrun_table_editor, 
                                             show_label = False, style = 'custom' )
                                        ),
                                VGroup( Item('[email protected]', 
                                             show_label = False ),
                                        Item('plot', 
                                             editor=ComponentEditor(), 
                                             show_label = False,
                                             resizable = True
                                                                                          ),
                                          ),
                                ),
                        resizable = True,
                        buttons = [ OKButton, CancelButton ],
                        height = 1.,
                        width = 1. )
    
    
path = os.path.join( get_home_directory(), 'simviz_data/rubber_pullout/rubber_pullout.eds' )
doe_reader = EXDesignReader( exdesign_spec_file = path)
#print doe_reader.response_array
doe_reader.configure_traits( view = 'view_traits' )
Exemplo n.º 4
0
        """ Factory method for the current selection of the engine. """

        from enthought.pyface.workbench.traits_ui_view import \
                TraitsUIView

        worker = window.get_service(Worker)
        tui_worker_view = TraitsUIView(obj=worker,
                                       view='view',
                                       id='user_mayavi.Worker.view',
                                       name='Custom Mayavi2 View',
                                       window=window,
                                       position='left',
                                       **traits
                                       )
        return tui_worker_view

# END OF CODE THAT SHOULD REALLY BE IN SEPARATE MODULES.
######################################################################

if __name__ == '__main__':
    import sys
    print "*"*80
    print "ERROR: This script isn't supposed to be executed."
    print __doc__
    print "*"*80

    from enthought.util.home_directory import get_home_directory
    print "Your .mayavi2 directory should be in %s"%get_home_directory()
    print "*"*80
    sys.exit(1)
Exemplo n.º 5
0
def create_email_message(fromaddr, toaddrs, ccaddrs, subject, priority,
                         include_project=False, stack_trace="", comments=""):
    # format a message suitable to be sent to the Roundup bug tracker

    from email.MIMEMultipart import MIMEMultipart
    from email.MIMEText import MIMEText
    from email.MIMEBase import MIMEBase

    message = MIMEMultipart()
    message['Subject'] = "%s [priority=%s]" % (subject, priority)
    message['To'] = ', '.join(toaddrs)
    message['Cc'] = ', '.join(ccaddrs)
    message['From'] = fromaddr
    message.preamble = 'You will not see this in a MIME-aware mail reader.\n'
    message.epilogue = ' ' # To guarantee the message ends with a newline

    # First section is simple ASCII data ...
    m = []
    m.append("Bug Report")
    m.append("==============================")
    m.append("")

    if len(comments) > 0:
        m.append("Comments:")
        m.append("========")
        m.append(comments)
        m.append("")

    if len(stack_trace) > 0:
        m.append("Stack Trace:")
        m.append("===========")
        m.append(stack_trace)
        m.append("")

    msg = MIMEText('\n'.join(m))
    message.attach(msg)

    # Include the log file ...
    if True:
        try:
            log = os.path.join(get_home_directory(), 'envisage.log')
            f = open(log, 'r')
            entries = f.readlines()
            f.close()

            ctype = 'application/octet-stream'
            maintype, subtype = ctype.split('/', 1)
            msg = MIMEBase(maintype, subtype)

            msg = MIMEText(''.join(entries))
            msg.add_header('Content-Disposition', 'attachment', filename='logfile.txt')
            message.attach(msg)
        except:
            logger.exception('Failed to include log file with message')

    # Include the environment variables ...
    if True:
        """
        Transmit the user's environment settings as well.  Main purpose is to
        work out the user name to help with following up on bug reports and
        in future we should probably send less data.
        """
        try:
            entries = []
            for key, value in os.environ.iteritems():
                entries.append('%30s : %s\n' % (key, value))

            ctype = 'application/octet-stream'
            maintype, subtype = ctype.split('/', 1)
            msg = MIMEBase(maintype, subtype)

            msg = MIMEText(''.join(entries))
            msg.add_header('Content-Disposition', 'attachment', filename='environment.txt')
            message.attach(msg)

        except:
            logger.exception('Failed to include environment variables with message')


# FIXME: no project plugins exist for Envisage 3, yet, and this isn't the right
# way to do it, either. See the docstring of attachments.py.
#    # Attach the project if requested ...
#    if include_project:
#        from attachments import Attachments
#        try:
#            attachments = Attachments(message)
#            attachments.package_any_relevant_files()
#        except:
#            logger.exception('Failed to include workspace files with message')

    return message
Exemplo n.º 6
0
 def _get_home_dir( self ):
     return get_home_directory()