Update
This commit is contained in:
parent
e4d7956ed1
commit
31b45cad15
44
getJson.py
44
getJson.py
@ -2,29 +2,43 @@ import requests
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
JsonAddress = "ocZXNtzpiUqBvzQorjAKmZ5MhXxGTLKeSH"
|
||||
|
||||
def searchDict(dicArr,key,val):
|
||||
for i in range(len(dicArr)):
|
||||
if(dicArr[i][key]==val):
|
||||
return i
|
||||
return -1
|
||||
|
||||
def readUnitFromBlockchain(txid):
|
||||
rawtx = subprocess.check_output(["flo-cli","--testnet", "getrawtransaction", str(txid)])
|
||||
rawtx = str(rawtx)
|
||||
rawtx = rawtx[2:-3]
|
||||
tx = subprocess.check_output(["flo-cli","--testnet", "decoderawtransaction", str(rawtx)])
|
||||
content = json.loads(tx)
|
||||
text = content['floData']
|
||||
return text
|
||||
|
||||
def getJsonData():
|
||||
r = requests.get("https://testnet.florincoin.info/ext/getaddress/ocZXNtzpiUqBvzQorjAKmZ5MhXxGTLKeSH")
|
||||
r = requests.get("https://testnet.florincoin.info/ext/getaddress/"+JsonAddress)
|
||||
data = json.loads(r.content)
|
||||
#print(data)
|
||||
|
||||
def readUnitFromBlockchain(txid):
|
||||
rawtx = subprocess.check_output(["flo-cli","--testnet", "getrawtransaction", str(txid)])
|
||||
rawtx = str(rawtx)
|
||||
rawtx = rawtx[2:-3]
|
||||
tx = subprocess.check_output(["flo-cli","--testnet", "decoderawtransaction", str(rawtx)])
|
||||
content = json.loads(tx)
|
||||
text = content['floData']
|
||||
return text
|
||||
|
||||
Dapps = []
|
||||
for i in range(len(data['last_txs'])):
|
||||
if(data['last_txs'][i]['type']=='vin'):
|
||||
content = readUnitFromBlockchain(data['last_txs'][i]['addresses'])
|
||||
#print(content)
|
||||
if content.startswith("text:Dapps"):
|
||||
print(data['last_txs'][i]['addresses'])
|
||||
#print(data['last_txs'][i]['addresses'])
|
||||
pos = content.find('{')
|
||||
Dapps = Dapps + [json.loads(content[pos:])]
|
||||
app = json.loads(content[pos:])
|
||||
i = searchDict(Dapps,'id',app['id'])
|
||||
if (i!=-1):
|
||||
del(Dapps[i])
|
||||
if ('remove' not in app.keys()):
|
||||
Dapps = Dapps + [app]
|
||||
#print(Dapps)
|
||||
return Dapps
|
||||
|
||||
print(Dapps)
|
||||
return Dapps
|
||||
apps = getJsonData()
|
||||
print(apps)
|
||||
13
main.py
13
main.py
@ -11,6 +11,12 @@ import requests
|
||||
|
||||
JsonAddress = "ocZXNtzpiUqBvzQorjAKmZ5MhXxGTLKeSH"
|
||||
|
||||
def searchDict(dicArr,key,val):
|
||||
for i in range(len(dicArr)):
|
||||
if(dicArr[i][key]==val):
|
||||
return i
|
||||
return -1
|
||||
|
||||
def isConnected():
|
||||
try:
|
||||
socket.create_connection(("www.github.com", 80))
|
||||
@ -40,7 +46,12 @@ def getJsonData():
|
||||
if content.startswith("text:Dapps"):
|
||||
#print(data['last_txs'][i]['addresses'])
|
||||
pos = content.find('{')
|
||||
Dapps = Dapps + [json.loads(content[pos:])]
|
||||
app = json.loads(content[pos:])
|
||||
i = searchDict(Dapps,'id',app['id'])
|
||||
if (i!=-1):
|
||||
del(Dapps[i])
|
||||
if ('remove' not in app.keys()):
|
||||
Dapps = Dapps + [app]
|
||||
#print(Dapps)
|
||||
return Dapps
|
||||
|
||||
|
||||
12
test.py
Normal file
12
test.py
Normal file
@ -0,0 +1,12 @@
|
||||
def searchDict(dicArr,key,val):
|
||||
for i in range(len(dicArr)):
|
||||
if(dicArr[i][key]==val):
|
||||
return i
|
||||
return -1
|
||||
|
||||
d = [{'id': '1', 'name': 'Alexandria', 'icon': 'Icon/Alexandria.png', 'type': 'Webapp', 'url': 'https://alexandria.io/browser/'}, {'id': '2', 'name': 'AlternateLove', 'icon': 'Icon/AternaLove.png', 'type': 'Cmdline', 'location': 'apps/aternalove', 'exec': './auto-aterna-love.sh', 'github': 'https://github.com/metacoin/aternalove.git'}, {'id': '3', 'name': 'Caltech', 'icon': 'Icon/Caltech.png', 'type': 'Webapp', 'url': 'https://etdb.caltech.edu/browse'}, {'id': '4', 'name': 'Flotorizer', 'icon': 'Icon/Flotorizer.png', 'type': 'Webapp', 'url': 'http://flotorizer.net/'}, {'id': '5', 'name': 'Medici', 'icon': 'Icon/Medici.png', 'type': 'Webapp', 'url': 'https://www.mediciventures.com/'}, {'id': '6', 'name': 'FloSharedSecret', 'icon': 'Icon/SharedSecret.png', 'type': 'Gui', 'location': 'apps/FLO-shared-secret/', 'exec': './FLO_Secret', 'github': 'https://github.com/akhil2015/FLO-shared-secret.git'}, {'id': '7', 'name': 'FloRate', 'icon': 'Icon/Florate.png', 'type': 'Gui', 'location': 'apps/FloRate-Dapp/', 'exec': './Florate', 'github': 'https://github.com/Tarun047/FloRate-Dapp.git'}, {'id': '8', 'name': 'tZero', 'icon': 'Icon/tZero.png', 'type': 'Webapp', 'url': 'https://www.tzero.com/'}, {'id': '9', 'name': 'WorldMood', 'icon': 'Icon/WorldMood.png', 'type': 'Webapp', 'url': 'http://worldmood.io/'}, {'id': '10', 'name': 'Xcertify', 'icon': 'Icon/Xcertify.png', 'type': 'Cmdline', 'location': 'apps/Xcertify/', 'exec': './xcertify', 'github': 'https://github.com/akhil2015/Xcertify.git'}]
|
||||
del(d[1])
|
||||
print(d)
|
||||
i = searchDict(d,'id','4')
|
||||
if(i!=-1):
|
||||
print(i)
|
||||
Loading…
Reference in New Issue
Block a user