Skip to content

Commit 1496aa3

Browse files
committed
analytics code added
1 parent 1195083 commit 1496aa3

File tree

5 files changed

+219
-110
lines changed

5 files changed

+219
-110
lines changed

lib/analytics.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from imports import *
2+
3+
4+
class Analytics(object):
5+
def __init__(self):
6+
self.user = ref
7+
self.dict = dict()
8+
self.container = deque()
9+
10+
@staticmethod
11+
def finding_address():
12+
val = get_mac()
13+
return val
14+
15+
@staticmethod
16+
def finding_ip():
17+
val = socket.gethostbyname(socket.gethostname())
18+
return val
19+
20+
@staticmethod
21+
def finding_system():
22+
return platform.system()
23+
24+
def __setitem__(self, key, val):
25+
self.dict[key] = val
26+
27+
def __getitem__(self, key):
28+
return self.dict[key]
29+
30+
def random_string_generator(self, n=10):
31+
random_str = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n))
32+
return random_str
33+
34+
def insert_data(self):
35+
random_str = self.random_string_generator(15)
36+
self.container.append(random_str)
37+
self.user.child(random_str).set(self.dict)
38+
39+
def update_data(self):
40+
val = self.container.pop()
41+
result = self.user.child(val)
42+
result.update({
43+
'finish_time': str(datetime.datetime.now())
44+
})

lib/config_det.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
data_det = {
2+
"apiKey": "AIzaSyDhr5PJcaWBX15h1PayXSDpM-vsiqHqdUg",
3+
"authDomain": "explainx-25b88.firebaseapp.com",
4+
"databaseURL": "https://explainx-25b88.firebaseio.com",
5+
"projectId": "explainx-25b88",
6+
"storageBucket": "explainx-25b88.appspot.com",
7+
"messagingSenderId": "150067985334",
8+
"appId": "1:150067985334:web:a579d58390dee19837df17",
9+
"measurementId": "G-SSP86WD8HG",
10+
"type": "service_account"
11+
}

0 commit comments

Comments
 (0)