Commit a9a27ccc by Kálmán Viktor

dashboard: dummy error handling for store

parent 2314ab88
...@@ -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):
......
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