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):
...
@@ -179,7 +179,6 @@ class DataArray(BigFile):
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
ranges
=
HTTPRangeSupport
.
parseRange
(
range
)
array
=
self
.
getArray
()
array
=
self
.
getArray
()
factor
=
array
.
nbytes
/
array
.
shape
[
0
]
if
if_range
is
not
None
:
if
if_range
is
not
None
:
# Only send ranges if the data isn't modified, otherwise send
# Only send ranges if the data isn't modified, otherwise send
...
@@ -240,9 +239,10 @@ class DataArray(BigFile):
...
@@ -240,9 +239,10 @@ class DataArray(BigFile):
RESPONSE
.
setHeader
(
'Content-Range'
,
RESPONSE
.
setHeader
(
'Content-Range'
,
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
'bytes %d-%d/%d'
%
(
start
,
end
-
1
,
self
.
getSize
()))
RESPONSE
.
setStatus
(
206
)
# Partial content
RESPONSE
.
setStatus
(
206
)
# Partial content
self
.
log
(
str
((
start
,
end
)))
# convert ranges from bytes to array indices
# convert array to bytes
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
data
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
()
RESPONSE
.
setBody
(
data
,
lock
=
True
)
else
:
else
:
boundary
=
choose_boundary
()
boundary
=
choose_boundary
()
...
@@ -260,6 +260,7 @@ class DataArray(BigFile):
...
@@ -260,6 +260,7 @@ class DataArray(BigFile):
# will only accept x-byteranges.
# will only accept x-byteranges.
draftprefix
=
(
request_range
is
not
None
)
and
'x-'
or
''
draftprefix
=
(
request_range
is
not
None
)
and
'x-'
or
''
self
.
log
(
size
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Content-Length'
,
size
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Accept-Ranges'
,
'bytes'
)
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_data_mtime
()))
RESPONSE
.
setHeader
(
'Last-Modified'
,
rfc1123_date
(
self
.
_data_mtime
()))
...
@@ -267,17 +268,19 @@ class DataArray(BigFile):
...
@@ -267,17 +268,19 @@ class DataArray(BigFile):
'multipart/%sbyteranges; boundary=%s'
%
(
'multipart/%sbyteranges; boundary=%s'
%
(
draftprefix
,
boundary
))
draftprefix
,
boundary
))
RESPONSE
.
setStatus
(
206
)
# Partial content
RESPONSE
.
setStatus
(
206
)
# Partial content
data
=
''
for
start
,
end
in
ranges
:
for
start
,
end
in
ranges
:
RESPONSE
.
write
(
'
\
r
\
n
--%s
\
r
\
n
'
%
boundary
)
data
=
'{data}
\
r
\
n
--{boundary}
\
r
\
n
'
\
RESPONSE
.
write
(
'Content-Type: %s
\
r
\
n
'
%
'Content-Type: {content_type}
\
r
\
n
'
\
self
.
content_type
)
'Content-Range: bytes {start:d}-{end:d}/{size:d}
\
r
\
n
\
r
\
n
'
\
RESPONSE
.
write
(
'{array}'
.
format
(
data
=
data
,
'Content-Range: bytes %d-%d/%d
\
r
\
n
\
r
\
n
'
%
(
boundary
=
boundary
,
start
,
end
-
1
,
self
.
getSize
()))
content_type
=
self
.
content_type
,
start
=
start
,
# convert ranges from bytes to array indices
end
=
end
-
1
,
RESPONSE
.
write
(
array
[
start
/
factor
:
end
/
factor
].
tobytes
())
size
=
self
.
getSize
(),
array
=
array
[:].
view
(
'<b'
).
reshape
((
-
1
,))[
start
:
end
].
tobytes
())
RESPONSE
.
write
(
'
\
r
\
n
--%s--
\
r
\
n
'
%
boundary
)
data
=
'{}
\
r
\
n
--{}--
\
r
\
n
'
.
format
(
data
,
boundary
)
RESPONSE
.
setBody
(
data
,
lock
=
True
)
return
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 @@
...
@@ -46,9 +46,9 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<tuple>
<string>
W:13
3
, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:13
9
, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:1
65
, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:1
71
, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:19
2
, 10: No exception type(s) specified (bare-except)
</string>
<string>
W:19
7
, 10: No exception type(s) specified (bare-except)
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</item>
...
@@ -104,11 +104,13 @@
...
@@ -104,11 +104,13 @@
</record>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
</pickle>
<pickle>
<pickle>
<tuple>
<dictionary>
<none/>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<list>
<dictionary>
<dictionary>
<item>
<item>
...
@@ -121,7 +123,9 @@
...
@@ -121,7 +123,9 @@
</item>
</item>
</dictionary>
</dictionary>
</list>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</pickle>
</record>
</record>
</ZopeData>
</ZopeData>
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
35447649
...
@@ -33,6 +33,10 @@ import numpy as np
...
@@ -33,6 +33,10 @@ import numpy as np
import
string
import
string
import
random
import
random
import
urllib
import
urllib
import
requests
import
StringIO
as
st
from
Products.ERP5Type.Log
import
log
def
getRandomString
():
def
getRandomString
():
return
'test_%s'
%
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
\
return
'test_%s'
%
''
.
join
([
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
\
...
@@ -230,6 +234,18 @@ class Test(ERP5TypeTestCase):
...
@@ -230,6 +234,18 @@ class Test(ERP5TypeTestCase):
np
.
array_equal
(
data_array
.
getArraySlice
(
0
,
100
),
\
np
.
array_equal
(
data_array
.
getArraySlice
(
0
,
100
),
\
new_array
[:
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
):
def
test_04_DataBucket
(
self
):
"""
"""
Test data bucket
Test data bucket
...
...
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.xml
View file @
35447649
...
@@ -46,7 +46,8 @@
...
@@ -46,7 +46,8 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<value>
<tuple>
<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>
</tuple>
</value>
</value>
</item>
</item>
...
@@ -102,11 +103,13 @@
...
@@ -102,11 +103,13 @@
</record>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
patches.WorkflowTool
"
/>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.
Workflow
"
/>
</pickle>
</pickle>
<pickle>
<pickle>
<tuple>
<dictionary>
<none/>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<list>
<dictionary>
<dictionary>
<item>
<item>
...
@@ -119,7 +122,9 @@
...
@@ -119,7 +122,9 @@
</item>
</item>
</dictionary>
</dictionary>
</list>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</pickle>
</record>
</record>
</ZopeData>
</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