Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloudooo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
cloudooo
Commits
a073ec45
Commit
a073ec45
authored
May 16, 2019
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework
@yusei
patch
a5157949
parent
bbe27cf2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
21 deletions
+27
-21
cloudooo/handler/ooo/application/openoffice.py
cloudooo/handler/ooo/application/openoffice.py
+14
-7
cloudooo/handler/ooo/helper/helper_util.py
cloudooo/handler/ooo/helper/helper_util.py
+1
-9
cloudooo/handler/ooo/helper/openoffice_tester.py
cloudooo/handler/ooo/helper/openoffice_tester.py
+12
-5
No files found.
cloudooo/handler/ooo/application/openoffice.py
View file @
a073ec45
...
@@ -35,10 +35,14 @@ from threading import Lock
...
@@ -35,10 +35,14 @@ from threading import Lock
from
zope.interface
import
implements
from
zope.interface
import
implements
from
application
import
Application
from
application
import
Application
from
cloudooo.interfaces.lockable
import
ILockable
from
cloudooo.interfaces.lockable
import
ILockable
from
cloudooo.util
import
logger
,
convertStringToBool
from
cloudooo.util
import
logger
from
cloudooo.handler.ooo.util
import
waitStartDaemon
,
\
from
cloudooo.handler.ooo.util
import
waitStartDaemon
,
\
removeDirectory
,
\
removeDirectory
,
\
socketStatus
socketStatus
try
:
import
json
except
ImportError
:
import
simplejson
as
json
class
OpenOffice
(
Application
):
class
OpenOffice
(
Application
):
...
@@ -55,6 +59,7 @@ class OpenOffice(Application):
...
@@ -55,6 +59,7 @@ class OpenOffice(Application):
"""
"""
self
.
_bin_soffice
=
'soffice.bin'
self
.
_bin_soffice
=
'soffice.bin'
self
.
_lock
=
Lock
()
self
.
_lock
=
Lock
()
self
.
last_test_error
=
None
self
.
_cleanRequest
()
self
.
_cleanRequest
()
def
_testOpenOffice
(
self
,
host
,
port
):
def
_testOpenOffice
(
self
,
host
,
port
):
...
@@ -70,16 +75,18 @@ class OpenOffice(Application):
...
@@ -70,16 +75,18 @@ class OpenOffice(Application):
"--port=%s"
%
port
,
"--port=%s"
%
port
,
"--uno_path=%s"
%
self
.
uno_path
,
"--uno_path=%s"
%
self
.
uno_path
,
"--office_binary_path=%s"
%
self
.
office_binary_path
]
"--office_binary_path=%s"
%
self
.
office_binary_path
]
logger
.
debug
(
"Testing Openoffice Instance %s"
%
port
)
stdout
,
stderr
=
Popen
(
args
,
stdout
=
PIPE
,
stdout
,
stderr
=
Popen
(
args
,
stdout
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
True
).
communicate
()
stderr
=
PIPE
,
close_fds
=
True
).
communicate
()
stdout_bool
=
convertStringToBool
(
stdout
.
replace
(
"
\
n
"
,
""
))
if
stdout
==
""
:
if
stdout_bool
and
stderr
!=
""
:
logger
.
error
(
"openoffice_tester.py cmdline: %s"
,
" "
.
join
(
args
))
logger
.
debug
(
"%s
\
n
%s"
%
(
stderr
,
stdout
))
logger
.
error
(
"openoffice_tester.py stdout: %s"
,
stdout
)
logger
.
error
(
"openoffice_tester.py stderr: %s"
,
stderr
)
return
False
return
False
else
:
stdout
=
json
.
loads
(
stdout
)
self
.
last_test_error
=
stderr
if
stdout
==
True
:
logger
.
debug
(
"Instance %s works"
%
port
)
logger
.
debug
(
"Instance %s works"
%
port
)
return
True
return
stdout
def
_cleanRequest
(
self
):
def
_cleanRequest
(
self
):
"""Define request attribute as 0"""
"""Define request attribute as 0"""
...
...
cloudooo/handler/ooo/helper/helper_util.py
View file @
a073ec45
import
signal
import
signal
import
sys
import
sys
import
os
import
os
import
time
def
getServiceManager
(
host
,
port
,
uno_path
,
office_binary_path
):
def
getServiceManager
(
host
,
port
,
uno_path
,
office_binary_path
):
"""Get the ServiceManager from the running OpenOffice.org.
"""Get the ServiceManager from the running OpenOffice.org.
...
@@ -22,14 +21,7 @@ def getServiceManager(host, port, uno_path, office_binary_path):
...
@@ -22,14 +21,7 @@ def getServiceManager(host, port, uno_path, office_binary_path):
uno_context
)
uno_context
)
# Connect to the running OpenOffice.org and get its
# Connect to the running OpenOffice.org and get its
# context.
# context.
# Retry 10 times if needed.
uno_connection
=
resolver
.
resolve
(
"uno:socket,host=%s,port=%s,tcpNoDelay=1;urp;StarOffice.ComponentContext"
%
(
host
,
port
))
for
i
in
range
(
10
):
try
:
uno_connection
=
resolver
.
resolve
(
"uno:socket,host=%s,port=%s;urp;StarOffice.ComponentContext"
%
(
host
,
port
))
break
except
:
# I don't know how to import com.sun.star.connection.NoConnectException
time
.
sleep
(
1
)
# Get the ServiceManager object
# Get the ServiceManager object
return
uno_connection
.
ServiceManager
return
uno_connection
.
ServiceManager
...
...
cloudooo/handler/ooo/helper/openoffice_tester.py
View file @
a073ec45
...
@@ -3,13 +3,18 @@ import sys
...
@@ -3,13 +3,18 @@ import sys
import
helper_util
import
helper_util
from
getopt
import
getopt
,
GetoptError
from
getopt
import
getopt
,
GetoptError
try
:
import
json
except
ImportError
:
import
simplejson
as
json
def
test_openoffice
(
hostname
,
port
,
uno_path
,
office_binary_path
):
def
test_openoffice
(
hostname
,
port
,
uno_path
,
office_binary_path
):
import
pyuno
try
:
try
:
helper_util
.
getServiceManager
(
hostname
,
port
,
uno_path
,
office_binary_path
)
helper_util
.
getServiceManager
(
hostname
,
port
,
uno_path
,
office_binary_path
)
return
True
return
True
except
Exception
,
err
:
except
pyuno
.
getClass
(
"com.sun.star.connection.NoConnectException"
):
print
err
return
False
return
False
...
@@ -30,12 +35,14 @@ def main():
...
@@ -30,12 +35,14 @@ def main():
hostname
=
arg
hostname
=
arg
elif
opt
==
"--uno_path"
:
elif
opt
==
"--uno_path"
:
uno_path
=
arg
uno_path
=
arg
if
uno_path
not
in
sys
.
path
:
sys
.
path
.
append
(
uno_path
)
elif
opt
==
"--office_binary_path"
:
elif
opt
==
"--office_binary_path"
:
office_binary_path
=
arg
office_binary_path
=
arg
sys
.
stdout
.
write
(
str
(
test_openoffice
(
hostname
,
port
,
output
=
json
.
dumps
(
test_openoffice
(
hostname
,
port
,
uno_path
,
office_binary_path
))
)
uno_path
,
office_binary_path
))
sys
.
stdout
.
write
(
output
)
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
helper_util
.
exitOverAbort
(
main
)
helper_util
.
exitOverAbort
(
main
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment