Exemple #1
0
def launch_application(parsed_options, args):
    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from glob import glob
    theme = None
    bundle = Foundation.NSBundle.mainBundle()
    bundle_path = bundle.bundlePath()
    bundle_theme_dir_path = os.path.join(bundle_path, "Contents", "Theme")
    if os.path.exists(bundle_theme_dir_path):
        theme_dirs = glob(os.path.join(bundle_theme_dir_path, "*"))
        theme_dir = theme_dirs[0]
        if os.path.isdir(theme_dir):
            theme = os.path.basename(themeDir)

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro import app
    from miro import prefs

    # Tee output off to a log file
    class AutoflushingTeeStream:
        def __init__(self, streams):
            self.streams = streams
        def write(self, *args):
            for s in self.streams:
                try:
                    s.write(*args)
                except IOError:
                    pass
            self.flush()
        def flush(self):
            for s in self.streams:
                try:
                    s.flush()
                except IOError:
                    pass

    log_file = app.config.get(prefs.LOG_PATHNAME)
    if log_file:
        h = open(log_file, "wt")
        sys.stdout = AutoflushingTeeStream([h, sys.stdout])
        sys.stderr = AutoflushingTeeStream([h, sys.stderr])

    # handle command line args
    if parsed_options.debugmode:
        if parsed_options.debugmode.lower() in ("y", "yes"):
            app.debugmode = True
        else:
            app.debugmode = False
    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro import startfrontend
    startfrontend.run_application(parsed_options.frontend, {}, theme)

    # This code is useless, but it tells py2app that we need to import these
    # modules
    import miro.plat.frontends.widgets.application
    import miro.frontends.cli.application
    import miro.frontends.profilewidgets.application
    import miro.frontends.shell.application
Exemple #2
0
def startup(argv):
    # Rewrite the stdout and stderr to catch cases debug being printed via
    # a print or via a write to stderr.  Normally we would use shortAppName
    # but at this point nothing has been bootstrapped yet.  We only want to
    # catch it though if py2exe has fiddled with our file descriptors.
    #
    # The stdout/stderr are redirected again in the Windows-specific
    # setup_logging().
    #
    # See bz17793
    redirected = sys.stdout != sys.__stdout__
    if redirected:
        try:
            logfile = os.path.join(tempfile.gettempdir(), 'Miro_console.log')
            sys.stderr = sys.stdout = open(logfile, 'w')
        except EnvironmentError:
            # too bad ... let's silence rather than spew stuff to stop it
            # writing to a file that it might not have permissions to.
            # Hopefully, this does not happen often.
            sys.stderr = sys.stdout = open(os.devnull, 'w')

    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    from miro.plat import config
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH
    # normally we'd use app.config to get this, but we're starting up
    os.environ["GST_REGISTRY"] = os.path.join(config._get_support_directory(),
                                              'gst_registry.bin')

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index + 1]
        del args[index:index + 1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro import startfrontend
    startfrontend.run_application('widgets', {}, None)
    pipe_server.quit()
Exemple #3
0
def launch_application(parsed_options, args):
    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from glob import glob
    theme = None
    bundle = NSBundle.mainBundle()
    bundle_path = bundle.bundlePath()
    bundle_theme_dir_path = os.path.join(bundle_path, "Contents", "Theme")
    if os.path.exists(bundle_theme_dir_path):
        theme_dirs = glob(os.path.join(bundle_theme_dir_path, "*"))
        theme_dir = theme_dirs[0]
        if os.path.isdir(theme_dir):
            theme = os.path.basename(theme_dir)

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro import app
    from miro import prefs

    # Tee output off to a log file
    class AutoflushingTeeStream:
        def __init__(self, streams):
            self.streams = streams
        def write(self, *args):
            for s in self.streams:
                try:
                    s.write(*args)
                except IOError:
                    pass
            self.flush()
        def flush(self):
            for s in self.streams:
                try:
                    s.flush()
                except IOError:
                    pass

    log_file = app.config.get(prefs.LOG_PATHNAME)
    if log_file:
        h = open(log_file, "wt")
        sys.stdout = AutoflushingTeeStream([h, sys.stdout])
        sys.stderr = AutoflushingTeeStream([h, sys.stderr])

    # handle command line args
    if parsed_options.debugmode:
        if parsed_options.debugmode.lower() in ("y", "yes"):
            app.debugmode = True
        else:
            app.debugmode = False
    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    from miro import startfrontend
    startfrontend.run_application(parsed_options.frontend, {}, theme)

    # This code is useless, but it tells py2app that we need to import these
    # modules
    import miro.plat.frontends.widgets.application
    import miro.frontends.cli.application
    import miro.frontends.profilewidgets.application
    import miro.frontends.shell.application
Exemple #4
0
def startup(argv):
    # Rewrite the stdout and stderr to catch cases debug being printed via
    # a print or via a write to stderr.  Normally we would use shortAppName
    # but at this point nothing has been bootstrapped yet.  We only want to
    # catch it though if py2exe has fiddled with our file descriptors.
    #
    # The stdout/stderr are redirected again in the Windows-specific
    # setup_logging(). 
    #
    # See bz17793
    redirected = sys.stdout != sys.__stdout__
    if redirected:
        try:
            logfile = os.path.join(tempfile.gettempdir(), 'Miro_console.log')
            sys.stderr = sys.stdout = open(logfile, 'w')
        except EnvironmentError:
            # too bad ... let's silence rather than spew stuff to stop it 
            # writing to a file that it might not have permissions to.  
            # Hopefully, this does not happen often.
            sys.stderr = sys.stdout = open(os.devnull, 'w')

    # Before importing gstreamer, fix os.environ so gstreamer finds its
    # plugins.  Do this early before any code is run to prevent any import
    # of gst missing this!
    from miro.plat import resources
    from miro.plat import config
    GST_PLUGIN_PATH = os.path.join(resources.app_root(), 'gstreamer-0.10')
    os.environ["GST_PLUGIN_PATH"] = GST_PLUGIN_PATH
    os.environ["GST_PLUGIN_SYSTEM_PATH"] = GST_PLUGIN_PATH
    # normally we'd use app.config to get this, but we're starting up
    os.environ["GST_REGISTRY"] = os.path.join(config._get_support_directory(),
                                              'gst_registry.bin')

    theme = None
    # Should have code to figure out the theme.

    from miro.plat import pipeipc
    try:
        pipe_server = pipeipc.Server()
    except pipeipc.PipeExists:
        pipeipc.send_command_line_args()
        return
    pipe_server.start_process()

    from miro.plat import prelogger
    prelogger.install()

    from miro.plat.utils import initialize_locale
    initialize_locale()

    from miro import bootstrap
    bootstrap.bootstrap()

    from miro.plat import commandline
    args = commandline.get_command_line()[1:]

    if '--theme' in args:
        index = args.index('--theme')
        theme = args[index+1]
        del args[index:index+1]

    if '--debug' in args:
        index = args.index('--debug')
        del args[index]
        from miro import app
        app.debugmode = True

    from miro import startup
    startup.initialize(theme)

    from miro.plat import migrateappname
    migrateappname.migrateSupport('Democracy', 'Miro')

    from miro import commandline
    commandline.set_command_line_args(args)

    # Kick off the application
    startfrontend.run_application('widgets', {}, None)
    pipe_server.quit()