-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from astiunov/spawner-form
User-friendly everware, lot of stuff
- Loading branch information
Showing
23 changed files
with
665 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rm -f jupyterhub.sqlite |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
|
||
from .spawner import * | ||
from .authenticator import * | ||
from .user_spawn_handler import * | ||
from .user_wait_handler import * | ||
from .home_handler import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from tornado import web, gen | ||
|
||
from jupyterhub.handlers.base import BaseHandler | ||
from IPython.html.utils import url_path_join | ||
from tornado.httputil import url_concat | ||
|
||
|
||
class HomeHandler(BaseHandler): | ||
"""Render the user's home page.""" | ||
|
||
@web.authenticated | ||
def get(self): | ||
user = self.get_current_user() | ||
repourl = self.get_argument('repourl', '') | ||
if repourl: | ||
self.log.info('Got %s in home' % repourl) | ||
self.redirect(url_concat( | ||
url_path_join(self.hub.server.base_url, 'spawn'), { | ||
'repourl': repourl | ||
} | ||
)) | ||
return | ||
html = self.render_template('home.html', | ||
user=user | ||
) | ||
self.finish(html) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from tornado import gen | ||
from tornado.locks import Event | ||
from tornado.ioloop import IOLoop | ||
from itertools import count | ||
|
||
|
||
def singleton(cls): | ||
instances = {} | ||
|
||
def getinstance(): | ||
if cls not in instances: | ||
instances[cls] = cls() | ||
return instances[cls] | ||
return getinstance | ||
|
||
|
||
@singleton | ||
class ImageHandler(): | ||
|
||
def __init__(self): | ||
self._images = {} | ||
|
||
def get_waiter(self, image_name): | ||
if image_name not in self._images: | ||
self._images[image_name] = ImageMutex() | ||
return self._images[image_name] | ||
|
||
|
||
class ImageMutex(): | ||
|
||
def __init__(self): | ||
self._mutex = Event() | ||
self._blocked = count() | ||
self._building_log = [] | ||
self._exception = None | ||
|
||
@gen.coroutine | ||
def block(self): | ||
value = self._blocked.__next__() # single bytecode operation | ||
if value: | ||
yield self._mutex.wait() | ||
return value | ||
|
||
def __enter__(self): | ||
if self._exception is not None: | ||
raise self._exception | ||
return self | ||
|
||
def __exit__(self, exc_type, exc_value, traceback): | ||
self._building_log = [] | ||
if isinstance(exc_value, Exception): | ||
self._exception = exc_type(exc_value) | ||
self._mutex.set() | ||
|
||
def add_to_log(self, message, level=1): | ||
self._building_log.append({ | ||
'text': message, | ||
'level': level | ||
}) | ||
|
||
@property | ||
def building_log(self): | ||
return self._building_log | ||
|
||
@property | ||
def last_exception(self): | ||
return self._exception |
Oops, something went wrong.