From 7528fe8043d40641b1ddf102c50275c1d3695117 Mon Sep 17 00:00:00 2001
From: anima
Date: Sun, 9 May 2021 18:53:06 +0200
Subject: [PATCH] inital timeTrack in python. write __init__ and load_config
methode
---
timeTrack.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+)
create mode 100644 timeTrack.py
diff --git a/timeTrack.py b/timeTrack.py
new file mode 100644
index 0000000..16f9cce
--- /dev/null
+++ b/timeTrack.py
@@ -0,0 +1,66 @@
+#!/bin/python3
+#########################
+#
+# timeTrack.py
+# by 4nima
+# v.0.0
+#
+#########################
+# simple time tracking with database
+#########################
+
+import datetime
+import sqlite3
+import json
+import os
+import logging
+
+class TimeTrack:
+ def __init__(self, DATABASE='timetrack.db', CONFIG='timetrack.conf'):
+ self.DATABASE = DATABASE
+ self.CONFIG = CONFIG
+ self.USER = 0
+ self.LOGFILE = 'timetrack.log'
+ logging.basicConfig(filename=self.LOGFILE,
+ level=logging.DEBUG,
+ format='%(asctime)s - %(process)d-%(levelname)s: %(message)s',
+ datefmt='%Y-%m-%d %H:%M:%S'
+ )
+ self.load_config()
+
+ ## Läd oder erstellt das config file
+ def load_config(self):
+ if os.path.isfile(self.CONFIG):
+ logging.info('Config file found')
+ try:
+ with open(self.CONFIG) as config_data:
+ data = json.load(config_data)
+ except ValueError:
+ logging.error('Config file has no valid JSON syntax')
+ print('TimeTrack wird beendet. Fehler in der JSON-Konfig')
+ quit()
+ else:
+ logging.info('Config file loaded successfully')
+ self.USER = data['user']
+
+ else:
+ logging.info('Config file not found')
+ ##> ausgabe nicht in einer zeile
+ config = {
+ 'user' : 1,
+ 'default' : 'interactive'
+ }
+
+ ##> logging erweitert falls nicht möglich
+ with open(self.CONFIG, "w") as outfile:
+ json.dump(config, outfile)
+ logging.info('config file successfully created')
+
+ def db_connect(self):
+ pass
+
+ def set_user(self):
+ pass
+
+
+test = TimeTrack()
\ No newline at end of file