Show More
@@ -14,6 +14,7 b'' | |||
|
14 | 14 | # Imports |
|
15 | 15 | #----------------------------------------------------------------------------- |
|
16 | 16 | |
|
17 | from __future__ import with_statement | |
|
17 | 18 | import os |
|
18 | 19 | |
|
19 | 20 | from IPython.kernel.fcutil import Tub, find_furl |
@@ -474,6 +475,30 b' class AsyncCluster(object):' | |||
|
474 | 475 | cluster_dir=self.cluster_dir_obj.location |
|
475 | 476 | ) |
|
476 | 477 | |
|
478 | def get_ipengine_logs(self): | |
|
479 | return self.get_logs_by_name('ipengine') | |
|
480 | ||
|
481 | def get_ipcontroller_logs(self): | |
|
482 | return self.get_logs_by_name('ipcontroller') | |
|
483 | ||
|
484 | def get_ipcluster_logs(self): | |
|
485 | return self.get_logs_by_name('ipcluster') | |
|
486 | ||
|
487 | def get_logs_by_name(self, name='ipcluster'): | |
|
488 | log_dir = self.cluster_dir_obj.log_dir | |
|
489 | logs = {} | |
|
490 | for log in os.listdir(log_dir): | |
|
491 | if log.startswith(name + '-') and log.endswith('.log'): | |
|
492 | with open(os.path.join(log_dir, log), 'r') as f: | |
|
493 | logs[log] = f.read() | |
|
494 | return logs | |
|
495 | ||
|
496 | def get_logs(self): | |
|
497 | d = self.get_ipcluster_logs() | |
|
498 | d.update(self.get_ipengine_logs()) | |
|
499 | d.update(self.get_ipcontroller_logs()) | |
|
500 | return d | |
|
501 | ||
|
477 | 502 | def _handle_start(self, r): |
|
478 | 503 | self.state = 'running' |
|
479 | 504 | |
@@ -580,5 +605,51 b' class Cluster(object):' | |||
|
580 | 605 | cluster_dir=self.cluster_dir_obj.location |
|
581 | 606 | ) |
|
582 | 607 | |
|
583 | ||
|
608 | def __repr__(self): | |
|
609 | s = "<Cluster(running=%r, location=%s)" % (self.running, self.location) | |
|
610 | return s | |
|
611 | ||
|
612 | def get_logs_by_name(self, name='ipcluter'): | |
|
613 | """Get a dict of logs by process name (ipcluster, ipengine, etc.)""" | |
|
614 | return self.async_cluster.get_logs_by_name(name) | |
|
615 | ||
|
616 | def get_ipengine_logs(self): | |
|
617 | """Get a dict of logs for all engines in this cluster.""" | |
|
618 | return self.async_cluster.get_ipengine_logs() | |
|
619 | ||
|
620 | def get_ipcontroller_logs(self): | |
|
621 | """Get a dict of logs for the controller in this cluster.""" | |
|
622 | return self.async_cluster.get_ipcontroller_logs() | |
|
623 | ||
|
624 | def get_ipcluster_logs(self): | |
|
625 | """Get a dict of the ipcluster logs for this cluster.""" | |
|
626 | return self.async_cluster.get_ipcluster_logs() | |
|
627 | ||
|
628 | def get_logs(self): | |
|
629 | """Get a dict of all logs for this cluster.""" | |
|
630 | return self.async_cluster.get_logs() | |
|
631 | ||
|
632 | def _print_logs(self, logs): | |
|
633 | for k, v in logs.iteritems(): | |
|
634 | print "===================================" | |
|
635 | print "Logfile: %s" % k | |
|
636 | print "===================================" | |
|
637 | print v | |
|
638 | ||
|
639 | ||
|
640 | def print_ipengine_logs(self): | |
|
641 | """Print the ipengine logs for this cluster to stdout.""" | |
|
642 | self._print_logs(self.get_ipengine_logs()) | |
|
643 | ||
|
644 | def print_ipcontroller_logs(self): | |
|
645 | """Print the ipcontroller logs for this cluster to stdout.""" | |
|
646 | self._print_logs(self.get_ipcontroller_logs()) | |
|
647 | ||
|
648 | def print_ipcluster_logs(self): | |
|
649 | """Print the ipcluster logs for this cluster to stdout.""" | |
|
650 | self._print_logs(self.get_ipcluster_logs()) | |
|
651 | ||
|
652 | def print_logs(self): | |
|
653 | """Print all the logs for this cluster to stdout.""" | |
|
654 | self._print_logs(self.get_logs()) | |
|
584 | 655 |
General Comments 0
You need to be logged in to leave comments.
Login now