initial commit of dwtt, skeleton for now

This commit is contained in:
Josh Holtrop 2010-12-02 16:29:45 -05:00
parent 2185408b45
commit b0b8ce1716

49
dwtt Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env python
import gtk
import sqlite3
import os
import sys
import getopt
from datetime import datetime
PROGRAM_NAME = 'dwtt'
def usage():
print '''Usage: dwtt [options]
Options:
-c Open a window to take a command as input
-d|--dbfile <dbfile> Use dbfile as the database file
--help Show this help
'''
def main(argv):
try:
opts, args = getopt.getopt(argv[1:], "d:c", ["help", "dbfile="])
except getopt.GetoptError:
usage()
sys.exit(1)
timedbfile = os.path.expanduser('~/.' + PROGRAM_NAME + '.db')
for opt, arg in opts:
if opt in ("-d", "--dbfile"):
timedbfile = arg
elif opt == "--help":
usage()
sys.exit()
if not os.path.exists(timedbfile):
createdb(timedbfile)
def createdb(dbfile):
conn = sqlite3.connect(dbfile)
c = conn.cursor()
c.execute('''CREATE TABLE projects (name TEXT UNIQUE)''')
c.execute('''CREATE TABLE aliases (name TEXT UNIQUE, project TEXT)''')
conn.commit()
c.close()
conn.close()
if __name__ == "__main__":
main(sys.argv)