Compare commits
No commits in common. "aa9222075691fa7d56ec82c49ca1dec676cb51e9" and "2595503dc0dabe15dd97cbb78b99e0b94e87f3b0" have entirely different histories.
aa92220756
...
2595503dc0
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,5 +10,3 @@ ignore/
|
||||
plugins/signatures.json
|
||||
|
||||
.venv/
|
||||
|
||||
user_data/
|
3
main.py
3
main.py
@ -1040,9 +1040,6 @@ def settings():
|
||||
if success == None:
|
||||
success = ""
|
||||
|
||||
if not os.path.exists(".git"):
|
||||
return render_template("settings.html", account=account,sync=account_module.getNodeSync(),
|
||||
error=error,success=success,version="Error")
|
||||
info = gitinfo.get_git_info()
|
||||
branch = info['refs']
|
||||
if branch != "main":
|
||||
|
16
plugin.py
16
plugin.py
@ -5,6 +5,7 @@ import sys
|
||||
import hashlib
|
||||
|
||||
|
||||
|
||||
def listPlugins():
|
||||
plugins = []
|
||||
for file in os.listdir("plugins"):
|
||||
@ -44,7 +45,6 @@ def pluginExists(plugin: str):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def verifyPlugin(plugin: str):
|
||||
signatures = []
|
||||
try:
|
||||
@ -75,6 +75,12 @@ def hashPlugin(plugin: str):
|
||||
return sha256.hexdigest()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def getPluginData(pluginStr: str):
|
||||
plugin = importlib.import_module("plugins."+pluginStr)
|
||||
|
||||
@ -98,12 +104,10 @@ def getPluginData(pluginStr: str):
|
||||
|
||||
return info
|
||||
|
||||
|
||||
def getPluginFunctions(plugin: str):
|
||||
plugin = importlib.import_module("plugins."+plugin)
|
||||
return plugin.functions
|
||||
|
||||
|
||||
def runPluginFunction(plugin: str, function: str, params: dict, authentication: str):
|
||||
plugin_module = importlib.import_module("plugins."+plugin)
|
||||
if function not in plugin_module.functions:
|
||||
@ -130,6 +134,7 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
|
||||
if pluginHash not in signatures:
|
||||
return {"error": "Plugin not verified"}
|
||||
|
||||
|
||||
# Call the function with provided parameters
|
||||
try:
|
||||
result = plugin_function(params, authentication)
|
||||
@ -139,17 +144,14 @@ def runPluginFunction(plugin: str, function: str, params: dict, authentication:
|
||||
return {"error": str(e)}
|
||||
# return plugin.runFunction(function, params, authentication)
|
||||
|
||||
|
||||
def getPluginFunctionInputs(plugin: str, function: str):
|
||||
plugin = importlib.import_module("plugins."+plugin)
|
||||
return plugin.functions[function]["params"]
|
||||
|
||||
|
||||
def getPluginFunctionReturns(plugin: str, function: str):
|
||||
plugin = importlib.import_module("plugins."+plugin)
|
||||
return plugin.functions[function]["returns"]
|
||||
|
||||
|
||||
def getDomainFunctions():
|
||||
plugins = listPlugins()
|
||||
domainFunctions = []
|
||||
@ -164,7 +166,6 @@ def getDomainFunctions():
|
||||
})
|
||||
return domainFunctions
|
||||
|
||||
|
||||
def getSearchFunctions():
|
||||
plugins = listPlugins()
|
||||
searchFunctions = []
|
||||
@ -179,7 +180,6 @@ def getSearchFunctions():
|
||||
})
|
||||
return searchFunctions
|
||||
|
||||
|
||||
def getDashboardFunctions():
|
||||
plugins = listPlugins()
|
||||
dashboardFunctions = []
|
||||
|
@ -34,45 +34,6 @@ functions = {
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"disable":{
|
||||
"name": "Disable Automations",
|
||||
"type": "default",
|
||||
"description": "Disable Automations for this wallet",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"Status":
|
||||
{
|
||||
"name": "Status",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"enable":{
|
||||
"name": "Enable Automations",
|
||||
"type": "default",
|
||||
"description": "Enable Automations for this wallet",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"Status":
|
||||
{
|
||||
"name": "Status",
|
||||
"type": "text"
|
||||
}
|
||||
}
|
||||
},
|
||||
"list":{
|
||||
"name": "List Disabled Wallets",
|
||||
"type": "default",
|
||||
"description": "List wallets with automations disabled",
|
||||
"params": {},
|
||||
"returns": {
|
||||
"wallets":
|
||||
{
|
||||
"name": "List of wallets",
|
||||
"type": "list"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,43 +43,16 @@ started = False
|
||||
def automation(params, authentication):
|
||||
global started
|
||||
|
||||
wallet = authentication.split(":")[0]
|
||||
if os.path.exists(f"user_data/{wallet}.autoRenew"):
|
||||
return {"Status": "Automations disabled"}
|
||||
|
||||
if started:
|
||||
return {"Status": "Automations running"}
|
||||
return {"Status": "Auto Renews running"}
|
||||
started = True
|
||||
|
||||
threading.Thread(target=automations_background, args=(authentication,)).start()
|
||||
return {"Status": "Starting Automations..."}
|
||||
|
||||
def disable(params, authentication):
|
||||
# Create walletname file in user_data
|
||||
wallet = authentication.split(":")[0]
|
||||
with open(f"user_data/{wallet}.autoRenew", "w") as f:
|
||||
f.write(f"This file is used to disable automations for '{wallet}' wallet.\nDelete this file to enable automations.")
|
||||
return {"Status": "Disabled Automations"}
|
||||
|
||||
def enable(params, authentication):
|
||||
# Delete walletname file in user_data
|
||||
wallet = authentication.split(":")[0]
|
||||
if os.path.exists(f"user_data/{wallet}.autoRenew"):
|
||||
os.remove(f"user_data/{wallet}.autoRenew")
|
||||
|
||||
return {"Status": "Enabled Automations"}
|
||||
|
||||
def list(params, authentication):
|
||||
wallets = []
|
||||
for file in os.listdir("user_data"):
|
||||
if file.endswith(".autoRenew"):
|
||||
wallets.append(file[:-10])
|
||||
return {"wallets": wallets}
|
||||
return {"Status": "Started Auto Renews"}
|
||||
|
||||
# Background function to run the automations
|
||||
def automations_background(authentication):
|
||||
|
||||
while True:
|
||||
print("Running automations")
|
||||
# Get account details
|
||||
account_name = account.check_account(authentication)
|
||||
password = ":".join(authentication.split(":")[1:])
|
||||
@ -130,17 +64,12 @@ def automations_background(authentication):
|
||||
}
|
||||
}
|
||||
|
||||
if os.path.exists(f"user_data/{account_name}.autoRenew"):
|
||||
print("Skipping Automations")
|
||||
time.sleep(300)
|
||||
continue
|
||||
print("Running automations")
|
||||
try:
|
||||
# Try to select and login to the wallet
|
||||
response = account.hsw.rpc_selectWallet(account_name)
|
||||
if response['error'] is not None:
|
||||
return
|
||||
response = account.hsw.rpc_walletPassphrase(password,30)
|
||||
response = account.hsw.rpc_walletPassphrase(password,10)
|
||||
if response['error'] is not None:
|
||||
return
|
||||
# Try to send the batch of all renew, reveal and redeem actions
|
||||
|
Loading…
Reference in New Issue
Block a user