Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e98b628f
authored
Jul 20, 2014
by
Őry Máté
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: refactor get_request_arguments
parent
7f451e3e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
20 deletions
+10
-20
circle/dashboard/store_api.py
+10
-20
No files found.
circle/dashboard/store_api.py
View file @
e98b628f
...
@@ -19,22 +19,14 @@ def get_host():
...
@@ -19,22 +19,14 @@ def get_host():
return
settings
.
STORE_URL
return
settings
.
STORE_URL
def
get_request_arguments
(
ssl_auth
,
basic_auth
):
def
get_request_arguments
():
args
=
{
args
=
{
'verify'
:
settings
.
STORE_VERIFY_SSL
}
'verify'
:
settings
.
STORE_VERIFY_SSL
,
'cert'
:
(
settings
.
STORE_CLIENT_CERT
,
settings
.
STORE_CLIENT_KEY
),
if
settings
.
STORE_SSL_AUTH
:
'auth'
:
(
settings
.
STORE_CLIENT_USER
,
settings
.
STORE_CLIENT_PASSWORD
),
args
[
'cert'
]
=
(
settings
.
STORE_CLIENT_CERT
,
settings
.
STORE_CLIENT_KEY
)
}
if
settings
.
STORE_BASIC_AUTH
:
if
ssl_auth
and
basic_auth
:
args
[
'auth'
]
=
(
settings
.
STORE_CLIENT_USER
,
pass
settings
.
STORE_CLIENT_PASSWORD
)
elif
ssl_auth
:
del
args
[
'auth'
]
elif
basic_auth
:
del
args
[
'cert'
]
else
:
del
args
[
'cert'
]
del
args
[
'auth'
]
return
args
return
args
...
@@ -42,8 +34,7 @@ def post_request(url, payload, timeout=None):
...
@@ -42,8 +34,7 @@ def post_request(url, payload, timeout=None):
try
:
try
:
headers
=
{
'content-type'
:
'application/json'
}
headers
=
{
'content-type'
:
'application/json'
}
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
timeout
=
timeout
,
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
timeout
=
timeout
,
**
get_request_arguments
(
settings
.
STORE_SSL_AUTH
,
**
get_request_arguments
())
settings
.
STORE_BASIC_AUTH
))
return
r
return
r
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Error in store POST:
%
s"
%
e
)
logger
.
error
(
"Error in store POST:
%
s"
%
e
)
...
@@ -57,8 +48,7 @@ def get_request(url, timeout=None):
...
@@ -57,8 +48,7 @@ def get_request(url, timeout=None):
try
:
try
:
headers
=
{
'content-type'
:
'application/json'
}
headers
=
{
'content-type'
:
'application/json'
}
r
=
requests
.
get
(
url
,
headers
=
headers
,
timeout
=
timeout
,
r
=
requests
.
get
(
url
,
headers
=
headers
,
timeout
=
timeout
,
**
get_request_arguments
(
settings
.
STORE_SSL_AUTH
,
**
get_request_arguments
())
settings
.
STORE_BASIC_AUTH
))
return
r
return
r
except
Exception
as
e
:
except
Exception
as
e
:
logger
.
error
(
"Error in store GET:
%
s"
%
e
)
logger
.
error
(
"Error in store GET:
%
s"
%
e
)
...
...
Bach Dániel
@bachdaniel
commented
Jul 20, 2014
Owner
:trollface:
:trollface:
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