-
Notifications
You must be signed in to change notification settings - Fork 51
Fixing some bugs with ipython creation in python3 and some issues with creating namespaces #8
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import pickle | ||
| import json | ||
|
|
||
|
|
||
| def noop(): | ||
| pass | ||
|
|
||
|
|
@@ -24,15 +25,21 @@ def km_from_string(s=''): | |
| or just 'kernel-12345.json' for IPython 0.12 | ||
| """ | ||
| global km, kc, send, Empty | ||
|
|
||
| from os.path import join as pjoin | ||
|
|
||
| from IPython.config.loader import KeyValueConfigLoader | ||
| from Queue import Empty | ||
|
|
||
| if int(sys.version.split(' ')[0][0]) > 2: | ||
| from queue import Empty | ||
| else: | ||
| from Queue import Empty | ||
|
|
||
| try: | ||
| from IPython.kernel import ( | ||
| KernelManager, | ||
| find_connection_file, | ||
| ) | ||
|
|
||
| except ImportError: | ||
| from IPython.zmq.blockingkernelmanager import BlockingKernelManager as KernelManager | ||
| from IPython.zmq.kernelapp import kernel_aliases | ||
|
|
@@ -54,6 +61,7 @@ def km_from_string(s=''): | |
| send = km.shell_channel.execute | ||
|
|
||
| respond(None, "python.client.error.ipython-version", None) | ||
|
|
||
| return | ||
|
|
||
|
|
||
|
|
@@ -84,6 +92,7 @@ def msgId(m): | |
| return m['parent_header']['msg_id'] | ||
|
|
||
| def normalize(m): | ||
|
|
||
| mid = msgId(m) | ||
| content = m['content'] | ||
|
|
||
|
|
@@ -163,9 +172,17 @@ def msgloop(): | |
| global ipy | ||
| while not ipy.returncode and not ltmain.stopped(): | ||
| for m in msgs(): | ||
| #mw(str(time.time())+'\n','a') | ||
| #mw(str(m)+'\n\n','a') | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are those function calls added, but commented out?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tired to clean all those up before commit, looks like I missed some, they were just so that I could write some information out to a file to track down what the code was doing at various parts since it was being executed in a background python process. I had to figure out why it was failing to python instead of ipython |
||
| handleMsg(m) | ||
| time.sleep(0.01) | ||
|
|
||
| #def mw(string,mode): | ||
| #f = open('/Users/nate/Desktop/log_file.txt',mode) | ||
| #f.write(string) | ||
| #f.close() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are those function calls added, but commented out?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see note above, these are safe to remove completely |
||
|
|
||
|
|
||
| def initIPy(s): | ||
| try: | ||
| cur = km_from_string(s) | ||
|
|
@@ -175,9 +192,11 @@ def initIPy(s): | |
| disconnected() | ||
|
|
||
| loc = os.path.dirname(__file__) | ||
|
|
||
| send("import sys\nsys.path.append('" + loc.replace('\\','\\\\') + "')\nimport lttools") | ||
| connected() | ||
| msgloop() | ||
|
|
||
| disconnected() | ||
| except: | ||
| disconnected() | ||
|
|
@@ -189,6 +208,7 @@ def IPyOutput(l): | |
| m = re.search('--existing (.*\.json)', l) | ||
| if m: | ||
| initIPy(m.group(1)) | ||
|
|
||
| if re.search('ImportError: IPython.zmq', l): | ||
| respond(None, "python.client.error.pyzmq", None) | ||
|
|
||
|
|
@@ -201,13 +221,15 @@ def listenIPy(): | |
| disconnected() | ||
| break | ||
| IPyOutput(next_line) | ||
|
|
||
|
|
||
| def startIPy(opts): | ||
| global ipy | ||
| global respond | ||
| global disconnected | ||
| global connected | ||
| global km | ||
| global f | ||
| respond = opts["respond"] | ||
| connected = opts["connected"] | ||
| disconnected = opts["disconnected"] | ||
|
|
@@ -228,6 +250,8 @@ def startIPy(opts): | |
| disconnected() | ||
| return None | ||
|
|
||
|
|
||
|
|
||
| def killIPy(): | ||
| global ipy | ||
| try: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here it would be much easier to use
sys.version_info[0](that's already an integer)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, that was just something quick and dirty