61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
import sqlite3
|
|
import os
|
|
import argparse
|
|
import json
|
|
import getpass
|
|
import datetime
|
|
import logging
|
|
|
|
import project
|
|
import action
|
|
import task
|
|
import note
|
|
import pit_argparser
|
|
|
|
# logging.basicConfig(level=logging.DEBUG, format='%(asctime)s :: %(levelname)s :: %(message)s')
|
|
logging.basicConfig(level=logging.DEBUG, format='%(levelname)7s :: %(message)s')
|
|
|
|
def info():
|
|
logging.info('info function')
|
|
|
|
def handle_note(args):
|
|
logging.info('>> handle note')
|
|
|
|
def create_connection(db_filename):
|
|
try:
|
|
conn = sqlite3.connect(db_filename)
|
|
return conn
|
|
except Error as e:
|
|
print(e)
|
|
|
|
return None
|
|
|
|
db_filename = 'pits.db'
|
|
schema_filename = 'pits_schema.sql'
|
|
|
|
# TODO Use init command like original pit
|
|
# TODO Need to add an action - log init
|
|
db_is_new = not os.path.exists(db_filename)
|
|
|
|
with sqlite3.connect(db_filename) as conn:
|
|
if db_is_new:
|
|
logging.info('Creating schema')
|
|
with open(schema_filename, 'rt') as f:
|
|
schema = f.read()
|
|
conn.executescript(schema)
|
|
|
|
# logging.info('Inserting initial data')
|
|
# conn.executescript("""
|
|
# insert into project values(1, 'me', 'test', 'in progress', 'now', 'now')""")
|
|
|
|
if __name__ == '__main__':
|
|
parser = pit_argparser.create_parser()
|
|
args = parser.parse_args()
|
|
|
|
with conn:
|
|
last_action = action.read_last_action(conn)
|
|
logging.debug('Last action: {}'.format(last_action))
|
|
|
|
args.func(args, last_action, conn)
|
|
|
|
print('END') |