Show More
@@ -6,62 +6,67 b' c = get_config()' | |||||
6 | # Global configuration |
|
6 | # Global configuration | |
7 | #----------------------------------------------------------------------------- |
|
7 | #----------------------------------------------------------------------------- | |
8 |
|
8 | |||
9 | c.Global.log_to_file = False |
|
9 | # Basic Global config attributes | |
10 | c.Global.import_statements = [] |
|
10 | # c.Global.log_to_file = False | |
11 | c.Global.reuse_furls = False |
|
11 | # c.Global.import_statements = ['import math'] | |
|
12 | # c.Global.reuse_furls = True | |||
|
13 | # c.Global.secure = True | |||
12 |
|
14 | |||
13 |
# You shouldn't have to |
|
15 | # You shouldn't have to modify these | |
14 | c.Global.log_dir_name = 'log' |
|
16 | # c.Global.log_dir_name = 'log' | |
15 | c.Global.security_dir_name = 'security' |
|
17 | # c.Global.security_dir_name = 'security' | |
16 |
|
18 | |||
17 |
|
19 | |||
18 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- | |
19 | # Configure the client services |
|
21 | # Configure the client services | |
20 | #----------------------------------------------------------------------------- |
|
22 | #----------------------------------------------------------------------------- | |
21 |
|
23 | |||
22 | c.FCClientServiceFactory.ip = '' |
|
24 | # Basic client service config attributes | |
23 |
c.FCClientServiceFactory. |
|
25 | # c.FCClientServiceFactory.ip = '' | |
24 |
c.FCClientServiceFactory. |
|
26 | # c.FCClientServiceFactory.port = 0 | |
25 |
c.FCClientServiceFactory. |
|
27 | # c.FCClientServiceFactory.location = '' | |
26 |
c.FCClientServiceFactory. |
|
28 | # c.FCClientServiceFactory.secure = True | |
27 |
c.FCClientServiceFactory. |
|
29 | # c.FCClientServiceFactory.reuse_furls = False | |
28 |
|
30 | |||
29 | c.FCClientServiceFactory.Interfaces.Task.interface_chain = [ |
|
31 | # You shouldn't have to modify the rest of this section | |
30 | 'IPython.kernel.task.ITaskController', |
|
32 | # c.FCClientServiceFactory.cert_file = 'ipcontroller-client.pem' | |
31 | 'IPython.kernel.taskfc.IFCTaskController' |
|
33 | ||
32 | ] |
|
34 | # default_client_interfaces = Config() | |
33 | # This is just the filename of the furl file. The path is always the |
|
35 | # default_client_interfaces.Task.interface_chain = [ | |
34 | # security dir of the cluster directory. |
|
36 | # 'IPython.kernel.task.ITaskController', | |
35 | c.FCClientServiceFactory.Interfaces.Task.furl_file = 'ipcontroller-tc.furl' |
|
37 | # 'IPython.kernel.taskfc.IFCTaskController' | |
36 |
|
38 | # ] | ||
37 | c.FCClientServiceFactory.Interfaces.MultiEngine.interface_chain = [ |
|
39 | # | |
38 | 'IPython.kernel.multiengine.IMultiEngine', |
|
40 | # default_client_interfaces.Task.furl_file = 'ipcontroller-tc.furl' | |
39 | 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine' |
|
41 | # | |
40 | ] |
|
42 | # default_client_interfaces.MultiEngine.interface_chain = [ | |
41 | # This is just the filename of the furl file. The path is always the |
|
43 | # 'IPython.kernel.multiengine.IMultiEngine', | |
42 | # security dir of the cluster directory. |
|
44 | # 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine' | |
43 | c.FCClientServiceFactory.Interfaces.MultiEngine.furl_file = 'ipcontroller-mec.furl' |
|
45 | # ] | |
44 |
|
46 | # | ||
|
47 | # default_client_interfaces.MultiEngine.furl_file = 'ipcontroller-mec.furl' | |||
|
48 | # | |||
|
49 | # c.FCEngineServiceFactory.interfaces = default_client_interfaces | |||
45 |
|
50 | |||
46 | #----------------------------------------------------------------------------- |
|
51 | #----------------------------------------------------------------------------- | |
47 | # Configure the engine services |
|
52 | # Configure the engine services | |
48 | #----------------------------------------------------------------------------- |
|
53 | #----------------------------------------------------------------------------- | |
49 |
|
54 | |||
50 | c.FCEngineServiceFactory.ip = '' |
|
55 | # Basic config attributes for the engine services | |
51 |
c.FCEngineServiceFactory. |
|
56 | # c.FCEngineServiceFactory.ip = '' | |
52 |
c.FCEngineServiceFactory. |
|
57 | # c.FCEngineServiceFactory.port = 0 | |
53 |
c.FCEngineServiceFactory. |
|
58 | # c.FCEngineServiceFactory.location = '' | |
54 |
c.FCEngineServiceFactory. |
|
59 | # c.FCEngineServiceFactory.secure = True | |
55 |
c.FCEngineServiceFactory. |
|
60 | # c.FCEngineServiceFactory.reuse_furls = False | |
56 |
|
61 | |||
57 | c.FCEngineServiceFactory.Intefaces.Default.interface_chain = [ |
|
62 | # You shouldn't have to modify the rest of this section | |
58 | 'IPython.kernel.enginefc.IFCControllerBase' |
|
63 | # c.FCEngineServiceFactory.cert_file = 'ipcontroller-engine.pem' | |
59 | ] |
|
64 | ||
60 |
|
65 | # default_engine_interfaces = Config() | ||
61 | # This is just the filename of the furl file. The path is always the |
|
66 | # default_engine_interfaces.Default.interface_chain = [ | |
62 | # security dir of the cluster directory. |
|
67 | # 'IPython.kernel.enginefc.IFCControllerBase' | |
63 | c.FCEngineServiceFactory.Intefaces.Default.furl_file = 'ipcontroller-engine.furl' |
|
68 | # ] | |
64 |
|
69 | # | ||
65 |
|
70 | # default_engine_interfaces.Default.furl_file = 'ipcontroller-engine.furl' | ||
66 |
|
71 | # | ||
67 |
|
72 | # c.FCEngineServiceFactory.interfaces = default_engine_interfaces |
@@ -77,9 +77,9 b' class Application(object):' | |||||
77 | """Load a config, construct an app and run it. |
|
77 | """Load a config, construct an app and run it. | |
78 | """ |
|
78 | """ | |
79 |
|
79 | |||
80 | config_file_name = 'ipython_config.py' |
|
|||
81 | name = 'ipython' |
|
80 | name = 'ipython' | |
82 | description = 'IPython: an enhanced interactive Python shell.' |
|
81 | description = 'IPython: an enhanced interactive Python shell.' | |
|
82 | config_file_name = 'ipython_config.py' | |||
83 | default_log_level = logging.WARN |
|
83 | default_log_level = logging.WARN | |
84 |
|
84 | |||
85 |
|
85 | |||
@@ -351,7 +351,11 b' class AppWithDirArgParseConfigLoader(ArgParseConfigLoader):' | |||||
351 | metavar='Global.ipythondir') |
|
351 | metavar='Global.ipythondir') | |
352 | self.parser.add_argument('-p','-profile', '--profile', |
|
352 | self.parser.add_argument('-p','-profile', '--profile', | |
353 | dest='Global.profile',type=str, |
|
353 | dest='Global.profile',type=str, | |
354 |
help='The string name of the |
|
354 | help='The string name of the profile to be used. This determines ' | |
|
355 | 'the name of the application dir: basename_<profile>. The basename is ' | |||
|
356 | 'determined by the particular application. The default profile ' | |||
|
357 | 'is named "default". This convention is used if the -app_dir ' | |||
|
358 | 'option is not used.', | |||
355 | default=NoConfigDefault, |
|
359 | default=NoConfigDefault, | |
356 | metavar='Global.profile') |
|
360 | metavar='Global.profile') | |
357 | self.parser.add_argument('-log_level', '--log-level', |
|
361 | self.parser.add_argument('-log_level', '--log-level', | |
@@ -360,22 +364,40 b' class AppWithDirArgParseConfigLoader(ArgParseConfigLoader):' | |||||
360 | default=NoConfigDefault) |
|
364 | default=NoConfigDefault) | |
361 | self.parser.add_argument('-app_dir', '--app-dir', |
|
365 | self.parser.add_argument('-app_dir', '--app-dir', | |
362 | dest='Global.app_dir',type=str, |
|
366 | dest='Global.app_dir',type=str, | |
363 |
help='Set the application dir |
|
367 | help='Set the application dir where everything for this ' | |
364 |
'application will be found (including the config file).' |
|
368 | 'application will be found (including the config file). This ' | |
|
369 | 'overrides the logic used by the profile option.', | |||
365 | default=NoConfigDefault, |
|
370 | default=NoConfigDefault, | |
366 | metavar='Global.app_dir') |
|
371 | metavar='Global.app_dir') | |
367 |
|
372 | |||
368 |
|
373 | |||
369 | class ApplicationWithDir(Application): |
|
374 | class ApplicationWithDir(Application): | |
|
375 | """An application that puts everything into a application directory. | |||
370 |
|
|
376 | ||
371 | name = 'appname' |
|
377 | Instead of looking for things in the ipythondir, this type of application | |
372 | description = 'Application: foo and bar it.' |
|
378 | will use its own private directory called the "application directory" | |
373 | config_file_name = 'appname_config.py' |
|
379 | for things like config files, log files, etc. | |
374 | default_log_level = logging.WARN |
|
380 | ||
|
381 | The application directory is resolved as follows: | |||
|
382 | ||||
|
383 | * If the ``--app-dir`` option is given, it is used. | |||
|
384 | * If ``--app-dir`` is not given, the application directory is resolve using | |||
|
385 | ``app_dir_basename`` and ``profile`` as ``<app_dir_basename>_<profile>``. | |||
|
386 | The search path for this directory is then i) cwd if it is found there | |||
|
387 | and ii) in ipythondir otherwise. | |||
|
388 | ||||
|
389 | The config file for the application is to be put in the application | |||
|
390 | dir and named the value of the ``config_file_name`` class attribute. | |||
|
391 | """ | |||
|
392 | ||||
|
393 | # The basename used for the application dir: <app_dir_basename>_<profile> | |||
|
394 | app_dir_basename = 'cluster' | |||
375 |
|
395 | |||
376 | def create_default_config(self): |
|
396 | def create_default_config(self): | |
377 | super(ApplicationWithDir, self).create_default_config() |
|
397 | super(ApplicationWithDir, self).create_default_config() | |
378 | self.default_config.Global.profile = 'default' |
|
398 | self.default_config.Global.profile = 'default' | |
|
399 | # The application dir. This is empty initially so the default is to | |||
|
400 | # try to resolve this using the profile. | |||
379 | self.default_config.Global.app_dir = '' |
|
401 | self.default_config.Global.app_dir = '' | |
380 |
|
402 | |||
381 | def create_command_line_config(self): |
|
403 | def create_command_line_config(self): | |
@@ -391,10 +413,10 b' class ApplicationWithDir(Application):' | |||||
391 | self.create_app_dir() |
|
413 | self.create_app_dir() | |
392 |
|
414 | |||
393 | def find_app_dir(self): |
|
415 | def find_app_dir(self): | |
394 |
"""This resolves |
|
416 | """This resolves the app directory. | |
395 |
|
417 | |||
396 |
This method must set ``self.app_dir`` to the |
|
418 | This method must set ``self.app_dir`` to the location of the app | |
397 |
|
|
419 | dir. | |
398 | """ |
|
420 | """ | |
399 | # Instead, first look for an explicit app_dir |
|
421 | # Instead, first look for an explicit app_dir | |
400 | try: |
|
422 | try: | |
@@ -408,7 +430,7 b' class ApplicationWithDir(Application):' | |||||
408 | self.profile = self.command_line_config.Global.profile |
|
430 | self.profile = self.command_line_config.Global.profile | |
409 | except AttributeError: |
|
431 | except AttributeError: | |
410 | self.profile = self.default_config.Global.profile |
|
432 | self.profile = self.default_config.Global.profile | |
411 |
app_dir_name = ' |
|
433 | app_dir_name = self.app_dir_basename + '_' + self.profile | |
412 | try_this = os.path.join(os.getcwd(), app_dir_name) |
|
434 | try_this = os.path.join(os.getcwd(), app_dir_name) | |
413 | if os.path.isdir(try_this): |
|
435 | if os.path.isdir(try_this): | |
414 | self.app_dir = try_this |
|
436 | self.app_dir = try_this | |
@@ -421,7 +443,7 b' class ApplicationWithDir(Application):' | |||||
421 | self.command_line_config.Global.app_dir = self.app_dir |
|
443 | self.command_line_config.Global.app_dir = self.app_dir | |
422 |
|
444 | |||
423 | def create_app_dir(self): |
|
445 | def create_app_dir(self): | |
424 |
"""Make sure that the |
|
446 | """Make sure that the app dir exists.""" | |
425 | if not os.path.isdir(self.app_dir): |
|
447 | if not os.path.isdir(self.app_dir): | |
426 | os.makedirs(self.app_dir, mode=0777) |
|
448 | os.makedirs(self.app_dir, mode=0777) | |
427 |
|
449 |
@@ -296,7 +296,19 b' class Component(HasTraitlets):' | |||||
296 | if new._has_section(sname): |
|
296 | if new._has_section(sname): | |
297 | my_config = new[sname] |
|
297 | my_config = new[sname] | |
298 | for k, v in traitlets.items(): |
|
298 | for k, v in traitlets.items(): | |
|
299 | # Don't allow traitlets with config=True to start with | |||
|
300 | # uppercase. Otherwise, they are confused with Config | |||
|
301 | # subsections. But, developers shouldn't have uppercase | |||
|
302 | # attributes anyways! (PEP 6) | |||
|
303 | if k[0].upper()==k[0] and not k.startswith('_'): | |||
|
304 | raise ComponentError('Component traitlets with ' | |||
|
305 | 'config=True must start with a lowercase so they are ' | |||
|
306 | 'not confused with Config subsections: %s.%s' % \ | |||
|
307 | (self.__class__.__name__, k)) | |||
299 | try: |
|
308 | try: | |
|
309 | # Here we grab the value from the config | |||
|
310 | # If k has the naming convention of a config | |||
|
311 | # section, it will be auto created. | |||
300 | config_value = my_config[k] |
|
312 | config_value = my_config[k] | |
301 | except KeyError: |
|
313 | except KeyError: | |
302 | pass |
|
314 | pass |
@@ -294,13 +294,13 b' class IPythonAppCLConfigLoader(BaseAppArgParseConfigLoader):' | |||||
294 | arguments = cl_args |
|
294 | arguments = cl_args | |
295 |
|
295 | |||
296 |
|
296 | |||
297 |
|
|
297 | default_config_file_name = 'ipython_config.py' | |
298 |
|
298 | |||
299 |
|
299 | |||
300 | class IPythonApp(Application): |
|
300 | class IPythonApp(Application): | |
301 | name = 'ipython' |
|
301 | name = 'ipython' | |
302 | description = 'IPython: an enhanced interactive Python shell.' |
|
302 | description = 'IPython: an enhanced interactive Python shell.' | |
303 |
config_file_name = |
|
303 | config_file_name = default_config_file_name | |
304 |
|
304 | |||
305 | def create_default_config(self): |
|
305 | def create_default_config(self): | |
306 | super(IPythonApp, self).create_default_config() |
|
306 | super(IPythonApp, self).create_default_config() | |
@@ -533,7 +533,7 b' def load_default_config(ipythondir=None):' | |||||
533 | """ |
|
533 | """ | |
534 | if ipythondir is None: |
|
534 | if ipythondir is None: | |
535 | ipythondir = get_ipython_dir() |
|
535 | ipythondir = get_ipython_dir() | |
536 |
cl = PyFileConfigLoader( |
|
536 | cl = PyFileConfigLoader(default_config_file_name, ipythondir) | |
537 | config = cl.load_config() |
|
537 | config = cl.load_config() | |
538 | return config |
|
538 | return config | |
539 |
|
539 |
@@ -68,7 +68,11 b' class AdaptedConfiguredObjectFactory(Component):' | |||||
68 | # zi.implements(IAdaptedConfiguredObjectFactory) |
|
68 | # zi.implements(IAdaptedConfiguredObjectFactory) | |
69 |
|
69 | |||
70 | def __init__(self, config, adaptee): |
|
70 | def __init__(self, config, adaptee): | |
|
71 | ||||
|
72 | # print "config pre:", config | |||
71 | super(AdaptedConfiguredObjectFactory, self).__init__(None, config=config) |
|
73 | super(AdaptedConfiguredObjectFactory, self).__init__(None, config=config) | |
|
74 | ||||
|
75 | # print "config post:", config | |||
72 | self.adaptee = adaptee |
|
76 | self.adaptee = adaptee | |
73 |
|
77 | |||
74 | def create(self): |
|
78 | def create(self): |
@@ -67,11 +67,11 b' def is_secure(furl):' | |||||
67 | elif furl.startswith("pbu://"): |
|
67 | elif furl.startswith("pbu://"): | |
68 | return False |
|
68 | return False | |
69 | else: |
|
69 | else: | |
70 |
raise ValueError("invalid |
|
70 | raise ValueError("invalid FURL: %s" % furl) | |
71 |
|
71 | |||
72 |
|
72 | |||
73 | def is_valid(furl): |
|
73 | def is_valid(furl): | |
74 |
"""Is the str a valid |
|
74 | """Is the str a valid FURL or not.""" | |
75 | if isinstance(furl, str): |
|
75 | if isinstance(furl, str): | |
76 | if furl.startswith("pb://") or furl.startswith("pbu://"): |
|
76 | if furl.startswith("pb://") or furl.startswith("pbu://"): | |
77 | return True |
|
77 | return True | |
@@ -88,11 +88,11 b' def find_furl(furl_or_file):' | |||||
88 | furl = open(furl_or_file, 'r').read().strip() |
|
88 | furl = open(furl_or_file, 'r').read().strip() | |
89 | if is_valid(furl): |
|
89 | if is_valid(furl): | |
90 | return furl |
|
90 | return furl | |
91 |
raise ValueError("not a |
|
91 | raise ValueError("not a FURL or a file containing a FURL: %s" % furl_or_file) | |
92 |
|
92 | |||
93 |
|
93 | |||
94 | def get_temp_furlfile(filename): |
|
94 | def get_temp_furlfile(filename): | |
95 |
"""Return a temporary |
|
95 | """Return a temporary FURL file.""" | |
96 | return tempfile.mktemp(dir=os.path.dirname(filename), |
|
96 | return tempfile.mktemp(dir=os.path.dirname(filename), | |
97 | prefix=os.path.basename(filename)) |
|
97 | prefix=os.path.basename(filename)) | |
98 |
|
98 | |||
@@ -132,6 +132,7 b' def make_tub(ip, port, secure, cert_file):' | |||||
132 | strport = "tcp:%i" % port |
|
132 | strport = "tcp:%i" % port | |
133 | else: |
|
133 | else: | |
134 | strport = "tcp:%i:interface=%s" % (port, ip) |
|
134 | strport = "tcp:%i:interface=%s" % (port, ip) | |
|
135 | log.msg("Starting listener with [secure=%r] on: %s" % (secure, strport)) | |||
135 | listener = tub.listenOn(strport) |
|
136 | listener = tub.listenOn(strport) | |
136 |
|
137 | |||
137 | return tub, listener |
|
138 | return tub, listener | |
@@ -147,7 +148,7 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):' | |||||
147 |
|
148 | |||
148 | Attributes |
|
149 | Attributes | |
149 | ---------- |
|
150 | ---------- | |
150 |
|
|
151 | interfaces : Config | |
151 | A Config instance whose values are sub-Config objects having two |
|
152 | A Config instance whose values are sub-Config objects having two | |
152 | keys: furl_file and interface_chain. |
|
153 | keys: furl_file and interface_chain. | |
153 |
|
154 | |||
@@ -160,7 +161,7 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):' | |||||
160 | cert_file = Str('', config=True) |
|
161 | cert_file = Str('', config=True) | |
161 | location = Str('', config=True) |
|
162 | location = Str('', config=True) | |
162 | reuse_furls = Bool(False, config=True) |
|
163 | reuse_furls = Bool(False, config=True) | |
163 |
|
|
164 | interfaces = Instance(klass=Config, kw={}, allow_none=False, config=True) | |
164 |
|
165 | |||
165 | def __init__(self, config, adaptee): |
|
166 | def __init__(self, config, adaptee): | |
166 | super(FCServiceFactory, self).__init__(config, adaptee) |
|
167 | super(FCServiceFactory, self).__init__(config, adaptee) | |
@@ -171,11 +172,14 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):' | |||||
171 | self.location = '127.0.0.1' |
|
172 | self.location = '127.0.0.1' | |
172 |
|
173 | |||
173 | def _check_reuse_furls(self): |
|
174 | def _check_reuse_furls(self): | |
174 | if not self.reuse_furls: |
|
175 | furl_files = [i.furl_file for i in self.interfaces.values()] | |
175 | furl_files = [i.furl_file for i in self.Interfaces.values()] |
|
176 | for ff in furl_files: | |
176 | for ff in furl_files: |
|
177 | fullfile = self._get_security_file(ff) | |
177 | fullfile = self._get_security_file(ff) |
|
178 | if self.reuse_furls: | |
|
179 | log.msg("Reusing FURL file: %s" % fullfile) | |||
|
180 | else: | |||
178 | if os.path.isfile(fullfile): |
|
181 | if os.path.isfile(fullfile): | |
|
182 | log.msg("Removing old FURL file: %s" % fullfile) | |||
179 | os.remove(fullfile) |
|
183 | os.remove(fullfile) | |
180 |
|
184 | |||
181 | def _get_security_file(self, filename): |
|
185 | def _get_security_file(self, filename): | |
@@ -185,11 +189,14 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):' | |||||
185 | """Create and return the Foolscap tub with everything running.""" |
|
189 | """Create and return the Foolscap tub with everything running.""" | |
186 |
|
190 | |||
187 | self.tub, self.listener = make_tub( |
|
191 | self.tub, self.listener = make_tub( | |
188 |
self.ip, self.port, self.secure, |
|
192 | self.ip, self.port, self.secure, | |
189 | log.msg("Created a tub and listener [%r]: %r, %r" % (self.__class__, self.tub, self.listener)) |
|
193 | self._get_security_file(self.cert_file) | |
190 | log.msg("Interfaces to register [%r]: %r" % (self.__class__, self.Interfaces)) |
|
194 | ) | |
|
195 | # log.msg("Interfaces to register [%r]: %r" % \ | |||
|
196 | # (self.__class__, self.interfaces)) | |||
191 | if not self.secure: |
|
197 | if not self.secure: | |
192 |
log.msg("WARNING: running with no security: %s" % |
|
198 | log.msg("WARNING: running with no security: %s" % \ | |
|
199 | self.__class__.__name__) | |||
193 | reactor.callWhenRunning(self.set_location_and_register) |
|
200 | reactor.callWhenRunning(self.set_location_and_register) | |
194 | return self.tub |
|
201 | return self.tub | |
195 |
|
202 | |||
@@ -206,10 +213,11 b' class FCServiceFactory(AdaptedConfiguredObjectFactory):' | |||||
206 | def adapt_to_interfaces(self, d): |
|
213 | def adapt_to_interfaces(self, d): | |
207 | """Run through the interfaces, adapt and register.""" |
|
214 | """Run through the interfaces, adapt and register.""" | |
208 |
|
215 | |||
209 |
for ifname, ifconfig in self. |
|
216 | for ifname, ifconfig in self.interfaces.iteritems(): | |
210 | ff = self._get_security_file(ifconfig.furl_file) |
|
217 | ff = self._get_security_file(ifconfig.furl_file) | |
211 |
log.msg("Adapting |
|
218 | log.msg("Adapting [%s] to interface: %s" % \ | |
212 | log.msg("Saving furl for interface [%s] to file: %s" % (ifname, ff)) |
|
219 | (self.adaptee.__class__.__name__, ifname)) | |
|
220 | log.msg("Saving FURL for interface [%s] to file: %s" % (ifname, ff)) | |||
213 | check_furl_file_security(ff, self.secure) |
|
221 | check_furl_file_security(ff, self.secure) | |
214 | adaptee = self.adaptee |
|
222 | adaptee = self.adaptee | |
215 | for i in ifconfig.interface_chain: |
|
223 | for i in ifconfig.interface_chain: |
@@ -28,7 +28,7 b' from IPython.config.loader import Config, NoConfigDefault' | |||||
28 |
|
28 | |||
29 | from IPython.core.application import ( |
|
29 | from IPython.core.application import ( | |
30 | ApplicationWithDir, |
|
30 | ApplicationWithDir, | |
31 |
|
|
31 | AppWithDirArgParseConfigLoader | |
32 | ) |
|
32 | ) | |
33 |
|
33 | |||
34 | from IPython.core import release |
|
34 | from IPython.core import release | |
@@ -49,7 +49,7 b' from IPython.kernel.fcutil import FCServiceFactory' | |||||
49 | #----------------------------------------------------------------------------- |
|
49 | #----------------------------------------------------------------------------- | |
50 |
|
50 | |||
51 |
|
51 | |||
52 |
# The default client interfaces for FCClientServiceFactory. |
|
52 | # The default client interfaces for FCClientServiceFactory.interfaces | |
53 | default_client_interfaces = Config() |
|
53 | default_client_interfaces = Config() | |
54 | default_client_interfaces.Task.interface_chain = [ |
|
54 | default_client_interfaces.Task.interface_chain = [ | |
55 | 'IPython.kernel.task.ITaskController', |
|
55 | 'IPython.kernel.task.ITaskController', | |
@@ -57,6 +57,7 b' default_client_interfaces.Task.interface_chain = [' | |||||
57 | ] |
|
57 | ] | |
58 |
|
58 | |||
59 | default_client_interfaces.Task.furl_file = 'ipcontroller-tc.furl' |
|
59 | default_client_interfaces.Task.furl_file = 'ipcontroller-tc.furl' | |
|
60 | ||||
60 | default_client_interfaces.MultiEngine.interface_chain = [ |
|
61 | default_client_interfaces.MultiEngine.interface_chain = [ | |
61 | 'IPython.kernel.multiengine.IMultiEngine', |
|
62 | 'IPython.kernel.multiengine.IMultiEngine', | |
62 | 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine' |
|
63 | 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine' | |
@@ -69,7 +70,7 b' default_client_interfaces = dict(copy.deepcopy(default_client_interfaces.items()' | |||||
69 |
|
70 | |||
70 |
|
71 | |||
71 |
|
72 | |||
72 |
# The default engine interfaces for FCEngineServiceFactory. |
|
73 | # The default engine interfaces for FCEngineServiceFactory.interfaces | |
73 | default_engine_interfaces = Config() |
|
74 | default_engine_interfaces = Config() | |
74 | default_engine_interfaces.Default.interface_chain = [ |
|
75 | default_engine_interfaces.Default.interface_chain = [ | |
75 | 'IPython.kernel.enginefc.IFCControllerBase' |
|
76 | 'IPython.kernel.enginefc.IFCControllerBase' | |
@@ -90,7 +91,7 b' class FCClientServiceFactory(FCServiceFactory):' | |||||
90 | """A Foolscap implementation of the client services.""" |
|
91 | """A Foolscap implementation of the client services.""" | |
91 |
|
92 | |||
92 | cert_file = Str('ipcontroller-client.pem', config=True) |
|
93 | cert_file = Str('ipcontroller-client.pem', config=True) | |
93 |
|
|
94 | interfaces = Instance(klass=Config, kw=default_client_interfaces, | |
94 | allow_none=False, config=True) |
|
95 | allow_none=False, config=True) | |
95 |
|
96 | |||
96 |
|
97 | |||
@@ -98,7 +99,7 b' class FCEngineServiceFactory(FCServiceFactory):' | |||||
98 | """A Foolscap implementation of the engine services.""" |
|
99 | """A Foolscap implementation of the engine services.""" | |
99 |
|
100 | |||
100 | cert_file = Str('ipcontroller-engine.pem', config=True) |
|
101 | cert_file = Str('ipcontroller-engine.pem', config=True) | |
101 |
|
|
102 | interfaces = Instance(klass=dict, kw=default_engine_interfaces, | |
102 | allow_none=False, config=True) |
|
103 | allow_none=False, config=True) | |
103 |
|
104 | |||
104 |
|
105 | |||
@@ -124,10 +125,6 b' cl_args = (' | |||||
124 | help='The hostname or ip that clients should connect to.', |
|
125 | help='The hostname or ip that clients should connect to.', | |
125 | metavar='FCClientServiceFactory.location') |
|
126 | metavar='FCClientServiceFactory.location') | |
126 | ), |
|
127 | ), | |
127 | (('-x',), dict( |
|
|||
128 | action='store_false', dest='FCClientServiceFactory.secure', default=NoConfigDefault, |
|
|||
129 | help='Turn off all client security.') |
|
|||
130 | ), |
|
|||
131 | # Engine config |
|
128 | # Engine config | |
132 | (('--engine-ip',), dict( |
|
129 | (('--engine-ip',), dict( | |
133 | type=str, dest='FCEngineServiceFactory.ip', default=NoConfigDefault, |
|
130 | type=str, dest='FCEngineServiceFactory.ip', default=NoConfigDefault, | |
@@ -144,10 +141,6 b' cl_args = (' | |||||
144 | help='The hostname or ip that engines should connect to.', |
|
141 | help='The hostname or ip that engines should connect to.', | |
145 | metavar='FCEngineServiceFactory.location') |
|
142 | metavar='FCEngineServiceFactory.location') | |
146 | ), |
|
143 | ), | |
147 | (('-y',), dict( |
|
|||
148 | action='store_false', dest='FCEngineServiceFactory.secure', default=NoConfigDefault, |
|
|||
149 | help='Turn off all engine security.') |
|
|||
150 | ), |
|
|||
151 | # Global config |
|
144 | # Global config | |
152 | (('--log-to-file',), dict( |
|
145 | (('--log-to-file',), dict( | |
153 | action='store_true', dest='Global.log_to_file', default=NoConfigDefault, |
|
146 | action='store_true', dest='Global.log_to_file', default=NoConfigDefault, | |
@@ -156,33 +149,61 b' cl_args = (' | |||||
156 | (('-r','--reuse-furls'), dict( |
|
149 | (('-r','--reuse-furls'), dict( | |
157 | action='store_true', dest='Global.reuse_furls', default=NoConfigDefault, |
|
150 | action='store_true', dest='Global.reuse_furls', default=NoConfigDefault, | |
158 | help='Try to reuse all FURL files.') |
|
151 | help='Try to reuse all FURL files.') | |
|
152 | ), | |||
|
153 | (('-ns','--no-security'), dict( | |||
|
154 | action='store_false', dest='Global.secure', default=NoConfigDefault, | |||
|
155 | help='Turn off SSL encryption for all connections.') | |||
159 | ) |
|
156 | ) | |
160 | ) |
|
157 | ) | |
161 |
|
158 | |||
162 |
|
159 | |||
163 |
class IPControllerAppCLConfigLoader( |
|
160 | class IPControllerAppCLConfigLoader(AppWithDirArgParseConfigLoader): | |
164 |
|
161 | |||
165 | arguments = cl_args |
|
162 | arguments = cl_args | |
166 |
|
163 | |||
167 |
|
164 | |||
168 |
|
|
165 | default_config_file_name = 'ipcontroller_config.py' | |
169 |
|
166 | |||
170 |
|
167 | |||
171 | class IPControllerApp(ApplicationWithDir): |
|
168 | class IPControllerApp(ApplicationWithDir): | |
172 |
|
169 | |||
173 | name = 'ipcontroller' |
|
170 | name = 'ipcontroller' | |
|
171 | app_dir_basename = 'cluster' | |||
174 | description = 'Start the IPython controller for parallel computing.' |
|
172 | description = 'Start the IPython controller for parallel computing.' | |
175 |
config_file_name = |
|
173 | config_file_name = default_config_file_name | |
176 |
default_log_level = logging. |
|
174 | default_log_level = logging.WARN | |
177 |
|
175 | |||
178 | def create_default_config(self): |
|
176 | def create_default_config(self): | |
179 | super(IPControllerApp, self).create_default_config() |
|
177 | super(IPControllerApp, self).create_default_config() | |
180 | self.default_config.Global.reuse_furls = False |
|
178 | self.default_config.Global.reuse_furls = False | |
|
179 | self.default_config.Global.secure = True | |||
181 | self.default_config.Global.import_statements = [] |
|
180 | self.default_config.Global.import_statements = [] | |
182 | self.default_config.Global.log_dir_name = 'log' |
|
181 | self.default_config.Global.log_dir_name = 'log' | |
183 | self.default_config.Global.security_dir_name = 'security' |
|
182 | self.default_config.Global.security_dir_name = 'security' | |
184 | self.default_config.Global.log_to_file = False |
|
183 | self.default_config.Global.log_to_file = False | |
185 |
|
184 | |||
|
185 | def create_command_line_config(self): | |||
|
186 | """Create and return a command line config loader.""" | |||
|
187 | return IPControllerAppCLConfigLoader( | |||
|
188 | description=self.description, | |||
|
189 | version=release.version | |||
|
190 | ) | |||
|
191 | ||||
|
192 | def post_load_command_line_config(self): | |||
|
193 | # Now setup reuse_furls | |||
|
194 | if hasattr(self.command_line_config.Global, 'reuse_furls'): | |||
|
195 | self.command_line_config.FCClientServiceFactory.reuse_furls = \ | |||
|
196 | self.command_line_config.Global.reuse_furls | |||
|
197 | self.command_line_config.FCEngineServiceFactory.reuse_furls = \ | |||
|
198 | self.command_line_config.Global.reuse_furls | |||
|
199 | del self.command_line_config.Global.reuse_furls | |||
|
200 | if hasattr(self.command_line_config.Global, 'secure'): | |||
|
201 | self.command_line_config.FCClientServiceFactory.secure = \ | |||
|
202 | self.command_line_config.Global.secure | |||
|
203 | self.command_line_config.FCEngineServiceFactory.secure = \ | |||
|
204 | self.command_line_config.Global.secure | |||
|
205 | del self.command_line_config.Global.secure | |||
|
206 | ||||
186 | def pre_construct(self): |
|
207 | def pre_construct(self): | |
187 | # Now set the security_dir and log_dir and create them. We use |
|
208 | # Now set the security_dir and log_dir and create them. We use | |
188 | # the names an construct the absolute paths. |
|
209 | # the names an construct the absolute paths. | |
@@ -200,13 +221,6 b' class IPControllerApp(ApplicationWithDir):' | |||||
200 | self.security_dir = self.master_config.Global.security_dir = security_dir |
|
221 | self.security_dir = self.master_config.Global.security_dir = security_dir | |
201 | self.log_dir = self.master_config.Global.log_dir = log_dir |
|
222 | self.log_dir = self.master_config.Global.log_dir = log_dir | |
202 |
|
223 | |||
203 | # Now setup reuse_furls |
|
|||
204 | if hasattr(self.master_config.Global, 'reuse_furls'): |
|
|||
205 | self.master_config.FCClientServiceFactory.reuse_furls = \ |
|
|||
206 | self.master_config.Global.reuse_furls |
|
|||
207 | self.master_config.FCEngineServiceFactory.reuse_furls = \ |
|
|||
208 | self.master_config.Global.reuse_furls |
|
|||
209 |
|
||||
210 | def construct(self): |
|
224 | def construct(self): | |
211 | # I am a little hesitant to put these into InteractiveShell itself. |
|
225 | # I am a little hesitant to put these into InteractiveShell itself. | |
212 | # But that might be the place for them |
|
226 | # But that might be the place for them | |
@@ -214,7 +228,7 b' class IPControllerApp(ApplicationWithDir):' | |||||
214 |
|
228 | |||
215 | self.start_logging() |
|
229 | self.start_logging() | |
216 | self.import_statements() |
|
230 | self.import_statements() | |
217 |
|
231 | |||
218 | # Create the service hierarchy |
|
232 | # Create the service hierarchy | |
219 | self.main_service = service.MultiService() |
|
233 | self.main_service = service.MultiService() | |
220 | # The controller service |
|
234 | # The controller service | |
@@ -242,9 +256,10 b' class IPControllerApp(ApplicationWithDir):' | |||||
242 | statements = self.master_config.Global.import_statements |
|
256 | statements = self.master_config.Global.import_statements | |
243 | for s in statements: |
|
257 | for s in statements: | |
244 | try: |
|
258 | try: | |
|
259 | log.msg("Executing statement: '%s'" % s) | |||
245 | exec s in globals(), locals() |
|
260 | exec s in globals(), locals() | |
246 | except: |
|
261 | except: | |
247 |
log.msg("Error running |
|
262 | log.msg("Error running statement: %s" % s) | |
248 |
|
263 | |||
249 | def start_app(self): |
|
264 | def start_app(self): | |
250 | # Start the controller service and set things running |
|
265 | # Start the controller service and set things running |
General Comments 0
You need to be logged in to leave comments.
Login now