Debugged Code

This commit is contained in:
Kaushal Kumar Agarwal 2018-10-01 20:14:09 +05:30
parent 3b17810e63
commit ffaa7e27ed

20
main.py
View File

@ -3,6 +3,7 @@ from tkinter import *
from tkinter import messagebox from tkinter import messagebox
import subprocess import subprocess
import os import os
import sys
import webbrowser import webbrowser
import json import json
import math import math
@ -41,14 +42,17 @@ def readUnitFromBlockchain(txid):
def Dappend(Dapps,app): def Dappend(Dapps,app):
i = searchDict(Dapps,'id',app['id']) i = searchDict(Dapps,'id',app['id'])
#print(str(i))
if (i!=-1): if (i!=-1):
del(Dapps[i]) del(Dapps[i])
#print(app.keys())
if ('remove' not in app.keys()): if ('remove' not in app.keys()):
Dapps = Dapps + [app] Dapps = Dapps + [app]
return Dapps return Dapps
def verifyHash(localHash,txid): def verifyHash(localHash,txid):
content = readUnitFromBlockchain(txid) content = readUnitFromBlockchain(txid)
#print(content)
try: try:
if(json.loads(content)['hash'] == localHash): if(json.loads(content)['hash'] == localHash):
return True return True
@ -59,13 +63,19 @@ def verifyHash(localHash,txid):
def getJsonData(Dapps, lastTx): def getJsonData(Dapps, lastTx):
try:
r = requests.get("https://testnet.florincoin.info/ext/getaddress/"+JsonAddress) r = requests.get("https://testnet.florincoin.info/ext/getaddress/"+JsonAddress)
data = json.loads(r.content) data = json.loads(r.content)
#print(data) except:
isConnected()
return
#print(Dapps)
localHash = findHash(str(Dapps)) localHash = findHash(str(Dapps))
try: try:
if(lastTx == -1 or not verifyHash(localHash,data['last_txs'][lastTx]['addresses'])): if(lastTx == -1 or not verifyHash(localHash,data['last_txs'][lastTx]['addresses'])):
lastTx = 0 lastTx = 0
else:
lastTx = lastTx+1
except: except:
lastTx = 0 lastTx = 0
#print(lastTx) #print(lastTx)
@ -170,7 +180,7 @@ class FLOappStore:
self.listFrame.grid(column=1,columnspan=2) self.listFrame.grid(column=1,columnspan=2)
def execute(self,app): def execute(self,app):
print(app["name"]) #print(app["name"])
isConnected() isConnected()
self.appWin = Toplevel() self.appWin = Toplevel()
self.appWin.title(app["name"]) self.appWin.title(app["name"])
@ -242,7 +252,11 @@ except:
apps = [] apps = []
lastTx = -1 lastTx = -1
(apps,lastTx) = getJsonData(apps,lastTx) try:
(apps,lastTx) = getJsonData(apps,lastTx)
except:
sys.exit(1)
with open('Apps.json','w+') as F: with open('Apps.json','w+') as F:
data = json.dumps({'Dapps':apps ,'lastTx':lastTx}) data = json.dumps({'Dapps':apps ,'lastTx':lastTx})