Uhm.. dynamic typing is fun
[llpp.git] / misc / gc.py
blobaf5c24127ee4608b8151ad8aa408e8a962588ab8
1 #!/usr/bin/env python
2 import os, sys, string, subprocess, socket
4 fields = string.split (sys.stdin.read (), '\x00')
6 while len (fields) > 1:
7 opath, atime = fields[0:2]
8 fields = fields[2:]
9 npath = ""
10 if not os.path.exists (opath):
11 try:
12 npath = subprocess.check_output (
13 "locate -b -l 1 -e '/%s$'" % opath,
14 shell = False
16 except:
17 pass
18 npath = npath[:-1]
19 sys.stdout.write (opath + "\000" + npath + "\000")
20 elif os.path.isdir (opath):
21 sys.stdout.write (opath + "\000\000")
23 sys.stdout.flush ()
24 socket.fromfd (sys.stdout.fileno (),
25 socket.AF_UNIX,
26 socket.SOCK_STREAM).shutdown (socket.SHUT_RDWR)
27 sys.stderr.write ("gc.py done\n")
28 os._exit (0)