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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
cloudooo
Commits
5ed8286e
Commit
5ed8286e
authored
Nov 25, 2016
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
logging
parent
574a94cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
cloudooo/manager.py
cloudooo/manager.py
+24
-8
No files found.
cloudooo/manager.py
View file @
5ed8286e
...
@@ -115,18 +115,24 @@ class Manager(object):
...
@@ -115,18 +115,24 @@ class Manager(object):
zip -- Boolean Attribute. If true, returns the file in the form of a
zip -- Boolean Attribute. If true, returns the file in the form of a
zip archive
zip archive
"""
"""
self
.
kw
[
'zip'
]
=
zip
log
(
"TRISTAN convertFile %r - %r"
%
(
source_format
,
destination_format
))
self
.
kw
[
'refresh'
]
=
refresh
try
:
handler_class
=
getHandlerClass
(
source_format
,
self
.
kw
[
'zip'
]
=
zip
self
.
kw
[
'refresh'
]
=
refresh
handler_class
=
getHandlerClass
(
source_format
,
destination_format
,
destination_format
,
self
.
mimetype_registry
,
self
.
mimetype_registry
,
self
.
handler_dict
)
self
.
handler_dict
)
handler
=
handler_class
(
self
.
_path_tmp_dir
,
handler
=
handler_class
(
self
.
_path_tmp_dir
,
decodestring
(
file
),
decodestring
(
file
),
source_format
,
source_format
,
**
self
.
kw
)
**
self
.
kw
)
decode_data
=
handler
.
convert
(
destination_format
,
**
conversion_kw
)
decode_data
=
handler
.
convert
(
destination_format
,
**
conversion_kw
)
return
encodestring
(
decode_data
)
return
encodestring
(
decode_data
)
except
Exception
,
e
:
import
traceback
log
(
"TRISTAN convertFile - %s"
%
(
traceback
.
format_exc
(),))
raise
e
def
updateFileMetadata
(
self
,
file
,
source_format
,
metadata_dict
):
def
updateFileMetadata
(
self
,
file
,
source_format
,
metadata_dict
):
"""Receives the string of document and a dict with metadatas. The metadata
"""Receives the string of document and a dict with metadatas. The metadata
...
@@ -136,6 +142,7 @@ class Manager(object):
...
@@ -136,6 +142,7 @@ class Manager(object):
{"title":"abc","description":...})
{"title":"abc","description":...})
return encodestring(document_with_metadata)
return encodestring(document_with_metadata)
"""
"""
log
(
"TRISTAN updateFileMetadata %r"
%
(
source_format
,))
handler_class
=
getHandlerClass
(
source_format
,
handler_class
=
getHandlerClass
(
source_format
,
None
,
None
,
self
.
mimetype_registry
,
self
.
mimetype_registry
,
...
@@ -163,6 +170,7 @@ class Manager(object):
...
@@ -163,6 +170,7 @@ class Manager(object):
Note that all keys of the dictionary have the first word in uppercase.
Note that all keys of the dictionary have the first word in uppercase.
"""
"""
log
(
"TRISTAN getFileMetadataItemList %r"
%
(
source_format
,))
handler_class
=
getHandlerClass
(
source_format
,
handler_class
=
getHandlerClass
(
source_format
,
None
,
None
,
self
.
mimetype_registry
,
self
.
mimetype_registry
,
...
@@ -190,6 +198,7 @@ class Manager(object):
...
@@ -190,6 +198,7 @@ class Manager(object):
if
not
mimetype
:
if
not
mimetype
:
if
extension
:
if
extension
:
mimetype
,
_
=
BBB_guess_type
(
"a."
+
extension
)
mimetype
,
_
=
BBB_guess_type
(
"a."
+
extension
)
log
(
"TRISTAN getAllowedExtensionList guessing type of %r -> %r"
%
(
extension
,
mimetype
))
elif
document_type
:
elif
document_type
:
# BBB no other choice than to ask ooo.mimemapper
# BBB no other choice than to ask ooo.mimemapper
return
mimemapper
.
getAllowedExtensionList
(
document_type
=
document_type
)
return
mimemapper
.
getAllowedExtensionList
(
document_type
=
document_type
)
...
@@ -199,8 +208,10 @@ class Manager(object):
...
@@ -199,8 +208,10 @@ class Manager(object):
ext
=
BBB_guess_extension
(
content_type
,
title
)
ext
=
BBB_guess_extension
(
content_type
,
title
)
if
ext
:
if
ext
:
allowed_extension_set
.
add
((
ext
.
lstrip
(
'.'
),
title
))
allowed_extension_set
.
add
((
ext
.
lstrip
(
'.'
),
title
))
log
(
"TRISTAN getAllowedExtensionList for %r -> %r"
%
(
mimetype
,
list
(
allowed_extension_set
)))
return
list
(
allowed_extension_set
)
or
[(
''
,
''
)]
return
list
(
allowed_extension_set
)
or
[(
''
,
''
)]
else
:
else
:
log
(
"TRISTAN getAllowedExtensionList for / -> %r"
%
(
list
(
allowed_extension_set
),))
return
[(
''
,
''
)]
return
[(
''
,
''
)]
def
getAllowedConversionFormatList
(
self
,
source_mimetype
):
def
getAllowedConversionFormatList
(
self
,
source_mimetype
):
...
@@ -239,6 +250,7 @@ class Manager(object):
...
@@ -239,6 +250,7 @@ class Manager(object):
output_mimetype_set
.
add
(
output_mimetype
)
output_mimetype_set
.
add
(
output_mimetype
)
break
break
log
(
"TRISTAN getAllowedConversionFormatList for %r -> %r"
%
(
source_mimetype
,
list
(
output_mimetype_set
)))
return
list
(
output_mimetype_set
)
return
list
(
output_mimetype_set
)
def
run_convert
(
self
,
filename
=
''
,
data
=
None
,
meta
=
None
,
extension
=
None
,
def
run_convert
(
self
,
filename
=
''
,
data
=
None
,
meta
=
None
,
extension
=
None
,
...
@@ -248,6 +260,7 @@ class Manager(object):
...
@@ -248,6 +260,7 @@ class Manager(object):
This is a Backwards compatibility provided for ERP5 Project, in order to
This is a Backwards compatibility provided for ERP5 Project, in order to
keep compatibility with OpenOffice.org Daemon.
keep compatibility with OpenOffice.org Daemon.
"""
"""
log
(
"TRISTAN run_convert from %r to %r"
%
(
orig_format
,
extension
))
if
not
extension
:
if
not
extension
:
extension
=
filename
.
split
(
'.'
)[
-
1
]
extension
=
filename
.
split
(
'.'
)[
-
1
]
try
:
try
:
...
@@ -273,6 +286,7 @@ class Manager(object):
...
@@ -273,6 +286,7 @@ class Manager(object):
This is a Backwards compatibility provided for ERP5 Project, in order to
This is a Backwards compatibility provided for ERP5 Project, in order to
keep compatibility with OpenOffice.org Daemon.
keep compatibility with OpenOffice.org Daemon.
"""
"""
log
(
"TRISTAN run_setmetadata from %r to %r"
%
(
orig_format
,
extension
))
if
not
extension
:
if
not
extension
:
extension
=
filename
.
split
(
'.'
)[
-
1
]
extension
=
filename
.
split
(
'.'
)[
-
1
]
response_dict
=
{}
response_dict
=
{}
...
@@ -289,6 +303,7 @@ class Manager(object):
...
@@ -289,6 +303,7 @@ class Manager(object):
This is a Backwards compatibility provided for ERP5 Project, in order to
This is a Backwards compatibility provided for ERP5 Project, in order to
keep compatibility with OpenOffice.org Daemon.
keep compatibility with OpenOffice.org Daemon.
"""
"""
log
(
"TRISTAN run_getmetadata from %r to %r"
%
(
orig_format
,
extension
))
if
not
extension
:
if
not
extension
:
extension
=
filename
.
split
(
'.'
)[
-
1
]
extension
=
filename
.
split
(
'.'
)[
-
1
]
response_dict
=
{}
response_dict
=
{}
...
@@ -308,6 +323,7 @@ class Manager(object):
...
@@ -308,6 +323,7 @@ class Manager(object):
This is a Backwards compatibility provided for ERP5 Project, in order
This is a Backwards compatibility provided for ERP5 Project, in order
to keep compatibility with OpenOffice.org Daemon.
to keep compatibility with OpenOffice.org Daemon.
"""
"""
log
(
"TRISTAN run_generate from %r to %r"
%
(
orig_format
,
extension
))
# calculate original extension required by convertFile from
# calculate original extension required by convertFile from
# given content_type (orig_format)
# given content_type (orig_format)
original_extension
=
BBB_guess_extension
(
orig_format
).
strip
(
'.'
)
original_extension
=
BBB_guess_extension
(
orig_format
).
strip
(
'.'
)
...
@@ -348,7 +364,7 @@ class Manager(object):
...
@@ -348,7 +364,7 @@ class Manager(object):
This is a Backwards compatibility provided for ERP5 Project, in order to
This is a Backwards compatibility provided for ERP5 Project, in order to
keep compatibility with OpenOffice.org Daemon.
keep compatibility with OpenOffice.org Daemon.
"""
"""
#log("TRISTAN atil"
)
log
(
"TRISTAN getAllowedTargetItemList of %r"
%
(
content_type
,)
)
response_dict
=
{}
response_dict
=
{}
try
:
try
:
mimetype_list
=
self
.
getAllowedConversionFormatList
(
content_type
)
mimetype_list
=
self
.
getAllowedConversionFormatList
(
content_type
)
...
@@ -362,7 +378,7 @@ class Manager(object):
...
@@ -362,7 +378,7 @@ class Manager(object):
except
Exception
,
e
:
except
Exception
,
e
:
logger
.
error
(
e
)
logger
.
error
(
e
)
import
traceback
import
traceback
log
(
"TRISTAN %s"
%
traceback
.
format_exc
())
log
(
"TRISTAN
getAllowedTargetItemList
%s"
%
traceback
.
format_exc
())
return
(
402
,
{},
e
.
args
[
0
])
return
(
402
,
{},
e
.
args
[
0
])
def
_getOOGranulator
(
self
,
data
,
source_format
=
"odt"
):
def
_getOOGranulator
(
self
,
data
,
source_format
=
"odt"
):
...
...
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