##// END OF EJS Templates
Merging bug fixed to ipcluster in bg-trunk-dev branch....
Brian Granger -
r1828:febb92be merge
parent child Browse files
Show More
@@ -335,7 +335,7 class MultiEngine(ControllerAdapterBase):
335 #---------------------------------------------------------------------------
335 #---------------------------------------------------------------------------
336 # IEngineMultiplexer methods
336 # IEngineMultiplexer methods
337 #---------------------------------------------------------------------------
337 #---------------------------------------------------------------------------
338
338
339 def execute(self, lines, targets='all'):
339 def execute(self, lines, targets='all'):
340 return self._performOnEnginesAndGatherBoth('execute', lines, targets=targets)
340 return self._performOnEnginesAndGatherBoth('execute', lines, targets=targets)
341
341
@@ -22,15 +22,19 pjoin = os.path.join
22
22
23 from twisted.internet import reactor, defer
23 from twisted.internet import reactor, defer
24 from twisted.internet.protocol import ProcessProtocol
24 from twisted.internet.protocol import ProcessProtocol
25 from twisted.python import failure, log
26 from twisted.internet.error import ProcessDone, ProcessTerminated
25 from twisted.internet.error import ProcessDone, ProcessTerminated
27 from twisted.internet.utils import getProcessOutput
26 from twisted.internet.utils import getProcessOutput
27 from twisted.python import failure, log
28
28
29 from IPython.external import argparse
29 from IPython.external import argparse
30 from IPython.external import Itpl
30 from IPython.external import Itpl
31 from IPython.genutils import get_ipython_dir, num_cpus
32 from IPython.kernel.fcutil import have_crypto
33 from IPython.kernel.error import SecurityError
34 from IPython.kernel.fcutil import have_crypto
31 from IPython.kernel.twistedutil import gatherBoth
35 from IPython.kernel.twistedutil import gatherBoth
32 from IPython.kernel.util import printer
36 from IPython.kernel.util import printer
33 from IPython.genutils import get_ipython_dir, num_cpus
37
34
38
35 #-----------------------------------------------------------------------------
39 #-----------------------------------------------------------------------------
36 # General process handling code
40 # General process handling code
@@ -42,8 +46,11 def find_exe(cmd):
42 except ImportError:
46 except ImportError:
43 raise ImportError('you need to have pywin32 installed for this to work')
47 raise ImportError('you need to have pywin32 installed for this to work')
44 else:
48 else:
45 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd)
49 try:
46 return path
50 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd + '.exe')
51 except:
52 (path, offset) = win32api.SearchPath(os.environ['PATH'],cmd + '.bat')
53 return path
47
54
48 class ProcessStateError(Exception):
55 class ProcessStateError(Exception):
49 pass
56 pass
@@ -171,7 +178,13 class ControllerLauncher(ProcessLauncher):
171
178
172 def __init__(self, extra_args=None):
179 def __init__(self, extra_args=None):
173 if sys.platform == 'win32':
180 if sys.platform == 'win32':
174 args = [find_exe('ipcontroller.bat')]
181 # This logic is needed because the ipcontroller script doesn't
182 # always get installed in the same way or in the same location.
183 from IPython.kernel.scripts import ipcontroller
184 script_location = ipcontroller.__file__.replace('.pyc', '.py')
185 # The -u option here turns on unbuffered output, which is required
186 # on Win32 to prevent wierd conflict and problems with Twisted
187 args = [find_exe('python'), '-u', script_location]
175 else:
188 else:
176 args = ['ipcontroller']
189 args = ['ipcontroller']
177 self.extra_args = extra_args
190 self.extra_args = extra_args
@@ -185,7 +198,13 class EngineLauncher(ProcessLauncher):
185
198
186 def __init__(self, extra_args=None):
199 def __init__(self, extra_args=None):
187 if sys.platform == 'win32':
200 if sys.platform == 'win32':
188 args = [find_exe('ipengine.bat')]
201 # This logic is needed because the ipcontroller script doesn't
202 # always get installed in the same way or in the same location.
203 from IPython.kernel.scripts import ipengine
204 script_location = ipengine.__file__.replace('.pyc', '.py')
205 # The -u option here turns on unbuffered output, which is required
206 # on Win32 to prevent wierd conflict and problems with Twisted
207 args = [find_exe('python'), '-u', script_location]
189 else:
208 else:
190 args = ['ipengine']
209 args = ['ipengine']
191 self.extra_args = extra_args
210 self.extra_args = extra_args
@@ -273,7 +292,7 class BatchEngineSet(object):
273 f = open(self.batch_file,'w')
292 f = open(self.batch_file,'w')
274 f.write(script_as_string)
293 f.write(script_as_string)
275 f.close()
294 f.close()
276
295
277 def handle_error(self, f):
296 def handle_error(self, f):
278 f.printTraceback()
297 f.printTraceback()
279 f.raiseException()
298 f.raiseException()
@@ -285,7 +304,7 class BatchEngineSet(object):
285 d.addCallback(self.parse_job_id)
304 d.addCallback(self.parse_job_id)
286 d.addErrback(self.handle_error)
305 d.addErrback(self.handle_error)
287 return d
306 return d
288
307
289 def kill(self):
308 def kill(self):
290 d = getProcessOutput(self.delete_command,
309 d = getProcessOutput(self.delete_command,
291 [self.job_id],env=os.environ)
310 [self.job_id],env=os.environ)
@@ -311,13 +330,27 class PBSEngineSet(BatchEngineSet):
311 # The main functions should then just parse the command line arguments, create
330 # The main functions should then just parse the command line arguments, create
312 # the appropriate class and call a 'start' method.
331 # the appropriate class and call a 'start' method.
313
332
314 def main_local(args):
333 def check_security(args, cont_args):
315 cont_args = []
334 if (not args.x or not args.y) and not have_crypto:
316 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
335 log.err("""
336 OpenSSL/pyOpenSSL is not available, so we can't run in secure mode.
337 Try running ipcluster with the -xy flags: ipcluster local -xy -n 4""")
338 reactor.stop()
339 return False
317 if args.x:
340 if args.x:
318 cont_args.append('-x')
341 cont_args.append('-x')
319 if args.y:
342 if args.y:
320 cont_args.append('-y')
343 cont_args.append('-y')
344 return True
345
346 def main_local(args):
347 cont_args = []
348 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
349
350 # Check security settings before proceeding
351 if not check_security(args, cont_args):
352 return
353
321 cl = ControllerLauncher(extra_args=cont_args)
354 cl = ControllerLauncher(extra_args=cont_args)
322 dstart = cl.start()
355 dstart = cl.start()
323 def start_engines(cont_pid):
356 def start_engines(cont_pid):
@@ -346,10 +379,11 def main_local(args):
346 def main_mpirun(args):
379 def main_mpirun(args):
347 cont_args = []
380 cont_args = []
348 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
381 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
349 if args.x:
382
350 cont_args.append('-x')
383 # Check security settings before proceeding
351 if args.y:
384 if not check_security(args, cont_args):
352 cont_args.append('-y')
385 return
386
353 cl = ControllerLauncher(extra_args=cont_args)
387 cl = ControllerLauncher(extra_args=cont_args)
354 dstart = cl.start()
388 dstart = cl.start()
355 def start_engines(cont_pid):
389 def start_engines(cont_pid):
@@ -382,10 +416,11 def main_mpirun(args):
382 def main_pbs(args):
416 def main_pbs(args):
383 cont_args = []
417 cont_args = []
384 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
418 cont_args.append('--logfile=%s' % pjoin(args.logdir,'ipcontroller'))
385 if args.x:
419
386 cont_args.append('-x')
420 # Check security settings before proceeding
387 if args.y:
421 if not check_security(args, cont_args):
388 cont_args.append('-y')
422 return
423
389 cl = ControllerLauncher(extra_args=cont_args)
424 cl = ControllerLauncher(extra_args=cont_args)
390 dstart = cl.start()
425 dstart = cl.start()
391 def start_engines(r):
426 def start_engines(r):
General Comments 0
You need to be logged in to leave comments. Login now