Added multiple appstore address, added feature to show description
This commit is contained in:
parent
2fa6999ecc
commit
105c1a8dd3
@ -12,7 +12,7 @@
|
|||||||
"name": "AlternateLove",
|
"name": "AlternateLove",
|
||||||
"icon": "Icon/AternaLove.png",
|
"icon": "Icon/AternaLove.png",
|
||||||
"type": "Cmdline",
|
"type": "Cmdline",
|
||||||
"location": "apps/aternalove",
|
"location": "apps/aternalove/",
|
||||||
"exec": "./auto-aterna-love.sh",
|
"exec": "./auto-aterna-love.sh",
|
||||||
"github": "https://github.com/metacoin/aternalove.git"
|
"github": "https://github.com/metacoin/aternalove.git"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
FLO_appStore
BIN
FLO_appStore
Binary file not shown.
@ -4,11 +4,13 @@ The details are as follows
|
|||||||
id - App id
|
id - App id
|
||||||
name - Name of the app
|
name - Name of the app
|
||||||
icon - Icon img location
|
icon - Icon img location
|
||||||
|
description - App Description
|
||||||
type - App type (webapp, cmdline or gui)
|
type - App type (webapp, cmdline or gui)
|
||||||
exec - Execution Command
|
exec - Execution Command
|
||||||
github - github link
|
github - github link
|
||||||
|
|
||||||
Note:-Inorder to remove a dapp from the flostore permanently,the authoritative user has to make a transaction of that app,with 'remove' paramater/key(in json format) added in the detail of that dapp.
|
**Use generateAppData.py for generating the data required to send for the respective app**
|
||||||
|
|
||||||
|
|
||||||
Webapps are available as website n should be opened in browser
|
Webapps are available as website n should be opened in browser
|
||||||
Gui apps are open by running their binary files
|
Gui apps are open by running their binary files
|
||||||
|
|||||||
83
generateAppData.py
Normal file
83
generateAppData.py
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import subprocess
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
import hashlib
|
||||||
|
|
||||||
|
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 str(text)
|
||||||
|
|
||||||
|
def Dappend(Dapps,app):
|
||||||
|
i = searchDict(Dapps,'id',app['id'])
|
||||||
|
if (i!=-1):
|
||||||
|
del(Dapps[i])
|
||||||
|
if ('remove' not in app.keys()):
|
||||||
|
Dapps = Dapps + [app]
|
||||||
|
return Dapps
|
||||||
|
|
||||||
|
def getJsonData(JsonAddress):
|
||||||
|
r = requests.get("https://testnet.florincoin.info/ext/getaddress/"+JsonAddress)
|
||||||
|
data = json.loads(r.content)
|
||||||
|
#print(data)
|
||||||
|
Dapps = []
|
||||||
|
for i in range(len(data['last_txs'])):
|
||||||
|
if(data['last_txs'][i]['type']=='vin'):
|
||||||
|
content = readUnitFromBlockchain(data['last_txs'][i]['addresses'])
|
||||||
|
try:
|
||||||
|
app = json.loads(content)
|
||||||
|
except :
|
||||||
|
continue
|
||||||
|
#print(app)
|
||||||
|
try:
|
||||||
|
if 'Dapp' in app.keys():
|
||||||
|
Dapps = Dappend(Dapps,app['Dapp'])
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
#print(Dapps)
|
||||||
|
return Dapps
|
||||||
|
|
||||||
|
def findHash(data):
|
||||||
|
result = hashlib.sha1(data.encode())
|
||||||
|
return str(result.hexdigest())
|
||||||
|
|
||||||
|
|
||||||
|
JsonAddress=input('Enter Admin address :')
|
||||||
|
apps = getJsonData(JsonAddress)
|
||||||
|
#print(apps)
|
||||||
|
|
||||||
|
print("Enter app Details :")
|
||||||
|
appData = {}
|
||||||
|
appData['id'] = input('Enter App ID \t: ')
|
||||||
|
if input('Remove app ? (Y/N)') == 'Y':
|
||||||
|
appData['remove'] = True
|
||||||
|
else:
|
||||||
|
appData['name'] = input('Enter App Name \t: ')
|
||||||
|
appData['description'] = input('Enter Description \t: ')
|
||||||
|
appData['icon'] = input('Enter Icon location \t: ')
|
||||||
|
appData['type'] = input('Enter App Type (Webapp|Cmdline|Gui): ')
|
||||||
|
if appData['type'] == 'Webapp':
|
||||||
|
appData['url'] = input('Enter App url \t: ')
|
||||||
|
elif appData['type'] == 'Cmdline' or appData['type'] == 'Gui':
|
||||||
|
appData['github'] = input('Enter Github link (.git) \t: ')
|
||||||
|
appData['location'] = 'apps/'+input('Enter Repository name \t: ') +'/'
|
||||||
|
appData['exec'] = input('Enter execution cmd (eg. ./binary) \t: ')
|
||||||
|
|
||||||
|
print(appData)
|
||||||
|
apps = Dappend(apps ,appData)
|
||||||
|
#print(apps)
|
||||||
|
apphash = findHash(str(apps))
|
||||||
|
|
||||||
|
floData = json.dumps({'Dapp':appData ,'hash':apphash})
|
||||||
|
print('\nfloData = '+floData)
|
||||||
|
|
||||||
67
main.py
67
main.py
@ -11,7 +11,7 @@ import socket
|
|||||||
import requests
|
import requests
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
JsonAddress = "oXa7t72t3CgnR11ycxVfdupz55eucHufHj"
|
JsonAddresses = ["oXa7t72t3CgnR11ycxVfdupz55eucHufHj","oYcLBQZkgj9taQ5Zj6ziu8eqMREhyAPCcT","oYtGSrrfLvurYLKouZw3E7AyNuM8ZushbC"]
|
||||||
|
|
||||||
def searchDict(dicArr,key,val):
|
def searchDict(dicArr,key,val):
|
||||||
for i in range(len(dicArr)):
|
for i in range(len(dicArr)):
|
||||||
@ -62,7 +62,7 @@ def verifyHash(localHash,txid):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def getJsonData(Dapps, lastTx):
|
def getJsonData(Dapps, lastTx,JsonAddress):
|
||||||
try:
|
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)
|
||||||
@ -90,10 +90,17 @@ def getJsonData(Dapps, lastTx):
|
|||||||
#print(e)
|
#print(e)
|
||||||
continue
|
continue
|
||||||
#print(app)
|
#print(app)
|
||||||
if 'Dapp' in app.keys():
|
try:
|
||||||
Dapps = Dappend(Dapps,app['Dapp'])
|
if 'Dapp' in app.keys():
|
||||||
|
Dapps = Dappend(Dapps,app['Dapp'])
|
||||||
|
except:
|
||||||
|
continue
|
||||||
#print(Dapps)
|
#print(Dapps)
|
||||||
return (Dapps,len(data['last_txs'])-1)
|
{'Dapps':apps ,'lastTx':lastTx}
|
||||||
|
returndata = {}
|
||||||
|
returndata['Dapps'] = Dapps
|
||||||
|
returndata['lastTx'] = len(data['last_txs'])-1
|
||||||
|
return (returndata)
|
||||||
|
|
||||||
class FLOappStore:
|
class FLOappStore:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
@ -184,8 +191,27 @@ class FLOappStore:
|
|||||||
isConnected()
|
isConnected()
|
||||||
self.appWin = Toplevel()
|
self.appWin = Toplevel()
|
||||||
self.appWin.title(app["name"])
|
self.appWin.title(app["name"])
|
||||||
#self.appWin.geometry("500x100")
|
self.appWin.geometry("500x400")
|
||||||
#self.appWin.resizable(0,0)
|
self.appWin.resizable(0,0)
|
||||||
|
|
||||||
|
try:
|
||||||
|
description = app["description"]
|
||||||
|
except:
|
||||||
|
description = '*NIL*'
|
||||||
|
|
||||||
|
Label1 = Label(self.appWin, text="Description")
|
||||||
|
Label1.pack()
|
||||||
|
GTextFrame = Frame(self.appWin)
|
||||||
|
GScroll = Scrollbar(GTextFrame)
|
||||||
|
GScroll.pack(side=RIGHT, fill=Y)
|
||||||
|
self.GLMsg = Text(GTextFrame,height=10,width=50,yscrollcommand=GScroll.set)
|
||||||
|
self.GLMsg.insert(END, description)
|
||||||
|
self.GLMsg.config(state='disabled')
|
||||||
|
self.GLMsg.pack(side = LEFT)
|
||||||
|
GTextFrame.pack()
|
||||||
|
GScroll.config(command=self.GLMsg.yview)
|
||||||
|
|
||||||
|
|
||||||
if(app["type"] == "Gui" or app["type"] == "Cmdline"):
|
if(app["type"] == "Gui" or app["type"] == "Cmdline"):
|
||||||
if(os.path.isdir(app["location"]) and subprocess.Popen("git config --get remote.origin.url",cwd=app["location"],stdout=subprocess.PIPE,shell=True).communicate()[0].decode("utf-8").strip()==app["github"]):
|
if(os.path.isdir(app["location"]) and subprocess.Popen("git config --get remote.origin.url",cwd=app["location"],stdout=subprocess.PIPE,shell=True).communicate()[0].decode("utf-8").strip()==app["github"]):
|
||||||
openButton = Button(self.appWin,text="Open App",command=lambda :self.openApp(app))
|
openButton = Button(self.appWin,text="Open App",command=lambda :self.openApp(app))
|
||||||
@ -238,22 +264,31 @@ class FLOappStore:
|
|||||||
|
|
||||||
def refreshAppData():
|
def refreshAppData():
|
||||||
global apps
|
global apps
|
||||||
|
apps = []
|
||||||
print("Refreshing App Details")
|
print("Refreshing App Details")
|
||||||
try:
|
try:
|
||||||
with open('Apps.json','r') as F:
|
with open('Apps.json','r') as F:
|
||||||
data=json.loads(F.read())
|
data=json.loads(F.read())
|
||||||
apps = data['Dapps']
|
flag = True
|
||||||
lastTx = data['lastTx']
|
|
||||||
except:
|
except:
|
||||||
apps = []
|
flag = False
|
||||||
lastTx = -1
|
data = {}
|
||||||
|
|
||||||
try:
|
|
||||||
(apps,lastTx) = getJsonData(apps,lastTx)
|
for addr in JsonAddresses:
|
||||||
except:
|
try:
|
||||||
sys.exit(1)
|
appdata = data[addr]['Dapps']
|
||||||
|
#print(appdata)
|
||||||
|
lastTx = data[addr]['lastTx']
|
||||||
|
except:
|
||||||
|
appdata = []
|
||||||
|
lastTx = -1
|
||||||
|
data[addr] = getJsonData(appdata,lastTx,addr)
|
||||||
|
#print(data[addr])
|
||||||
|
apps = apps + data[addr]['Dapps']
|
||||||
with open('Apps.json','w+') as F:
|
with open('Apps.json','w+') as F:
|
||||||
data = json.dumps({'Dapps':apps ,'lastTx':lastTx})
|
#print(data)
|
||||||
|
data = json.dumps(data)
|
||||||
F.write(data)
|
F.write(data)
|
||||||
print("Loaded App Details")
|
print("Loaded App Details")
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user