diff options
author | Michele Simionato <michele.simionato@gmail.com> | 2010-12-03 12:08:13 +0100 |
---|---|---|
committer | Michele Simionato <michele.simionato@gmail.com> | 2010-12-03 12:08:13 +0100 |
commit | fd9a2705af0c57459243d6c2e985e5393ee3d6e1 (patch) | |
tree | d611c615e73bfa88a0d1f93446ba60443d338d1c | |
parent | 7fa512b4bbf45e9ec97a7f3c88b990273ae4a7ae (diff) | |
download | micheles-fd9a2705af0c57459243d6c2e985e5393ee3d6e1.tar.gz |
plac: added dump of task output to a file
-rw-r--r-- | plac/plac_ext.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/plac/plac_ext.py b/plac/plac_ext.py index 0d89c9a..29471bb 100644 --- a/plac/plac_ext.py +++ b/plac/plac_ext.py @@ -4,7 +4,7 @@ from contextlib import contextmanager from operator import attrgetter from gettext import gettext as _ import imp, inspect, os, sys, cmd, shlex, subprocess -import itertools, traceback, time, select, multiprocessing, signal, threading +import itertools, traceback, multiprocessing, signal, threading import plac_core try: import readline @@ -476,8 +476,8 @@ class TaskManager(object): @plac_core.annotations( taskno=('task number', 'positional', None, int)) - def output(self, taskno=-1): - 'show the output of a given task' + def output(self, taskno=-1, fname=None): + 'show the output of a given task (and optionally save it to a file)' if taskno < 0: task = self._get_latest(taskno) if task is None: @@ -489,6 +489,8 @@ class TaskManager(object): else: task = self.registry[taskno] outstr = '\n'.join(map(str, task.outlist)) + if fname: + open(fname, 'w').write(outstr) yield task if len(task.outlist) > 20 and use_less: less(outstr) |