Show More
@@ -24,15 +24,16 b' class ExecutePreprocessor(Preprocessor):' | |||||
24 | """ |
|
24 | """ | |
25 | Executes all the cells in a notebook |
|
25 | Executes all the cells in a notebook | |
26 | """ |
|
26 | """ | |
27 |
def __init__(self, |
|
27 | def __init__(self, extra_arguments=[], **kwargs): | |
28 | """ |
|
28 | """ | |
29 | Start an kernel to run the Python code |
|
29 | Start an kernel to run the Python code | |
30 | """ |
|
30 | """ | |
31 |
super(ExecutePreprocessor, self).__init__(* |
|
31 | super(ExecutePreprocessor, self).__init__(**kwargs) | |
|
32 | self.extra_arguments = [] | |||
|
33 | ||||
|
34 | def preprocess(self, nb, resources): | |||
32 | self.km = KernelManager() |
|
35 | self.km = KernelManager() | |
33 | # run %pylab inline, because some notebooks assume this |
|
36 | self.km.start_kernel(extra_arguments=self.extra_arguments, stderr=open(os.devnull, 'w')) | |
34 | # even though they shouldn't |
|
|||
35 | self.km.start_kernel(extra_arguments=['--pylab=inline'], stderr=open(os.devnull, 'w')) |
|
|||
36 | self.kc = self.km.client() |
|
37 | self.kc = self.km.client() | |
37 | self.kc.start_channels() |
|
38 | self.kc.start_channels() | |
38 | self.iopub = self.kc.iopub_channel |
|
39 | self.iopub = self.kc.iopub_channel | |
@@ -41,6 +42,12 b' class ExecutePreprocessor(Preprocessor):' | |||||
41 | self.shell.execute("pass") |
|
42 | self.shell.execute("pass") | |
42 | self.shell.get_msg() |
|
43 | self.shell.get_msg() | |
43 |
|
44 | |||
|
45 | ||||
|
46 | create_client() | |||
|
47 | nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) | |||
|
48 | shutdown_client() | |||
|
49 | return nb, resources | |||
|
50 | ||||
44 | def preprocess_cell(self, cell, resources, cell_index): |
|
51 | def preprocess_cell(self, cell, resources, cell_index): | |
45 | """ |
|
52 | """ | |
46 | Apply a transformation on each code cell. See base.py for details. |
|
53 | Apply a transformation on each code cell. See base.py for details. |
General Comments 0
You need to be logged in to leave comments.
Login now