Completed
Push — master ( 5644bc...b87258 )
by Paolo
17s queued 13s
created

biosample.helpers.parse_image_alias()   A

Complexity

Conditions 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 17
rs 9.9
c 0
b 0
f 0
cc 3
nop 1
1
#!/usr/bin/env python3
2
# -*- coding: utf-8 -*-
3
"""
4
Created on Mon Jan 21 12:13:16 2019
5
6
@author: Paolo Cozzi <[email protected]>
7
"""
8
9
import os
10
11
from decouple import AutoConfig
12
13
from pyUSIrest.auth import Auth
14
15
from django.conf import settings
16
17
18
# define a decouple config object
19
settings_dir = os.path.join(settings.BASE_DIR, 'image')
20
config = AutoConfig(search_path=settings_dir)
21
22
23
def get_auth(user=None, password=None, token=None):
24
    """Returns an Auth instance"""
25
26
    # instantiate an Auth object if a token is provieded
27
    if token:
28
        return Auth(token=token)
29
30
    return Auth(user, password)
31
32
33
def get_manager_auth():
34
    """Get an Auth object for imagemanager user"""
35
36
    return get_auth(
37
        user=config('USI_MANAGER'),
38
        password=config('USI_MANAGER_PASSWORD'))
39