Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
cloudooo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
cloudooo
Commits
a77f5599
Commit
a77f5599
authored
Apr 22, 2023
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*: cleanups
lazy loging and other obvious changes
parent
ad60ba5b
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
34 additions
and
34 deletions
+34
-34
cloudooo/bin/cloudooo_tester.py
cloudooo/bin/cloudooo_tester.py
+1
-1
cloudooo/handler/ffmpeg/handler.py
cloudooo/handler/ffmpeg/handler.py
+1
-1
cloudooo/handler/imagemagick/handler.py
cloudooo/handler/imagemagick/handler.py
+2
-2
cloudooo/handler/ooo/application/application.py
cloudooo/handler/ooo/application/application.py
+6
-4
cloudooo/handler/ooo/application/openoffice.py
cloudooo/handler/ooo/application/openoffice.py
+7
-5
cloudooo/handler/ooo/granulator.py
cloudooo/handler/ooo/granulator.py
+3
-3
cloudooo/handler/ooo/handler.py
cloudooo/handler/ooo/handler.py
+2
-2
cloudooo/handler/ooo/monitor/request.py
cloudooo/handler/ooo/monitor/request.py
+2
-2
cloudooo/handler/ooo/monitor/sleeping_time.py
cloudooo/handler/ooo/monitor/sleeping_time.py
+2
-2
cloudooo/handler/ooo/monitor/timeout.py
cloudooo/handler/ooo/monitor/timeout.py
+3
-3
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
+1
-5
cloudooo/handler/pdf/handler.py
cloudooo/handler/pdf/handler.py
+2
-2
cloudooo/handler/wkhtmltopdf/handler.py
cloudooo/handler/wkhtmltopdf/handler.py
+1
-1
cloudooo/handler/x2t/handler.py
cloudooo/handler/x2t/handler.py
+1
-1
No files found.
cloudooo/bin/cloudooo_tester.py
View file @
a77f5599
...
...
@@ -33,7 +33,7 @@ class CloudoooTestCase(unittest.TestCase):
'application/vnd.oasis.opendocument.text'
)
res
=
proxy
.
run_setmetadata
(
"t.odt"
,
odt_data
,
{
"Title"
:
"test"
})
self
.
assertEqual
(
res
[
0
],
200
)
response_code
,
response_dict
,
response_message
=
\
response_code
,
response_dict
,
_
=
\
proxy
.
run_convert
(
"t.odt"
,
res
[
1
][
'data'
])
self
.
assertEqual
(
response_code
,
200
)
self
.
assertEqual
(
response_dict
[
'meta'
][
'Title'
],
"test"
)
...
...
cloudooo/handler/ffmpeg/handler.py
View file @
a77f5599
...
...
@@ -56,7 +56,7 @@ class Handler(object):
# XXX This implementation could use ffmpeg -i pipe:0, but
# XXX seems super unreliable currently and it generates currupted files in
# the end
logger
.
debug
(
"FfmpegConvert: %s > %s"
%
(
self
.
input
.
source_format
,
destination_format
)
)
logger
.
debug
(
"FfmpegConvert: %s > %s"
,
self
.
input
.
source_format
,
destination_format
)
output_url
=
mktemp
(
suffix
=
".%s"
%
destination_format
,
dir
=
self
.
input
.
directory_name
)
command
=
[
"ffmpeg"
,
...
...
cloudooo/handler/imagemagick/handler.py
View file @
a77f5599
...
...
@@ -49,7 +49,7 @@ class Handler(object):
def
convert
(
self
,
destination_format
=
None
,
**
kw
):
"""Convert a image"""
logger
.
debug
(
"ImageMagickConvert: %s > %s"
%
(
self
.
file
.
source_format
,
destination_format
)
)
logger
.
debug
(
"ImageMagickConvert: %s > %s"
,
self
.
file
.
source_format
,
destination_format
)
output_url
=
mktemp
(
suffix
=
'.%s'
%
destination_format
,
dir
=
self
.
base_folder_url
)
command
=
[
"convert"
,
self
.
file
.
getUrl
(),
output_url
]
...
...
@@ -80,7 +80,7 @@ class Handler(object):
std
=
std
.
strip
()
if
re
.
search
(
"^[a-zA-Z]"
,
std
):
if
std
.
count
(
":"
)
>
1
:
key
,
value
=
re
.
compile
(
".*
\
:
\
"
).
split
(
std
)
key
,
value
=
re
.
compile
(
r
".*\
:
\ "
).
split
(
std
)
else
:
key
,
value
=
std
.
split
(
":"
)
metadata_dict
[
key
]
=
value
.
strip
()
...
...
cloudooo/handler/ooo/application/application.py
View file @
a77f5599
...
...
@@ -44,15 +44,17 @@ class Application(object):
def
start
(
self
,
init
=
True
):
"""Start Application"""
logger
.
debug
(
"Process Started %s, Port %s. Pid %s"
%
(
self
.
name
,
self
.
getAddress
()[
-
1
],
self
.
pid
()))
logger
.
debug
(
"Process Started %s, Port %s. Pid %s"
,
self
.
name
,
self
.
getAddress
()[
-
1
],
self
.
pid
())
def
stop
(
self
):
"""Stop the process"""
if
hasattr
(
self
,
'process'
)
and
self
.
status
():
process_pid
=
self
.
process
.
pid
logger
.
debug
(
"Stop Pid - %s"
%
process_pid
)
logger
.
debug
(
"Stop Pid - %s"
,
process_pid
)
try
:
self
.
process
.
terminate
()
waitStopDaemon
(
self
,
self
.
timeout
)
...
...
cloudooo/handler/ooo/application/openoffice.py
View file @
a77f5599
...
...
@@ -60,8 +60,10 @@ class OpenOffice(Application):
def
_testOpenOffice
(
self
,
host
,
port
):
"""Test if OpenOffice was started correctly"""
logger
.
debug
(
"Test OpenOffice %s - Pid %s"
%
(
self
.
getAddress
()[
-
1
],
self
.
pid
()))
logger
.
debug
(
"Test OpenOffice %s - Pid %s"
,
self
.
getAddress
()[
-
1
],
self
.
pid
())
python
=
join
(
self
.
office_binary_path
,
"python"
)
args
=
[
exists
(
python
)
and
python
or
"python3"
,
pkg_resources
.
resource_filename
(
"cloudooo"
,
...
...
@@ -70,14 +72,14 @@ class OpenOffice(Application):
"--hostname=%s"
%
host
,
"--port=%s"
%
port
,
"--uno_path=%s"
%
self
.
uno_path
]
logger
.
debug
(
"Testing Openoffice Instance %s"
%
port
)
logger
.
debug
(
"Testing Openoffice Instance %s"
,
port
)
try
:
subprocess
.
check_output
(
args
,
stderr
=
subprocess
.
STDOUT
,
close_fds
=
True
)
except
subprocess
.
CalledProcessError
as
e
:
logger
.
warning
(
e
.
output
)
return
False
else
:
logger
.
debug
(
"Instance %s works"
%
port
)
logger
.
debug
(
"Instance %s works"
,
port
)
return
True
def
_cleanRequest
(
self
):
...
...
@@ -174,7 +176,7 @@ class OpenOffice(Application):
def
release
(
self
):
"""Unlock Instance."""
logger
.
debug
(
"OpenOffice %s, %s unlocked"
%
self
.
getAddress
())
logger
.
debug
(
"OpenOffice %s, %s unlocked"
,
*
self
.
getAddress
())
self
.
_lock
.
release
()
openoffice
=
OpenOffice
()
cloudooo/handler/ooo/granulator.py
View file @
a77f5599
...
...
@@ -250,9 +250,9 @@ class OOGranulator(object):
text
=
''
.
join
(
paragraph
.
itertext
())
if
TEXT_ATTRIB_STYLENAME
not
in
paragraph
.
attrib
.
keys
()
:
logger
.
error
(
"Unable to find %s attribute at paragraph %s "
%
\
(
TEXT_ATTRIB_STYLENAME
,
paragraph_id
)
)
if
TEXT_ATTRIB_STYLENAME
not
in
paragraph
.
attrib
:
logger
.
error
(
"Unable to find %s attribute at paragraph %s "
,
TEXT_ATTRIB_STYLENAME
,
paragraph_id
)
return
None
p_class
=
paragraph
.
attrib
[
TEXT_ATTRIB_STYLENAME
]
...
...
cloudooo/handler/ooo/handler.py
View file @
a77f5599
...
...
@@ -165,7 +165,7 @@ class Handler(object):
filter_list
.
append
((
destination_extension
,
service_type
,
mimemapper
.
getFilterName
(
destination_extension
,
service_type
)))
logger
.
debug
(
"Filter List: %r"
%
filter_list
)
logger
.
debug
(
"Filter List: %r"
,
filter_list
)
return
json
.
dumps
(
dict
(
doc_type_list_by_extension
=
mimemapper
.
_doc_type_list_by_extension
,
filter_list
=
filter_list
,
mimetype_by_filter_type
=
mimemapper
.
_mimetype_by_filter_type
))
...
...
@@ -177,7 +177,7 @@ class Handler(object):
"""
if
not
self
.
enable_scripting
and
kw
.
get
(
'script'
):
raise
Exception
(
"ooo: scripting is disabled"
)
logger
.
debug
(
"OooConvert: %s > %s"
%
(
self
.
source_format
,
destination_format
)
)
logger
.
debug
(
"OooConvert: %s > %s"
,
self
.
source_format
,
destination_format
)
kw
[
'source_format'
]
=
self
.
source_format
if
destination_format
:
kw
[
'destination_format'
]
=
destination_format
...
...
cloudooo/handler/ooo/monitor/request.py
View file @
a77f5599
...
...
@@ -55,8 +55,8 @@ class MonitorRequest(Monitor, Thread):
while
self
.
status_flag
:
if
self
.
openoffice
.
request
>
self
.
request_limit
:
self
.
openoffice
.
acquire
()
logger
.
debug
(
"Openoffice: %s, %s will be restarted"
%
\
self
.
openoffice
.
getAddress
())
logger
.
debug
(
"Openoffice: %s, %s will be restarted"
,
*
self
.
openoffice
.
getAddress
())
self
.
openoffice
.
restart
()
self
.
openoffice
.
release
()
sleep
(
self
.
interval
)
...
...
cloudooo/handler/ooo/monitor/sleeping_time.py
View file @
a77f5599
...
...
@@ -66,8 +66,8 @@ class MonitorSpleepingTime(Monitor, Thread):
current_time
=
time
()
if
self
.
openoffice
.
status
()
and
\
(
self
.
_touched_at
+
self
.
sleeping_time
)
<=
current_time
:
logger
.
debug
(
"Stopping OpenOffice after sleeping time of %is"
%
\
self
.
sleeping_time
)
logger
.
debug
(
"Stopping OpenOffice after sleeping time of %is"
,
self
.
sleeping_time
)
self
.
openoffice
.
acquire
()
self
.
openoffice
.
stop
()
self
.
openoffice
.
release
()
...
...
cloudooo/handler/ooo/monitor/timeout.py
View file @
a77f5599
...
...
@@ -47,14 +47,14 @@ class MonitorTimeout(Monitor, Process):
"""Start the process"""
port
=
self
.
openoffice
.
getAddress
()[
-
1
]
pid
=
self
.
openoffice
.
pid
()
logger
.
debug
(
"Monitoring OpenOffice:
Port %s, Pid: %s"
%
(
port
,
pid
)
)
logger
.
debug
(
"Monitoring OpenOffice:
port %s pid %s timeout: %s"
,
port
,
pid
,
self
.
interval
)
self
.
status_flag
=
True
sleep
(
self
.
interval
)
if
self
.
openoffice
.
isLocked
():
logger
.
debug
(
"Stop
OpenOffice - Port %s - Pid %s"
%
(
port
,
pid
)
)
logger
.
debug
(
"Stop
ing OpenOffice: port %s pid %s"
,
port
,
pid
)
self
.
openoffice
.
stop
()
def
terminate
(
self
):
"""Stop the process"""
Monitor
.
terminate
(
self
)
Process
.
terminate
(
self
)
Process
.
terminate
(
self
)
\ No newline at end of file
cloudooo/handler/ooo/tests/testOooUnoMimemapper.py
View file @
a77f5599
...
...
@@ -70,8 +70,6 @@ class TestUnoMimeMapper(HandlerTestCase):
stderr
=
PIPE
).
communicate
()
self
.
assertEqual
(
stderr
,
''
)
filter_dict
,
type_dict
=
json
.
loads
(
stdout
)
self
.
assertTrue
(
'filter_dict'
in
locals
())
self
.
assertTrue
(
'type_dict'
in
locals
())
self
.
assertNotEqual
(
filter_dict
.
get
(
'writer8'
),
None
)
self
.
assertEqual
(
type_dict
.
get
(
'writer8'
).
get
(
'Name'
),
'writer8'
)
self
.
assertNotEqual
(
filter_dict
.
get
(
'writer8'
),
None
)
...
...
@@ -91,8 +89,6 @@ class TestUnoMimeMapper(HandlerTestCase):
stderr
=
PIPE
).
communicate
()
self
.
assertEqual
(
stderr
,
''
)
filter_dict
,
type_dict
=
json
.
loads
(
stdout
)
self
.
assertTrue
(
'filter_dict'
in
locals
())
self
.
assertTrue
(
'type_dict'
in
locals
())
self
.
assertNotEqual
(
filter_dict
.
get
(
'writer8'
),
None
)
self
.
assertEqual
(
type_dict
.
get
(
'writer8'
).
get
(
'Name'
),
'writer8'
)
self
.
assertNotEqual
(
filter_dict
.
get
(
'writer8'
),
None
)
...
...
@@ -119,7 +115,7 @@ class TestUnoMimeMapper(HandlerTestCase):
stdout
=
PIPE
,
stderr
=
PIPE
).
communicate
()
self
.
assertEqual
(
stdout
,
''
)
self
.
assert
True
(
stderr
.
endswith
(
error_msg
)
,
stderr
)
self
.
assert
In
(
error_msg
,
stderr
)
openoffice
.
start
()
cloudooo/handler/pdf/handler.py
View file @
a77f5599
...
...
@@ -52,7 +52,7 @@ class Handler(object):
def
convert
(
self
,
destination_format
=
None
,
**
kw
):
""" Convert a pdf document """
# TODO: use pyPdf
logger
.
debug
(
"PDFConvert: %s > %s"
%
(
self
.
document
.
source_format
,
destination_format
)
)
logger
.
debug
(
"PDFConvert: %s > %s"
,
self
.
document
.
source_format
,
destination_format
)
output_url
=
mktemp
(
suffix
=
".%s"
%
destination_format
,
dir
=
self
.
document
.
directory_name
)
command
=
[
"pdftotext"
,
self
.
document
.
getUrl
(),
output_url
]
...
...
@@ -78,7 +78,7 @@ class Handler(object):
stderr
=
PIPE
,
close_fds
=
True
,
env
=
self
.
environment
).
communicate
()
info_list
=
filter
(
None
,
stdout
.
split
(
"
\
n
"
))
info_list
=
[
_f
for
_f
in
stdout
.
split
(
"
\
n
"
)
if
_f
]
metadata
=
{}
for
info
in
iter
(
info_list
):
info
=
info
.
split
(
":"
)
...
...
cloudooo/handler/wkhtmltopdf/handler.py
View file @
a77f5599
...
...
@@ -66,7 +66,7 @@ class Handler(object):
def
convert
(
self
,
destination_format
=
None
,
**
kw
):
"""Convert a image"""
logger
.
debug
(
"wkhtmltopdf convert: %s > %s"
%
(
self
.
file
.
source_format
,
destination_format
)
)
logger
.
debug
(
"wkhtmltopdf convert: %s > %s"
,
self
.
file
.
source_format
,
destination_format
)
output_path
=
self
.
makeTempFile
(
destination_format
)
command
=
self
.
makeWkhtmltopdfCommandList
(
self
.
convertPathToUrl
(
self
.
file
.
getUrl
()),
...
...
cloudooo/handler/x2t/handler.py
View file @
a77f5599
...
...
@@ -183,7 +183,7 @@ class Handler(object):
def
convert
(
self
,
destination_format
=
None
,
**
kw
):
""" Convert the inputed file to output as format that were informed """
source_format
=
self
.
file
.
source_format
logger
.
debug
(
"x2t convert: %s > %s"
%
(
source_format
,
destination_format
)
)
logger
.
debug
(
"x2t convert: %s > %s"
,
source_format
,
destination_format
)
# init vars and xml configuration file
in_format
=
format_code_map
[
source_format
]
...
...
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