Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 0f6a73b2 authored by GARNIER Laurent's avatar GARNIER Laurent
Browse files

Merge branch 'jupyter-token_2021' into 'master'

Jupyter token 2021

See merge request !5
parents fc55d0dd 6841e947
No related branches found
No related tags found
1 merge request!5Jupyter token 2021
......@@ -2,6 +2,7 @@ import logging
import os
import time
try:
from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
......@@ -13,8 +14,12 @@ except ImportError:
import requests
log = logging.getLogger('allgo')
__version__ = '0.1.11'
# API version
__version__ = '0.2.1'
# API token for JupyterLab
API_token = None
API_token_valid = False
def local_token():
from os.path import expanduser
......@@ -24,6 +29,47 @@ def local_token():
with open(filetoken) as f:
return f.read()
class Init:
"""
manage initialization of the API.
check if there is an existing token
| No: generate a temporary token and return the allgo login page
| Yes: Display "Allgo is already initialized"
"""
def __init__(self):
"""Initialization of Allgo-instance.
Parameters
----------
Returns
-------
string
allgo login page link or already initialized message
"""
# if user.is_authenticated:
# print("User authenticated")
# else:
# print("User not authenticated")
# is token valid ?
if not API_token_valid:
# Generate temp token
print("First: " + API_token+ " \n")
API_token = get_random_string(length=32)
print("____")
print("You need first to sign in with your existing https://allgo18.inria.fr/accounts/login/?token=" + API_token+ " A||GO account \n")
print("____")
else:
# FIXME : Have to check that the user is register
print("____")
msg = "A||GO already initialized\n"
print("____")
print(msg)
class App:
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment