Manually Moving Worksheets

67 views
Skip to first unread message

Luis Finotti

unread,
Feb 11, 2015, 3:26:26 PM2/11/15
to sage-s...@googlegroups.com
Dear all,

After some problems with an older computer, I'm trying to move its worksheets to a new one.  (Both running Linux.)

The problem is that I cannot download the worksheets via Sage: when I try I can select the worksheets and click "Download", but nothing happens.  It could very well be due to the computer itself, which is having some hardware/memory problems.  I can still access the files, though, and could manually move them.

Note that the new computer already has some worksheets in it, so I cannot simply move the '.sage" directory.

Also, FWIW, the old computer seems to have two places for worksheets: sage_notebook/ and  sage_notebook.sagenb/.  I can see:




boole
[~/.sage]$ ls sage_notebook/worksheets/admin/
0/ 10/ 12/ 14/ 16/ 18/ 2/ 21/ 23/ 25/ 27/ 29/ 30/ 4/ 6/ 8/ history.sobj
1/ 11/ 13/ 15/ 17/ 19/ 20/ 22/ 24/ 26/ 28/ 3/ 31/ 5/ 7/ 9/

boole
[~/.sage]$ ls sage_notebook.sagenb/home/admin/
0/ 10/ 12/ 14/ 16/ 18/ 2/ 21/ 23/ 25/ 27/ 29/ 30/ 32/ 34/ 36/ 38/ 4/ 41/ 43/ 45/ 47/ 5/ 7/ 9/
1/ 11/ 13/ 15/ 17/ 19/ 20/ 22/ 24/ 26/ 28/ 3/ 31/ 33/ 35/ 37/ 39/ 40/ 42/ 44/ 46/ 48/ 6/ 8/ history.pickle*



Is there a way to move these worksheets?

Thanks,

Luis

Andrey Novoseltsev

unread,
Feb 12, 2015, 5:49:28 PM2/12/15
to sage-s...@googlegroups.com

Hi Luis,

I believe you want the folder with ".sagenb" extension -  the other one is from a quite old version which should have been migrated to the new one (but a copy of an old one remains).

If you put it anywhere on the new computer, you can launch notebook with "directory" option specifying the path. Then try to download those that you want and upload into your new installation.

Best,
Andrey

Luis Finotti

unread,
Feb 19, 2015, 12:01:45 PM2/19/15
to sage-s...@googlegroups.com

Thanks, Andrey.  (Sorry for the delay in replying)

I could indeed copy the old directory and open in a new computer.  But, I can't download the worksheets all together.  I can download some individually, but not all.  This was in fact the same problem I had in my old computer.  So apparently it was not a hardware problem...

Clicking on "Download All Active" I get the following:

sage: notebook(directory='/home/finotti/utk/.sage/sage_notebook.sagenb')
The notebook files are stored in: sage_notebook.sagenb
┌────────────────────────────────────────────────┐
                                               
Open your web browser to http://localhost:8080 │
                                               
└────────────────────────────────────────────────┘
Executing twistd  --pidfile="sage_notebook.sagenb/sagenb.pid" -ny "sage_notebook.sagenb/twistedconf.tac"
/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Crypto/Util/number.py:57: PowmInsecureWarning: Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.
  _warn
("Not using mpz_powm_sec.  You should rebuild using libgmp >= 5 to avoid timing attack vulnerability.", PowmInsecureWarning)
2015-02-19 11:57:51-0500 [-] Log opened.
2015-02-19 11:57:51-0500 [-] twistd 14.0.2 (/usr/local/sage-6.4.1/local/bin/python 2.7.8) starting up.
2015-02-19 11:57:51-0500 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2015-02-19 11:57:51-0500 [-] QuietSite starting on 8080
2015-02-19 11:57:51-0500 [-] Starting factory <__builtin__.QuietSite instance at 0x7f90b8420dd0>

