Browse Source

Comentarios

Rafael Arce Nazario 6 years ago
parent
commit
e3cb883c49
1 changed files with 12 additions and 5 deletions
  1. 12
    5
      tp-smart-process.py

+ 12
- 5
tp-smart-process.py View File

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
 import datetime
7
 import datetime
2
 import base64
8
 import base64
3
 import os
9
 import os
4
 import glob
10
 import glob
5
 import functools
11
 import functools
6
 import sys
12
 import sys
7
-
8
 from Crypto.Cipher import AES
13
 from Crypto.Cipher import AES
9
 
14
 
10
 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}
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
     return max(files, key = lambda x: os.path.getmtime(x))
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
 if len(sys.argv) != 3:
89
 if len(sys.argv) != 3:
81
 	print("Usage: " + sys.argv[0] + " (directory) (UserID)")
90
 	print("Usage: " + sys.argv[0] + " (directory) (UserID)")
86
 userID = sys.argv[2]
95
 userID = sys.argv[2]
87
 
96
 
88
 (tokenApp,tokenMonth, tokenDay, tokenYear, tokenTime) = (0,3,4,7,5)
97
 (tokenApp,tokenMonth, tokenDay, tokenYear, tokenTime) = (0,3,4,7,5)
89
-# print(latestUserFile(searchDir,userID))
90
 results = decryptFileAndProcess( latestUserFile(searchDir,userID))
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)