Statistics
| Branch: | Tag: | Revision:

root / snf-pithos-tools / pithos / tools / lib / util.py @ db117cac

History | View | Annotate | Download (2 kB)

1 2e662088 Antony Chazapis
# Copyright 2011-2012 GRNET S.A. All rights reserved.
2 46499544 Antony Chazapis
# 
3 46499544 Antony Chazapis
# Redistribution and use in source and binary forms, with or
4 46499544 Antony Chazapis
# without modification, are permitted provided that the following
5 46499544 Antony Chazapis
# conditions are met:
6 46499544 Antony Chazapis
# 
7 46499544 Antony Chazapis
#   1. Redistributions of source code must retain the above
8 46499544 Antony Chazapis
#      copyright notice, this list of conditions and the following
9 46499544 Antony Chazapis
#      disclaimer.
10 46499544 Antony Chazapis
# 
11 46499544 Antony Chazapis
#   2. Redistributions in binary form must reproduce the above
12 46499544 Antony Chazapis
#      copyright notice, this list of conditions and the following
13 46499544 Antony Chazapis
#      disclaimer in the documentation and/or other materials
14 46499544 Antony Chazapis
#      provided with the distribution.
15 46499544 Antony Chazapis
# 
16 46499544 Antony Chazapis
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
17 46499544 Antony Chazapis
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 46499544 Antony Chazapis
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 46499544 Antony Chazapis
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
20 46499544 Antony Chazapis
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 46499544 Antony Chazapis
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 46499544 Antony Chazapis
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23 46499544 Antony Chazapis
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
24 46499544 Antony Chazapis
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 46499544 Antony Chazapis
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26 46499544 Antony Chazapis
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 46499544 Antony Chazapis
# POSSIBILITY OF SUCH DAMAGE.
28 46499544 Antony Chazapis
# 
29 46499544 Antony Chazapis
# The views and conclusions contained in the software and
30 46499544 Antony Chazapis
# documentation are those of the authors and should not be
31 46499544 Antony Chazapis
# interpreted as representing official policies, either expressed
32 46499544 Antony Chazapis
# or implied, of GRNET S.A.
33 46499544 Antony Chazapis
34 a5149fd0 Sofia Papagiannaki
import os
35 a5149fd0 Sofia Papagiannaki
36 bff2c0e0 Sofia Papagiannaki
DEFAULT_URL = 'https://pithos.okeanos.grnet.gr/v1'
37 a5149fd0 Sofia Papagiannaki
DEFAULT_USER = 'test'
38 2a0d6ae0 Sofia Papagiannaki
DEFAULT_TOKEN = '0000'
39 a5149fd0 Sofia Papagiannaki
40 a5149fd0 Sofia Papagiannaki
def get_user():
41 d7eb5499 Sofia Papagiannaki
    try:
42 d7eb5499 Sofia Papagiannaki
        return os.environ['PITHOS_USER']
43 d7eb5499 Sofia Papagiannaki
    except KeyError:
44 d7eb5499 Sofia Papagiannaki
        return DEFAULT_USER
45 a5149fd0 Sofia Papagiannaki
46 a5149fd0 Sofia Papagiannaki
def get_auth():
47 d7eb5499 Sofia Papagiannaki
    try:
48 2a0d6ae0 Sofia Papagiannaki
        return os.environ['PITHOS_TOKEN']
49 d7eb5499 Sofia Papagiannaki
    except KeyError:
50 2a0d6ae0 Sofia Papagiannaki
        return DEFAULT_TOKEN
51 a5149fd0 Sofia Papagiannaki
52 09fd65c7 Sofia Papagiannaki
def get_url():
53 a5149fd0 Sofia Papagiannaki
    try:
54 c35fa943 Sofia Papagiannaki
        return os.environ['PITHOS_URL'].rstrip('/')
55 a5149fd0 Sofia Papagiannaki
    except KeyError:
56 09fd65c7 Sofia Papagiannaki
        return DEFAULT_URL