switched cfg_util over to new version
This commit is contained in:
48
README.md
48
README.md
@@ -48,7 +48,7 @@ A basic script to find all miners on the network and get the hashrate from them
|
||||
```python
|
||||
import asyncio
|
||||
from network import MinerNetwork
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_hashrate():
|
||||
@@ -84,7 +84,7 @@ You can also create your own miner without scanning if you know the IP:
|
||||
import asyncio
|
||||
import ipaddress
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_hashrate(ip: str):
|
||||
@@ -103,7 +103,8 @@ async def get_miner_hashrate(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_hashrate(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
<br>
|
||||
@@ -112,7 +113,7 @@ Or generate a miner directly without the factory:
|
||||
```python
|
||||
import asyncio
|
||||
from miners.bosminer import BOSMiner
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_hashrate(ip: str):
|
||||
@@ -127,7 +128,8 @@ async def get_miner_hashrate(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_hashrate(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
<br>
|
||||
@@ -136,7 +138,7 @@ Or finally, just get the API directly:
|
||||
```python
|
||||
import asyncio
|
||||
from API.bosminer import BOSMinerAPI
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_hashrate(ip: str):
|
||||
@@ -152,7 +154,8 @@ async def get_miner_hashrate(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_hashrate(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
|
||||
@@ -165,7 +168,7 @@ Now that you know that, lets move on to some common API functions that you might
|
||||
import asyncio
|
||||
import ipaddress
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_pool_data(ip: str):
|
||||
@@ -189,7 +192,8 @@ async def get_miner_pool_data(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_pool_data(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_pool_data(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
* Getting temperature data:
|
||||
@@ -204,7 +208,7 @@ A pretty good example of really trying to make this robust is in ```cfg_util.fun
|
||||
import asyncio
|
||||
import ipaddress
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_temperature_data(ip: str):
|
||||
@@ -223,7 +227,8 @@ async def get_miner_temperature_data(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_temperature_data(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_temperature_data(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
* Getting power data:
|
||||
@@ -234,7 +239,7 @@ How about data on the power usage of the miner? This one only works for Whatsmi
|
||||
import asyncio
|
||||
import ipaddress
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_power_data(ip: str):
|
||||
@@ -249,7 +254,8 @@ async def get_miner_power_data(ip: str):
|
||||
# send the command
|
||||
tunerstatus = await miner.api.tunerstatus()
|
||||
# parse the return
|
||||
data = await safe_parse_api_data(tunerstatus, 'TUNERSTATUS', 0, "PowerLimit")
|
||||
data = await safe_parse_api_data(tunerstatus, 'TUNERSTATUS', 0,
|
||||
"PowerLimit")
|
||||
else:
|
||||
# send the command
|
||||
# whatsminers have the power info in summary
|
||||
@@ -261,7 +267,8 @@ async def get_miner_power_data(ip: str):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_power_data(str("192.168.1.69")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_power_data(str("192.168.1.69")))
|
||||
```
|
||||
|
||||
* Multicommands:
|
||||
@@ -273,7 +280,7 @@ How about we get the current pool user and hashrate in 1 command?
|
||||
import asyncio
|
||||
import ipaddress
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.func.parse_data import safe_parse_api_data
|
||||
|
||||
|
||||
async def get_miner_hashrate_and_pool(ip: str):
|
||||
@@ -286,15 +293,16 @@ async def get_miner_hashrate_and_pool(ip: str):
|
||||
# Get the API data
|
||||
api_data = await miner.api.multicommand("pools", "summary")
|
||||
if "pools" in api_data.keys():
|
||||
user = await safe_parse_api_data(api_data, "pools", 0, "POOLS", 0, "User")
|
||||
user = await safe_parse_api_data(api_data, "pools", 0, "POOLS", 0,
|
||||
"User")
|
||||
print(user)
|
||||
if "summary" in api_data.keys():
|
||||
hashrate = await safe_parse_api_data(api_data, "summary", 0, "SUMMARY", 0, "MHS av")
|
||||
hashrate = await safe_parse_api_data(api_data, "summary", 0, "SUMMARY",
|
||||
0, "MHS av")
|
||||
print(hashrate)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.new_event_loop().run_until_complete(get_miner_hashrate_and_pool(str("192.168.1.9")))
|
||||
asyncio.new_event_loop().run_until_complete(
|
||||
get_miner_hashrate_and_pool(str("192.168.1.9")))
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -1 +1,10 @@
|
||||
from tools.cfg_util.cfg_util_sg import main
|
||||
from .ui import ui
|
||||
import asyncio
|
||||
|
||||
|
||||
def main():
|
||||
asyncio.run(ui())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.cfg_util_qt.layout import window
|
||||
from tools.cfg_util.cfg_util_qt.tables import TableManager
|
||||
from tools.cfg_util.cfg_util_qt.decorators import disable_buttons
|
||||
from tools.cfg_util.layout import window
|
||||
from tools.cfg_util.tables import TableManager
|
||||
from tools.cfg_util.decorators import disable_buttons
|
||||
|
||||
|
||||
@disable_buttons("Flashing Lights")
|
||||
@@ -1,12 +1,12 @@
|
||||
import PySimpleGUI as sg
|
||||
from config.bos import bos_config_convert
|
||||
import time
|
||||
from tools.cfg_util.cfg_util_qt.layout import window, update_prog_bar
|
||||
from tools.cfg_util.cfg_util_qt.decorators import disable_buttons
|
||||
from tools.cfg_util.layout import window, update_prog_bar
|
||||
from tools.cfg_util.decorators import disable_buttons
|
||||
from miners.miner_factory import MinerFactory
|
||||
import asyncio
|
||||
from settings import CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS
|
||||
from tools.cfg_util.cfg_util_qt.general import update_miners_data
|
||||
from tools.cfg_util.general import update_miners_data
|
||||
|
||||
|
||||
progress_bar_len = 0
|
||||
@@ -1,5 +1,5 @@
|
||||
from tools.cfg_util.cfg_util_qt.layout import window
|
||||
from tools.cfg_util.cfg_util_qt.layout import BUTTON_KEYS
|
||||
from tools.cfg_util.layout import window
|
||||
from tools.cfg_util.layout import BUTTON_KEYS
|
||||
|
||||
|
||||
def disable_buttons(status: str = ""):
|
||||
@@ -2,10 +2,10 @@ import asyncio
|
||||
import webbrowser
|
||||
|
||||
from miners.miner_factory import MinerFactory
|
||||
from tools.cfg_util.cfg_util_qt.decorators import disable_buttons
|
||||
from tools.cfg_util.cfg_util_qt.layout import TABLE_KEYS
|
||||
from tools.cfg_util.cfg_util_qt.layout import window, update_prog_bar
|
||||
from tools.cfg_util.cfg_util_qt.tables import TableManager
|
||||
from tools.cfg_util.decorators import disable_buttons
|
||||
from tools.cfg_util.layout import TABLE_KEYS
|
||||
from tools.cfg_util.layout import window, update_prog_bar
|
||||
from tools.cfg_util.tables import TableManager
|
||||
|
||||
progress_bar_len = 0
|
||||
|
||||
@@ -2,6 +2,8 @@ import PySimpleGUI as sg
|
||||
|
||||
from .imgs import WINDOW_ICON
|
||||
|
||||
sg.set_options(font=("Liberation Mono", 10))
|
||||
|
||||
TABLE_HEADERS = {
|
||||
"SCAN": [
|
||||
"IP",
|
||||
@@ -2,9 +2,9 @@ import asyncio
|
||||
|
||||
from miners.miner_factory import MinerFactory
|
||||
from network import MinerNetwork
|
||||
from tools.cfg_util.cfg_util_qt.decorators import disable_buttons
|
||||
from tools.cfg_util.cfg_util_qt.layout import window, update_prog_bar
|
||||
from tools.cfg_util.cfg_util_qt.tables import clear_tables, TableManager
|
||||
from tools.cfg_util.decorators import disable_buttons
|
||||
from tools.cfg_util.layout import window, update_prog_bar
|
||||
from tools.cfg_util.tables import clear_tables, TableManager
|
||||
|
||||
progress_bar_len = 0
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
from tools.cfg_util.cfg_util_qt.layout import (
|
||||
from tools.cfg_util.layout import (
|
||||
MINER_COUNT_BUTTONS,
|
||||
TABLE_KEYS,
|
||||
TABLE_HEADERS,
|
||||
window,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_qt.imgs import TkImages, LIGHT, FAULT_LIGHT
|
||||
from tools.cfg_util.imgs import TkImages, LIGHT, FAULT_LIGHT
|
||||
import PySimpleGUI as sg
|
||||
import ipaddress
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def update_miner_count(count):
|
||||
@@ -1,28 +1,26 @@
|
||||
import PySimpleGUI as sg
|
||||
import asyncio
|
||||
import sys
|
||||
from tools.cfg_util.cfg_util_qt.imgs import FAULT_LIGHT, TkImages
|
||||
from tools.cfg_util.cfg_util_qt.scan import btn_scan
|
||||
from tools.cfg_util.cfg_util_qt.commands import (
|
||||
from tools.cfg_util.imgs import TkImages
|
||||
from tools.cfg_util.scan import btn_scan
|
||||
from tools.cfg_util.commands import (
|
||||
btn_light,
|
||||
btn_reboot,
|
||||
btn_backend,
|
||||
btn_command,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_qt.configure import (
|
||||
from tools.cfg_util.configure import (
|
||||
generate_config_ui,
|
||||
btn_import,
|
||||
btn_config,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_qt.layout import window
|
||||
from tools.cfg_util.cfg_util_qt.general import btn_all, btn_web, btn_refresh
|
||||
from tools.cfg_util.cfg_util_qt.tables import TableManager
|
||||
from tools.cfg_util.layout import window
|
||||
from tools.cfg_util.general import btn_all, btn_web, btn_refresh
|
||||
from tools.cfg_util.tables import TableManager
|
||||
import tkinter as tk
|
||||
|
||||
sg.set_options(font=("Liberation Mono", 10))
|
||||
|
||||
|
||||
async def main():
|
||||
async def ui():
|
||||
window.read(0)
|
||||
|
||||
# create images used in the table, they will not show if not saved here
|
||||
@@ -121,4 +119,4 @@ async def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
asyncio.run(ui())
|
||||
1
tools/cfg_util_old/__init__.py
Normal file
1
tools/cfg_util_old/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from tools.cfg_util_old.cfg_util_sg import main
|
||||
@@ -2,7 +2,7 @@ import asyncio
|
||||
import sys
|
||||
import logging
|
||||
|
||||
from tools.cfg_util.cfg_util_sg.ui import ui
|
||||
from tools.cfg_util_old.cfg_util_sg.ui import ui
|
||||
|
||||
|
||||
# initialize logger and get settings
|
||||
@@ -1,4 +1,4 @@
|
||||
from tools.cfg_util.cfg_util_sg.layout import window
|
||||
from tools.cfg_util_old.cfg_util_sg.layout import window
|
||||
|
||||
|
||||
def disable_buttons(func):
|
||||
@@ -6,8 +6,8 @@ import time
|
||||
import aiofiles
|
||||
import toml
|
||||
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import update_ui_with_data
|
||||
from tools.cfg_util.cfg_util_sg.layout import window
|
||||
from tools.cfg_util_old.cfg_util_sg.func.ui import update_ui_with_data
|
||||
from tools.cfg_util_old.cfg_util_sg.layout import window
|
||||
from config.bos import bos_config_convert, general_config_convert_bos
|
||||
|
||||
|
||||
@@ -5,16 +5,16 @@ import warnings
|
||||
import logging
|
||||
|
||||
from API import APIError
|
||||
from tools.cfg_util.cfg_util_sg.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import (
|
||||
from tools.cfg_util_old.cfg_util_sg.func.parse_data import safe_parse_api_data
|
||||
from tools.cfg_util_old.cfg_util_sg.func.ui import (
|
||||
update_ui_with_data,
|
||||
update_prog_bar,
|
||||
set_progress_bar_len,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_sg.layout import window
|
||||
from tools.cfg_util_old.cfg_util_sg.layout import window
|
||||
from miners.miner_factory import MinerFactory
|
||||
from config.bos import bos_config_convert
|
||||
from tools.cfg_util.cfg_util_sg.func.decorators import disable_buttons
|
||||
from tools.cfg_util_old.cfg_util_sg.func.decorators import disable_buttons
|
||||
from settings import (
|
||||
CFG_UTIL_CONFIG_THREADS as CONFIG_THREADS,
|
||||
CFG_UTIL_REBOOT_THREADS as REBOOT_THREADS,
|
||||
@@ -1,7 +1,7 @@
|
||||
import ipaddress
|
||||
import re
|
||||
|
||||
from tools.cfg_util.cfg_util_sg.layout import window
|
||||
from tools.cfg_util_old.cfg_util_sg.layout import window
|
||||
|
||||
import pyperclip
|
||||
|
||||
@@ -3,12 +3,12 @@ import sys
|
||||
import PySimpleGUI as sg
|
||||
import tkinter as tk
|
||||
|
||||
from tools.cfg_util.cfg_util_sg.layout import (
|
||||
from tools.cfg_util_old.cfg_util_sg.layout import (
|
||||
window,
|
||||
generate_config_layout,
|
||||
send_ssh_cmd_layout,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_sg.func.miners import (
|
||||
from tools.cfg_util_old.cfg_util_sg.func.miners import (
|
||||
send_config,
|
||||
miner_light,
|
||||
refresh_data,
|
||||
@@ -19,15 +19,15 @@ from tools.cfg_util.cfg_util_sg.func.miners import (
|
||||
reboot_miners,
|
||||
send_miners_ssh_commands,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_sg.func.files import (
|
||||
from tools.cfg_util_old.cfg_util_sg.func.files import (
|
||||
import_iplist,
|
||||
import_config_file,
|
||||
export_iplist,
|
||||
export_config_file,
|
||||
export_csv,
|
||||
)
|
||||
from tools.cfg_util.cfg_util_sg.func.decorators import disable_buttons
|
||||
from tools.cfg_util.cfg_util_sg.func.ui import (
|
||||
from tools.cfg_util_old.cfg_util_sg.func.decorators import disable_buttons
|
||||
from tools.cfg_util_old.cfg_util_sg.func.ui import (
|
||||
sort_data,
|
||||
copy_from_table,
|
||||
table_select_all,
|
||||
Reference in New Issue
Block a user