Kleines Tool um die Downloaddatenbank zu bearbeiten

This commit is contained in:
Stefan Bethke 2010-08-07 09:04:37 +00:00
parent 4b00bad4c2
commit b8a12f7c44

33
src/tivomirror/dbtool Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/python
# $Schlepperbande$
import anydbm
import getopt
import sys
def usage():
print >>sys.stderr, "usage: dbtool {-a entry|-d entry|-l}"
try:
optlist, args = getopt.getopt(sys.argv[1:], "a:d:l")
except getopt.GetoptError, err:
print >>sys.stderr, str(err)
usage()
sys.exit(64)
if len(args) != 0 or len(optlist) != 1:
usage()
sys.exit(64)
downloaddb = anydbm.open("tivo/.downloads", "c")
for (o, a) in optlist:
if o == "-l":
for i in sorted(downloaddb.keys()):
print "%s: %s" % (i, downloaddb[i])
elif o == "-d":
del downloaddb[a]
elif o == "-a":
downloaddb[a] = "manually added"
downloaddb.close()