-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbhistorywrite.py
96 lines (82 loc) · 3.62 KB
/
dbhistorywrite.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import json
import requests
import sqlite3
import HismoduleSQL
import logging
import time
import Datamodule
import fetcher
import telegramclient
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
running = True
#debug = False
def main(interval,debug):
global variable
variable = 1
fetcher.getlastpage()
while running:
time.sleep(interval)
def check():
global variable
fetcher.getdata(variable)
datafetch = fetcher.datavalue
#logging.info("variable=")
#logging.info(variable)
variable = variable + 1
for loadsql in datafetch:
try:
time.sleep(0)
keyretrieve = loadsql["publicKey"]
activestatus = loadsql["active"]
truststatus = loadsql["countTrust"]
if debug:
logging.info("key is send to module")
if HismoduleSQL.checkifpresent(keyretrieve,debug) == True:
if debug:
logging.info("Key already in db")
logging.info("Trying if node value is changed")
HismoduleSQL.checkifrunning(keyretrieve,debug)
HismoduleSQL.checktrust(keyretrieve,debug)
try:
if activestatus > HismoduleSQL.runningvalue:
HismoduleSQL.singlewrite(loadsql)
#telegramclient.dev()
if debug:
logging.info("Active status changed trying to write data")
if activestatus < HismoduleSQL.runningvalue:
HismoduleSQL.singlewrite(loadsql)
#telegramclient.dev()
if debug:
logging.info("Active status changed trying to write data")
if int(truststatus) != int(HismoduleSQL.trustvalue):
HismoduleSQL.singlewrite(loadsql)
#telegramclient.dev()
if debug:
logging.info("Trust amount increased trying to write data")
else:
if debug:
logging.info("nothing changed")
except Exception as E:
logging.info('Error : {}'.format(E))
if HismoduleSQL.checkifpresent(keyretrieve,debug) == False:
if debug:
logging.info("Key is going to be stored in db")
HismoduleSQL.singlewrite(loadsql)
time.sleep(0)
except Exception as E:
logging.info('Error : {}'.format(E))
if variable < fetcher.lastpage1:
if debug:
logging.info("Going to next page")
check()
if variable == fetcher.lastpage1:
if debug:
logging.info("reached max page Starting at page 1")
time.sleep(2)
check()
variable = 1
if variable > fetcher.lastpage1:
if debug:
logging.info("Error")
#main(1,True)