| 1 | #!/usr/bin/python |
| 2 | |
| 3 | import sys, os |
| 4 | from popen2 import popen2 |
| 5 | |
| 6 | def combine(list): |
| 7 | for i in xrange(len(list) - 1): |
| 8 | for o in xrange(i + 1, len(list)): |
| 9 | yield list[i], list[o] |
| 10 | |
| 11 | if len(sys.argv) < 2: |
| 12 | sys.stderr.write("usage: icom-dir DIRECTORY\n") |
| 13 | |
| 14 | files = os.listdir(sys.argv[1]) |
| 15 | files.sort() |
| 16 | pj = os.path.join |
| 17 | |
| 18 | for file1, file2 in combine(files): |
| 19 | co, ci = popen2(["icom", pj(sys.argv[1], file1), pj(sys.argv[1], file2)]) |
| 20 | ci.close() |
| 21 | index = int(co.readline().split()[0]) |
| 22 | co.close() |
| 23 | sys.stdout.write("%i %s %s\n" % (index, file1, file2)) |