Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ebulk
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
nexedi
ebulk
Commits
9ee153ad
Commit
9ee153ad
authored
Jul 12, 2019
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
solving http request issue due to frontend ciphers
- see
nexedi/ebulk#1
parent
15ea30c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
53 deletions
+52
-53
ebulk
ebulk
+2
-2
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/wendelin_client.rb
...mbulk-wendelin-dataset-tool/lib/embulk/wendelin_client.rb
+50
-51
No files found.
ebulk
View file @
9ee153ad
#! /usr/bin/env bash
DOWN_URL
=
'https://softinst104003.host.vifib.net/erp5/'
ING_URL
=
'https://softinst104003.host.vifib.net/erp5/portal_ingestion_policies/wendelin_embulk'
DOWN_URL
=
'https://softinst104003.
l
host.vifib.net/erp5/'
ING_URL
=
'https://softinst104003.
l
host.vifib.net/erp5/portal_ingestion_policies/wendelin_embulk'
EBULK_VERSION
=
"0.9.7"
EBULK_DATA_PATH
=
~/.ebulk
...
...
ebulk-data/embulk-wendelin-dataset-tool/lib/embulk/wendelin_client.rb
View file @
9ee153ad
...
...
@@ -36,7 +36,7 @@ class WendelinClient
checkReferenceChars
(
reference
)
uri
=
URI
(
URI
.
escape
(
"
#{
@erp5_url
}
/ingestionReferenceExists?reference=
#{
reference
}
"
))
begin
res
=
open
(
uri
,
http_basic_authentication:
[
@user
,
@password
]).
read
res
ponse
=
handleRequest
(
uri
)
rescue
Exception
=>
e
@logger
.
error
(
"An error occurred while checking if reference exists: "
+
e
.
to_s
)
@logger
.
error
(
e
.
backtrace
)
...
...
@@ -45,7 +45,7 @@ class WendelinClient
end
return
FALSE
else
return
res
.
to_s
==
'TRUE'
return
res
ponse
.
to_s
==
'TRUE'
end
end
...
...
@@ -78,8 +78,8 @@ class WendelinClient
else
@logger
.
info
(
"Increasing dataset version"
)
begin
uri
=
URI
(
URI
.
escape
(
"
#{
@erp5_url
}
/ERP5Site_increaseDatasetVersion?reference=
#{
reference
}
"
))
res
=
open
(
uri
,
http_basic_authentication:
[
@user
,
@password
]).
read
uri
=
URI
(
URI
.
escape
(
"
#{
@erp5_url
}
/ERP5Site_increaseDatasetVersion?reference=
#{
reference
}
"
))
response
=
handleRequest
(
uri
)
rescue
Exception
=>
e
@logger
.
error
(
"An error occurred while increasing dataset version: "
+
e
.
to_s
)
@logger
.
error
(
e
.
backtrace
)
...
...
@@ -151,7 +151,7 @@ class WendelinClient
n_retry
=
0
while
!
success
&&
n_retry
<
10
begin
res
=
open
(
uri
,
http_basic_authentication:
[
@user
,
@password
])
{
res
=
open
(
uri
,
http_basic_authentication:
[
@user
,
@password
]
,
ssl_verify_mode:
OpenSSL
::
SSL
::
VERIFY_NONE
)
{
|
content
|
chunk
=
content
.
read
()
if
chunk
.
nil?
||
chunk
.
empty?
...
...
@@ -196,54 +196,53 @@ class WendelinClient
private
def
handleRequest
(
uri
,
reference
=
nil
,
data_chunk
=
nil
)
req
=
Net
::
HTTP
::
Post
.
new
(
uri
)
req
.
basic_auth
@user
,
@password
if
data_chunk
!=
nil
@logger
.
info
(
"Setting request form data..."
,
print
=
TRUE
)
if
reference
!=
nil
begin
req
.
set_form_data
(
'data_chunk'
=>
data_chunk
)
rescue
java
.
lang
.
OutOfMemoryError
@logger
.
logOutOfMemoryError
(
reference
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MEMORY_ERROR
}
rescue
Exception
=>
e
@logger
.
error
(
"Error setting form data: "
+
e
.
to_s
,
print
=
TRUE
)
@logger
.
error
(
e
.
backtrace
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_EXCEPTION
}
end
@logger
.
info
(
"Sending record:'
#{
reference
}
'..."
,
print
=
TRUE
)
if
reference
!=
nil
end
req
=
Net
::
HTTP
::
Post
.
new
(
uri
)
req
.
basic_auth
@user
,
@password
if
data_chunk
!=
nil
@logger
.
info
(
"Setting request form data..."
,
print
=
TRUE
)
if
reference
!=
nil
begin
res
=
Net
::
HTTP
.
start
(
uri
.
hostname
,
uri
.
port
,
:use_ssl
=>
(
uri
.
scheme
==
'https'
),
:verify_mode
=>
OpenSSL
::
SSL
::
VERIFY_NONE
,
:ssl_timeout
=>
300
,
:open_timeout
=>
300
,
:read_timeout
=>
300
,
)
do
|
http
|
http
.
request
(
req
)
end
req
.
set_form_data
(
'data_chunk'
=>
data_chunk
)
rescue
java
.
lang
.
OutOfMemoryError
@logger
.
logOutOfMemoryError
(
reference
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MEMORY_ERROR
}
rescue
Exception
=>
e
@logger
.
error
(
"HTTP ERROR: "
+
e
.
to_s
,
print
=
TRUE
)
@logger
.
error
(
e
.
backtrace
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_EXCEPTION
}
@logger
.
error
(
"Error setting form data: "
+
e
.
to_s
,
print
=
TRUE
)
@logger
.
error
(
e
.
backtrace
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_EXCEPTION
}
end
@logger
.
info
(
"Sending record:'
#{
reference
}
'..."
,
print
=
TRUE
)
if
reference
!=
nil
end
begin
res
=
Net
::
HTTP
.
start
(
uri
.
hostname
,
uri
.
port
,
:use_ssl
=>
(
uri
.
scheme
==
'https'
),
:verify_mode
=>
OpenSSL
::
SSL
::
VERIFY_NONE
,
:ssl_timeout
=>
300
,
:open_timeout
=>
300
,
:read_timeout
=>
300
,
)
do
|
http
|
http
.
request
(
req
)
end
rescue
Exception
=>
e
@logger
.
error
(
"HTTP ERROR: "
+
e
.
to_s
,
print
=
TRUE
)
@logger
.
error
(
e
.
backtrace
)
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_EXCEPTION
}
else
if
res
.
kind_of?
(
Net
::
HTTPSuccess
)
# res.code is 2XX
@logger
.
info
(
"Done"
)
return
{
"success"
=>
TRUE
,
"message"
=>
res
.
body
}
else
if
res
.
kind_of?
(
Net
::
HTTPSuccess
)
# res.code is 2XX
@logger
.
info
(
"Done"
)
return
{
"success"
=>
TRUE
,
"message"
=>
res
.
body
}
else
@logger
.
error
(
"HTTP FAIL - code:
#{
res
.
code
}
"
,
print
=
TRUE
)
if
res
.
code
==
'500'
or
res
.
code
==
'502'
or
res
.
code
==
'503'
@logger
.
error
(
HTTP_MESSAGE_5XX
,
print
=
TRUE
)
elsif
res
.
code
==
'401'
@logger
.
error
(
HTTP_MESSAGE_401
,
print
=
TRUE
)
@logger
.
abortExecution
()
elsif
res
.
code
==
'400'
@logger
.
error
(
HTTP_MESSAGE_400
,
print
=
TRUE
)
@logger
.
abortExecution
()
else
@logger
.
error
(
HTTP_MESSAGE_OTHER
,
print
=
TRUE
)
end
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_NOT_2XX
}
end
end
@logger
.
error
(
"HTTP FAIL - code:
#{
res
.
code
}
"
,
print
=
TRUE
)
if
res
.
code
==
'500'
or
res
.
code
==
'502'
or
res
.
code
==
'503'
@logger
.
error
(
HTTP_MESSAGE_5XX
,
print
=
TRUE
)
elsif
res
.
code
==
'401'
@logger
.
error
(
HTTP_MESSAGE_401
,
print
=
TRUE
)
@logger
.
abortExecution
()
elsif
res
.
code
==
'400'
@logger
.
error
(
HTTP_MESSAGE_400
,
print
=
TRUE
)
@logger
.
abortExecution
()
else
@logger
.
error
(
HTTP_MESSAGE_OTHER
,
print
=
TRUE
)
end
return
{
"success"
=>
FALSE
,
"message"
=>
HTTP_MESSAGE_NOT_2XX
}
end
end
end
end
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