(process:1194): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
2015-02-19 11:57:53-0500 [HTTPChannel,0,127.0.0.1] Starting zipping a group of worksheets in a separate thread...
2015-02-19 11:57:54-0500 [-] WSGI application error
       
Traceback (most recent call last):
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg/twisted/python/threadpool.py", line 217, in _worker
            o
= self.q.get()
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
           
return self.currentContext().callWithContext(ctx, func, *args, **kw)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg/twisted/python/context.py", line 83, in callWithContext
           
self.contexts.pop()
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg/twisted/web/wsgi.py", line 340, in run
           
self.started = True
       
--- <exception caught here> ---
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Twisted-14.0.2-py2.7-linux-x86_64.egg/twisted/web/wsgi.py", line 315, in run
            appIterator
= self.application(self.environ, self.startResponse)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1836, in __call__
           
return self.wsgi_app(environ, start_response)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1820, in wsgi_app
            response
= self.make_response(self.handle_exception(e))
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1403, in handle_exception
            reraise
(exc_type, exc_value, tb)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
            response
= self.full_dispatch_request()
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
            rv
= self.handle_user_exception(e)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
            reraise
(exc_type, exc_value, tb)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
            rv
= self.dispatch_request()
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
           
return self.view_functions[rule.endpoint](**req.view_args)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/sagenb-0.11.1-py2.7.egg/sagenb/flask_version/decorators.py", line 22, in wrapper
           
return f(*args, **kwds)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/sagenb-0.11.1-py2.7.egg/sagenb/flask_version/worksheet_listing.py", line 214, in download_worksheets
            g
.notebook.export_worksheet(worksheet.filename(), sws_filename)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/sagenb-0.11.1-py2.7.egg/sagenb/notebook/notebook.py", line 741, in export_worksheet
            S
.export_worksheet(username, id_number, output_filename, title=title)
         
File "/usr/local/sage-6.4.1/local/lib/python2.7/site-packages/sagenb-0.11.1-py2.7.egg/sagenb/storage/filesystem_storage.py", line 468, in export_worksheet
            f
.write(old_heading + g.read())
        exceptions
.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 5454: ordinal not in range(128)

Any help would be appreciated.

Best to all,

Luis

 

kcrisman

unread,
Feb 19, 2015, 2:17:24 PM2/19/15
to sage-s...@googlegroups.com

            f
.write(old_heading + g.read())
        exceptions
.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 5454: ordinal not in range(128)

Any help would be appreciated.

I would recommend looking at what happens when you do them - which worksheet seems to trigger this?  My guess is there is some unusual character, see for instance 
or 
for some details - maybe it even is the same character in question.  I guess we need to ask this to be written with utf-8 or something.  Andrey, any suggestions?

Andrey Novoseltsev

unread,
Feb 19, 2015, 4:05:25 PM2/19/15
to sage-s...@googlegroups.com

Well, my guess is that there are some worksheet titles with non-Latin characters. Luis - do you have any? Can you try to download them separately and in a small group? (Separately meaning a single one into sws file, and a group means two or more that should be packed into an archive.) I am not sure where exactly encoding commands should be added, but to start with we need a reproducible behaviour.

Luis Finotti

unread,
Feb 20, 2015, 8:52:48 AM2/20/15
to sage-s...@googlegroups.com
Thanks Andrey and kcrisman for the replies!


On Thursday, February 19, 2015 at 4:05:25 PM UTC-5, Andrey Novoseltsev wrote:
On Thursday, 19 February 2015 12:17:24 UTC-7, kcrisman wrote:

            f
.write(old_heading + g.read())
        exceptions
.UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 5454: ordinal not in range(128)

Any help would be appreciated.

I would recommend looking at what happens when you do them - which worksheet seems to trigger this?  My guess is there is some unusual character, see for instance 
or 
for some details - maybe it even is the same character in question.  I guess we need to ask this to be written with utf-8 or something.  Andrey, any suggestions?

I thought of that, when I saw the error.  There was only one worksheet with a weird name (which I had imported from someone).  I tried changing the name, but it did not work.
 

