Rafael Arce Nazario před 6 roky
rodič
revize
e3cb883c49
1 změnil soubory, kde provedl 12 přidání a 5 odebrání
  1. 12
    5
      tp-smart-process.py

+ 12
- 5
tp-smart-process.py Zobrazit soubor

@@ -1,10 +1,15 @@
1
+'''
2
+Script for processing the log generated by the TPSmart app. 
3
+Given a directory and userID will determine the latest log file, decrypt it and 
4
+compute the time that was spent on each app.
5
+'''
6
+
1 7
 import datetime
2 8
 import base64
3 9
 import os
4 10
 import glob
5 11
 import functools
6 12
 import sys
7
-
8 13
 from Crypto.Cipher import AES
9 14
 
10 15
 monthDict = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep':9, 'Oct':10, 'Nov': 11, 'Dec' : 12}
@@ -76,6 +81,10 @@ def latestUserFile(searchDir, userID):
76 81
     return max(files, key = lambda x: os.path.getmtime(x))
77 82
 
78 83
 
84
+'''
85
+The main program....
86
+'''
87
+
79 88
 
80 89
 if len(sys.argv) != 3:
81 90
 	print("Usage: " + sys.argv[0] + " (directory) (UserID)")
@@ -86,8 +95,6 @@ searchDir = sys.argv[1]
86 95
 userID = sys.argv[2]
87 96
 
88 97
 (tokenApp,tokenMonth, tokenDay, tokenYear, tokenTime) = (0,3,4,7,5)
89
-# print(latestUserFile(searchDir,userID))
90 98
 results = decryptFileAndProcess( latestUserFile(searchDir,userID))
91
-
92
-print("Results:\n",results)
93
-# print(decryptFileAndProcess( latestUserFile("5000")))
99
+print("Results for user", userID)
100
+print(results)