def _include_subtasks(tasks, task_names, include_subtasks): """append any subtasks of 'task_names' """ # get task by name subtasks = [] for name in task_names: subtasks.extend(cmd_base.subtasks_iter(tasks, tasks[name])) return subtasks
def _include_subtasks(tasks, task_names, include_subtasks): """append any subtasks of 'task_names' """ # get task by name subtasks = [] for name in task_names: subtasks.extend( cmd_base.subtasks_iter(tasks, tasks[name])) return subtasks
def names(task_name): return [t.name for t in subtasks_iter(tasks, tasks[task_name])]
def _execute(self, html=None, bar_length=20, pos_args=None): from astropy.table import Table tasks = dict([(t.name, t) for t in self.task_list]) if pos_args: # list only tasks passed on command line check_tasks_exist(tasks, pos_args) task_list = [tasks[name] for name in pos_args] else: task_list = self.task_list stat = OrderedDict() for task in task_list: if task.has_subtask: stat[task.name] = d = defaultdict(int) for subtask in subtasks_iter(tasks, task): res = self.dep_manager.get_status(subtask, tasks) d[res.status] += 1 d['total'] = sum(d.values()) states = ['run', 'error', 'up-to-date', 'total'] cols = [list(stat.keys())] for state in states: cols.append([stat[name][state] for name in cols[0]]) if html: progress = [ generate_html_bar(stat[name], bar_length) for name in cols[0] ] else: progress = [ generate_ascii_bar(stat[name], bar_length) for name in cols[0] ] cols.append(progress) cols.append([tasks[name].doc for name in cols[0]]) t = Table(cols, names=['name'] + states + ['progress', 'doc']) if html: from astropy.table.jsviewer import DEFAULT_CSS, conf htmldict = { 'table_id': 'progress', 'table_class': 'dataTable display compact', 'css': DEFAULT_CSS, 'cssfiles': conf.css_urls, # Small hackish script to unescape the table's content ... 'js': """ document.onreadystatechange = function () { if (document.readyState == 'complete') { document.title = 'Doit HTML report'; var title = document.createElement('h1'); title.innerHTML = 'Report generated on %s'; document.body.insertBefore(title, document.getElementById('progress')); Array.prototype.forEach.call( document.querySelectorAll('#progress td:nth-child(6)'), function(el) { el.innerHTML = el.textContent; } ); } } """ % datetime.now().strftime('%Y-%m-%d %H:%M:%S') } t.write(html, format='html', htmldict=htmldict, overwrite=True) else: print(t) # self.outstream.write(str(t).decode('utf8') + '\n') self.dep_manager.close()