View Issue Details

IDProjectCategoryView StatusLast Update
0000530ascendpygtk guipublic2018-05-27 17:37
Reporterjohn 
Assigned Tojohn 
PrioritynormalSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
PlatformWindowsOSWindowsOS Version7
Product Version0.9.8 
Target Version0.9.9Fixed in VersionSVN 
Summary0000530: Console (IPython) pane doesn't show with recent IPython versions
DescriptionThere is an error saying that 'module' has no attribute 'iplib'.

This looks like IPython's API might have changed. We could check the Accerciser project from which our GTK+IPython code came, and see if there is an update.

Occurs with Windows 7 and also Ubuntu 12.04.
TagsNo tags attached.

Relationships

Activities

john

2012-04-19 03:35

administrator   ~0000868

This bug arises from recent changes to IPython. The Accerciser project has provided an update to their ipython_view.py but their patches also upgrade IPython to using GTK3, which ASCEND does not yet use. We need to carefully review the Accerciser changes and work out a solution.

http://live.gnome.org/Accerciser

john

2013-02-27 13:32

administrator   ~0000954

See also:
http://ipython.org/ipython-doc/dev/interactive/reference.html#embedding

(applies to IPython 0.13, which is newer than the 0.12.1 installed on Ubuntu 12.04)

pallavtinna

2013-03-29 09:09

developer  

0000530.patch (5,579 bytes)
64a65,68
> 
>     # Handling the IOstream for newer versions of IPython
>     io = IPython.utils.io
> 
66c70
<       IPython.iplib.raw_input_original = input_func
---
>       IPython.frontend.terminal.interactiveshell.raw_input_original = input_func
68c72
<       IPython.Shell.Term.cin = cin
---
>       io.stdin = io.IOStream(cin)
70c74
<       IPython.Shell.Term.cout = cout
---
>       io.stdout = io.IOStream(cout)
72c76
<       IPython.Shell.Term.cerr = cerr
---
>       io.stderr = io.IOStream(cerr)
76d79
<     IPython.iplib.raw_input = lambda x: None
78c81,83
<     self.term = IPython.genutils.IOTerm(cin=cin, cout=cout, cerr=cerr)
---
>     io.raw_input = lambda x: None
> 
> 
81,88c86,99
<     self.IP = IPython.Shell.make_IPython(
<       argv,user_ns=user_ns,
<       user_global_ns=user_global_ns,
<       embedded=True,
<       shell_class=IPython.Shell.InteractiveShell)
<     self.IP.system = lambda cmd: self.shell(self.IP.var_expand(cmd),
<                                             header='IPython system call: ',
<                                             verbose=self.IP.rc.system_verbose)
---
> 
>     from IPython.config.loader import Config
>     configuring = Config()
>     configuring.InteractiveShell.colors = "Linux"
>     old_stdout, old_stderr = sys.stdout, sys.stderr
>     sys.stdout, sys.stderr = io.stdout.stream, io.stderr.stream
>     self.IP = IPython.frontend.terminal.embed.InteractiveShellEmbed.instance(\
>             config=configuring, user_ns=user_ns)
>     sys.stdout, sys.stderr = old_stdout, old_stderr
> 
> 
>     self.IP.system = lambda cmd: self.shell(self.IP.var_expand(cmd),header='IPython system call: ') 
>     self.IP.raw_input = input_func
> 
93a105,128
> ################################################################
> # Temporary fix for now
> 
> # Mapping exit and quit calls to None
>     
>     self.updateNamespace({'exit':lambda:None})
>     self.updateNamespace({'quit':lambda:None})
> 
> ################################################################
> 
> 
>     self.IP.readline_startup_hook(self.IP.pre_readline)
>     self.__update_namespace()
> 
> 
>   def __update_namespace(self):
>     '''
>     This function updates namespace with sys.modules
>     '''
>     for k,v in sys.modules.items():
>       if not '.' in k:
>         self.IP.user_ns.update({k:v})
> 
> 
100c135,150
<     sys.stdout = IPython.Shell.Term.cout
---
>     sys.stdout = IPython.utils.io.stdout
> 
>     orig_stdin = sys.stdin
>     sys.stdin = IPython.utils.io.stdin;
>     self.prompt = self.generatePrompt(self.iter_more)
>     self.IP.hooks.pre_prompt_hook()
> 
>     if self.iter_more:
>        try:
>           self.prompt = self.generatePrompt(self.iter_more)
>        except:
>           self.IP.showtraceback()
>        if self.IP.autoindent:
>           self.IP.rl_do_indent = True
> 
> 
102,104c152
<       line = self.IP.raw_input(None, self.iter_more)
<       if self.IP.autoindent:
<         self.IP.readline_startup_hook(None)
---
>       line = self.IP.raw_input(self.prompt)
107d154
<       self.IP.resetbuffer()
110,113c157
<         
<       if self.IP.autoindent:
<         self.IP.indent_current_nsp = 0
<       self.iter_more = 0
---
>       self.IP.input_splitter.reset()
117,119c161,165
<       self.iter_more = self.IP.push(line)
<       if (self.IP.SyntaxTB.last_syntax_error and
<           self.IP.rc.autoedit_syntax):
---
>        self.IP.input_splitter.push(line)
>        self.iter_more = self.IP.input_splitter.push_accepts_more()
>        self.prompt = self.generatePrompt(self.iter_more)
> 
>     if (self.IP.SyntaxTB.last_syntax_error and self.IP.autoedit_syntax):
121,124c167,169
<     if self.iter_more:
<       self.prompt = str(self.IP.outputcache.prompt2).strip()
<       if self.IP.autoindent:
<         self.IP.readline_startup_hook(self.IP.pre_readline)
---
>     if not self.iter_more:
>         source_raw = self.IP.input_splitter.source_raw_reset()[1]
>         self.IP.run_cell(source_raw, store_history=True)
126c171,172
<       self.prompt = str(self.IP.outputcache.prompt1).strip()
---
>         pass
> 
127a174
>     sys.stdin = orig_stdin
184c231,235
<     possibilities = self.IP.complete(split_line[-1])
---
>     if split_line[-1]:
>       possibilities = self.IP.complete(split_line[-1])
>     else:
>       completed = line
>       possibilities = ['',[]]
202,203c253,257
<       common_prefix = reduce(_commonPrefix, possibilities)
<       completed = line[:-len(split_line[-1])]+common_prefix
---
>       if possibilities[1]:
>         common_prefix = reduce(_commonPrefix, possibilities[1]) or line[-1]
>         completed = line[:-len(split_line[-1])]+common_prefix
>       else:
>         completed = line
206c260
<     return completed, possibilities
---
>     return completed, possibilities[1]
230a285,304
> 
>   def generatePrompt(self, is_continuation):
>       '''
>       This function helps to provide backward compatibility for the previous versions
>       of IPython
>       '''
> 
>       if '0.11' in IPython.__version__ or '0.10' in IPython.__version__:
>         prompt = self.IP.hooks.generate_prompt(is_continuation)
>       else:
>         if is_continuation:
>           prompt = self.IP.prompt_manager.render('in2')
>         else:
>           prompt = self.IP.prompt_manager.render('in')
> 
>       return prompt
> 
> 
> 
> 
303c377
<                                              segments[i+1], tag)
---
>                 segments[i+1], str(tag))
443a518
>     self.interrupt = False
444a520
>     self.prompt = self.generatePrompt(False)
0000530.patch (5,579 bytes)

pallavtinna

2013-03-29 09:11

developer   ~0000965

Details of the patch (file : "0000530.patch")

1. Removed the uncompatibilities based on the IPython API changes.

2. Added new IO stream handling methods.

3. Added a method generatePrompt to provide backward compatibility for the previous versions of IPython (0.10 and 0.11) and renders the prompt manager. ( http://ipython.sourcearchive.com/documentation/0.10/classIPython_1_1kernel_1_1core_1_1interpreter_1_1Interpreter_9c6c621858bb8b870de3af05fe53fd29.html#9c6c621858bb8b870de3af05fe53fd29
)

4. Changed the configuring of the IPython config loader.

5. Disabled the auto-indent behaviour, because it was incompatible with the new API changes. Need to add a workaround for the auto-indent issue.

john

2013-05-01 13:55

administrator   ~0000969

Hi Pallav

Tried to apply your patch on current trunk (at changeset 4461) but I get errors when applying the patch. I tried:
john@thunder:~/ascend/pygtk$ patch -l console.py ~/0000530.patch
patching file console.py
Hunk #2 FAILED at 70.
Hunk #3 FAILED at 72.
Hunk #4 FAILED at 74.
Hunk #5 FAILED at 76.
Hunk #6 FAILED at 80.
Hunk #7 FAILED at 82.
Hunk #8 FAILED at 85.
Hunk #10 FAILED at 128.
Hunk #11 FAILED at 130.
Hunk #12 FAILED at 135.
Hunk #13 FAILED at 138.
Hunk #14 FAILED at 145.
Hunk #15 FAILED at 149.
Hunk #16 FAILED at 154.
Hunk #18 FAILED at 213.
Hunk #19 FAILED at 231.
Hunk #20 FAILED at 235.
Hunk #22 FAILED at 352.
18 out of 24 hunks FAILED -- saving rejects to file console.py.rej

Please use the "svn diff" command to generate patch files, as this ensures usable patch files.

Look forward to checking out your work soon...

Cheers
JP

john

2013-05-01 16:54

administrator   ~0000970

From Pallav:
> Thanks! for having a look at the patch. This patch applies to
> "ipython_view.py" and not "console.py".

I applied the patch to that file, and now it's working fine. I didn't check the 'exit()' issue yet, and didn't check on newer Ubuntu/Fedora/Windows releases. would be worth doing.

pallavtinna

2013-06-20 18:12

developer   ~0000985

For now,the auto-indent behaviour is disabled, because it was incompatible with the new API changes. Trying to add a workaround for this.

john

2018-05-27 17:37

administrator   ~0001022

Fixed, not ideal but operational again:
http://code.ascend4.org/ascend/trunk/pygtk/ipython_view.py?view=markup
https://stackoverflow.com/questions/16639199

Issue History

Date Modified Username Field Change
2012-03-21 04:25 john New Issue
2012-04-19 03:35 john Note Added: 0000868
2012-04-19 03:36 john Status new => confirmed
2012-04-19 03:36 john Summary Console (IPython) pane doesn't show in Windows 7 64-bit => Console (IPython) pane doesn't show with recent IPython versions
2012-04-19 03:36 john Description Updated View Revisions
2013-02-26 13:39 john Target Version 1.0 => 0.9.9
2013-02-27 13:32 john Note Added: 0000954
2013-03-29 09:09 pallavtinna File Added: 0000530.patch
2013-03-29 09:11 pallavtinna Note Added: 0000965
2013-05-01 13:55 john Note Added: 0000969
2013-05-01 16:54 john Note Added: 0000970
2013-05-01 16:55 svn
2013-06-20 18:12 pallavtinna Note Added: 0000985
2018-05-27 17:37 john Assigned To => john
2018-05-27 17:37 john Status confirmed => resolved
2018-05-27 17:37 john Resolution open => fixed
2018-05-27 17:37 john Fixed in Version => SVN
2018-05-27 17:37 john Note Added: 0001022