Exemple #1
0
def login(username, password=None, conf=None):
    if username is None:
        username = raw_input('Username: '******'Password: '******'verce.registry']['workspace']
    url = None
    if 'VERCEREGISTRY_HOST' in os.environ:
        url = os.environ['VERCEREGISTRY_HOST'] + '/rest/'
    else:
        url = conf['verce.registry']['url']
    try:
        reg = core.initRegistry(username, password, url=url, workspace=workspace)
    except core.NotAuthorisedException:
        sys.stderr.write("Not authorised.\n")
        sys.exit(4)
    enc = base64.b64encode(password)
    try:
        os.mkdir(DISPEL4PY_CONFIG_DIR)
    except:
        pass
    with open(CACHE, 'w') as file:
        file.write('%s\n%s\n%s' % (username, enc, reg.token))
    # print 'Logged in.'
    return reg
Exemple #2
0
def login(username, password=None):
    if username is None:
        username = raw_input('Username: '******'Password: '******'w') as file:
        file.write('%s\n%s\n%s' % (username, enc, reg.token))
    print 'Logged in.'
    return reg
Exemple #3
0
def login(username, password=None):
    if username is None:
        username = raw_input('Username: '******'Password: '******'w') as file:
        file.write('%s\n%s\n%s' % (username, enc, reg.token))
    print 'Logged in.'
    return reg
Exemple #4
0
def _initRegistry(username=None, password=None):
    token = None
    if not username:
        try:
            with open(CACHE, 'r') as file:
                [username, enc, token] = file.read().splitlines()
                password = base64.b64decode(enc)
        except IOError:
            username = raw_input("Username: "******"Not authorised.\n")
        sys.exit(4)

    return reg
Exemple #5
0
def _initRegistry(config=None, username=None, password=None):
    token = None
    if (config==None):
        config = configure()
    if not username:
        try:
            with open(CACHE, 'r') as file:
                [username, enc, token] = file.read().splitlines()
                password = base64.b64decode(enc)
        except IOError:
            username = raw_input("Username: "******"Not authorised.\n")
        sys.exit(4)
    
    return reg