diff --git svarga core commands py svarga core commands py --- svarga

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
diff --git a/svarga/core/commands.py b/svarga/core/commands.py
--- a/svarga/core/commands.py
+++ b/svarga/core/commands.py
@@ -1,3 +1,5 @@
+import sys
+
from svarga.core.dispatch import command
from svarga.core.handler import SvargaHandler
from svarga.core.settings import init_environment
@@ -25,13 +27,20 @@ def shell(no_ipython=('', False, 'do not
namespace = init_environment(None)
if not no_ipython:
try:
- import IPython
+ from IPython.Shell import IPShellEmbed
except ImportError:
pass
else:
- sh = IPython.Shell.IPShellEmbed(banner=banner)
- sh(global_ns={}, local_ns=namespace)
- return
+ try:
+ if sys.platform == 'win32':
+ import pyreadline
+ except ImportError:
+ banner = ('There is IPython installed on your system, '
+ 'but no pyreadline\n' + banner)
+ else:
+ sh = IPShellEmbed(banner=banner)
+ sh(global_ns={}, local_ns=namespace)
+ return
from code import interact
interact(banner, local=namespace)