config file extended by categories, clients, references
This commit is contained in:
21
timeTrack.py
21
timeTrack.py
@@ -23,8 +23,11 @@ class TimeTrack:
|
|||||||
self.USERID = 0
|
self.USERID = 0
|
||||||
self.USERNAME = ''
|
self.USERNAME = ''
|
||||||
self.OLDEVENT = 2
|
self.OLDEVENT = 2
|
||||||
|
self.CLIENTS = False
|
||||||
|
self.CATEGORIES = False
|
||||||
|
self.REFERENCES = False
|
||||||
self.LOGFILE = 'timetrack.log'
|
self.LOGFILE = 'timetrack.log'
|
||||||
self.DBCON = sqlite3.connect(self.DATABASE, detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
|
self.DBCON = sqlite3.connect(self.DATABASE, detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename=self.LOGFILE,
|
filename=self.LOGFILE,
|
||||||
level=logging.DEBUG,
|
level=logging.DEBUG,
|
||||||
@@ -61,17 +64,23 @@ class TimeTrack:
|
|||||||
quit()
|
quit()
|
||||||
else:
|
else:
|
||||||
logging.info('Config file was loaded successfully')
|
logging.info('Config file was loaded successfully')
|
||||||
self.USERID = data['user']
|
self.USERID = data['userid']
|
||||||
self.OLDEVENT = data['oldevent']
|
self.OLDEVENT = data['oldevent']
|
||||||
logging.debug('UserID {} was used'.format(data['user']))
|
self.CLIENTS = data['clients']
|
||||||
|
self.CATEGORIES = data['categories']
|
||||||
|
self.REFERENCES = data['references']
|
||||||
|
logging.debug('UserID {} was used'.format(data['userid']))
|
||||||
self.set_user()
|
self.set_user()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logging.warning('Config file not found')
|
logging.warning('Config file not found')
|
||||||
config = {
|
config = {
|
||||||
'default' : 'interactive',
|
'default' : 'interactive',
|
||||||
'user' : 1,
|
'userid' : 1,
|
||||||
'oldevent' : 2
|
'oldevent' : 2,
|
||||||
|
'clients' : False,
|
||||||
|
'categories' : False,
|
||||||
|
'references' : False
|
||||||
}
|
}
|
||||||
with open(self.CONFIG, "w") as outfile:
|
with open(self.CONFIG, "w") as outfile:
|
||||||
json.dump(config, outfile, indent=4, sort_keys=True)
|
json.dump(config, outfile, indent=4, sort_keys=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user