Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jupyter-jsc-custom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jupyterjsc
packages
jupyter-jsc-custom
Commits
baf5fa6f
Commit
baf5fa6f
authored
3 months ago
by
Tim Kreuzer
Browse files
Options
Downloads
Patches
Plain Diff
support old shares
parent
03735449
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jsc_custom/handler/share_handler.py
+59
-2
59 additions, 2 deletions
jsc_custom/handler/share_handler.py
with
59 additions
and
2 deletions
jsc_custom/handler/share_handler.py
+
59
−
2
View file @
baf5fa6f
...
...
@@ -32,6 +32,59 @@ class ShareUserOptionsSpawnHandler(SpawnHandler):
"
home.html
"
,
for_user
=
for_user
,
auth_state
=
auth_state
,
row
=
server_name
)
def
upgrade_user_options
(
self
,
user_options
):
# In the past we had a different structure for our share user options
# To support old share links, we have to upgrade them to the newest structure
if
user_options
.
get
(
"
profile
"
,
""
).
startswith
(
"
JupyterLab/
"
):
name
=
user_options
.
get
(
"
name
"
,
"
Unnamed
"
)
option_dict
=
{
"
JupyterLab/repo2docker
"
:
"
repo2docker
"
,
"
JupyterLab/custom
"
:
"
custom
"
,
}
profile
=
option
=
option_dict
.
get
(
user_options
.
get
(
"
profile
"
,
""
))
service
=
"
jupyterlab
"
secret_keys
=
[]
system
=
user_options
.
get
(
"
system
"
,
"
unknown
"
)
flavor
=
user_options
.
get
(
"
flavor
"
,
None
)
r2dnotebooktype
=
user_options
.
get
(
"
notebook_type
"
,
"
file
"
)
r2drepo
=
user_options
.
get
(
"
repo
"
,
None
)
if
r2drepo
and
r2drepo
.
startswith
(
"
https://github.com/
"
):
r2dtype
=
"
gh
"
r2drepo
=
r2drepo
[
len
(
"
https://github.com/
"
)
:]
else
:
r2dtype
=
"
git
"
r2dgitref
=
user_options
.
get
(
"
gitref
"
,
""
)
r2dnotebook
=
user_options
.
get
(
"
notebook
"
,
None
)
ret
=
{
"
name
"
:
name
,
"
service
"
:
service
,
"
option
"
:
option
,
"
profile
"
:
profile
,
"
system
"
:
system
,
"
secrets
"
:
secret_keys
,
}
if
flavor
:
ret
[
"
flavor
"
]
=
flavor
if
r2drepo
:
ret
[
"
repo2docker
"
]
=
{
"
repotype
"
:
r2dtype
,
"
repourl
"
:
r2drepo
,
"
reporef
"
:
r2dgitref
,
}
if
r2dnotebook
:
ret
[
"
repo2docker
"
][
"
repopath
"
]
=
r2dnotebook
ret
[
"
repo2docker
"
][
"
repopathtype
"
]
=
r2dnotebooktype
image
=
user_options
.
get
(
"
image
"
,
None
)
if
image
:
ret
[
"
custom
"
]
=
{
"
customimage
"
:
image
}
userdata_path
=
user_options
.
get
(
"
userdata_path
"
,
None
)
if
userdata_path
:
ret
[
"
storage
"
]
=
{
"
localstoragepath
"
:
userdata_path
}
return
True
,
ret
else
:
return
False
,
user_options
@web.authenticated
async
def
get
(
self
,
secret
):
user
=
self
.
current_user
...
...
@@ -52,8 +105,12 @@ class ShareUserOptionsSpawnHandler(SpawnHandler):
server_name
=
generate_random_id
()
spawner
=
user
.
get_spawner
(
server_name
,
replace_failed
=
True
)
spawner
.
user_options
=
db_entry
.
user_options
upgrade
,
user_options
=
self
.
upgrade_user_options
(
db_entry
.
user_options
)
if
upgrade
:
db_entry
.
user_options
=
user_options
self
.
db
.
add
(
db_entry
)
self
.
db
.
commit
()
spawner
.
user_options
=
user_options
service
=
db_entry
.
user_options
.
get
(
"
service
"
,
"
jupyterlab
"
)
spawner
.
user_options
[
"
share_id
"
]
=
secret
spawner
.
orm_spawner
.
user_options
=
db_entry
.
user_options
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment