diff options
| author | Lennart Poettering <lennart@poettering.net> | 2005-11-21 14:15:24 +0000 |
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2005-11-21 14:15:24 +0000 |
| commit | 60cd2a763756529262ae7bbe58b3272ed51e5598 (patch) | |
| tree | 02443608eb4a01d1567a057a0ab9727c425aab0a /sse-feed | |
| parent | 6a9e54615b4da50ad0f288e1bd5f0e3cea4a1fc9 (diff) | |
move everything down a directory
git-svn-id: file:///home/lennart/svn/public/sse/trunk@6 5fbabb74-0606-0410-a5e4-b5cc6a42724e
Diffstat (limited to 'sse-feed')
| -rwxr-xr-x | sse-feed | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/sse-feed b/sse-feed deleted file mode 100755 index 29718ca..0000000 --- a/sse-feed +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/python - -import sys, os, MySQLdb, stat -from popen2 import Popen3 - -def last_insert_id(cursor): - cursor.execute("SELECT LAST_INSERT_ID()"); - return cursor.fetchone()[0] - -def process_file(package_id, root, path): - global cursor - print "Processing %s" % path - - cursor.execute("INSERT INTO file (package_id, path, language_id) VALUES (%i, '%s', '0')" % (package_id, path)); - - file_id = last_insert_id(cursor); - - p = Popen3("lex-c %s" % (os.path.join(root, path))) - - for identifier in p.fromchild: - text = identifier.strip() - - cursor.execute("INSERT IGNORE INTO word (text, type, file_id) VALUES ('%s', 'word', '%i')" % (text, file_id)) - cursor.execute("UPDATE word SET cnt=cnt+1 WHERE text='%s' AND type='word' AND file_id=%i" % (text, file_id)) - - if p.wait() != 0: - print "WARNING: Subprocess failed!" - - del p - -def handle_file(package_id, root, path, filename): - - t = sys.lstat(os.path.join(path, filename)) - - if stat.F_ISREG(t.st_mode): - - extension = filename.split(".")[-1] - - if extension in ("c", "h"): - process_file(package_id, root, os.path.join(path, filename)) - return - - os.unlink(os.path.join(root, path, filename)) - -def handle_tree(path, name, url, md): - global cursor - - cursor.execute("INSERT INTO package (path, name, url, timestamp, md) VALUES ('%s', '%s', '%s', NOW(), '%s')" % (path + "/%s", name, url, md)); - package_id = last_insert_id(cursor); - - path = os.path.realpath(path) - - for dirpath, dirs, files in os.walk(path): - for f in files: - assert path + "/" == (dirpath + "/") [:len(path)+1] - - handle_file(package_id, path, dirpath[len(path)+1:], f) - -db = MySQLdb.connect(host = "localhost", user = "sse_web", passwd = "ece6Yoli", db = "sse") -cursor = db.cursor(); -cursor.execute("SET AUTOCOMMIT=0") -cursor.execute("START TRANSACTION") - -assert len(sys.argv) == 5 - -handle_tree(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]) - -cursor.execute("COMMIT") -cursor.close() -db.close() |
