@@ -81,8 +81,9 @@ jupyterhub:
81
81
- Duplicate the code here and in binderhub/binderspawner_mixin.py
82
82
"""
83
83
from tornado import web
84
+ from traitlets import Bool
85
+ from traitlets import Unicode
84
86
from traitlets.config import Configurable
85
- from traitlets import Bool, Unicode
86
87
87
88
88
89
class BinderSpawnerMixin(Configurable):
@@ -100,7 +101,7 @@ jupyterhub:
100
101
# classes using traitlets?
101
102
# https://stackoverflow.com/questions/9575409/calling-parent-class-init-with-multiple-inheritance-whats-the-right-way
102
103
# https://github.com/ipython/traitlets/pull/175
103
- super(BinderSpawnerMixin, self ).__init__(*args, **kwargs)
104
+ super().__init__(*args, **kwargs)
104
105
105
106
auth_enabled = Bool(
106
107
False,
@@ -110,7 +111,7 @@ jupyterhub:
110
111
Requires `jupyterhub-singleuser` to be available inside the repositories
111
112
being built.
112
113
""",
113
- config=True
114
+ config=True,
114
115
)
115
116
116
117
cors_allow_origin = Unicode(
@@ -125,55 +126,55 @@ jupyterhub:
125
126
See also BinderHub.cors_allow_origin in binderhub config
126
127
for controlling CORS policy for the BinderHub API endpoint.
127
128
""",
128
- config=True
129
+ config=True,
129
130
)
130
131
131
132
def get_args(self):
132
133
if self.auth_enabled:
133
134
args = super().get_args()
134
135
else:
135
136
args = [
136
- ' --ip=0.0.0.0' ,
137
- f' --port={self.port}' ,
138
- f' --NotebookApp.base_url={self.server.base_url}' ,
137
+ " --ip=0.0.0.0" ,
138
+ f" --port={self.port}" ,
139
+ f" --NotebookApp.base_url={self.server.base_url}" ,
139
140
f"--NotebookApp.token={self.user_options['token']}",
140
- ' --NotebookApp.trust_xheaders=True' ,
141
+ " --NotebookApp.trust_xheaders=True" ,
141
142
]
142
143
if self.default_url:
143
- args.append(f' --NotebookApp.default_url={self.default_url}' )
144
+ args.append(f" --NotebookApp.default_url={self.default_url}" )
144
145
145
146
if self.cors_allow_origin:
146
- args.append(' --NotebookApp.allow_origin=' + self.cors_allow_origin)
147
+ args.append(" --NotebookApp.allow_origin=" + self.cors_allow_origin)
147
148
# allow_origin=* doesn't properly allow cross-origin requests to single files
148
149
# see https://github.com/jupyter/notebook/pull/5898
149
- if self.cors_allow_origin == '*' :
150
- args.append(' --NotebookApp.allow_origin_pat=.*' )
150
+ if self.cors_allow_origin == "*" :
151
+ args.append(" --NotebookApp.allow_origin_pat=.*" )
151
152
args += self.args
152
153
return args
153
154
154
155
def start(self):
155
156
if not self.auth_enabled:
156
- if ' token' not in self.user_options:
157
+ if " token" not in self.user_options:
157
158
raise web.HTTPError(400, "token required")
158
- if ' image' not in self.user_options:
159
+ if " image" not in self.user_options:
159
160
raise web.HTTPError(400, "image required")
160
- if ' image' in self.user_options:
161
- self.image = self.user_options[' image' ]
161
+ if " image" in self.user_options:
162
+ self.image = self.user_options[" image" ]
162
163
return super().start()
163
164
164
165
def get_env(self):
165
166
env = super().get_env()
166
- if ' repo_url' in self.user_options:
167
- env[' BINDER_REPO_URL' ] = self.user_options[' repo_url' ]
167
+ if " repo_url" in self.user_options:
168
+ env[" BINDER_REPO_URL" ] = self.user_options[" repo_url" ]
168
169
for key in (
169
- 'binder_ref_url',
170
- 'binder_launch_host',
171
- 'binder_persistent_request',
172
- 'binder_request'):
170
+ "binder_ref_url",
171
+ "binder_launch_host",
172
+ "binder_persistent_request",
173
+ "binder_request",
174
+ ):
173
175
if key in self.user_options:
174
176
env[key.upper()] = self.user_options[key]
175
177
return env
176
-
177
178
00-binder : |
178
179
# image & token are set via spawn options
179
180
from kubespawner import KubeSpawner
0 commit comments