Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ekaterina
wendelin
Commits
35447649
Commit
35447649
authored
Feb 03, 2020
by
Ekaterina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin: fix byte size of data array and add test
parent
f27a9a0b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
54 deletions
+82
-54
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+21
-18
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.xml
...emplateItem/portal_components/document.erp5.DataArray.xml
+23
-19
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+16
-0
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.xml
...TemplateItem/portal_components/test.erp5.testWendelin.xml
+22
-17
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
35447649
...
...
@@ -179,7 +179,6 @@ class DataArray(BigFile):
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
array
=
self
.
getArray
()
factor
=
array
.
nbytes
/
array
.
shape
[
0
]
if
if_range
is
not
None
:
# Only send ranges if the data isn't modified, otherwise send
...
...
@@ -240,9 +239,10 @@ class DataArray(BigFile):
RESPONSE
.
setHeader
(
'Content-Range'
,
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
RESPONSE
.
setStatus
(
206
)
# Partial content
# convert ranges from bytes to array indices
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
self
.
log
(
str
((
start
,
end
)))
# convert array to bytes
data
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
()
RESPONSE
.
setBody
(
data
,
lock
=
True
)
else
:
boundary
=
choose_boundary
()
...
...
@@ -260,6 +260,7 @@ class DataArray(BigFile):
# will only accept x-byteranges.
draftprefix
=
(
request_range
is
not
None
)
and
'x-'
or
''
self
.
log
(
size
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_data_mtime
()))
...
...
@@ -267,17 +268,19 @@ class DataArray(BigFile):
'multipart/%sbyteranges; boundary=%s'
%
(
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
''
for
start
,
end
in
ranges
:
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
self
.
content_type
)
RESPONSE
.
write
(
'Content-Range: bytes %d-%d/%d
\
r
\
n
\
r
\
n
'
%
(
start
,
end
-
1
,
self
.
getSize
()))
# convert ranges from bytes to array indices
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
RESPONSE
.
write
(
'
\
r
\
n
--%s--
\
r
\
n
'
%
boundary
)
data
=
'{data}
\
r
\
n
--{boundary}
\
r
\
n
'
\
'Content-Type: {content_type}
\
r
\
n
'
\
'Content-Range: bytes {start:d}-{end:d}/{size:d}
\
r
\
n
\
r
\
n
'
\
'{array}'
.
format
(
data
=
data
,
boundary
=
boundary
,
content_type
=
self
.
content_type
,
start
=
start
,
end
=
end
-
1
,
size
=
self
.
getSize
(),
array
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
())
data
=
'{}
\
r
\
n
--{}--
\
r
\
n
'
.
format
(
data
,
boundary
)
RESPONSE
.
setBody
(
data
,
lock
=
True
)
return
True
\ No newline at end of file
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.xml
View file @
35447649
...
...
@@ -46,9 +46,9 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W:13
3
, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:1
65
, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:19
2
, 10: No exception type(s) specified (bare-except)
</string>
<string>
W:13
9
, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:1
71
, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:19
7
, 10: No exception type(s) specified (bare-except)
</string>
</tuple>
</value>
</item>
...
...
@@ -104,11 +104,13 @@
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
...
...
@@ -121,7 +123,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
35447649
...
...
@@ -33,6 +33,10 @@ import numpy as np
import
string
import
random
import
urllib
import
requests
import
StringIO
as
st
from
Products.ERP5Type.Log
import
log
def
getRandomString
():
return
'test_%s'
%
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
\
...
...
@@ -230,6 +234,18 @@ class Test(ERP5TypeTestCase):
np
.
array_equal
(
data_array
.
getArraySlice
(
0
,
100
),
\
new_array
[:
100
]))
# test get array by request if exists and chech that length is correct
data_arrays
=
self
.
portal
.
data_array_module
.
objectValues
()
spectrum_array
=
[
o
for
o
in
data_arrays
if
o
.
getTitle
()
==
'pydata-spectrum2'
]
if
len
(
spectrum_array
)
==
1
:
spectrum_array_id
=
spectrum_array
[
0
].
getId
()
headers
=
{
'Range'
:
'bytes=0-'
}
url
=
'https://softinst127199.host.vifib.net/erp5/web_site_module/pydata_runner/hateoas/data_array_module/'
+
spectrum_array_id
response
=
requests
.
get
(
url
,
auth
=
(
'zope'
,
'aybvtnkf'
),
headers
=
headers
)
response_string
=
st
.
StringIO
()
response_string
.
write
(
response
.
content
)
self
.
assertEquals
(
response_string
.
len
,
spectrum_array
[
0
].
getSize
())
def
test_04_DataBucket
(
self
):
"""
Test data bucket
...
...
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.xml
View file @
35447649
...
...
@@ -46,7 +46,8 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 63, 35: Unused variable \'data_product\' (unused-variable)
</string>
<string>
W: 67, 35: Unused variable \'data_product\' (unused-variable)
</string>
<string>
W: 39, 0: Unused log imported from Products.ERP5Type.Log (unused-import)
</string>
</tuple>
</value>
</item>
...
...
@@ -102,11 +103,13 @@
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
...
...
@@ -119,7 +122,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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