Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/sugar-shell
diff options
context:
space:
mode:
authorJohn (J5) Palmieri <quinticent@localhost.localdomain>2007-08-20 19:02:58 (GMT)
committer John (J5) Palmieri <quinticent@localhost.localdomain>2007-08-20 19:02:58 (GMT)
commitb24a28a77dcfbe79ec45531e6477251830edfabd (patch)
tree4d9bd9b56d4a99866e16a10c2dabed3331ca0033 /shell/sugar-shell
parent655d7f41741d90617aa341db7542153261c9f6e7 (diff)
make sugar shell easier to profile startup times
Diffstat (limited to 'shell/sugar-shell')
-rwxr-xr-xshell/sugar-shell88
1 files changed, 49 insertions, 39 deletions
diff --git a/shell/sugar-shell b/shell/sugar-shell
index 8d9fd2f..2121782 100755
--- a/shell/sugar-shell
+++ b/shell/sugar-shell
@@ -69,17 +69,6 @@ def _setup_translations():
gettext.bindtextdomain(domain, env.get_locale_path())
gettext.textdomain(domain)
-_save_session_info()
-_start_matchbox()
-_setup_translations()
-
-# Do initial setup if needed
-if not profile.is_valid():
- win = intro.IntroWindow()
- win.show_all()
- gtk.main()
- profile.update()
-
def check_gabble(bus_name):
try:
import dbus
@@ -92,34 +81,55 @@ def check_gabble(bus_name):
pass
return False
-if os.environ.has_key("TP_DEBUG"):
- # Allow the user time to start up telepathy connection managers
- # using the Sugar DBus bus address
- import time
- from telepathy.client import ManagerRegistry
-
- registry = ManagerRegistry()
- registry.LoadManagers()
- try:
- gabble = registry.services["gabble"]
- except KeyError:
- raise RuntimeError("Gabble connection manager not found!")
-
- while not check_gabble(gabble['busname']):
- print "Waiting for gabble on: DBUS_SESSION_BUS_ADDRESS=%s" % os.environ["DBUS_SESSION_BUS_ADDRESS"]
+def main()
+ _save_session_info()
+ _start_matchbox()
+ _setup_translations()
+
+ # Do initial setup if needed
+ if not profile.is_valid():
+ win = intro.IntroWindow()
+ win.show_all()
+ gtk.main()
+ profile.update()
+
+ if os.environ.has_key("TP_DEBUG"):
+ # Allow the user time to start up telepathy connection managers
+ # using the Sugar DBus bus address
+ import time
+ from telepathy.client import ManagerRegistry
+
+ registry = ManagerRegistry()
+ registry.LoadManagers()
try:
- time.sleep(5)
- except KeyboardInterrupt:
- print "Got Ctrl+C, continuing..."
- break
-
-model = ShellModel()
-shell = Shell(model)
-service = ShellService(shell)
+ gabble = registry.services["gabble"]
+ except KeyError:
+ raise RuntimeError("Gabble connection manager not found!")
+
+ while not check_gabble(gabble['busname']):
+ print "Waiting for gabble on: DBUS_SESSION_BUS_ADDRESS=%s" % os.environ["DBUS_SESSION_BUS_ADDRESS"]
+ try:
+ time.sleep(5)
+ except KeyboardInterrupt:
+ print "Got Ctrl+C, continuing..."
+ break
+
+ model = ShellModel()
+ shell = Shell(model)
+ service = ShellService(shell)
+
+if name == '__main__':
+ # running the gtk.main outside of the main() function allows us to
+ # profile startup times. To profile startup times replace the following
+ # call to main with:
+ # import cProfile
+ # cProfile.run('main()', '/home/olpc/sugar-startup.stats')
+
+ main()
-try:
- gtk.main()
-except KeyboardInterrupt:
- print 'Ctrl+C pressed, exiting...'
+ try:
+ gtk.main()
+ except KeyboardInterrupt:
+ print 'Ctrl+C pressed, exiting...'
-os.remove(dsba_file)
+ os.remove(dsba_file)