8
8
9
9
from contextlib import contextmanager
10
10
import collections
11
+ import sys
11
12
12
13
from IPython .core .getipython import get_ipython
13
14
from ipykernel .comm import Comm
@@ -461,16 +462,20 @@ def _trait_from_json(x, self):
461
462
462
463
def _ipython_display_ (self , ** kwargs ):
463
464
"""Called when `IPython.display.display` is called on the widget."""
465
+ def loud_error (message ):
466
+ self .log .warn (message )
467
+ sys .stderr .write ('%s\n ' % message )
468
+
464
469
# Show view.
465
470
if self ._view_name is not None :
466
- validated = validate_version ()
471
+ validated = Widget . _version_validated
467
472
468
473
# Before the user tries to display a widget. Validate that the
469
474
# widget front-end is what is expected.
470
475
if validated is None :
471
- self . log . warn ('Widget Javascript not detected. It may not be installed properly.' )
476
+ loud_error ('Widget Javascript not detected. It may not be installed properly.' )
472
477
elif not validated :
473
- self . log . warn ('The installed widget Javascript is the wrong version.' )
478
+ loud_error ('The installed widget Javascript is the wrong version.' )
474
479
475
480
self ._send ({"method" : "display" })
476
481
self ._handle_displayed (** kwargs )
@@ -480,14 +485,11 @@ def _send(self, msg, buffers=None):
480
485
self .comm .send (data = msg , buffers = buffers )
481
486
482
487
483
- _version_validated = None
488
+ Widget . _version_validated = None
484
489
def handle_version_comm_opened (comm , msg ):
485
490
"""Called when version comm is opened, because the front-end wants to
486
491
validate the version."""
487
492
def handle_version_message (msg ):
488
- _version_validated = msg ['content' ]['data' ]['validated' ]
493
+ Widget . _version_validated = msg ['content' ]['data' ]['validated' ]
489
494
comm .on_msg (handle_version_message )
490
495
comm .send ({'version' : '4.1.0dev' })
491
-
492
- def validate_version ():
493
- return _version_validated
0 commit comments