Well, my guess is that there are some worksheet titles with non-Latin characters. Luis - do you have any? Can you try to download them separately and in a small group? (Separately meaning a single one into sws file, and a group means two or more that should be packed into an archive.) I am not sure where exactly encoding commands should be added, but to start with we need a reproducible behaviour.

OK, so I went over all worksheets, deleting a bunch I did not need anymore, and then tried each worksheet individually.  I found out that I had two worksheets causing the problem, i.e., I could not download them individually or whenever they were in a group.  They were both imported, i.e., I saw them somewhere (sorry, can't remember where), liked, downloaded and imported.  Both run fine, by the way.

One is "Newton's Method".  It is short, and I could not spot any weird characters after I changed its name.  (This is the one that had a strange name, but I think not UTF-8 characters.  It had simply things like & and ').  Here is its content:
{{{id=0|
%hide

html
("<h2>Newton's Method</h2>")
html
("Here you can experiment with how Newton's Method approximates the zeros of a function.")
html
("<ul><li>Modify <i>f</i> for the function whose zero you want.</li>")
html
("<li>Modify <i>Number of steps</i> for the number of steps the method should take (1—5, default 2).</li>")
html
("<li>Modify <i>x</i><sub>0</sub> for the starting <i>x</i>-value.</li></ul>")
html
("If 5 steps is not enough, change the starting value to the last approximation.<p>")
html
("The default setup provides an example using ")
html
("<i>x</i><sup>3</sup> + 0.4 <i>x</i><sup>2</sup> - 0.51 <i>x</i> - 0.16")
html
("<br>")
var('x')
@interact
def squeezers(f=input_box(default=x^3+0.4*x^2-0.51*x-0.16), num_approx=slider(1,5,default=2,step_size=1,label="Number of steps"), xstart=input_box(label="<i>x</i><sub>0</sub>",default=2), xm=input_box(label="<i>x</i><sub>min</sub>",default=0), xM=input_box(label="<i>x</i><sub>max</sub>",default=2),roundto=input_box(label="Round answers to how many digits? (0: don't round)",default=4)):
   
if (roundto!=0):
        xprev
= round(xstart,roundto)
   
else:
        xprev
= xstart
    df
= diff(f)
    displayplot
= plot(f,xm,xM,rgbcolor='black',thickness=2)
   
#ym = displayplot.ymin()
   
#yM = displayplot.ymax()
   
for each in range(num_approx):
       
if (df(x=xprev) != 0):
            xnext
= -f(x=xprev)/df(x=xprev)+xprev
            displayplot
= displayplot + line([[xprev,0],[xprev,f(x=xprev)]],linestyle='--')
            displayplot
= displayplot + plot(df(x=xprev)*(x-xprev)+f(x=xprev),xprev,xnext)
            displayplot
= displayplot + point((xnext,0),pointsize=20)
            xprev
= xnext
       
else:
            displayplot
= displayplot + line([[xm,f(x=xprev)],[xM,f(x=xprev)]],linestyle='--')
   
if (df(x=xprev) != 0):
       
if (roundto!=0):
            html
("Approximation is " + (str(round(xprev,roundto)).rstrip('0')))
       
else:
            html
("Approximation is " + (str(xprev).rstrip('0')))
        displayplot
= displayplot + point((xprev,0),pointsize=30,rgbcolor='red')
   
else:
        html
("Unable to complete, due to horizontal tangent line.")
   
#displayplot.show(xmin=xm,xmax=xM,ymin=ym,ymax=yM)
    displayplot
.show(xmin=xm,xmax=xM)
///
}}}

{{{id=1|

///
}}}

The other is very long is called "Grand Tour" (and at the top has "The Sage Library -- a Grand Tour, June 2009".  It is too long for me to search for characters "manually".

I can live without them, so I am happy enough, but anyone is interested in finding exactly what went wrong, I'd be glad to help.

Thanks for the help!

Luis
 
Reply all
Reply to author
Forward
0 new messages