Commit a9a27ccc by Kálmán Viktor

dashboard: dummy error handling for store

parent 2314ab88
...@@ -9,11 +9,16 @@ from sizefield.utils import filesizeformat ...@@ -9,11 +9,16 @@ 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):
try:
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True': if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True':
r = requests.post(url, data=payload, headers=headers, r = requests.post(url, data=payload, headers=headers,
...@@ -40,9 +45,15 @@ def post_request(url, payload): ...@@ -40,9 +45,15 @@ def post_request(url, payload):
verify=settings['verify_ssl'] == 'True' 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):
try:
headers = {'content-type': 'application/json'} headers = {'content-type': 'application/json'}
if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True': if settings['ssl_auth'] == 'True' and settings['basic_auth'] == 'True':
r = requests.get( r = requests.get(
...@@ -76,6 +87,11 @@ def get_request(url): ...@@ -76,6 +87,11 @@ def get_request(url):
verify=settings['verify_ssl'] == 'True' 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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment