ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 17 Jan 2018 12:12:20 -0600REST API for SageMathCell / SageCellhttp://ask.sagemath.org/question/40659/rest-api-for-sagemathcell-sagecell/ Hi All,
I spun up my own SageCell and now I want to be able to execute commands get responses via a REST API (or SOAP API).
How can I do this? There don't seem to be any docs on this.
Thanks
bragac2Wed, 17 Jan 2018 12:12:20 -0600http://ask.sagemath.org/question/40659/does sage server API work in 5.10?http://ask.sagemath.org/question/10469/does-sage-server-api-work-in-510/I am trying to run a simple notebook server to use API described [here](http://www.math.ucla.edu/~jimc/mathnet_d/sage/reference/sagenb/simple/twist.html) and [here](http://www.sagemath.org/doc/reference/notebook/sagenb/notebook/notebook_object.html)
I run the following code in sage command line:
sage:version()
'Sage Version 5.10, Release Date: 2013-06-17'
sage: from sagenb.notebook.notebook_object import test_notebook
sage: passwd = str(randint(1,1<<128))
sage: nb = test_notebook(passwd, secure=False, interface='localhost', port=Integer(9000), verbose=True, directory=None)
Instead of running server, I get the following:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-6fc45872bdcd> in <module>()
----> 1 nb = test_notebook(passwd, secure=False, interface='localhost', port=Integer(9000), verbose=True,directory=None)
/opt/sage/devel/sagenb/sagenb/notebook/notebook_object.pyc in test_notebook(admin_passwd, secure, directory, port, interface, verbose)
266
267 nb = _notebook.load_notebook(directory)
--> 268 nb.set_accounts(True)
269 nb.add_user('admin', admin_passwd, '')
270 nb.set_accounts(False)
AttributeError: 'Notebook' object has no attribute 'set_accounts'
I have also tried to connect to a "normal" sage server created by notebook() via 'simple' URL:
http://localhost:8080/simple/login?username=admin&password=%s
which returns error 404
Does the sage server API work in sage 5.10? Is there a workaround how to create such server? Is there any other way to execute some sage code remotely?
ADuC812Sun, 25 Aug 2013 10:26:41 -0500http://ask.sagemath.org/question/10469/Sage and Javascripthttp://ask.sagemath.org/question/9913/sage-and-javascript/Hi all,
I have never used Sage seriously and I have a newbie question.
I would like to use Sage Server as a math processor and read query results (i.e. raw data) though a kind of rest api. In this way, I could integrate my Javascript application with complex math.
I had a quick look at Sage Notebook and I saw that it uses json to interact with the server.
However, it seems (but I might be wrong) that this json is tightly coupled with the Notebook interface.
I was wondering:
1. If the Notebook api is documented anywhere.
2. If there are pure Javascript decoupled gui which use Sage.
Thanks a lot,
Marco
MarcosFri, 15 Mar 2013 05:30:45 -0500http://ask.sagemath.org/question/9913/Internal Python: `No module named all`http://ask.sagemath.org/question/7517/internal-python-no-module-named-all/## Please Note
This is not a duplicate because the other people who've got that error message all were using an external python installation instead of `sage -python /path/to.py`
## My Situation
I'm **not able to** execute scripts the following ways:
- `sage /path/to.sage` (preprocessed)
- `sage /path/to.spyx`
- `sage /path/to.py`
- `sage -python /path/to.py`
But I'm able to run correctly **without problems**:
- `sage $ load 'file'`
## The Traceback
When `cython` compiles an `.spyx` file:
Traceback (most recent call last):
[...]
File "_home_user_Dokumente_oak_code_sage_spyx_0.pyx", line 14, in init _home_user_Dokumente_oak_code_sage_spyx_0 (_home_user_Dokumente_oak_code_sage_spyx_0.c:754)
sg.var('a b c')
AttributeError: 'module' object has no attribute 'var'
The statement that there's no `var` in the loaded module seems to be true because `dir(sg)` wasn't able to find anything else than `__doc__` and other "underscored items".
When `python` tries to execute file (normal handwritten `.py` or a `sage` preprocessed `.sage`):
Traceback (most recent call last):
File "sage2.py", line 2, in <module>
from sage.all_cmdline import * # import sage library
File "/home/user/Dokumente/oak/code/sage.py", line 4, in <module>
import sage.all as sg
ImportError: No module named all
## The Source
#!/usr/bin/env sage -python
import sys
import sage.all as sg
print '== TESTOUTPUT =='
sg.var('a b c')
## The Environment
My system setup:
Ubuntu 12.4 LTS
743,6 MiB64
AMD Athlon(tm) II X4 620 Processor
64 Bit
My environment variables:
[...]
declare -x LD_LIBRARY_PATH="/opt/sage/local/lib"
declare -x LESSCLOSE="/usr/bin/lesspipe %s %s"
declare -x LESSOPEN="| /usr/bin/lesspipe %s"
declare -x LIBRARY_PATH="/opt/sage/local/lib/"
[...]
declare -x PATH="/opt/sage:/opt/sage/local/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
declare -x PWD="/home/jk/Dokumente/oak/code"
declare -x PYTHONHOME="/opt/sage/local"
declare -x PYTHONPATH="/opt/sage/local/lib/python"
declare -x RANLIB="ranlib"
declare -x RHOME="/opt/sage/local/lib/R"
declare -x RM="rm"
declare -x SAGE64="no"
declare -x SAGE_DATA="/opt/sage/data"
declare -x SAGE_DOC="/opt/sage/devel/sage/doc"
declare -x SAGE_EXTCODE="/opt/sage/spkg/installed/extcode-5.7"
declare -x SAGE_LOCAL="/opt/sage/local"
declare -x SAGE_ORIG_LD_LIBRARY_PATH="/opt/sage//local/lib"
declare -x SAGE_ORIG_LD_LIBRARY_PATH_SET="True"
declare -x SAGE_PACKAGES="/opt/sage/spkg"
declare -x SAGE_ROOT="/opt/sage"
declare -x SAGE_SERVER="http://www.sagemath.org/"
declare -x SAGE_SHARE="/opt/sage/local/share"
declare -x SAGE_STARTUP_FILE="/home/user/.sage//init.sage"
declare -x SAGE_TESTDIR="/home/user/.sage//tmp"
[...]
declare -x __sage__=""
## The Question
How can I get `sage -python` (`sage`'s internal `python`) to **execute** the files specified as command line argument **correctly**? How can I get `sage.all`'s members to get `import`ed correctly?
Thanks - if anything's unclear concerning my question, please leave a comment. fdj815Tue, 05 Mar 2013 07:43:39 -0600http://ask.sagemath.org/question/7517/Python's C API and SAGEhttp://ask.sagemath.org/question/9517/pythons-c-api-and-sage/I have written some python code which imports and uses the sage library. I would like to invoke some of this code from C++ code using the C API for python. The problem is that the C API uses the system-wide python installation, rather than sage's python, and therefore the "from sage.all import *" statement generates ImportError. Can anyone tell me how to<br>
(i) install the sage libraries into the system's python installation, OR<br>
(ii) tell the C API to use sage's python rather than the regular version, OR<br>
(iii) resolve this some other way?
rmp251Fri, 09 Nov 2012 16:47:05 -0600http://ask.sagemath.org/question/9517/notebook api: new worksheethttp://ask.sagemath.org/question/9171/notebook-api-new-worksheet/Hello I am here again for a second question:
I proxy connections to SAGE notebook, because I tried the API documented at
[http://www.sagemath.org/doc/reference/sagenb/simple/twist.html](http://www.sagemath.org/doc/reference/sagenb/simple/twist.html)
but I didn't succeed.
To my needing in this stage of early development is ok to proxy connections to notebook worksheet pages, hijacking the session cookie, but I'd like to be able to create new worksheets on the fly. I know it is a bit weird, but is it feasible in your opinion?
TIA
LucaferoSat, 21 Jul 2012 21:59:08 -0500http://ask.sagemath.org/question/9171/