primera version de melon-watch-dir.py
authorJorge Gorbe Moya <slack@codemaniacs.com>
Fri, 27 Jun 2008 01:47:13 +0000 (03:47 +0200)
committerJorge Gorbe Moya <slack@codemaniacs.com>
Fri, 27 Jun 2008 01:47:13 +0000 (03:47 +0200)
melon-watch-dir.py [new file with mode: 0755]

diff --git a/melon-watch-dir.py b/melon-watch-dir.py
new file mode 100755 (executable)
index 0000000..ba9eac0
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/python
+
+import sys
+import time
+import os
+import tempfile
+
+dst_dirname = sys.argv[1]
+name = sys.argv[2]
+dirname = sys.argv[3]
+total = int(sys.argv[4])
+user = os.getlogin()
+hostname = os.uname()[1]
+
+
+outfile=tempfile.NamedTemporaryFile("w+b",-1,".melon","log-",dst_dirname)
+
+old_count = -1
+count = len(os.listdir(dirname))
+
+while count < total:
+       if old_count != count:
+               outfile.write("!!%s&%s&%s&%s&%d!!\n"%(name, user, hostname, "dirname "+str(count)+"/"+str(total), (100*count)/total))
+               outfile.flush()
+       time.sleep(2)
+       old_count = count
+       count = len(os.listdir(dirname))
+
+
+
+