After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 616423 - Programm fails to start if it doesn't find the saved notebook directory
Programm fails to start if it doesn't find the saved notebook directory
Status: RESOLVED FIXED
Product: reinteract
Classification: Other
Component: general
unspecified
Other Linux
: Normal major
: ---
Assigned To: reinteract-maint
reinteract-maint
Depends on:
Blocks:
 
 
Reported: 2010-04-21 18:59 UTC by xiscu
Modified: 2010-08-28 20:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.29 KB, patch)
2010-04-22 03:35 UTC, Robert Schroll
none Details | Review
Patch, ver. 2 (1.65 KB, patch)
2010-04-23 04:57 UTC, Robert Schroll
committed Details | Review

Description xiscu 2010-04-21 18:59:54 UTC
Hi,
I was asked to report this bug upstream and I thougth that's the right place,
if not please let me know ... (I'm just copying the bug report from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=572217#5)

1- Start reinteract and create a test notebook in a local directory:
> ci@randog:~/prog/evo$ reinteract

2- Save the worksheet and the notebook and quit the programm
> ci@randog:~/prog/test_r$ dir
Test_notebook

> ci@randog:~/prog/test_r$ cd Test_notebook/
> ci@randog:~/prog/test_r/Test_notebook$ dir
index.rnb  test\ ws.rws

> ci@randog:~/prog/test_r/Test_notebook$ cat index.rnb 
[Notebook]
last_modified = 1267534216.02
description = Test the notebook feature


3- Delete or move the directory where the notebook was saved
> ci@randog:~/prog/test_r$ mv Test_notebook/ Test_notebook_moved
> ci@randog:~/prog/test_r$ dir
Test_notebook_moved

4- Try to start the programm and it will fail

> ci@randog:~/prog/test_r$ reinteract 
Traceback (most recent call last):
  • File "/usr/bin/reinteract", line 25 in <module>
    reinteract.main.main()
  • File "/usr/lib/pymodules/python2.5/reinteract/main.py", line 93 in main
  • File "/usr/lib/pymodules/python2.5/reinteract/application.py", line 99 in open_notebook
  • File "/usr/lib/pymodules/python2.5/reinteract/notebook.py", line 129 in __init__
  • File "/usr/lib/pymodules/python2.5/reinteract/notebook_info.py", line 53 in __init__
  • File "/usr/lib/pymodules/python2.5/reinteract/notebook_info.py", line 59 in __load
    OSError: [Errno 2] No such file or directory:        '/home/ci/prog/test_r/Test_notebook'


Thanks !

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages reinteract depends on:
ii  python                        2.5.4-9    An interactive high-level object-o
ii  python-gtk2                   2.16.0-2   Python bindings for the GTK+ widge
ii  python-matplotlib             0.99.1.2-3 Python based plotting system in a 
ii  python-support                1.0.6      automated rebuilding support for P

Versions of packages reinteract recommends:
pn  sox                           <none>     (no description available)

reinteract suggests no packages.

-- no debconf information
Comment 1 Robert Schroll 2010-04-22 03:04:31 UTC
I can confirm this bug.

It seems that while notebook_info is careful about checking for the existence of index.rnb, it doesn't check the existence of the directory before calling os.stat().

We could check for the directory before os.stat(), but it's not clear to me what to do if the directory doesn't exist.  If it's gone, presumably it was deleted on purpose and the user would be surprised to have it keep popping back up.  Maybe it's better to catch the Exception at the top of the stack and open the default notebook instead.  I don't know if this would leave Reinteract in an inconsistent state, though.
Comment 2 Robert Schroll 2010-04-22 03:35:20 UTC
Created attachment 159301 [details] [review]
Patch

This patch implements the second option I mention above in a brain-dead way.  It just traps OSErrors bubbling up from within open_notebook().  If we really want to trap only the error of the directory not existing, it would probably be better to do that at the lower levels and raise a specific error.  On the other hand, we could simply trap all error here, which might provide a partial solution to notebooks that cause Reinteract to crash when loaded.

This code has been mixed up with checking that recent_notebooks is non-empty, in an effort to conserve code that is either clever or (more likely) confusing.
Comment 3 Robert Schroll 2010-04-23 04:57:00 UTC
Created attachment 159389 [details] [review]
Patch, ver. 2

A better way to handle errors in opening a notebook:  Go through recent_notebooks until you find one that opens without error.  If none does this, fallback on Main, creating it if necessary (as before).  recent_notebooks being empty is handled naturally in this setup.
Comment 4 Owen Taylor 2010-08-28 20:23:47 UTC
Review of attachment 159389 [details] [review]:

Looks good, pushed. The one problem with catching OSError like this is that if some OSError is introduced anywhere inside the notebook loading code, it's really hard to debug, so there might be some argument for checking doing a double check of:

 if os.path.exist(dir):
     try:
         load(dir)
     except OSError, e:
         print >>sys.stderr, e

But I think we can just let the person debugging the hypothetical OSError have a bad day :-)