summaryrefslogtreecommitdiff
path: root/bjoern
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-06-15 16:29:26 +0200
committerNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-06-15 16:29:26 +0200
commit531cc0fd239ac909ca0138079a89eb898b16638a (patch)
tree8bf28c8500ba5ee8dfe260679562c059c83d08a9 /bjoern
parent556dd4a49bb336eb309287d291ad36f0df90b01b (diff)
reformatting
Diffstat (limited to 'bjoern')
-rwxr-xr-xbjoern/videoanalyse/LogParser.py18
1 files changed, 6 insertions, 12 deletions
diff --git a/bjoern/videoanalyse/LogParser.py b/bjoern/videoanalyse/LogParser.py
index c580cfe..e48662c 100755
--- a/bjoern/videoanalyse/LogParser.py
+++ b/bjoern/videoanalyse/LogParser.py
@@ -12,6 +12,8 @@ import codecs
from read_sqlite import get_url_from_sqlite
from pathlib import Path
+BROWSER_TITLE_SUFFIX = " - Mozilla Firefox"
+
# takes the log data string and returns a list of activity titles and their time windows
def extract_activities(log_data):
@@ -33,17 +35,15 @@ def extract_activities(log_data):
# extract squared brackets per string
for s in windows:
if not del_flag:
- print("STRING: ", s)
found_brackets = reg_titles.findall(s)
if found_brackets:
- if found_brackets[0].endswith(" - Mozilla Firefox"):
- title = found_brackets[0].replace(" - Mozilla Firefox", "")
+ # Only use Browser titles
+ if found_brackets[0].endswith(BROWSER_TITLE_SUFFIX):
+ title = found_brackets[0].replace(BROWSER_TITLE_SUFFIX, "")
brackets.append(title)
enter_exit = s.split("Enter-Exit: ")[-1]
timestamps = reg_titles.findall(enter_exit)
- print("ENTER: ", timestamps)
for timestamp in timestamps:
- print(timestamp.split("-"))
t_enter, t_exit = timestamp.split("-")
if not title in extracted_data:
extracted_data[title] = []
@@ -54,15 +54,11 @@ def extract_activities(log_data):
del_flag = False
if "Restricted Windows Summary:" in s:
del_flag = True
- print("-------------------------FINISH----------------------------------------")
- print(extracted_data)
return extracted_data
-# returns logged activities and their timestamps from a VP as a table
def get_log_data(data_path):
- # import browser history and .log files
files = os.listdir(data_path)
log_files = []
log_data = []
@@ -91,6 +87,7 @@ def match_urls(history_db, log):
return log
def generate_log(activities: dict):
+ # For each start time in ascending order, make an entry with title and timestamp
log = []
while activities:
first_title = list(activities.keys())[0]
@@ -102,9 +99,6 @@ def generate_log(activities: dict):
< activities[smallest_start_time[0]][smallest_start_time[1]][0]
):
smallest_start_time = (title, idx)
- # print(
- # f"title: {smallest_start_time[0]}, time: {activities[smallest_start_time[0]][smallest_start_time[1]]}"
- # )
log.append(
[
activities[smallest_start_time[0]][smallest_start_time[1]][0].isoformat(),