[sagenb] 45/179: Modify code so we can remove the old notebook from Sage. See http://trac.sagemath.org/sage_trac/ticket/11409.
felix salfelder
felix-guest at moszumanska.debian.org
Tue May 6 12:05:08 UTC 2014
This is an automated email from the git hooks/post-receive script.
felix-guest pushed a commit to branch master
in repository sagenb.
commit 91c41abcb3df72e204faab3b00b1b50c9d7f1d1c
Author: John H. Palmieri <palmieri at math.washington.edu>
Date: Thu Dec 6 13:18:43 2012 -0800
Modify code so we can remove the old notebook from Sage. See
http://trac.sagemath.org/sage_trac/ticket/11409.
---
sagenb/misc/misc.py | 25 ++++++++++++++-----------
sagenb/misc/support.py | 10 +++++-----
sagenb/notebook/cell.py | 4 ++--
sagenb/simple/twist.py | 8 ++++----
4 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/sagenb/misc/misc.py b/sagenb/misc/misc.py
index d55efdd..f0b6ad0 100644
--- a/sagenb/misc/misc.py
+++ b/sagenb/misc/misc.py
@@ -41,25 +41,26 @@ def print_open_msg(address, port, secure=False, path=""):
EXAMPLES::
- sage: sage.server.misc.print_open_msg('localhost', 8080, True)
+ sage: from sagenb.misc.misc import print_open_msg
+ sage: print_open_msg('localhost', 8080, True)
****************************************************
* *
* Open your web browser to https://localhost:8080 *
* *
****************************************************
- sage: sage.server.misc.print_open_msg('sagemath.org', 8080, False)
+ sage: print_open_msg('sagemath.org', 8080, False)
******************************************************
* *
* Open your web browser to http://sagemath.org:8080 *
* *
******************************************************
- sage: sage.server.misc.print_open_msg('sagemath.org', 90, False)
+ sage: print_open_msg('sagemath.org', 90, False)
****************************************************
* *
* Open your web browser to http://sagemath.org:90 *
* *
****************************************************
- sage: sage.server.misc.print_open_msg('sagemath.org', 80, False)
+ sage: print_open_msg('sagemath.org', 80, False)
**************************************************
* *
* Open your web browser to http://sagemath.org *
@@ -85,14 +86,16 @@ def print_open_msg(address, port, secure=False, path=""):
print '*'*n
-def find_next_available_port(interface, start, max_tries=100, verbose=False):
+def find_next_available_port(host, start, max_tries=100, verbose=False):
"""
- Find the next available port, that is, a port for which a
- current connection attempt returns a 'Connection refused' error
- message. If no port is found, raise a RuntimError exception.
+ Find the next available port on a given host, that is, a port for
+ which a current connection attempt returns a 'Connection refused'
+ error message. If no port is found, raise a RuntimeError exception.
INPUT:
+ - ``host`` - address to check
+
- ``start`` - an int; the starting port number for the scan
- ``max_tries`` - an int (default: 100); how many ports to scan
@@ -106,8 +109,8 @@ def find_next_available_port(interface, start, max_tries=100, verbose=False):
EXAMPLES::
- sage: import sagenb
- sage: sagenb.misc.misc.find_next_available_port('127.0.0.1', 9000, verbose=False) # random output -- depends on network
+ sage: from sagenb.misc.misc import find_next_available_port
+ sage: find_next_available_port('127.0.0.1', 9000, verbose=False) # random output -- depends on network
9002
"""
alarm_count = 0
@@ -115,7 +118,7 @@ def find_next_available_port(interface, start, max_tries=100, verbose=False):
try:
alarm(1)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- s.connect((interface, port))
+ s.connect((host, port))
except socket.error, msg:
if msg[1] == 'Connection refused':
if verbose: print "Using port = %s"%port
diff --git a/sagenb/misc/support.py b/sagenb/misc/support.py
index 510f52e..e5bf6e7 100644
--- a/sagenb/misc/support.py
+++ b/sagenb/misc/support.py
@@ -111,7 +111,7 @@ def help(obj):
sage: import numpy.linalg
sage: import os, sage.misc.misc ; current_dir = os.getcwd()
sage: os.chdir(sage.misc.misc.tmp_dir('server_doctest'))
- sage: sage.server.support.help(numpy.linalg.norm)
+ sage: sagenb.misc.support.help(numpy.linalg.norm)
<html><table notracebacks bgcolor="#386074" cellpadding=10 cellspacing=10><tr><td bgcolor="#f5f5f5"><font color="#37546d">
<a target='_new' href='cell://docs-....html'>Click to open help window</a>
<br></font></tr></td></table></html>
@@ -459,16 +459,16 @@ def syseval(system, cmd, dir=None):
EXAMPLES::
sage: from sage.misc.python import python
- sage: sage.server.support.syseval(python, '2+4/3')
+ sage: sagenb.misc.support.syseval(python, '2+4/3')
3
''
- sage: sage.server.support.syseval(python, 'import os; os.chdir(".")')
+ sage: sagenb.misc.support.syseval(python, 'import os; os.chdir(".")')
''
- sage: sage.server.support.syseval(python, 'import os; os.chdir(1,2,3)')
+ sage: sagenb.misc.support.syseval(python, 'import os; os.chdir(1,2,3)')
Traceback (most recent call last):
...
TypeError: chdir() takes exactly 1 argument (3 given)
- sage: sage.server.support.syseval(gap, "2+3")
+ sage: sagenb.misc.support.syseval(gap, "2+3")
'5'
"""
if dir:
diff --git a/sagenb/notebook/cell.py b/sagenb/notebook/cell.py
index 1580580..35e43f4 100644
--- a/sagenb/notebook/cell.py
+++ b/sagenb/notebook/cell.py
@@ -1619,7 +1619,7 @@ class Cell(Cell_generic):
output = output.replace('\r', '')
# We do not truncate if "notruncate" or "Output truncated!" already
# appears in the output. This notruncate tag is used right now
- # in sage.server.support.help.
+ # in sagenb.notebook.interact, sage.misc.html, and sage.database.sql_db.
if ('notruncate' not in output and
'Output truncated!' not in output
and
@@ -2474,7 +2474,7 @@ def format_exception(s0, ncols):
s = s0.lstrip()
# Add a notracebacks option -- if it is in the string then
# tracebacks aren't shrunk. This is currently used by the
- # sage.server.support.help command.
+ # functions sagenb.misc.support.help and sage.server.support.help.
if TRACEBACK not in s or 'notracebacks' in s:
return s0
if ncols > 0:
diff --git a/sagenb/simple/twist.py b/sagenb/simple/twist.py
index 296f040..ee222b1 100644
--- a/sagenb/simple/twist.py
+++ b/sagenb/simple/twist.py
@@ -24,11 +24,11 @@ server/API.
Start the notebook server.::
- sage: from sage.server.misc import find_next_available_port
+ sage: from sagenb.misc.misc import find_next_available_port
sage: port = find_next_available_port(9000, verbose=False)
sage: from sagenb.notebook.notebook_object import test_notebook
sage: passwd = str(randint(1,1<<128))
- sage: nb = test_notebook(passwd, secure=False, address='localhost', port=port, verbose=True) #doctest: +ELLIPSIS
+ sage: nb = test_notebook(passwd, secure=False, address='localhost', port=port, verbose=True)
...
Notebook started.
@@ -160,7 +160,7 @@ def simple_jsonize(data):
EXAMPLES::
- sage: from sage.server.simple.twist import simple_jsonize
+ sage: from sagenb.simple.twist import simple_jsonize
sage: print simple_jsonize({'a': [1,2,3], 'b': "yep"})
{ "a": [1, 2, 3], "b": "yep" }
"""
@@ -195,7 +195,7 @@ class SessionObject:
TEST::
- sage: from sage.server.simple.twist import SessionObject
+ sage: from sagenb.simple.twist import SessionObject
sage: s = SessionObject(id=1, username=None, worksheet=None)
sage: s.get_status()
{'session': 1}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/sagenb.git
More information about the debian-science-commits
mailing list