Created
September 8, 2023 23:22
-
-
Save imoutsatsos/7f666e83cc9ddaa7298c656e7630d8e5 to your computer and use it in GitHub Desktop.
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
/* | |
How to get a task IDs from a qstat grid engine report civilized | |
qstat reports failed tasks as comma separated mixed list of task-IDs and range-like task-IDs | |
Example: '135-139:1,143,146,147' | |
We want to transform this to a civilized Array List like: [135, 136, 137, 138, 139, 143, 146, 147] | |
*/ | |
mixedListRanges='135-139:1,143,146,147' | |
def failedTasks=mixedListRanges.tokenize(',').collect{qstatRangeToList(it)}.flatten() | |
def qstatRangeToList(String rangeString){ | |
l=[] | |
if (rangeString.contains('-')){ | |
println rangeString | |
rFirst=rangeString.split('-')[0] as int | |
rLast=rangeString.split('-')[1].split(':')[0]as int | |
rStep=rangeString.split('-')[1].split(':')[1] as int | |
taskRange=rFirst..rLast | |
taskRangeList=taskRange.step(rStep) | |
return taskRangeList | |
} else{ | |
l.add(rangeString as int) | |
return l | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment