added a new window to generate configs
This commit is contained in:
@@ -36,6 +36,7 @@ async def update_prog_bar(amount):
|
||||
async def set_progress_bar_len(amount):
|
||||
window["progress"].Update(0, max=amount)
|
||||
window["progress"].maxlen = amount
|
||||
window["progress_percent"].Update("0.0 %")
|
||||
|
||||
|
||||
async def scan_network(network):
|
||||
@@ -240,21 +241,38 @@ async def get_formatted_data(ip: ipaddress.ip_address):
|
||||
return {'TH/s': th5s, 'IP': str(miner.ip), 'host': host, 'user': user, 'wattage': wattage}
|
||||
|
||||
|
||||
async def generate_config():
|
||||
async def generate_config(username, workername, v2_allowed):
|
||||
if username and workername:
|
||||
user = f"{username}.{workername}"
|
||||
elif username and not workername:
|
||||
user = username
|
||||
else:
|
||||
return
|
||||
|
||||
if v2_allowed:
|
||||
url_1 = 'stratum2+tcp://v2.us-east.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt'
|
||||
url_2 = 'stratum2+tcp://v2.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt'
|
||||
url_3 = 'stratum+tcp://stratum.slushpool.com:3333'
|
||||
else:
|
||||
url_1 = 'stratum+tcp://ca.stratum.slushpool.com:3333'
|
||||
url_2 = 'stratum+tcp://us-east.stratum.slushpool.com:3333'
|
||||
url_3 = 'stratum+tcp://stratum.slushpool.com:3333'
|
||||
|
||||
|
||||
config = {'group': [{
|
||||
'name': 'group',
|
||||
'quota': 1,
|
||||
'pool': [{
|
||||
'url': 'stratum2+tcp://us-east.stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt',
|
||||
'user': 'UpstreamDataInc.test',
|
||||
'url': url_1,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}, {
|
||||
'url': 'stratum2+tcp://stratum.slushpool.com/u95GEReVMjK6k5YqiSFNqqTnKU4ypU2Wm8awa6tmbmDmk1bWt',
|
||||
'user': 'UpstreamDataInc.test',
|
||||
'url': url_2,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}, {
|
||||
'url': 'stratum+tcp://stratum.slushpool.com:3333',
|
||||
'user': 'UpstreamDataInc.test',
|
||||
'url': url_3,
|
||||
'user': user,
|
||||
'password': '123'
|
||||
}]
|
||||
}],
|
||||
|
||||
@@ -31,5 +31,15 @@ layout = [
|
||||
])
|
||||
],
|
||||
]
|
||||
def generate_config_layout():
|
||||
generate_config_layout = [
|
||||
[sg.Text("Enter your pool username and password below to generate a config for SlushPool.")],
|
||||
[sg.Text("")],
|
||||
[sg.Text('Username:', size=(19, 1)), sg.InputText(key='generate_config_window_username', do_not_clear=True, size=(45, 1))],
|
||||
[sg.Text('Worker Name (OPT):', size=(19, 1)), sg.InputText(key='generate_config_window_workername', do_not_clear=True, size=(45, 1))],
|
||||
[sg.Text('Allow Stratum V2?:', size=(19, 1)), sg.Checkbox('', key='generate_config_window_allow_v2', default=True)],
|
||||
[sg.Button("Generate", key="generate_config_window_generate")]
|
||||
]
|
||||
return generate_config_layout
|
||||
|
||||
window = sg.Window('Upstream Config Util', layout, icon=icon_of_window)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import asyncio
|
||||
import sys
|
||||
import PySimpleGUI as sg
|
||||
|
||||
from cfg_util.layout import window
|
||||
from cfg_util.layout import window, generate_config_layout
|
||||
from cfg_util.func import scan_network, sort_data, send_config, miner_light, get_data, export_config_file, \
|
||||
generate_config, import_config, import_iplist, import_config_file, export_iplist
|
||||
|
||||
@@ -11,7 +12,7 @@ from network import MinerNetwork
|
||||
async def ui():
|
||||
while True:
|
||||
event, value = window.read(timeout=10)
|
||||
if event in (None, 'Close'):
|
||||
if event in (None, 'Close', sg.WIN_CLOSED):
|
||||
sys.exit()
|
||||
if event == 'scan':
|
||||
if len(value['miner_network'].split("/")) > 1:
|
||||
@@ -43,7 +44,7 @@ async def ui():
|
||||
if event == "get_data":
|
||||
asyncio.create_task(get_data(value['ip_list']))
|
||||
if event == "generate_config":
|
||||
asyncio.create_task(generate_config())
|
||||
await generate_config_ui()
|
||||
if event == "sort_data_ip":
|
||||
asyncio.create_task(sort_data('ip'))
|
||||
if event == "sort_data_hr":
|
||||
@@ -54,3 +55,17 @@ async def ui():
|
||||
asyncio.create_task(sort_data('wattage'))
|
||||
if event == "__TIMEOUT__":
|
||||
await asyncio.sleep(0)
|
||||
|
||||
|
||||
async def generate_config_ui():
|
||||
generate_config_window = sg.Window("Generate Config", generate_config_layout(), modal=True)
|
||||
while True:
|
||||
event, values = generate_config_window.read()
|
||||
if event in (None, 'Close', sg.WIN_CLOSED):
|
||||
break
|
||||
if event == "generate_config_window_generate":
|
||||
if values['generate_config_window_username']:
|
||||
await generate_config(values['generate_config_window_username'], values['generate_config_window_workername'], values['generate_config_window_allow_v2'])
|
||||
generate_config_window.close()
|
||||
break
|
||||
|
||||
|
||||
Reference in New Issue
Block a user