Changeset 3889:d1945060338b
- Timestamp:
- 04/11/07 16:56:33 (6 years ago)
- Branch:
- default
- Location:
- sage
- Files:
-
- 1 added
- 3 edited
-
misc/hg.py (modified) (3 diffs)
-
server/misc.py (added)
-
server/notebook/notebook.py (modified) (5 diffs)
-
server/wiki/moin.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/misc/hg.py
r3631 r3889 35 35 from misc import tmp_filename, branch_current_hg 36 36 from remote_file import get_remote_file 37 from sage.server.misc import print_open_msg 37 38 38 39 def embedded(): … … 154 155 return out, err 155 156 156 def serve(self, port=8200, open_viewer=False): 157 def serve(self, port=8200, address='localhost', 158 open_viewer=True, options=''): 157 159 """ 158 160 Start a web server for this repository. … … 164 166 INPUT: 165 167 port -- port that the server will listen on 166 open_viewer -- boolean (default: False); whether to pop up the web page167 """168 print('Now serving repository on port %s'%port)169 print("Point your web browser at http://localhost:%s"%port)168 address -- (default: 'localhost') address to listen on 169 open_viewer -- boolean (default: True); whether to pop up the web page 170 options -- a string passed directly to hg's serve command. 171 """ 170 172 if open_viewer: 171 cmd = 'sleep 1; %s http://%s:%s 1>&2 >/dev/null'%(browser(), 'localhost', port) 173 cmd = 'sleep 1; %s http://%s:%s 1>&2 >/dev/null'%(browser(), 174 address, port) 172 175 t = tmp_filename() 173 176 open(t,'w').write(cmd) 174 177 P = os.path.abspath(t) 175 178 os.system('chmod +x %s; %s &'%(P, P)) 176 self('serve --port %s'%port) 179 180 print_open_msg(address, port) 181 tries = 0 182 while self('serve --address %s --port %s %s'%(address, port, options)) != 2: 183 port += 1 184 tries += 1 185 if tries > 100: 186 raise RuntimeError, "no port found after trying 100 (maybe your network is down)" 187 print_open_msg(address, port) 188 177 189 178 190 browse = serve -
sage/server/notebook/notebook.py
r3701 r3889 17 17 \subsection{Supported Browsers} 18 18 19 The SAGE notebook should fully work with Firefox (and Mozilla), 20 Safari, and Opera. The notebook works somewhat in Internet Explorer. 19 The SAGE notebook should fully work with Firefox (and Mozilla). It 20 may work to some extent with Safari and Opera. Internet Explorer is 21 not supported. 21 22 22 23 \subsection{Tutorial} … … 347 348 from sage.misc.viewer import browser 348 349 from sage.misc.misc import alarm, cancel_alarm 350 from sage.server.misc import print_open_msg 349 351 350 352 # SAGE Notebook … … 775 777 break 776 778 777 s = "Open your web browser to http://%s:%s"%(address, port) 778 t = len(s) 779 if t%2: 780 t += 1 781 s += ' ' 782 n = max(t+4, 50) 783 k = n - t - 1 784 j = k/2 785 print '*'*n 786 print '*'+ ' '*(n-2) + '*' 787 print '*' + ' '*j + s + ' '*j + '*' 788 print '*'+ ' '*(n-2) + '*' 789 print '*'*n 790 print "WARNING: The SAGE Notebook works best with Firefox/Mozilla, Safari, and Opera." 779 print_open_msg(address, port) 780 print "WARNING: The SAGE Notebook works best with ** Firefox/Mozilla **." 781 791 782 792 783 if open_viewer: … … 1475 1466 port = 8000, 1476 1467 address = 'localhost', 1477 open_viewer = False,1468 open_viewer = True, 1478 1469 max_tries = 10, 1479 1470 username = None, … … 1502 1493 address -- (default: 'localhost') address that the server 1503 1494 will listen on 1504 open_viewer -- bool (default: False); if True, pop up a web browser at the URL1495 open_viewer -- bool (default: True); if True, pop up a web browser at the URL 1505 1496 max_tries -- (default: 10) maximum number of ports > port to try in 1506 1497 case given port can't be opened. -
sage/server/wiki/moin.py
r3475 r3889 16 16 17 17 from sage.misc.viewer import browser 18 from sage.server.misc import print_open_msg 18 19 19 20 # if you change the default sage_wiki, you must also change local/bin/sage-wiki … … 39 40 port=9000, 40 41 address='localhost', 41 open_viewer = False,42 42 threads=10): 43 43 r""" … … 83 83 config.close() 84 84 85 ## Open a viewer if requested86 if open_viewer:87 cmd = '%s http://%s:%s 1>&2 >/dev/null &'%(browser(), address, port)88 os.system(cmd)89 90 85 ## Start up twisted 86 print_open_msg(address, port) 91 87 e = os.system('twistd -n --python twistedconf.py') 92 88 if not e: … … 98 94 run(port + i) 99 95 except socket.error: 100 print "Port %s is already in use. Trying next port..."% (Config.port)96 print "Port %s is already in use. Trying next port..."%port 101 97 else: 102 98 break … … 107 103 def wiki_simple_http(directory='sage_wiki', 108 104 port=9000, 109 address='localhost', 110 open_viewer = False): 105 address='localhost'): 111 106 r""" 112 107 Create (if necessary) and start up a Moin Moin wiki. … … 190 185 191 186 192 if open_viewer:193 cmd = '%s http://%s:%s 1>&2 >/dev/null &'%(browser(), address, port)194 os.system(cmd)195 196 187 for i in range(256): 197 188 try: 189 print_open_msg(address, port) 198 190 run(Config) 199 191 except socket.error:
Note: See TracChangeset
for help on using the changeset viewer.
