[Erp5-report] r16075 - /erp5/trunk/utils/oood/
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Sep 5 15:35:33 CEST 2007
Author: jerome
Date: Wed Sep 5 15:35:33 2007
New Revision: 16075
URL: http://svn.erp5.org?rev=16075&view=rev
Log:
More portability, by Klaus Wölfel:
Fix all restart problems under windows
Specify mode when openning files
Use \ for path separator when needed
Modified:
erp5/trunk/utils/oood/config.py
erp5/trunk/utils/oood/start.py
erp5/trunk/utils/oood/testOoodOldFormats.py
erp5/trunk/utils/oood/winservice.py
Modified: erp5/trunk/utils/oood/config.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/config.py?rev=16075&r1=16074&r2=16075&view=diff
==============================================================================
--- erp5/trunk/utils/oood/config.py (original)
+++ erp5/trunk/utils/oood/config.py Wed Sep 5 15:35:33 2007
@@ -39,7 +39,7 @@
config = ConfigParser()
if WIN:
- config.read([r'C:\ERP5\oood\oood.conf'])
+ config.read([os.path.join(os.path.dirname(__file__), 'oood.conf')])
else:
config.read(['/etc/oood/oood.conf', 'oood.conf'])
@@ -51,6 +51,13 @@
run_dir = config.get('System', 'run_dir')
uno_path = config.get('System', 'uno_path')
log_file = config.get('System', 'log_file')
+
+if WIN:
+ oood_home = oood_home.replace('\\', '/')
+ run_dir = run_dir.replace('\\', '/')
+ uno_path= uno_path.replace('\\', '/')
+ log_file = log_file.replace('\\', '/')
+
debug_mode = config.getboolean('System', 'debug_mode')
log_level = eval(config.get('System', 'log_level'))
Modified: erp5/trunk/utils/oood/start.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/start.py?rev=16075&r1=16074&r2=16075&view=diff
==============================================================================
--- erp5/trunk/utils/oood/start.py (original)
+++ erp5/trunk/utils/oood/start.py Wed Sep 5 15:35:33 2007
@@ -32,6 +32,7 @@
import re
import sys
import threading
+from urllib import quote
# 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()))
@@ -79,14 +80,15 @@
else:
BIN = "soffice"
cmd = '%s/%s' % (config.uno_path, BIN)
+ drive, tail = os.path.splitdrive(config.run_dir.strip('/'))
+ run_dir = drive + quote(tail)
# "'-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
if on_top:
args_and_env = [ BIN # First arg is always the name of the binary software we execute
, '-accept=socket,host=%s,port=%d;urp;' % (config.pool_host, instance_port)
- , '-env:UserInstallation=file:///%s/oood_instance_%d' %
- (config.run_dir.strip('/'),i)
+ , '-env:UserInstallation=file:///%s/oood_instance_%d' %(run_dir,i)
, new_context
]
else:
@@ -97,8 +99,7 @@
, '-nodefault'
, '-norestore'
, '-accept=socket,host=%s,port=%d;urp;' % (config.pool_host, instance_port)
- , '-env:UserInstallation=file:///%s/oood_instance_%d' %
- (config.run_dir.strip('/'),i)
+ , '-env:UserInstallation=file:///%s/oood_instance_%d' %(run_dir,i)
, new_context
]
if WIN:
@@ -117,14 +118,17 @@
# so we establish a waiting thread, not to block the whole process
_l("Starting waiting thread for process %s" % pid, i)
if WIN:
- waiting_thread = threading.Thread(target=justWait, args=(process._handle,))
+ waiting_thread = threading.Thread(target=justWait, args=(process))
else:
waiting_thread = threading.Thread(target=justWait, args=(pid,))
waiting_thread.start()
_l("Started as process %s" % pid, i)
def justWait(pid):
- os.waitpid(pid, 0)
+ if WIN:
+ pid.wait()
+ else:
+ os.waitpid(pid, 0)
def killInstance(i):
_l("Kill requested", i)
Modified: erp5/trunk/utils/oood/testOoodOldFormats.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/testOoodOldFormats.py?rev=16075&r1=16074&r2=16075&view=diff
==============================================================================
--- erp5/trunk/utils/oood/testOoodOldFormats.py (original)
+++ erp5/trunk/utils/oood/testOoodOldFormats.py Wed Sep 5 15:35:33 2007
@@ -68,7 +68,7 @@
print host
try:
- f = open('%s/test.odt' % doc_dir)
+ f = open('%s/test.odt' % doc_dir, 'rb')
except IOError:
print "you need a %s subdir with appropriate documents" % doc_dir
sys.exit(1)
@@ -107,19 +107,19 @@
def convertFile(self, src, ext, id=''):
if id: id = id + '.'
- data=open('doc/in/test.%s%s' % (id, src)).read()
+ data=open('doc/in/test.%s%s' % (id, src), 'rb').read()
res=sp.convert('test.%s%s' % (id, src),enc(data))
res = responseFactory(res)
self.assert_(res)
- open('doc/out/test.%sout.%s' % (id, ext), 'w').write(res.data)
+ open('doc/out/test.%sout.%s' % (id, ext), 'wb').write(res.data)
def generateFile(self, src, ext, id=''):
if id: id = id + '.'
- data=open('doc/in/test.%s%s' % (id, src)).read()
+ data=open('doc/in/test.%s%s' % (id, src), 'rb').read()
res=sp.generate('test.%s%s' % (id, src), enc(data), -1, ext)
res = responseFactory(res)
self.assert_(res)
- open('doc/out/test.%sout.%s' % (id, ext), 'w').write(res.data)
+ open('doc/out/test.%sout.%s' % (id, ext), 'wb').write(res.data)
if __name__=='__main__':
tests=(TestFileOperations,)
Modified: erp5/trunk/utils/oood/winservice.py
URL: http://svn.erp5.org/erp5/trunk/utils/oood/winservice.py?rev=16075&r1=16074&r2=16075&view=diff
==============================================================================
--- erp5/trunk/utils/oood/winservice.py (original)
+++ erp5/trunk/utils/oood/winservice.py Wed Sep 5 15:35:33 2007
@@ -28,9 +28,13 @@
import os
import sys
+import config
+
+sys.path.append(config.uno_path)
+os.environ['PATH'] += ';' + config.uno_path + ';'
+
import socket
import start
-import config
import pywintypes
import win32api
import win32con
@@ -44,11 +48,13 @@
from dispatcher import Dispatcher, MySerw
class ooodService(win32serviceutil.ServiceFramework):
- _svc_name_ = 'oood'
- _svc_display_name_ = 'oood'
+ _svc_name_ = 'ERP5oood'
+ _svc_display_name_ = 'ERP5oood'
_svc_description_ = ('A server for converting docs from other formats to '
'OOo, generating pdf files, getting and setting '
'metadata. To be used together with ERP5.')
+ _exe_name_ = os.path.join(os.path.dirname(sys.executable),'..','lib',
+ 'site-packages','win32','pythonservice.exe')
def __init__(self, args):
# set the timeout so the service can stop...Otherwise it hangs forever
More information about the Erp5-report
mailing list