Skip to content

Commit

Permalink
Merge pull request #1 from easy-node-pro/menu-testing
Browse files Browse the repository at this point in the history
v1.0.0 Menu testing
  • Loading branch information
patrickmogul authored Dec 10, 2022
2 parents 3588c3e + 758937c commit 68c2276
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 12 deletions.
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
python3 -m build &&
twine upload dist/* --skip-existing
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=42", "wheel"] # PEP 508 specifications.
build-backend = "setuptools.build_meta"
3 changes: 2 additions & 1 deletion requriements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ hexbytes==0.3.0
idna==3.4
parsimonious==0.8.1
pexpect==4.8.0
psutil==5.9.4
ptyprocess==0.7.0
pycryptodome==3.16.0
pyhmy==0.1.0
Expand All @@ -25,4 +26,4 @@ simple-term-menu==1.5.2
six==1.16.0
toolz==0.12.0
urllib3==1.26.13
validatortoolbox==1.7.2
validatortoolbox==1.7.3
25 changes: 25 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[metadata]
name = validatortoolbox-fra
version = 1.0.0
author = EasyNode.PRO
author_email = [email protected]
description = Findora FRA Validator Node Toolbox and Easy Setup
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/easy-node-pro/validatortoolbox-fra
project_urls =
Bug Tracker = https://github.com/easy-node-pro/validatortoolbox-fra/issues
repository = https://github.com/easy-node-pro/validatortoolbox-fra
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
package_dir =
= src
packages = find:
python_requires = >=3.6

[options.packages.find]
where = src
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from setuptools import setup

setup()
10 changes: 8 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
import subprocess
from subprocess import run
from toolbox.library import loaderIntro, printStars, askYesNo
from library import dockerCheck
from toolbox.toolbox import menuError
from library import docker_check, menu_findora, run_findora_menu

# Check the status and print a message

if __name__ == "__main__":
loaderIntro()
printStars()
dockerCheck()
docker_check()
if os.path.exists('/usr/local/bin/fn') is False:
# Run installer ya'll!
print(f'* Welcome to EasyNode.PRO Validator Toolbox for Findora!')
Expand All @@ -33,8 +34,13 @@

# Check the status and print a message
if status == 0:
# Launch menu, we're good to go!
print(f"* The container '{container_name}' is running.")
printStars()
run_findora_menu()

else:
# Container is not running, ruh roh!
print(f"* The container '{container_name}' is not running.")
printStars()

Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def getUrl() -> None:

class validatorToolbox:
easy_version = "1.0.0"
our_disk_mount = '/data/findora'
server_host_name = socket.gethostname()
user_home_dir = os.path.expanduser("~")
dotenv_file = f"{user_home_dir}/.easynode.env"
Expand Down
93 changes: 89 additions & 4 deletions src/library.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import subprocess
import os
import dotenv
import shutil
from os import environ
from colorama import Fore, Back, Style
from subprocess import PIPE, run
from toolbox.library import printStars, return_txt
from toolbox.library import printStars, printStarsReset, return_txt, loadVarFile, disk_partitions, convertedUnit, freeSpaceCheck
from toolbox.toolbox import menuError, menuUbuntuUpdates, menuRebootServer, finish_node
from toolbox.allsysinfo import allSysInfo
from config import validatorToolbox

def dockerCheck():
def docker_check():
status = subprocess.call(["docker"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if status == 0:
print("* Docker is available and working properly.")
Expand All @@ -16,7 +23,7 @@ def dockerCheck():
printStars()
raise SystemExit(0)

def menuFull() -> None:
def menu_findora() -> None:
# menuTopperFull()
for x in return_txt(validatorToolbox.findora_menu):
x = x.strip()
Expand All @@ -25,4 +32,82 @@ def menuFull() -> None:
except SyntaxError:
pass
if x:
print(x)
print(x)

def refresh_stats() -> None:
printStars()
print(f'* Coming soon!')
printStars()
input("* Press ENTER to continue.")

def check_balance_menu() -> None:
printStars()
print(f'* Coming soon!')
printStars()
input("* Press ENTER to continue.")

def operating_system_updates() -> None:
printStars()
print(f'* Coming soon!')
printStars()
input("* Press ENTER to continue.")

def server_disk_check() -> None:
printStarsReset()
print("* Here are all of your mount points: ")
for part in disk_partitions():
print(part)
printStars()
total, used, free = shutil.disk_usage(ourDiskMount)
total = str(convertedUnit(total))
used = str(convertedUnit(used))
print("Disk: " + str(ourDiskMount) + "\n" + freeSpaceCheck(validatorToolbox.our_disk_mount) + " Free\n" + used + " Used\n" + total + " Total")
printStars()
input("* Disk check complete, press ENTER to return to the main menu. ")

def coming_soon() -> None:
printStars()
print(f'* Coming soon!')
printStars()
input("* Press ENTER to continue.")

def menu_topper() -> None:
Load1, Load5, Load15 = os.getloadavg()
# get sign pct
# get balances
# get other validator data
os.system("clear")
printStars()
print(f'{Style.RESET_ALL}* {Fore.GREEN}validator-toolbox for Findora FRA Validators by Easy Node v{validatorToolbox.easy_version}{Style.RESET_ALL} https://easynode.pro *')
printStars()
print(f'* Current disk space free: {Fore.CYAN}{freeSpaceCheck(validatorToolbox.our_disk_mount): >6}{Style.RESET_ALL}\n')
printStars()
print(f"* CPU Load Averages: {round(Load1, 2)} over 1 min, {round(Load5, 2)} over 5 min, {round(Load15, 2)} over 15 min")
printStars()
return


def run_findora_menu() -> None:
menu_options = {
1: refresh_stats,
2: check_balance_menu,
10: coming_soon,
11: coming_soon,
12: coming_soon,
13: server_disk_check,
15: allSysInfo,
999: menuRebootServer,
}
while True:
os.system("clear")
menu_topper()
menu_findora()
try:
option = int(input("* Enter your option: "))
except ValueError:
menuError()
menu_findora()
if option == 0:
return finish_node()
os.system("clear")
menu_options[option]()
12 changes: 7 additions & 5 deletions src/messages/framenu.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
* Easy Node's validatortoolbox Menu Options:
* EasyNode.PRO Findora Validator Toolbox Menu Options:
print("*")
print("* 1 - Refresh Toolbox Info - Use this option to reload to get updated stats above!")
print("* 2 - Show Balance - Check Any Wallet Balance")
print(f"* {Fore.RED}{Back.GREEN}The Danger Zone:{Style.RESET_ALL}")
print("* 12 - Update Operating System - Update hmy binary file")
print("* 1 - Refresh Toolbox Info - Use this option to reload to get updated stats above!")
print("* 2 - Show Balance - Check Any Wallet Balance")
print("* 10 - Update fn Application - Pull update for the wallet application, fn")
print(f"* {Fore.GREEN}{Back.RED}The Danger Zone:{Style.RESET_ALL}")
print("* 11 - Update Findora Container - Pull & Restart the latest container from Findora")
print("* 12 - Update Operating System - Update Ubuntu Operating System Files")
print(f"* {Fore.CYAN}{Back.GREEN}Informational Section:{Style.RESET_ALL}")
print("* 13 - Show system disk info - Current drive space status")
print("* 14 - TMI about your Validator - Seriously too much information")
Expand Down

0 comments on commit 68c2276

Please sign in to comment.