Revision 860c5d9c snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/165ba3fbfe53_update_path_account.py

b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/alembic/versions/165ba3fbfe53_update_path_account.py
13 13
from alembic import op
14 14
from sqlalchemy.sql import table, column, literal, and_
15 15

  
16
from snf_django.lib.astakos import get_user_uuid, get_displayname as get_user_displayname
17
from pithos.api.settings import (
18
    SERVICE_TOKEN, USER_CATALOG_URL, AUTHENTICATION_USERS)
16
from pithos.api.settings import (SERVICE_TOKEN, ASTAKOS_URL)
17

  
18
from astakosclient import AstakosClient
19
from astakosclient.errors import NoUserName, NoUUID
20
astakos_client = AstakosClient(ASTAKOS_URL, retry=3, use_pool=True)
19 21

  
20 22
try:
21 23
    from progress.bar import IncrementalBar
......
30 32
        def finish(self):
31 33
            return
32 34

  
33
USER_CATALOG_URL = USER_CATALOG_URL.replace('user_catalogs', 'service/api/user_catalogs')
34

  
35 35
import sqlalchemy as sa
36 36

  
37 37
catalog = {}
......
40 40
    if account in catalog:
41 41
        return catalog[account]
42 42
    try:
43
        catalog[account] = get_user_uuid(
44
            SERVICE_TOKEN, account, USER_CATALOG_URL, AUTHENTICATION_USERS)
43
        catalog[account] = astakos_client.service_get_uuid(
44
            SERVICE_TOKEN, account
45
        )
45 46
        print '\n', account, '-->', catalog[account]
47
    except NoUUID:
48
        return None
46 49
    except:
47 50
        raise
48 51
    else:
......
54 57
    if account in inverse_catalog:
55 58
        return inverse_catalog[account]
56 59
    try:
57
        inverse_catalog[account] = get_user_displayname(
58
            SERVICE_TOKEN, account, USER_CATALOG_URL, AUTHENTICATION_USERS)
60
        inverse_catalog[account] = astakos_client.service_get_username(
61
            SERVICE_TOKEN, account
62
        )
59 63
        print '\n', account, '-->', inverse_catalog[account]
64
    except NoUserName:
65
        return None
60 66
    except:
61 67
        raise
62 68
    else:

Also available in: Unified diff