[Erp5-report] r13702 - /erp5/trunk/utils/oood/start.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Mar 27 12:44:25 CEST 2007
Author: bartek
Date: Tue Mar 27 12:44:23 2007
New Revision: 13702
URL: http://svn.erp5.org?rev=13702&view=rev
Log:
added a "--top" option to start OpenOffice instances in the foreground (e.g. to set up java environments)
Modified:
erp5/trunk/utils/oood/start.py
Modified: erp5/trunk/utils/oood/start.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/start.py?rev=13702&r1=13701&r2=13702&view=diff
==============================================================================
--- erp5/trunk/utils/oood/start.py (original)
+++ erp5/trunk/utils/oood/start.py Tue Mar 27 12:44:23 2007
@@ -32,6 +32,7 @@
# Add oood home (= current path) as a place to look for import
# XXX Is this magical things make oood_home parameter useless in oood config file ?
sys.path.append(os.path.abspath(os.getcwd()))
+sys.path.append('/etc/oood')
# Standard python libs
import getopt, time, glob
@@ -60,7 +61,7 @@
lib.log('%s%s' % (LOG_HEAD, msg), level)
-def startInstance(i):
+def startInstance(i, on_top=False):
"""
We spawn a new process and record its pid to be able to kill it if necessary.
"""
@@ -71,15 +72,19 @@
# "'-display :%d' % config.virtual_display_id" argument is not working, that's why we use
# environnment variable. See "man xhost" for more details.
new_context = os.environ
- new_context['DISPLAY'] = ':%s' % config.virtual_display_id
+ if not on_top:
+ new_context['DISPLAY'] = ':%s' % config.virtual_display_id
args_and_env = [ BIN # First arg is always the name of the binary software we execute
- , '-headless'
+ , '-accept=socket,host=%s,port=%d;urp;' % (config.pool_host, instance_port)
+ , '-env:UserInstallation=$SYSUSERCONFIG/./oood_instance_%d' % i
+ , new_context
+ ]
+ if not on_top:
+ args_and_env += [
+ '-headless'
, '-nologo'
, '-nodefault'
, '-norestore'
- , '-accept=socket,host=%s,port=%d;urp;' % (config.pool_host, instance_port)
- , '-env:UserInstallation=$SYSUSERCONFIG/./oood_instance_%d' % i
- , new_context
]
pid = os.spawnlpe(os.P_NOWAIT, cmd, *args_and_env)
_l("Listening at %s:%s" % (config.pool_host, instance_port), i, 0)
@@ -116,14 +121,14 @@
_l("Didn't exist, so no need to kill", i, 0)
-def initPool():
+def initPool(on_top=False):
"""
This mehod initialize the pool: it kill all previous OOo instances (if any) and re-populate the pool.
"""
lib.log("Pool - Initialize: populate the pool with %s instances" % config.pool_size, 0)
flushPool()
for i in range(config.pool_size):
- startInstance(i)
+ startInstance(i, on_top)
lib.log("Pool - Wait %s seconds to let the instance #%s start" % (config.instance_load_time, i), 0)
time.sleep(config.instance_load_time)
lib.log("Pool - Initialized: %s instances started" % config.pool_size, 0)
@@ -162,7 +167,9 @@
if os.path.exists(xorg_socket) and \
(os.stat(xorg_socket).st_uid != int(getoutput("id -u %s" % OOOD_USER_NAME)) or \
os.stat(xorg_socket).st_gid != int(getoutput("id -g %s" % OOOD_USER_NAME))):
- lib.log("Pool - Can't start Virtual Frame Buffer because '%s' is not owned by %s" % (xorg_socket, OOOD_USER_NAME), 3)
+ msg = "Pool - Can't start Virtual Frame Buffer because '%s' is not owned by %s" % (xorg_socket, OOOD_USER_NAME)
+ lib.log(msg, 3)
+ print msg
sys.exit(1)
# Start the new virtual display server
os.system("Xvfb -ac :%s -screen %s 800x600x16 -fbdir %s &" % ( config.virtual_display_id
@@ -208,6 +215,8 @@
print """Usage: %s [options]
-i, --init
Initialize the pool: kill all previous OOo instances (if any) and re-populate the pool.
+ -t, --top
+ Start on top
-f, --flush
Flush the pool: kill all OOo instances to empty the pool.
-s, --status, --stat
@@ -222,8 +231,8 @@
# Parse options and parameters
try:
opts, args = getopt.getopt( sys.argv[1:]
- , "hifsd"
- , ["help", "init", "flush", "status", "stat"]
+ , "hifsdt"
+ , ["help", "init", "flush", "status", "stat", "top"]
)
# Check args number
if len(opts) == 0:
@@ -242,6 +251,9 @@
startVirtualFrameBuffer()
initPool()
sys.exit(0)
+ elif o in ("-t", "--top"):
+ initPool(on_top=True)
+ sys.exit(0)
elif o in ("-f", "--flush"):
flushPool()
killVirtualFrameBuffer()
More information about the Erp5-report
mailing list