Add --debug and --verbose options to launcher scripts
Factor out a common Launcher class from start-in-Xepyhr and start-replace that handles option parsing and launching gnome-shell, and add options: -v/--verbose: Unless specified, suppress most gjs debug output -g/--debug: If specified run under gdb --debug-command: Run under some other debugging (strace/valgrind/etc.) Implies -g svn path=/trunk/; revision=18
This commit is contained in:
parent
4a651471e3
commit
e81ed61a38
84
scripts/launcher.py
Normal file
84
scripts/launcher.py
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
from optparse import OptionParser
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
class Launcher:
|
||||||
|
def __init__(self):
|
||||||
|
self.use_tfp = True
|
||||||
|
|
||||||
|
# Figure out the path to the plugin when uninstalled
|
||||||
|
scripts_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
||||||
|
top_dir = os.path.dirname(scripts_dir)
|
||||||
|
self.plugin_dir = os.path.join(top_dir, "src")
|
||||||
|
self.js_dir = os.path.join(top_dir, "js")
|
||||||
|
|
||||||
|
parser = OptionParser()
|
||||||
|
parser.add_option("-g", "--debug", action="store_true",
|
||||||
|
help="Run under a debugger")
|
||||||
|
parser.add_option("", "--debug-command", metavar="COMMAND",
|
||||||
|
help="Command to use for debugging (defaults to 'gdb --args')")
|
||||||
|
parser.add_option("-v", "--verbose", action="store_true")
|
||||||
|
|
||||||
|
self.options, args = parser.parse_args()
|
||||||
|
|
||||||
|
if args:
|
||||||
|
parser.print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if self.options.debug_command:
|
||||||
|
self.options.debug = True
|
||||||
|
self.debug_command = self.options.debug_command.split()
|
||||||
|
else:
|
||||||
|
self.debug_command = ["gdb", "--args"]
|
||||||
|
|
||||||
|
def set_use_tfp(self, use_tfp):
|
||||||
|
"""Sets whether we try to use GLX_EXT_texture_for_pixmap"""
|
||||||
|
|
||||||
|
self.use_tfp = use_tfp
|
||||||
|
|
||||||
|
def start_shell(self):
|
||||||
|
"""Starts gnome-shell. Returns a subprocess.Popen object"""
|
||||||
|
|
||||||
|
use_tfp = self.use_tfp
|
||||||
|
if use_tfp:
|
||||||
|
# Check if GLX supports GL_ARB_texture_non_power_of_two; currently clutter
|
||||||
|
# can only use GLX_EXT_texture_for_pixmap if we have that extension.
|
||||||
|
glxinfo = subprocess.Popen(["glxinfo"], stdout=subprocess.PIPE)
|
||||||
|
glxinfo_output = glxinfo.communicate()[0]
|
||||||
|
glxinfo.wait()
|
||||||
|
|
||||||
|
use_tfp = "GL_ARB_texture_non_power_of_two" in glxinfo_output
|
||||||
|
|
||||||
|
# Now launch metacity-clutter with our plugin
|
||||||
|
env=dict(os.environ)
|
||||||
|
env.update({'GNOME_SHELL_JS' : self.js_dir,
|
||||||
|
'GI_TYPELIB_PATH' : self.plugin_dir,
|
||||||
|
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ':' + self.plugin_dir})
|
||||||
|
|
||||||
|
if use_tfp:
|
||||||
|
# If we have NPOT textures, then we want to use GLX_EXT_texture_from_pixmap; in
|
||||||
|
# most cases, we have to force indirect rendering to do this. DRI2 will lift
|
||||||
|
# that restriction; in which case what we should do is parse the information
|
||||||
|
# from glxinfo more carefully... if the extension isn't listed under
|
||||||
|
# "GLX extensions" with LIBGL_ALWAYS_INDIRECT unset, then set LIBGL_ALWAYS_INDIRECT
|
||||||
|
# and try again.
|
||||||
|
env['LIBGL_ALWAYS_INDIRECT'] = '1'
|
||||||
|
|
||||||
|
if not self.options.verbose:
|
||||||
|
# Unless verbose() is specified, only let gjs log things that are explicit log()
|
||||||
|
# commands form javascript
|
||||||
|
env['GJS_DEBUG_TOPICS'] = 'JS LOG'
|
||||||
|
|
||||||
|
if self.options.debug:
|
||||||
|
args = list(self.options.debug_command)
|
||||||
|
else:
|
||||||
|
args = []
|
||||||
|
|
||||||
|
plugin = os.path.join(self.plugin_dir, "libgnome-shell.la")
|
||||||
|
args.extend(['metacity', '--mutter-plugins=' + plugin, '--replace'])
|
||||||
|
return subprocess.Popen(args, env=env)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,18 +1,22 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import os,sys,subprocess,signal
|
import os
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
|
|
||||||
# Uninstalled paths
|
from launcher import Launcher
|
||||||
scripts_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
||||||
top_dir = os.path.dirname(scripts_dir)
|
|
||||||
plugin_dir = os.path.join(top_dir, "src")
|
|
||||||
plugin = os.path.join(plugin_dir, "libgnome-shell.la")
|
|
||||||
js_dir = os.path.join(top_dir, "js")
|
|
||||||
|
|
||||||
|
launcher = Launcher()
|
||||||
|
|
||||||
|
# GL_EXT_texture_from_pixmap doesn't work in Xepyhr
|
||||||
|
launcher.set_use_tfp(False)
|
||||||
|
|
||||||
|
# Temporary directory to hold our X credentials
|
||||||
tmpdir = tempfile.mkdtemp("", "gnome-shell.")
|
tmpdir = tempfile.mkdtemp("", "gnome-shell.")
|
||||||
try:
|
try:
|
||||||
display = ":" + str(random.randint(10, 99))
|
display = ":" + str(random.randint(10, 99))
|
||||||
@ -41,14 +45,7 @@ try:
|
|||||||
subprocess.Popen(["xterm"])
|
subprocess.Popen(["xterm"])
|
||||||
|
|
||||||
# Now launch metacity-clutter with our plugin
|
# Now launch metacity-clutter with our plugin
|
||||||
env=dict(os.environ)
|
shell = launcher.start_shell()
|
||||||
env.update({'GNOME_SHELL_JS' : js_dir,
|
|
||||||
'GI_TYPELIB_PATH' : plugin_dir,
|
|
||||||
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ':' + plugin_dir})
|
|
||||||
args = 'DEBUG' in os.environ and os.environ['DEBUG'].split() or []
|
|
||||||
args.extend(['metacity', '--mutter-plugins=' + plugin, '--replace'])
|
|
||||||
print args
|
|
||||||
subprocess.Popen(args, env=env)
|
|
||||||
|
|
||||||
# Wait for Xephyr to exit
|
# Wait for Xephyr to exit
|
||||||
try:
|
try:
|
||||||
|
@ -1,17 +1,12 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import os,sys,subprocess,signal
|
import os
|
||||||
import random
|
import subprocess
|
||||||
import shutil
|
import signal
|
||||||
import tempfile
|
|
||||||
import time
|
|
||||||
|
|
||||||
# Uninstalled paths
|
from launcher import Launcher
|
||||||
scripts_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
||||||
top_dir = os.path.dirname(scripts_dir)
|
launcher = Launcher()
|
||||||
plugin_dir = os.path.join(top_dir, "src")
|
|
||||||
plugin = os.path.join(plugin_dir, "libgnome-shell.la")
|
|
||||||
js_dir = os.path.join(top_dir, "js")
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Kill gnome-panel in a way that it won't autorespawn
|
# Kill gnome-panel in a way that it won't autorespawn
|
||||||
@ -26,39 +21,14 @@ try:
|
|||||||
"-p", pid], stdout=devnull, stderr=devnull)
|
"-p", pid], stdout=devnull, stderr=devnull)
|
||||||
devnull.close()
|
devnull.close()
|
||||||
|
|
||||||
# Check if GLX supports GL_ARB_texture_non_power_of_two; currently clutter
|
shell = launcher.start_shell()
|
||||||
# can only use GLX_EXT_texture_for_pixmap if we have that extension.
|
|
||||||
glxinfo = subprocess.Popen(["glxinfo"], stdout=subprocess.PIPE)
|
|
||||||
glxinfo_output = glxinfo.communicate()[0]
|
|
||||||
glxinfo.wait()
|
|
||||||
|
|
||||||
have_npot_textures = "GL_ARB_texture_non_power_of_two" in glxinfo_output
|
# Wait for shell to exit
|
||||||
|
|
||||||
# Now launch metacity-clutter with our plugin
|
|
||||||
env=dict(os.environ)
|
|
||||||
env.update({'GNOME_SHELL_JS' : js_dir,
|
|
||||||
'GI_TYPELIB_PATH' : plugin_dir,
|
|
||||||
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ':' + plugin_dir})
|
|
||||||
|
|
||||||
if have_npot_textures:
|
|
||||||
# If we have NPOT textures, then we want to use GLX_EXT_texture_from_pixmap; in
|
|
||||||
# most cases, we have to force indirect rendering to do this. DRI2 will lift
|
|
||||||
# that restriction; in which case what we should do is parse the information
|
|
||||||
# from glxinfo more carefully... if the extension isn't listed under
|
|
||||||
# "GLX extensions" with LIBGL_ALWAYS_INDIRECT unset, then set LIBGL_ALWAYS_INDIRECT
|
|
||||||
# and try again.
|
|
||||||
env['LIBGL_ALWAYS_INDIRECT'] = '1'
|
|
||||||
|
|
||||||
args = 'DEBUG' in os.environ and os.environ['DEBUG'].split() or []
|
|
||||||
args.extend(['metacity', '--mutter-plugins=' + plugin, '--replace'])
|
|
||||||
metacity = subprocess.Popen(args, env=env)
|
|
||||||
|
|
||||||
# Wait for metacity to exit
|
|
||||||
try:
|
try:
|
||||||
metacity.wait()
|
shell.wait()
|
||||||
except KeyboardInterrupt, e:
|
except KeyboardInterrupt, e:
|
||||||
os.kill(metacity.pid, signal.SIGKILL)
|
os.kill(shell.pid, signal.SIGKILL)
|
||||||
metacity.wait()
|
shell.wait()
|
||||||
finally:
|
finally:
|
||||||
# Restart gnome-panel and window manager
|
# Restart gnome-panel and window manager
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user