#!/usr/bin/python

# @ Martin Kellogg, 1 July 2015

import sys
import subprocess

fl = sys.argv[1]

rgi = []

try:
    f = open(sys.argv[2])
    for ln in f:
        rgi.append(int(ln))
    f.close()
except:
    pass


fd = open(fl)

rgflTest = []
iln = 1

for ln in fd:
    if iln in rgi:
        rgflTest.append(ln.strip()[1:-2])
    iln += 1

for flTest in rgflTest:
    dirn = "/".join(flTest.split("/")[:-2])
    #basn = flTest.split("/")[-1]
    subprocess.call(["rm", "-f", dirn+"/tests.tar.gz"])
    subprocess.call(["tar", "czf", dirn+"/tests.tar.gz", dirn+"/tests/"])
