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
a9a27ccc
authored
Jul 09, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: dummy error handling for store
parent
2314ab88
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
59 deletions
+75
-59
circle/dashboard/store_api.py
+75
-59
No files found.
circle/dashboard/store_api.py
View file @
a9a27ccc
...
@@ -9,73 +9,89 @@ from sizefield.utils import filesizeformat
...
@@ -9,73 +9,89 @@ from sizefield.utils import filesizeformat
settings
=
django
.
conf
.
settings
.
STORE_SETTINGS
settings
=
django
.
conf
.
settings
.
STORE_SETTINGS
class
Mock
(
object
):
pass
def
get_host
():
def
get_host
():
return
settings
[
'store_url'
]
return
settings
[
'store_url'
]
def
post_request
(
url
,
payload
):
def
post_request
(
url
,
payload
):
headers
=
{
'content-type'
:
'application/json'
}
try
:
if
settings
[
'ssl_auth'
]
==
'True'
and
settings
[
'basic_auth'
]
==
'True'
:
headers
=
{
'content-type'
:
'application/json'
}
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
if
settings
[
'ssl_auth'
]
==
'True'
and
settings
[
'basic_auth'
]
==
'True'
:
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
cert
=
(
settings
[
'store_client_cert'
],
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_key'
]),
cert
=
(
settings
[
'store_client_cert'
],
auth
=
(
settings
[
'store_client_user'
],
settings
[
'store_client_key'
]),
settings
[
'store_client_pass'
])
auth
=
(
settings
[
'store_client_user'
],
)
settings
[
'store_client_pass'
])
elif
settings
[
'ssl_auth'
]
==
'True'
:
)
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
elif
settings
[
'ssl_auth'
]
==
'True'
:
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
cert
=
(
settings
[
'store_client_cert'
],
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_key'
])
cert
=
(
settings
[
'store_client_cert'
],
)
settings
[
'store_client_key'
])
elif
settings
[
'basic_auth'
]
==
'True'
:
)
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
elif
settings
[
'basic_auth'
]
==
'True'
:
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
auth
=
(
settings
[
'store_client_user'
],
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_pass'
])
auth
=
(
settings
[
'store_client_user'
],
)
settings
[
'store_client_pass'
])
else
:
)
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
else
:
verify
=
settings
[
'verify_ssl'
]
==
'True'
r
=
requests
.
post
(
url
,
data
=
payload
,
headers
=
headers
,
)
verify
=
settings
[
'verify_ssl'
]
==
'True'
return
r
)
return
r
except
:
dummy
=
Mock
()
setattr
(
dummy
,
"status_code"
,
200
)
setattr
(
dummy
,
"content"
,
"[]"
)
return
dummy
def
get_request
(
url
):
def
get_request
(
url
):
headers
=
{
'content-type'
:
'application/json'
}
try
:
if
settings
[
'ssl_auth'
]
==
'True'
and
settings
[
'basic_auth'
]
==
'True'
:
headers
=
{
'content-type'
:
'application/json'
}
r
=
requests
.
get
(
if
settings
[
'ssl_auth'
]
==
'True'
and
settings
[
'basic_auth'
]
==
'True'
:
url
,
r
=
requests
.
get
(
headers
=
headers
,
url
,
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
headers
=
headers
,
cert
=
(
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_cert'
],
cert
=
(
settings
[
'store_client_key'
]),
settings
[
'store_client_cert'
],
auth
=
(
settings
[
'store_client_key'
]),
settings
[
'store_client_user'
],
auth
=
(
settings
[
'store_client_pass'
]))
settings
[
'store_client_user'
],
elif
settings
[
'ssl_auth'
]
==
'True'
:
settings
[
'store_client_pass'
]))
r
=
requests
.
get
(
elif
settings
[
'ssl_auth'
]
==
'True'
:
url
,
r
=
requests
.
get
(
headers
=
headers
,
url
,
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
headers
=
headers
,
cert
=
(
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_cert'
],
cert
=
(
settings
[
'store_client_key'
]))
settings
[
'store_client_cert'
],
elif
settings
[
'basic_auth'
]
==
'True'
:
settings
[
'store_client_key'
]))
r
=
requests
.
get
(
elif
settings
[
'basic_auth'
]
==
'True'
:
url
,
r
=
requests
.
get
(
headers
=
headers
,
url
,
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
headers
=
headers
,
auth
=
(
verify
=
settings
[
'verify_ssl'
]
==
'True'
,
settings
[
'store_client_user'
],
auth
=
(
settings
[
'store_client_pass'
]))
settings
[
'store_client_user'
],
else
:
settings
[
'store_client_pass'
]))
r
=
requests
.
get
(
url
,
headers
=
headers
,
else
:
verify
=
settings
[
'verify_ssl'
]
==
'True'
r
=
requests
.
get
(
url
,
headers
=
headers
,
)
verify
=
settings
[
'verify_ssl'
]
==
'True'
return
r
)
return
r
except
:
dummy
=
Mock
()
setattr
(
dummy
,
"status_code"
,
200
)
setattr
(
dummy
,
"content"
,
"[]"
)
return
dummy
def
listfolder
(
neptun
,
path
):
def
listfolder
(
neptun
,
path
):
...
...
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