Added logtail.
[utils.git] / icom-dir
CommitLineData
b2eb79ae 1#!/usr/bin/python
2
3import sys, os
4from popen2 import popen2
5
6def 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
11if len(sys.argv) < 2:
12 sys.stderr.write("usage: icom-dir DIRECTORY\n")
9959ad1a 13 sys.exit(1)
b2eb79ae 14
15files = os.listdir(sys.argv[1])
16files.sort()
17pj = os.path.join
18
19for file1, file2 in combine(files):
20 co, ci = popen2(["icom", pj(sys.argv[1], file1), pj(sys.argv[1], file2)])
21 ci.close()
22 index = int(co.readline().split()[0])
23 co.close()
24 sys.stdout.write("%i %s %s\n" % (index, file1, file2))