-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.py
More file actions
executable file
·36 lines (31 loc) · 949 Bytes
/
inject.py
File metadata and controls
executable file
·36 lines (31 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#! /usr/bin/python3.1
import sys
import os.path
import sqlite3
db = sqlite3.connect('queue.sqlite')
try:
# id will be used for order of processing as well...
db.execute('CREATE TABLE queue (id integer primary key, name text, done integer)')
except:
pass
def add(db, logfile):
SELECT = 'SELECT id FROM queue WHERE name = ?'
INSERT = 'INSERT INTO queue (name, done) VALUES (?, 0)'
r = db.execute(SELECT, (logfile, ))
r = r.fetchone()
if r is None:
db.execute(INSERT, (logfile, ))
db.commit()
return True
return False
# Of course this will crash if logs have space in their names, muhahaha:
for i in range(1, len(sys.argv)):
f = sys.argv[i]
if not os.path.exists(f):
print('WARNING: file %s does not exist' % f)
continue
r = add(db, f)
if r is False:
print('WARNING: cannot add %s: already in database' % f)
continue
print(f, 'added')