Ejemplo n.º 1
0
    def _get_default_dir(self):
        # directory management
        home_dir = get_home_directory()
        mod_base_name = self.__class__.__name__

        sim_data_dir = os.path.join(home_dir, 'simdb', 'simdata')
        if not os.path.exists(sim_data_dir):
            os.mkdir(sim_data_dir)
            print "simdata directory created"

        mod_path = os.path.join(sim_data_dir, mod_base_name)

        if not os.path.exists(mod_path):
            os.mkdir(mod_path)
            print mod_base_name, " directory created"

        return mod_path
Ejemplo n.º 2
0
 def _get_home_dir(self):
     return get_home_directory()
Ejemplo n.º 3
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
Ejemplo n.º 4
0
        """ Factory method for the current selection of the engine. """

        from 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 traits.util.home_directory import get_home_directory
    print("Your .mayavi2 directory should be in %s"%get_home_directory())
    print("*"*80)
    sys.exit(1)
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
Ejemplo n.º 6
0
 def _directory_default(self):
     home = get_home_directory()
     return os.path.join(home, "Documents", "mayavi_movies")