14
14
from bittensor_wallet import Wallet
15
15
from bittensor_cli .src import defaults
16
16
17
- root_symbol_html = f"&#x{ ord ('τ' ):X} ;"
18
17
19
-
20
- env = Environment (loader = PackageLoader ("bittensor" ), autoescape = select_autoescape ())
18
+ ROOT_SYMBOL_HTML = f"&#x{ ord ('τ' ):X} ;"
19
+ env = Environment (
20
+ loader = PackageLoader ("bittensor_cli" , "src/bittensor/templates" ),
21
+ autoescape = select_autoescape (),
22
+ )
21
23
22
24
23
25
async def display_network_dashboard (
@@ -41,30 +43,15 @@ async def display_network_dashboard(
41
43
42
44
if use_wry :
43
45
console .print (
44
- "[dark_sea_green3]Opening dashboard in a window. Press Ctrl+C to close.[/dark_sea_green3]"
45
- )
46
- window = PyWry ()
47
- window .send_html (
48
- html = html_content ,
49
- title = "Bittensor View" ,
50
- width = 1200 ,
51
- height = 800 ,
46
+ "[dark_sea_green3]Opening dashboard in a window.[/dark_sea_green3]"
52
47
)
53
- window .start ()
54
- await asyncio .sleep (10 )
55
- try :
56
- while True :
57
- if _has_exited (window ):
58
- break
59
- await asyncio .sleep (1 )
60
- except KeyboardInterrupt :
61
- console .print ("\n [yellow]Closing Bittensor View...[/yellow]" )
62
- finally :
63
- if not _has_exited (window ):
64
- try :
65
- window .close ()
66
- except Exception :
67
- pass
48
+ with tempfile .NamedTemporaryFile (
49
+ "w" , delete = False , suffix = ".html"
50
+ ) as dashboard_file :
51
+ url = f"file://{ dashboard_file .name } "
52
+ dashboard_file .write (html_content )
53
+
54
+ webbrowser .open (url , new = 1 )
68
55
else :
69
56
if save_file :
70
57
dir_path = os .path .expanduser (dashboard_path )
@@ -365,9 +352,10 @@ def generate_full_page(data: dict[str, Any]) -> str:
365
352
template = env .get_template ("view.j2" )
366
353
367
354
return template .render (
368
- root_symbol_html = root_symbol_html ,
355
+ root_symbol_html = ROOT_SYMBOL_HTML ,
369
356
block_number = block_number ,
370
357
truncated_coldkey = truncated_coldkey ,
371
358
slippage_percentage = slippage_percentage ,
359
+ wallet_info = wallet_info ,
372
360
subnets = data ["subnets" ],
373
361
)
0 commit comments