##// END OF EJS Templates
Merge branch 'master' of https://github.com/abakan/ipython
Ahmet Bakan -
r10598:235caf66 merge
parent child Browse files
Show More
@@ -0,0 +1,157 b''
1 /*
2
3 Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
4 Adapted from GitHub theme
5
6 */
7
8 pre code {
9 display: block;
10 padding: 0.5em;
11 }
12
13 .highlight-base,
14 pre code,
15 pre .subst,
16 pre .tag .title,
17 pre .lisp .title,
18 pre .clojure .built_in,
19 pre .nginx .title {
20 color: black;
21 }
22
23 .highlight-string,
24 pre .string,
25 pre .constant,
26 pre .parent,
27 pre .tag .value,
28 pre .rules .value,
29 pre .rules .value .number,
30 pre .preprocessor,
31 pre .ruby .symbol,
32 pre .ruby .symbol .string,
33 pre .aggregate,
34 pre .template_tag,
35 pre .django .variable,
36 pre .smalltalk .class,
37 pre .addition,
38 pre .flow,
39 pre .stream,
40 pre .bash .variable,
41 pre .apache .tag,
42 pre .apache .cbracket,
43 pre .tex .command,
44 pre .tex .special,
45 pre .erlang_repl .function_or_atom,
46 pre .markdown .header {
47 color: #BA2121;
48 }
49
50 .highlight-comment,
51 pre .comment,
52 pre .annotation,
53 pre .template_comment,
54 pre .diff .header,
55 pre .chunk,
56 pre .markdown .blockquote {
57 color: #408080;
58 font-style: italic;
59 }
60
61 .highlight-number,
62 pre .number,
63 pre .date,
64 pre .regexp,
65 pre .literal,
66 pre .smalltalk .symbol,
67 pre .smalltalk .char,
68 pre .go .constant,
69 pre .change,
70 pre .markdown .bullet,
71 pre .markdown .link_url {
72 color: #080;
73 }
74
75 pre .label,
76 pre .javadoc,
77 pre .ruby .string,
78 pre .decorator,
79 pre .filter .argument,
80 pre .localvars,
81 pre .array,
82 pre .attr_selector,
83 pre .important,
84 pre .pseudo,
85 pre .pi,
86 pre .doctype,
87 pre .deletion,
88 pre .envvar,
89 pre .shebang,
90 pre .apache .sqbracket,
91 pre .nginx .built_in,
92 pre .tex .formula,
93 pre .erlang_repl .reserved,
94 pre .prompt,
95 pre .markdown .link_label,
96 pre .vhdl .attribute,
97 pre .clojure .attribute,
98 pre .coffeescript .property {
99 color: #88F
100 }
101
102 .highlight-keyword,
103 pre .keyword,
104 pre .id,
105 pre .phpdoc,
106 pre .aggregate,
107 pre .css .tag,
108 pre .javadoctag,
109 pre .phpdoc,
110 pre .yardoctag,
111 pre .smalltalk .class,
112 pre .winutils,
113 pre .bash .variable,
114 pre .apache .tag,
115 pre .go .typename,
116 pre .tex .command,
117 pre .markdown .strong,
118 pre .request,
119 pre .status {
120 color: #008000;
121 font-weight: bold;
122 }
123
124 .highlight-builtin,
125 pre .built_in {
126 color: #008000;
127 }
128
129 pre .markdown .emphasis {
130 font-style: italic;
131 }
132
133 pre .nginx .built_in {
134 font-weight: normal;
135 }
136
137 pre .coffeescript .javascript,
138 pre .javascript .xml,
139 pre .tex .formula,
140 pre .xml .javascript,
141 pre .xml .vbscript,
142 pre .xml .css,
143 pre .xml .cdata {
144 opacity: 0.5;
145 }
146
147 /* apply the same style to codemirror */
148
149 .cm-s-ipython span.cm-variable { .highlight-base()}
150 .cm-s-ipython span.cm-keyword { .highlight-keyword() }
151 .cm-s-ipython span.cm-number { .highlight-number() }
152 .cm-s-ipython span.cm-comment { .highlight-comment() }
153 .cm-s-ipython span.cm-string { .highlight-string()}
154 .cm-s-ipython span.cm-builtin { .highlight-builtin() }
155 .cm-s-ipython span.cm-error { color: #f00; }
156 .cm-s-ipython span.cm-operator {color: #AA22FF; font-weight: bold;}
157 .cm-s-ipython span.cm-meta {color: #AA22FF;}
@@ -1,3 +1,3 b''
1 [submodule "components"]
1 [submodule "components"]
2 path = IPython/frontend/html/notebook/static/components
2 path = IPython/frontend/html/notebook/static/components
3 url = git://github.com/ipython/ipython-components.git
3 url = https://github.com/ipython/ipython-components.git
@@ -144,8 +144,17 b' class BaseIPythonApplication(Application):'
144 # The class to use as the crash handler.
144 # The class to use as the crash handler.
145 crash_handler_class = Type(crashhandler.CrashHandler)
145 crash_handler_class = Type(crashhandler.CrashHandler)
146
146
147 @catch_config_error
147 def __init__(self, **kwargs):
148 def __init__(self, **kwargs):
148 super(BaseIPythonApplication, self).__init__(**kwargs)
149 super(BaseIPythonApplication, self).__init__(**kwargs)
150 # ensure current working directory exists
151 try:
152 directory = os.getcwdu()
153 except:
154 # raise exception
155 self.log.error("Current working directory doesn't exist.")
156 raise
157
149 # ensure even default IPYTHONDIR exists
158 # ensure even default IPYTHONDIR exists
150 if not os.path.exists(self.ipython_dir):
159 if not os.path.exists(self.ipython_dir):
151 self._ipython_dir_changed('ipython_dir', self.ipython_dir, self.ipython_dir)
160 self._ipython_dir_changed('ipython_dir', self.ipython_dir, self.ipython_dir)
@@ -77,8 +77,7 b' python-profiler package from non-free.""")'
77
77
78 @skip_doctest
78 @skip_doctest
79 @line_cell_magic
79 @line_cell_magic
80 def prun(self, parameter_s='', cell=None, user_mode=True,
80 def prun(self, parameter_s='', cell=None):
81 opts=None,arg_lst=None,prog_ns=None):
82
81
83 """Run a statement through the python code profiler.
82 """Run a statement through the python code profiler.
84
83
@@ -178,38 +177,33 b' python-profiler package from non-free.""")'
178
177
179 In [1]: import profile; profile.help()
178 In [1]: import profile; profile.help()
180 """
179 """
180 opts, arg_str = self.parse_options(parameter_s, 'D:l:rs:T:q',
181 list_all=True, posix=False)
182 if cell is not None:
183 arg_str += '\n' + cell
184 return self._run_with_profiler(arg_str, opts, self.shell.user_ns)
181
185
182 opts_def = Struct(D=[''],l=[],s=['time'],T=[''])
186 def _run_with_profiler(self, code, opts, namespace):
187 """
188 Run `code` with profiler. Used by ``%prun`` and ``%run -p``.
183
189
184 if user_mode: # regular user call
190 Parameters
185 opts,arg_str = self.parse_options(parameter_s,'D:l:rs:T:q',
191 ----------
186 list_all=True, posix=False)
192 code : str
187 namespace = self.shell.user_ns
193 Code to be executed.
188 if cell is not None:
194 opts : Struct
189 arg_str += '\n' + cell
195 Options parsed by `self.parse_options`.
190 else: # called to run a program by %run -p
196 namespace : dict
191 try:
197 A dictionary for Python namespace (e.g., `self.shell.user_ns`).
192 filename = get_py_filename(arg_lst[0])
193 except IOError as e:
194 try:
195 msg = str(e)
196 except UnicodeError:
197 msg = e.message
198 error(msg)
199 return
200
198
201 arg_str = 'execfile(filename,prog_ns)'
199 """
202 namespace = {
203 'execfile': self.shell.safe_execfile,
204 'prog_ns': prog_ns,
205 'filename': filename
206 }
207
200
208 opts.merge(opts_def)
201 # Fill default values for unspecified options:
202 opts.merge(Struct(D=[''], l=[], s=['time'], T=['']))
209
203
210 prof = profile.Profile()
204 prof = profile.Profile()
211 try:
205 try:
212 prof = prof.runctx(arg_str,namespace,namespace)
206 prof = prof.runctx(code, namespace, namespace)
213 sys_exit = ''
207 sys_exit = ''
214 except SystemExit:
208 except SystemExit:
215 sys_exit = """*** SystemExit exception caught in code being profiled."""
209 sys_exit = """*** SystemExit exception caught in code being profiled."""
@@ -327,8 +321,10 b' python-profiler package from non-free.""")'
327 file_finder=get_py_filename):
321 file_finder=get_py_filename):
328 """Run the named file inside IPython as a program.
322 """Run the named file inside IPython as a program.
329
323
330 Usage:\\
324 Usage:
331 %run [-n -i -t [-N<N>] -d [-b<N>] -p [profile options] -G] file [args]
325 %run [-n -i -e -G]
326 [( -t [-N<N>] | -d [-b<N>] | -p [profile options] )]
327 ( -m mod | file ) [args]
332
328
333 Parameters after the filename are passed as command-line arguments to
329 Parameters after the filename are passed as command-line arguments to
334 the program (put in sys.argv). Then, control returns to IPython's
330 the program (put in sys.argv). Then, control returns to IPython's
@@ -541,62 +537,45 b' python-profiler package from non-free.""")'
541 # every single object ever created.
537 # every single object ever created.
542 sys.modules[main_mod_name] = main_mod
538 sys.modules[main_mod_name] = main_mod
543
539
540 if 'p' in opts or 'd' in opts:
541 if 'm' in opts:
542 code = 'run_module(modulename, prog_ns)'
543 code_ns = {
544 'run_module': self.shell.safe_run_module,
545 'prog_ns': prog_ns,
546 'modulename': modulename,
547 }
548 else:
549 code = 'execfile(filename, prog_ns)'
550 code_ns = {
551 'execfile': self.shell.safe_execfile,
552 'prog_ns': prog_ns,
553 'filename': get_py_filename(filename),
554 }
555
544 try:
556 try:
545 stats = None
557 stats = None
546 with self.shell.readline_no_record:
558 with self.shell.readline_no_record:
547 if 'p' in opts:
559 if 'p' in opts:
548 stats = self.prun('', None, False, opts, arg_lst, prog_ns)
560 stats = self._run_with_profiler(code, opts, code_ns)
549 else:
561 else:
550 if 'd' in opts:
562 if 'd' in opts:
551 deb = debugger.Pdb(self.shell.colors)
563 self._run_with_debugger(
552 # reset Breakpoint state, which is moronically kept
564 code, code_ns, opts.get('b', ['1'])[0], filename)
553 # in a class
554 bdb.Breakpoint.next = 1
555 bdb.Breakpoint.bplist = {}
556 bdb.Breakpoint.bpbynumber = [None]
557 # Set an initial breakpoint to stop execution
558 maxtries = 10
559 bp_file, bp_line = parse_breakpoint(opts.get('b', ['1'])[0], filename)
560 checkline = deb.checkline(bp_file, bp_line)
561 if not checkline:
562 for bp in range(bp_line + 1, bp_line + maxtries + 1):
563 if deb.checkline(bp_file, bp):
564 break
565 else:
566 msg = ("\nI failed to find a valid line to set "
567 "a breakpoint\n"
568 "after trying up to line: %s.\n"
569 "Please set a valid breakpoint manually "
570 "with the -b option." % bp)
571 error(msg)
572 return
573 # if we find a good linenumber, set the breakpoint
574 deb.do_break('%s:%s' % (bp_file, bp_line))
575
576 # Mimic Pdb._runscript(...)
577 deb._wait_for_mainpyfile = True
578 deb.mainpyfile = deb.canonic(filename)
579
580 # Start file run
581 print "NOTE: Enter 'c' at the",
582 print "%s prompt to start your script." % deb.prompt
583 ns = {'execfile': py3compat.execfile, 'prog_ns': prog_ns}
584 try:
585 #save filename so it can be used by methods on the deb object
586 deb._exec_filename = filename
587 deb.run('execfile("%s", prog_ns)' % filename, ns)
588
589 except:
590 etype, value, tb = sys.exc_info()
591 # Skip three frames in the traceback: the %run one,
592 # one inside bdb.py, and the command-line typed by the
593 # user (run by exec in pdb itself).
594 self.shell.InteractiveTB(etype, value, tb, tb_offset=3)
595 else:
565 else:
596 if runner is None:
566 if 'm' in opts:
597 runner = self.default_runner
567 def run():
598 if runner is None:
568 self.shell.safe_run_module(modulename, prog_ns)
599 runner = self.shell.safe_execfile
569 else:
570 if runner is None:
571 runner = self.default_runner
572 if runner is None:
573 runner = self.shell.safe_execfile
574
575 def run():
576 runner(filename, prog_ns, prog_ns,
577 exit_ignore=exit_ignore)
578
600 if 't' in opts:
579 if 't' in opts:
601 # timed execution
580 # timed execution
602 try:
581 try:
@@ -606,37 +585,10 b' python-profiler package from non-free.""")'
606 return
585 return
607 except (KeyError):
586 except (KeyError):
608 nruns = 1
587 nruns = 1
609 twall0 = time.time()
588 self._run_with_timing(run, nruns)
610 if nruns == 1:
611 t0 = clock2()
612 runner(filename, prog_ns, prog_ns,
613 exit_ignore=exit_ignore)
614 t1 = clock2()
615 t_usr = t1[0] - t0[0]
616 t_sys = t1[1] - t0[1]
617 print "\nIPython CPU timings (estimated):"
618 print " User : %10.2f s." % t_usr
619 print " System : %10.2f s." % t_sys
620 else:
621 runs = range(nruns)
622 t0 = clock2()
623 for nr in runs:
624 runner(filename, prog_ns, prog_ns,
625 exit_ignore=exit_ignore)
626 t1 = clock2()
627 t_usr = t1[0] - t0[0]
628 t_sys = t1[1] - t0[1]
629 print "\nIPython CPU timings (estimated):"
630 print "Total runs performed:", nruns
631 print " Times : %10s %10s" % ('Total', 'Per run')
632 print " User : %10.2f s, %10.2f s." % (t_usr, t_usr / nruns)
633 print " System : %10.2f s, %10.2f s." % (t_sys, t_sys / nruns)
634 twall1 = time.time()
635 print "Wall time: %10.2f s." % (twall1 - twall0)
636
637 else:
589 else:
638 # regular execution
590 # regular execution
639 runner(filename, prog_ns, prog_ns, exit_ignore=exit_ignore)
591 run()
640
592
641 if 'i' in opts:
593 if 'i' in opts:
642 self.shell.user_ns['__name__'] = __name__save
594 self.shell.user_ns['__name__'] = __name__save
@@ -676,7 +628,114 b' python-profiler package from non-free.""")'
676 del sys.modules[main_mod_name]
628 del sys.modules[main_mod_name]
677
629
678 return stats
630 return stats
679
631
632 def _run_with_debugger(self, code, code_ns, break_point, filename):
633 """
634 Run `code` in debugger with a break point.
635
636 Parameters
637 ----------
638 code : str
639 Code to execute.
640 code_ns : dict
641 A namespace in which `code` is executed.
642 break_point : str
643 Line number in the file specified by `filename` argument
644 or a string in the format ``file:line``. In the latter
645 case, `filename` is ignored.
646 See also :func:`.parse_breakpoint`.
647 filename : str
648 Path to the file in which break point is specified.
649
650 Raises
651 ------
652 UsageError
653 If no meaningful break point is given by `break_point` and
654 `filename`.
655
656 """
657 deb = debugger.Pdb(self.shell.colors)
658 # reset Breakpoint state, which is moronically kept
659 # in a class
660 bdb.Breakpoint.next = 1
661 bdb.Breakpoint.bplist = {}
662 bdb.Breakpoint.bpbynumber = [None]
663 # Set an initial breakpoint to stop execution
664 maxtries = 10
665 bp_file, bp_line = parse_breakpoint(break_point, filename)
666 checkline = deb.checkline(bp_file, bp_line)
667 if not checkline:
668 for bp in range(bp_line + 1, bp_line + maxtries + 1):
669 if deb.checkline(bp_file, bp):
670 break
671 else:
672 msg = ("\nI failed to find a valid line to set "
673 "a breakpoint\n"
674 "after trying up to line: %s.\n"
675 "Please set a valid breakpoint manually "
676 "with the -b option." % bp)
677 raise UsageError(msg)
678 # if we find a good linenumber, set the breakpoint
679 deb.do_break('%s:%s' % (bp_file, bp_line))
680
681 # Mimic Pdb._runscript(...)
682 deb._wait_for_mainpyfile = True
683 deb.mainpyfile = deb.canonic(filename)
684
685 # Start file run
686 print "NOTE: Enter 'c' at the",
687 print "%s prompt to start your script." % deb.prompt
688 try:
689 #save filename so it can be used by methods on the deb object
690 deb._exec_filename = filename
691 deb.run(code, code_ns)
692
693 except:
694 etype, value, tb = sys.exc_info()
695 # Skip three frames in the traceback: the %run one,
696 # one inside bdb.py, and the command-line typed by the
697 # user (run by exec in pdb itself).
698 self.shell.InteractiveTB(etype, value, tb, tb_offset=3)
699
700 @staticmethod
701 def _run_with_timing(run, nruns):
702 """
703 Run function `run` and print timing information.
704
705 Parameters
706 ----------
707 run : callable
708 Any callable object which takes no argument.
709 nruns : int
710 Number of times to execute `run`.
711
712 """
713 twall0 = time.time()
714 if nruns == 1:
715 t0 = clock2()
716 run()
717 t1 = clock2()
718 t_usr = t1[0] - t0[0]
719 t_sys = t1[1] - t0[1]
720 print "\nIPython CPU timings (estimated):"
721 print " User : %10.2f s." % t_usr
722 print " System : %10.2f s." % t_sys
723 else:
724 runs = range(nruns)
725 t0 = clock2()
726 for nr in runs:
727 run()
728 t1 = clock2()
729 t_usr = t1[0] - t0[0]
730 t_sys = t1[1] - t0[1]
731 print "\nIPython CPU timings (estimated):"
732 print "Total runs performed:", nruns
733 print " Times : %10s %10s" % ('Total', 'Per run')
734 print " User : %10.2f s, %10.2f s." % (t_usr, t_usr / nruns)
735 print " System : %10.2f s, %10.2f s." % (t_sys, t_sys / nruns)
736 twall1 = time.time()
737 print "Wall time: %10.2f s." % (twall1 - twall0)
738
680 @skip_doctest
739 @skip_doctest
681 @line_cell_magic
740 @line_cell_magic
682 def timeit(self, line='', cell=None):
741 def timeit(self, line='', cell=None):
@@ -13,9 +13,13 b' from __future__ import absolute_import'
13 # Imports
13 # Imports
14 #-----------------------------------------------------------------------------
14 #-----------------------------------------------------------------------------
15
15
16 import functools
16 import os
17 import os
18 import random
17 import sys
19 import sys
18 import tempfile
20 import tempfile
21 import textwrap
22 import unittest
19
23
20 import nose.tools as nt
24 import nose.tools as nt
21 from nose import SkipTest
25 from nose import SkipTest
@@ -23,6 +27,8 b' from nose import SkipTest'
23 from IPython.testing import decorators as dec
27 from IPython.testing import decorators as dec
24 from IPython.testing import tools as tt
28 from IPython.testing import tools as tt
25 from IPython.utils import py3compat
29 from IPython.utils import py3compat
30 from IPython.utils.tempdir import TemporaryDirectory
31 from IPython.core import debugger
26
32
27 #-----------------------------------------------------------------------------
33 #-----------------------------------------------------------------------------
28 # Test functions begin
34 # Test functions begin
@@ -337,3 +343,74 b' tclass.py: deleting object: C-third'
337 self.mktmp(src)
343 self.mktmp(src)
338 _ip.magic('run -t -N 1 %s' % self.fname)
344 _ip.magic('run -t -N 1 %s' % self.fname)
339 _ip.magic('run -t -N 10 %s' % self.fname)
345 _ip.magic('run -t -N 10 %s' % self.fname)
346
347
348 class TestMagicRunWithPackage(unittest.TestCase):
349
350 def writefile(self, name, content):
351 path = os.path.join(self.tempdir.name, name)
352 d = os.path.dirname(path)
353 if not os.path.isdir(d):
354 os.makedirs(d)
355 with open(path, 'w') as f:
356 f.write(textwrap.dedent(content))
357
358 def setUp(self):
359 self.package = package = 'tmp{0}'.format(repr(random.random())[2:])
360 """Temporary valid python package name."""
361
362 self.value = int(random.random() * 10000)
363
364 self.tempdir = TemporaryDirectory()
365 self.__orig_cwd = os.getcwdu()
366 sys.path.insert(0, self.tempdir.name)
367
368 self.writefile(os.path.join(package, '__init__.py'), '')
369 self.writefile(os.path.join(package, 'sub.py'), """
370 x = {0!r}
371 """.format(self.value))
372 self.writefile(os.path.join(package, 'relative.py'), """
373 from .sub import x
374 """)
375 self.writefile(os.path.join(package, 'absolute.py'), """
376 from {0}.sub import x
377 """.format(package))
378
379 def tearDown(self):
380 os.chdir(self.__orig_cwd)
381 sys.path[:] = [p for p in sys.path if p != self.tempdir.name]
382 self.tempdir.cleanup()
383
384 def check_run_submodule(self, submodule, opts=''):
385 _ip.magic('run {2} -m {0}.{1}'.format(self.package, submodule, opts))
386 self.assertEqual(_ip.user_ns['x'], self.value,
387 'Variable `x` is not loaded from module `{0}`.'
388 .format(submodule))
389
390 def test_run_submodule_with_absolute_import(self):
391 self.check_run_submodule('absolute')
392
393 def test_run_submodule_with_relative_import(self):
394 """Run submodule that has a relative import statement (#2727)."""
395 self.check_run_submodule('relative')
396
397 def test_prun_submodule_with_absolute_import(self):
398 self.check_run_submodule('absolute', '-p')
399
400 def test_prun_submodule_with_relative_import(self):
401 self.check_run_submodule('relative', '-p')
402
403 def with_fake_debugger(func):
404 @functools.wraps(func)
405 def wrapper(*args, **kwds):
406 with tt.monkeypatch(debugger.Pdb, 'run', staticmethod(eval)):
407 return func(*args, **kwds)
408 return wrapper
409
410 @with_fake_debugger
411 def test_debug_run_submodule_with_absolute_import(self):
412 self.check_run_submodule('absolute', '-d')
413
414 @with_fake_debugger
415 def test_debug_run_submodule_with_relative_import(self):
416 self.check_run_submodule('relative', '-d')
@@ -1,1 +1,1 b''
1 Subproject commit f7467391a9f9d4868f0bbf0d088fd572625862a4
1 Subproject commit 945dfca396a1a7ca66d36ee758c7d8dca2b11287
@@ -866,6 +866,26 b' a.label:hover,a.label:focus,a.badge:hover,a.badge:focus{color:#ffffff;text-decor'
866 .end{-webkit-box-pack:end;-moz-box-pack:end;box-pack:end;}
866 .end{-webkit-box-pack:end;-moz-box-pack:end;box-pack:end;}
867 .center{-webkit-box-pack:center;-moz-box-pack:center;box-pack:center;}
867 .center{-webkit-box-pack:center;-moz-box-pack:center;box-pack:center;}
868 .corner-all{border-radius:4px;}
868 .corner-all{border-radius:4px;}
869 pre code{display:block;padding:0.5em;}
870 .highlight-base,pre code,pre .subst,pre .tag .title,pre .lisp .title,pre .clojure .built_in,pre .nginx .title{color:black;}
871 .highlight-string,pre .string,pre .constant,pre .parent,pre .tag .value,pre .rules .value,pre .rules .value .number,pre .preprocessor,pre .ruby .symbol,pre .ruby .symbol .string,pre .aggregate,pre .template_tag,pre .django .variable,pre .smalltalk .class,pre .addition,pre .flow,pre .stream,pre .bash .variable,pre .apache .tag,pre .apache .cbracket,pre .tex .command,pre .tex .special,pre .erlang_repl .function_or_atom,pre .markdown .header{color:#BA2121;}
872 .highlight-comment,pre .comment,pre .annotation,pre .template_comment,pre .diff .header,pre .chunk,pre .markdown .blockquote{color:#408080;font-style:italic;}
873 .highlight-number,pre .number,pre .date,pre .regexp,pre .literal,pre .smalltalk .symbol,pre .smalltalk .char,pre .go .constant,pre .change,pre .markdown .bullet,pre .markdown .link_url{color:#080;}
874 pre .label,pre .javadoc,pre .ruby .string,pre .decorator,pre .filter .argument,pre .localvars,pre .array,pre .attr_selector,pre .important,pre .pseudo,pre .pi,pre .doctype,pre .deletion,pre .envvar,pre .shebang,pre .apache .sqbracket,pre .nginx .built_in,pre .tex .formula,pre .erlang_repl .reserved,pre .prompt,pre .markdown .link_label,pre .vhdl .attribute,pre .clojure .attribute,pre .coffeescript .property{color:#8888ff;}
875 .highlight-keyword,pre .keyword,pre .id,pre .phpdoc,pre .aggregate,pre .css .tag,pre .javadoctag,pre .phpdoc,pre .yardoctag,pre .smalltalk .class,pre .winutils,pre .bash .variable,pre .apache .tag,pre .go .typename,pre .tex .command,pre .markdown .strong,pre .request,pre .status{color:#008000;font-weight:bold;}
876 .highlight-builtin,pre .built_in{color:#008000;}
877 pre .markdown .emphasis{font-style:italic;}
878 pre .nginx .built_in{font-weight:normal;}
879 pre .coffeescript .javascript,pre .javascript .xml,pre .tex .formula,pre .xml .javascript,pre .xml .vbscript,pre .xml .css,pre .xml .cdata{opacity:0.5;}
880 .cm-s-ipython span.cm-variable{color:black;}
881 .cm-s-ipython span.cm-keyword{color:#008000;font-weight:bold;}
882 .cm-s-ipython span.cm-number{color:#080;}
883 .cm-s-ipython span.cm-comment{color:#408080;font-style:italic;}
884 .cm-s-ipython span.cm-string{color:#BA2121;}
885 .cm-s-ipython span.cm-builtin{color:#008000;}
886 .cm-s-ipython span.cm-error{color:#f00;}
887 .cm-s-ipython span.cm-operator{color:#AA22FF;font-weight:bold;}
888 .cm-s-ipython span.cm-meta{color:#AA22FF;}
869 body{background-color:#ffffff;}
889 body{background-color:#ffffff;}
870 body.notebook_app{overflow:hidden;}
890 body.notebook_app{overflow:hidden;}
871 blockquote{border-left:4px solid #DDD;padding:0 15px;color:#777;}
891 blockquote{border-left:4px solid #DDD;padding:0 15px;color:#777;}
@@ -42,7 +42,6 b' $(document).ready(function () {'
42 var baseProjectUrl = $('body').data('baseProjectUrl')
42 var baseProjectUrl = $('body').data('baseProjectUrl')
43
43
44 IPython.page = new IPython.Page();
44 IPython.page = new IPython.Page();
45 IPython.markdown_converter = new Markdown.Converter();
46 IPython.layout_manager = new IPython.LayoutManager();
45 IPython.layout_manager = new IPython.LayoutManager();
47 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
46 IPython.pager = new IPython.Pager('div#pager', 'div#pager_splitter');
48 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
47 IPython.quick_help = new IPython.QuickHelp('span#quick_help_area');
@@ -94,6 +93,23 b' $(document).ready(function () {'
94
93
95 $([IPython.events]).on('notebook_loaded.Notebook', first_load);
94 $([IPython.events]).on('notebook_loaded.Notebook', first_load);
96 IPython.notebook.load_notebook($('body').data('notebookId'));
95 IPython.notebook.load_notebook($('body').data('notebookId'));
96
97 if (marked) {
98 marked.setOptions({
99 gfm : true,
100 tables: true,
101 langPrefix: "language-",
102 highlight: function(code, lang) {
103 var highlighted;
104 try {
105 highlighted = hljs.highlight(lang, code, false);
106 } catch(err) {
107 highlighted = hljs.highlightAuto(code);
108 }
109 return highlighted.value;
110 }
111 })
112 }
97
113
98 });
114 });
99
115
@@ -140,6 +140,7 b' var IPython = (function (IPython) {'
140 SaveWidget.prototype.set_last_checkpoint = function (checkpoint) {
140 SaveWidget.prototype.set_last_checkpoint = function (checkpoint) {
141 if (!checkpoint) {
141 if (!checkpoint) {
142 this.set_checkpoint_status("");
142 this.set_checkpoint_status("");
143 return;
143 }
144 }
144 var d = new Date(checkpoint.last_modified);
145 var d = new Date(checkpoint.last_modified);
145 this.set_checkpoint_status(
146 this.set_checkpoint_status(
@@ -298,7 +298,7 b' var IPython = (function (IPython) {'
298
298
299 MarkdownCell.options_default = {
299 MarkdownCell.options_default = {
300 cm_config: {
300 cm_config: {
301 mode: 'markdown'
301 mode: 'gfm'
302 },
302 },
303 placeholder: "Type *Markdown* and LaTeX: $\\alpha^2$"
303 placeholder: "Type *Markdown* and LaTeX: $\\alpha^2$"
304 }
304 }
@@ -315,9 +315,9 b' var IPython = (function (IPython) {'
315 if (this.rendered === false) {
315 if (this.rendered === false) {
316 var text = this.get_text();
316 var text = this.get_text();
317 if (text === "") { text = this.placeholder; }
317 if (text === "") { text = this.placeholder; }
318 text = IPython.mathjaxutils.remove_math(text)
318 text = IPython.mathjaxutils.remove_math(text);
319 var html = IPython.markdown_converter.makeHtml(text);
319 var html = marked.parser(marked.lexer(text));
320 html = IPython.mathjaxutils.replace_math(html)
320 html = IPython.mathjaxutils.replace_math(html);
321 try {
321 try {
322 this.set_rendered(html);
322 this.set_rendered(html);
323 } catch (e) {
323 } catch (e) {
@@ -329,18 +329,6 b' var IPython = (function (IPython) {'
329 }
329 }
330 this.element.find('div.text_cell_input').hide();
330 this.element.find('div.text_cell_input').hide();
331 this.element.find("div.text_cell_render").show();
331 this.element.find("div.text_cell_render").show();
332 var code_snippets = this.element.find("pre > code");
333 code_snippets.replaceWith(function () {
334 var code = $(this).html();
335 /* Substitute br for newlines and &nbsp; for spaces
336 before highlighting, since prettify doesn't
337 preserve those on all browsers */
338 code = code.replace(/(\r\n|\n|\r)/gm, "<br/>");
339 code = code.replace(/ /gm, '&nbsp;');
340 code = prettyPrintOne(code);
341
342 return '<code class="prettyprint">' + code + '</code>';
343 });
344 this.typeset()
332 this.typeset()
345 this.rendered = true;
333 this.rendered = true;
346 }
334 }
@@ -5,7 +5,7 b''
5 */
5 */
6
6
7 @import "variables.less";
7 @import "variables.less";
8
8 @import "highlight.less";
9
9
10 body {
10 body {
11 background-color:@notebook_background;
11 background-color:@notebook_background;
@@ -12,9 +12,6 b' window.mathjax_url = "{{mathjax_url}}";'
12 </script>
12 </script>
13
13
14 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
14 <link rel="stylesheet" href="{{ static_url("components/codemirror/lib/codemirror.css") }}">
15 <link rel="stylesheet" href="{{ static_url("css/codemirror-ipython.css") }}">
16
17 <link rel="stylesheet" href="{{ static_url("prettify/prettify.css") }}"/>
18
15
19 <link rel="stylesheet" href="{{ static_url("css/celltoolbar.css") }}" type="text/css" />
16 <link rel="stylesheet" href="{{ static_url("css/celltoolbar.css") }}" type="text/css" />
20
17
@@ -198,6 +195,7 b' class="notebook_app"'
198 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
195 <script src="{{ static_url("components/codemirror/lib/codemirror.js") }}" charset="utf-8"></script>
199 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
196 <script src="{{ static_url("components/codemirror/addon/mode/loadmode.js") }}" charset="utf-8"></script>
200 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
197 <script src="{{ static_url("components/codemirror/addon/mode/multiplex.js") }}" charset="utf-8"></script>
198 <script src="{{ static_url("components/codemirror/addon/mode/overlay.js") }}" charset="utf-8"></script>
201 <script src="{{ static_url("js/codemirror-ipython.js") }}" charset="utf-8"></script>
199 <script src="{{ static_url("js/codemirror-ipython.js") }}" charset="utf-8"></script>
202 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
200 <script src="{{ static_url("components/codemirror/mode/htmlmixed/htmlmixed.js") }}" charset="utf-8"></script>
203 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
201 <script src="{{ static_url("components/codemirror/mode/xml/xml.js") }}" charset="utf-8"></script>
@@ -205,10 +203,11 b' class="notebook_app"'
205 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
203 <script src="{{ static_url("components/codemirror/mode/css/css.js") }}" charset="utf-8"></script>
206 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
204 <script src="{{ static_url("components/codemirror/mode/rst/rst.js") }}" charset="utf-8"></script>
207 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
205 <script src="{{ static_url("components/codemirror/mode/markdown/markdown.js") }}" charset="utf-8"></script>
206 <script src="{{ static_url("components/codemirror/mode/gfm/gfm.js") }}" charset="utf-8"></script>
208
207
209 <script src="{{ static_url("pagedown/Markdown.Converter.js") }}" charset="utf-8"></script>
208 <script src="{{ static_url("components/marked/lib/marked.js") }}" charset="utf-8"></script>
209 <script src="{{ static_url("components/highlight.js/build/highlight.pack.js") }}" charset="utf-8"></script>
210
210
211 <script src="{{ static_url("prettify/prettify.js") }}" charset="utf-8"></script>
212 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
211 <script src="{{ static_url("dateformat/date.format.js") }}" charset="utf-8"></script>
213
212
214 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
213 <script src="{{ static_url("js/events.js") }}" type="text/javascript" charset="utf-8"></script>
@@ -24,7 +24,7 b' from zmq.eventloop import ioloop, zmqstream'
24
24
25 from IPython.config.configurable import LoggingConfigurable
25 from IPython.config.configurable import LoggingConfigurable
26 from IPython.utils.py3compat import str_to_bytes
26 from IPython.utils.py3compat import str_to_bytes
27 from IPython.utils.traitlets import Set, Instance, CFloat, Integer
27 from IPython.utils.traitlets import Set, Instance, CFloat, Integer, Dict
28
28
29 from IPython.parallel.util import log_errors
29 from IPython.parallel.util import log_errors
30
30
@@ -74,6 +74,9 b' class HeartMonitor(LoggingConfigurable):'
74 help='The frequency at which the Hub pings the engines for heartbeats '
74 help='The frequency at which the Hub pings the engines for heartbeats '
75 '(in ms)',
75 '(in ms)',
76 )
76 )
77 max_heartmonitor_misses = Integer(10, config=True,
78 help='Allowed consecutive missed pings from controller Hub to engine before unregistering.',
79 )
77
80
78 pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream')
81 pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream')
79 pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream')
82 pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream')
@@ -84,7 +87,7 b' class HeartMonitor(LoggingConfigurable):'
84 # not settable:
87 # not settable:
85 hearts=Set()
88 hearts=Set()
86 responses=Set()
89 responses=Set()
87 on_probation=Set()
90 on_probation=Dict()
88 last_ping=CFloat(0)
91 last_ping=CFloat(0)
89 _new_handlers = Set()
92 _new_handlers = Set()
90 _failure_handlers = Set()
93 _failure_handlers = Set()
@@ -121,11 +124,12 b' class HeartMonitor(LoggingConfigurable):'
121 self.log.debug("heartbeat::sending %s", self.lifetime)
124 self.log.debug("heartbeat::sending %s", self.lifetime)
122 goodhearts = self.hearts.intersection(self.responses)
125 goodhearts = self.hearts.intersection(self.responses)
123 missed_beats = self.hearts.difference(goodhearts)
126 missed_beats = self.hearts.difference(goodhearts)
124 heartfailures = self.on_probation.intersection(missed_beats)
125 newhearts = self.responses.difference(goodhearts)
127 newhearts = self.responses.difference(goodhearts)
126 map(self.handle_new_heart, newhearts)
128 map(self.handle_new_heart, newhearts)
129 heartfailures, on_probation = self._check_missed(missed_beats, self.on_probation,
130 self.hearts)
127 map(self.handle_heart_failure, heartfailures)
131 map(self.handle_heart_failure, heartfailures)
128 self.on_probation = missed_beats.intersection(self.hearts)
132 self.on_probation = on_probation
129 self.responses = set()
133 self.responses = set()
130 #print self.on_probation, self.hearts
134 #print self.on_probation, self.hearts
131 # self.log.debug("heartbeat::beat %.3f, %i beating hearts", self.lifetime, len(self.hearts))
135 # self.log.debug("heartbeat::beat %.3f, %i beating hearts", self.lifetime, len(self.hearts))
@@ -133,6 +137,20 b' class HeartMonitor(LoggingConfigurable):'
133 # flush stream to force immediate socket send
137 # flush stream to force immediate socket send
134 self.pingstream.flush()
138 self.pingstream.flush()
135
139
140 def _check_missed(self, missed_beats, on_probation, hearts):
141 """Update heartbeats on probation, identifying any that have too many misses.
142 """
143 failures = []
144 new_probation = {}
145 for cur_heart in (b for b in missed_beats if b in hearts):
146 miss_count = on_probation.get(cur_heart, 0) + 1
147 self.log.info("heartbeat::missed %s : %s" % (cur_heart, miss_count))
148 if miss_count > self.max_heartmonitor_misses:
149 failures.append(cur_heart)
150 else:
151 new_probation[cur_heart] = miss_count
152 return failures, new_probation
153
136 def handle_new_heart(self, heart):
154 def handle_new_heart(self, heart):
137 if self._new_handlers:
155 if self._new_handlers:
138 for handler in self._new_handlers:
156 for handler in self._new_handlers:
@@ -11,8 +11,6 b''
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
15
16 from IPython.parallel.apps.ipclusterapp import launch_new_instance
14 from IPython.parallel.apps.ipclusterapp import launch_new_instance
17
15
18 launch_new_instance()
16 launch_new_instance()
@@ -11,8 +11,6 b''
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
15
16 from IPython.parallel.apps.ipcontrollerapp import launch_new_instance
14 from IPython.parallel.apps.ipcontrollerapp import launch_new_instance
17
15
18 launch_new_instance()
16 launch_new_instance()
@@ -11,10 +11,6 b''
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
15
16 from IPython.parallel.apps.ipengineapp import launch_new_instance
14 from IPython.parallel.apps.ipengineapp import launch_new_instance
17
15
18 launch_new_instance()
16 launch_new_instance()
19
20
@@ -11,10 +11,6 b''
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12 # Imports
12 # Imports
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14
15
16 from IPython.parallel.apps.iploggerapp import launch_new_instance
14 from IPython.parallel.apps.iploggerapp import launch_new_instance
17
15
18 launch_new_instance()
16 launch_new_instance()
19
20
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
This diff has been collapsed as it changes many lines, (1319 lines changed) Show them Hide them
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now