Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,50 @@ | ||
// Generated by CoffeeScript 1.3.1 | ||
var SUBTASK_RE, TASK_RE; | ||
var TASK_RE = /^\[(.+?)] (Finished|Running) (.*)/; | ||
var SUBTASK_RE = /^\[(.+?)\] \[(.+?)\] (\w+):\s*(.*)$/; | ||
|
||
TASK_RE = /^\[(.+?)] (Finished|Running) (.*)/; | ||
function parse_task(task_m, state) { | ||
var date=task_m[1], stat=task_m[2], task=task_m[3]; | ||
if(stat == "Running"){ | ||
state.task = [date, task]; | ||
} else if(stat == "Finished") { | ||
state.completed.push(task.match(/(.+?) \(([\d\.]+)s\)/).slice(1)); | ||
} | ||
} | ||
|
||
SUBTASK_RE = /^\[(.+?)\] \[(.+?)\] (\w+):\s*(.*)$/; | ||
function parse_subtask(subtask_m, state) { | ||
var date = subtask_m[1], | ||
host = subtask_m[2], | ||
kind = subtask_m[3], | ||
text = subtask_m[4]; | ||
if(kind == "running") { | ||
state.queue[host] = text; | ||
} else if(kind == "finished") { | ||
var res = text.match(/^(.*)\s+\((.*)\)$/); | ||
if(state.queue[host] == res[1]) { | ||
delete state.queue[host]; | ||
} | ||
} else if(kind == "failed") { | ||
state["failed"].push(state.task[0], state.task[1], host, task); | ||
} | ||
} | ||
|
||
exports.parselog = function(stream) { | ||
var date, host, kind, line, msg, state, status, task, text, time, _i, _len, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; | ||
state = { | ||
task: "", | ||
queue: {}, | ||
failed: [], | ||
completed: [] | ||
}; | ||
_ref = stream.split("\n"); | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
line = _ref[_i]; | ||
if (TASK_RE.test(line)) { | ||
_ref1 = TASK_RE.exec(line).slice(1), date = _ref1[0], status = _ref1[1], task = _ref1[2]; | ||
if (status === "Running") { | ||
state.task = [date, task]; | ||
} else if (status === "Finished") { | ||
_ref2 = /^(.+?) \(([\d\.]+)s\)/.exec(task).slice(1), task = _ref2[0], time = _ref2[1]; | ||
state.completed.push([task, time]); | ||
} | ||
state.task = [date, task]; | ||
} else if (SUBTASK_RE.test(line)) { | ||
_ref3 = SUBTASK_RE.exec(line).slice(1), date = _ref3[0], host = _ref3[1], kind = _ref3[2], text = _ref3[3]; | ||
if (kind === "running") { | ||
state.queue[host] = text; | ||
} else if (kind === "finished") { | ||
_ref4 = /^(.*)\s+\((.*)\)$/.exec(text).slice(1), msg = _ref4[0], time = _ref4[1]; | ||
if (state.queue[host] === msg) { | ||
delete state.queue[host]; | ||
state = { | ||
task: "", | ||
queue: {}, | ||
failed: [], | ||
completed: [] | ||
}; | ||
var lines = stream.split("\n"); | ||
for(var i=0; i < lines.length; i++) { | ||
var line = lines[i]; | ||
|
||
var task_m = line.match(TASK_RE); | ||
var subtask_m = line.match(SUBTASK_RE); | ||
if(task_m) { | ||
parse_task(task_m, state); | ||
} else if(subtask_m) { | ||
parse_subtask(subtask_m, state); | ||
} | ||
} else if (kind === "failed") { | ||
_ref5 = state.task, date = _ref5[0], task = _ref5[1]; | ||
state["failed"].push([date, task, host, text]); | ||
} | ||
} | ||
} | ||
return state; | ||
return state; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters