[gnome-shell] Move shell-running machinery to a function
- From: Owen Taylor <otaylor src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Move shell-running machinery to a function
- Date: Fri, 21 May 2010 05:49:20 +0000 (UTC)
commit 5d0536d7321190858bfd1436c2d9ff5ec98eae74
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Tue May 11 16:43:38 2010 -0400
Move shell-running machinery to a function
Move the code that starts gnome-shell and waits for it to exit
to a function in preparation for running it multiple times when
doing iterations of a performance test.
https://bugzilla.gnome.org/show_bug.cgi?id=618189
src/gnome-shell.in | 121 +++++++++++++++++++++++++++------------------------
1 files changed, 64 insertions(+), 57 deletions(-)
---
diff --git a/src/gnome-shell.in b/src/gnome-shell.in
index 7b2c0ad..8181071 100644
--- a/src/gnome-shell.in
+++ b/src/gnome-shell.in
@@ -1,4 +1,5 @@
#! PYTHON@
+# -*- mode: Python; indent-tabs-mode: nil; -*-
import atexit
import optparse
@@ -213,6 +214,68 @@ def start_shell():
args.append('--sync')
return subprocess.Popen(args, env=env)
+def run_shell():
+ if options.debug:
+ # Record initial terminal state so we can reset it to that
+ # later, in case we kill gdb at a bad time
+ termattrs = termios.tcgetattr(0);
+
+ normal_exit = False
+
+ if options.verbose:
+ print "Starting shell"
+
+ try:
+ shell = None
+ if options.xephyr:
+ xephyr = start_xephyr()
+ # This makes us not grab the org.gnome.Panel or
+ # org.freedesktop.Notifications D-Bus names
+ os.environ['GNOME_SHELL_NO_REPLACE'] = '1'
+ shell = start_shell()
+ else:
+ xephyr = None
+ shell = start_shell()
+
+ # Wait for shell to exit
+ if options.verbose:
+ print "Waiting for shell to exit"
+ shell.wait()
+
+ except KeyboardInterrupt, e:
+ try:
+ os.kill(shell.pid, signal.SIGKILL)
+ except:
+ pass
+ shell.wait()
+ finally:
+ # Clean up Xephyr if it outlived the shell
+ if xephyr:
+ try:
+ os.kill(xephyr.pid, signal.SIGKILL)
+ except OSError:
+ pass
+
+ if shell is None:
+ print "Failed to start shell"
+ elif shell.returncode == 0:
+ normal_exit = True
+ if options.verbose:
+ print "Shell exited normally"
+ elif shell.returncode < 0:
+ # Python has no mapping for strsignal; not worth using
+ # ctypes for this.
+ print "Shell killed with signal %d" % - shell.returncode
+ else:
+ # Normal reason here would be losing connection the X server
+ if options.verbose:
+ print "Shell exited with return code %d" % shell.returncode
+
+ if options.debug:
+ termios.tcsetattr(0, termios.TCSANOW, termattrs);
+
+ return normal_exit
+
def restore_gnome():
# Do imports lazily to save time and memory
import gio
@@ -405,69 +468,13 @@ else:
# tfp does not work correctly in Xephyr
use_tfp = not options.xephyr
-if options.verbose:
- print "Starting shell"
-
-
-
-if options.debug:
- # Record initial terminal state so we can reset it to that
- # later, in case we kill gdb at a bad time
- termattrs = termios.tcgetattr(0);
-
# We only respawn the previous environment on abnormal exit;
# for a clean exit, we assume that gnome-shell was replaced with
# something else.
normal_exit = False
try:
- shell = None
- if options.xephyr:
- xephyr = start_xephyr()
- # This makes us not grab the org.gnome.Panel or
- # org.freedesktop.Notifications D-Bus names
- os.environ['GNOME_SHELL_NO_REPLACE'] = '1'
- shell = start_shell()
- else:
- xephyr = None
- shell = start_shell()
-
- # Wait for shell to exit
- if options.verbose:
- print "Waiting for shell to exit"
- shell.wait()
-
-except KeyboardInterrupt, e:
- try:
- os.kill(shell.pid, signal.SIGKILL)
- except:
- pass
- shell.wait()
+ normal_exit = run_shell()
finally:
- # Clean up Xephyr if it outlived the shell
- if xephyr:
- try:
- os.kill(xephyr.pid, signal.SIGKILL)
- except OSError:
- pass
-
- if shell is None:
- print "Failed to start shell"
- elif shell.returncode == 0:
- normal_exit = True
- if options.verbose:
- print "Shell exited normally"
- elif shell.returncode < 0:
- # Python has no mapping for strsignal; not worth using
- # ctypes for this.
- print "Shell killed with signal %d" % - shell.returncode
- else:
- # Normal reason here would be losing connection the X server
- if options.verbose:
- print "Shell exited with return code %d" % shell.returncode
-
- if options.debug:
- termios.tcsetattr(0, termios.TCSANOW, termattrs);
-
if not options.xephyr and options.replace and not normal_exit:
restore_gnome()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]