Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
141
Merge Requests
141
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
609481b8
Commit
609481b8
authored
Oct 13, 2022
by
Kazuhiko Shiozaki
Committed by
Jérome Perrin
May 15, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py2/py3: str.decode('base64') and bytes.encode('base64') don't exist in Python 3.
parent
c337990d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
9 deletions
+17
-9
bt5/erp5_base/ModuleComponentTemplateItem/portal_components/module.erp5.ImageUtil.py
...ntTemplateItem/portal_components/module.erp5.ImageUtil.py
+3
-1
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/RequirementDocument_viewDetailedReportAsOdt.oot
...5_project/RequirementDocument_viewDetailedReportAsOdt.oot
+1
-1
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.py
...tTemplateItem/portal_components/test.erp5.testRunMyDoc.py
+2
-1
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/ERP5Site_migrateData.py
...eItem/portal_skins/erp5_hr_record/ERP5Site_migrateData.py
+2
-1
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/ExpenseRecord_updateRelatedTicket.py
...skins/erp5_hr_record/ExpenseRecord_updateRelatedTicket.py
+2
-1
bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_uploadScreenshot.py
.../portal_skins/erp5_ui_test_core/Zuite_uploadScreenshot.py
+2
-1
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
+3
-2
product/ERP5Form/GadgetField.py
product/ERP5Form/GadgetField.py
+2
-1
No files found.
bt5/erp5_base/ModuleComponentTemplateItem/portal_components/module.erp5.ImageUtil.py
View file @
609481b8
...
...
@@ -29,6 +29,8 @@
import
six.moves.urllib.request
from
lxml
import
etree
from
erp5.component.document.Document
import
ConversionError
import
base64
from
Products.ERP5Type.Utils
import
bytes2str
SVG_DEFAULT_NAMESPACE
=
"http://www.w3.org/2000/svg"
...
...
@@ -38,7 +40,7 @@ def getDataURI(url):
except
Exception
as
e
:
raise
ConversionError
(
"Error to transform url (%s) into data uri. ERROR = %s"
%
(
url
,
Exception
(
e
)))
return
'data:%s;base64,%s'
%
(
data
.
info
()[
"content-type"
],
data
.
read
().
encode
(
"base64"
).
replace
(
'
\
n
'
,
""
))
bytes2str
(
base64
.
b64encode
(
data
.
read
())
).
replace
(
'
\
n
'
,
""
))
def
transformUrlToDataURI
(
content
):
if
content
is
None
or
len
(
content
)
==
0
:
...
...
bt5/erp5_project/SkinTemplateItem/portal_skins/erp5_project/RequirementDocument_viewDetailedReportAsOdt.oot
View file @
609481b8
...
...
@@ -104,7 +104,7 @@
<draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="as-char" svg:width="3in" draw:z-index="0"
tal:attributes="draw:name python:'embedded_erp5_image_%s' % image.getId();
svg:height python: '%1.1fin' % (3.0 * image.getHeight() / (image.getWidth() or 1.0))">
<draw:image><office:binary-data tal:content="python:
str(image.convert(format='png')[1]).encode('base64'
)" /></draw:image>
<draw:image><office:binary-data tal:content="python:
modules['base64'].b64encode(image.convert(format='png')[1]
)" /></draw:image>
</draw:frame>
</text:p>
</tal:block>
...
...
bt5/erp5_run_my_doc/TestTemplateItem/portal_components/test.erp5.testRunMyDoc.py
View file @
609481b8
...
...
@@ -29,6 +29,7 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
erp5.component.test.testDms
import
makeFileUpload
from
time
import
time
import
base64
class
TestRunMyDoc
(
ERP5TypeTestCase
):
"""
...
...
@@ -132,7 +133,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
self
.
tic
()
# The right image were updated.
image_upload
.
seek
(
0
)
self
.
assertEqual
(
image_page_2
.
getData
(),
image_upload
.
read
().
decode
(
"base64"
))
self
.
assertEqual
(
image_page_2
.
getData
(),
base64
.
b64decode
(
image_upload
.
read
()
))
self
.
assertEqual
(
image_page_2
.
getFilename
(),
image_reference
+
'.png'
)
self
.
assertEqual
(
image_page
.
getData
(),
''
)
...
...
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/ERP5Site_migrateData.py
View file @
609481b8
import
base64
portal
=
context
.
getPortalObject
()
# Update Photos
...
...
@@ -9,7 +10,7 @@ for record in portal.expense_record_module.objectValues(portal_type="Expense Rec
if
ticket
.
getReference
():
photo_data
=
photo_data
.
split
(
","
)[
1
]
image
=
portal
.
portal_contributions
.
newContent
(
data
=
photo_data
.
decode
(
'base64'
),
data
=
base64
.
b64decode
(
photo_data
),
reference
=
ticket
.
getReference
()
+
"-justificatif"
,
title
=
ticket
.
getReference
()
+
" Justificatif"
,
description
=
ticket
.
getDescription
(),
...
...
bt5/erp5_travel_expense/SkinTemplateItem/portal_skins/erp5_hr_record/ExpenseRecord_updateRelatedTicket.py
View file @
609481b8
import
base64
import
json
portal
=
context
.
getPortalObject
()
record
=
context
...
...
@@ -80,7 +81,7 @@ if photo_data:
if
"application/pdf"
in
photo_type
:
filename
=
"tmp.pdf"
image
=
portal
.
portal_contributions
.
newContent
(
data
=
photo_data
.
decode
(
'base64'
),
data
=
base64
.
b64decode
(
photo_data
),
reference
=
ticket
.
getReference
()
+
"-justificatif"
,
title
=
ticket
.
getReference
()
+
" Justificatif"
,
description
=
ticket
.
getDescription
(),
...
...
bt5/erp5_ui_test_core/SkinTemplateItem/portal_skins/erp5_ui_test_core/Zuite_uploadScreenshot.py
View file @
609481b8
"""
Upload a screenshot taken by the test to ERP5
"""
import
base64
data_uri
=
context
.
REQUEST
.
form
.
get
(
'data_uri'
,
'default'
)
image_module
=
getattr
(
context
,
"image_module"
,
None
)
...
...
@@ -16,7 +17,7 @@ if image is None or image.getPortalType() != "Image":
image
.
setContentType
(
'image/png'
)
data_text
=
data_uri
.
read
()
data
=
data_text
.
decode
(
'base64'
)
data
=
base64
.
b64decode
(
data_text
)
image
.
edit
(
data
=
data
,
filename
=
str
(
image_reference
)
+
'.png'
,
...
...
product/ERP5/tests/testBusinessTemplateTwoFileExport.py
View file @
609481b8
...
...
@@ -30,6 +30,7 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import \
ERP5TypeTestCase
,
immediateCompilation
from
Products.PageTemplates.ZopePageTemplate
import
ZopePageTemplate
from
runUnitTest
import
tests_home
import
base64
import
glob
import
shutil
import
os
...
...
@@ -280,9 +281,9 @@ class TestBusinessTemplateTwoFileExport(ERP5TypeTestCase):
self
.
assertEqual
(
image_page
.
getProperty
(
property_id
),
property_value
)
png_data
=
"""iVBORw0KGgoAAAANSUhEUgAAAAUA
png_data
=
base64
.
b64decode
(
b
"""iVBORw0KGgoAAAANSUhEUgAAAAUA
AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
9TXL0Y4OHwAAAABJRU5ErkJggg=="""
.
decode
(
"base64"
)
9TXL0Y4OHwAAAABJRU5ErkJggg=="""
)
def
test_twoFileImportExportForImageIdentifyingTypeByContent
(
self
):
"""
...
...
product/ERP5Form/GadgetField.py
View file @
609481b8
...
...
@@ -7,6 +7,7 @@ from six.moves import cStringIO as StringIO
from
json
import
dumps
from
Acquisition
import
aq_base
from
six.moves.urllib.parse
import
urljoin
import
base64
class
GadgetWidget
(
Widget
.
Widget
):
"""
...
...
@@ -150,7 +151,7 @@ class GadgetFieldValidator(Validator.Validator):
if
value
is
not
None
:
if
field
.
get_value
(
'data_url'
):
value
=
value
.
split
(
","
)[
1
]
return
StringIO
(
value
.
decode
(
'base64'
))
return
StringIO
(
base64
.
b64decode
(
value
))
return
value
...
...
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