Really working hashrate monitor now and updated readme.

This commit is contained in:
jwinterm
2014-09-12 09:27:20 -05:00
parent 53ea880a02
commit 91a70fb80d
3 changed files with 111 additions and 31 deletions
+5
View File
@@ -0,0 +1,5 @@
# kivy-cpuminer
This is a GUI wrapper made with kivy for a qubit cpuminer. Rather than enter arguments on the command line, or create a batch file, the user can just open the program and fill the fields.
# How To Use
Just open the program, enter the number of threads to use, the mining pool (and port) you'd like to use, and your myriadcoin wallet address, and then press start mining. The miner should stop if you press stop mining or if you exit the program (if it crashes you may need to ctrl-alt-del and kill the miner process using task manager, but I don't think this should occur). Be aware that this is alpha quality software, so the paranthetical in the previous sentence may not be accurate.
+48 -11
View File
@@ -6,20 +6,21 @@
urlInput: urlInput
userAddress: userAddress
outputLabel: outputLabel
hashrateLabel: hashrateLabel
orientation: 'vertical'
padding: 30,30,30,30
padding: 30, 30, 30, 30
Image:
size_hint: 1,0.5
size_hint: 1, 0.25
source: 'logo_wide.png'
Label:
size_hint: 1,0.25
size_hint: 1, 0.15
text: "Myriadcoin Qubit CPU Miner"
BoxLayout:
size_hint: 1,0.1
size_hint: 1, 0.1
orientation: 'horizontal'
Label:
text: "Threads (max=# of cpu cores, min=1)"
@@ -29,7 +30,7 @@
text: "1"
BoxLayout:
size_hint: 1,0.1
size_hint: 1, 0.1
orientation: 'horizontal'
Label:
text: "Mining pool and port"
@@ -39,7 +40,7 @@
text: "birdspool.no-ip.org:5567"
BoxLayout:
size_hint: 1,0.1
size_hint: 1, 0.1
orientation: 'horizontal'
Label:
text: "Wallet address"
@@ -50,8 +51,8 @@
BoxLayout:
padding: 0,30,0,30
size_hint: 1,0.35
padding: 0, 10, 0, 10
size_hint: 1, 0.2
orientation: 'horizontal'
Button:
text: "Start mining"
@@ -60,6 +61,42 @@
text: "Stop mining"
on_press: root.stop_miner()
Label:
id: outputLabel
size_hint: 1,0.2
BoxLayout:
orientation: 'horizontal'
size_hint: 1, 0.35
BoxLayout:
orientation: 'vertical'
padding: 0, 10, 10, 10
size_hint: 0.75, 1
Label:
text: "Minerd output:"
size_hint: 0.25, 0.2
Label:
id: outputLabel
font_size: 10
size_hint: 1, 0.9
canvas.before:
Color:
rgb: .1, .2, .3
Rectangle:
pos: self.pos
size: self.size
BoxLayout:
orientation: 'vertical'
padding: 0, 10, 0, 10
size_hint: 0.25, 1
Label:
text: "Miner hashrate:"
size_hint: 0.75, 0.2
Label:
id: hashrateLabel
size_hint: 1, 0.9
font_size: 16
canvas.before:
Color:
rgb: .1, .2, .3
Rectangle:
pos: self.pos
size: self.size
+58 -20
View File
@@ -1,19 +1,28 @@
#!/usr/bin/env python
from subprocess import PIPE, Popen
from subprocess import PIPE, Popen, STDOUT
from threading import Thread
from Queue import Queue, Empty
from os import system
from re import sub
import sys
from kivy.app import App
from kivy.properties import ObjectProperty
from kivy.uix.boxlayout import BoxLayout
from kivy.config import Config
from kivy.clock import Clock
from kivy.uix.popup import Popup
from kivy.uix.label import Label
def enqueue_output(out, queue):
for line in iter(out.readline, b''):
queue.put(line)
out.close()
def read_output(process, stdout, queue):
while True:
out = stdout.readline()
if out == '' and process.poll() != None:
break
if out != '':
line = out.rstrip()
queue.put_nowait(line)
sys.stdout.flush()
class RootWidget(BoxLayout):
@@ -22,35 +31,61 @@ class RootWidget(BoxLayout):
urlInput = ObjectProperty()
userAddress = ObjectProperty()
outputLabel = ObjectProperty()
hashrateLabel = ObjectProperty()
p = None
q = Queue()
minerdOutput = ['...', '...', '...', '...', '...']
nThreads = 0
def __init__(self, **kwargs):
super(RootWidget, self).__init__(**kwargs)
def start_miner(self):
self.p = Popen(["QubitCPU32.exe", "-a", "qubit",
"-t", self.threadInput.text, "-o", self.urlInput.text,
"-u", self.userAddress.text, "-p", "x"],
stdout=PIPE,
stdin=PIPE,
bufsize=1)
try:
if int(self.threadInput.text) <= 32:
self.nThreads = float(self.threadInput.text)
self.p = Popen(["QubitCPU32.exe", "-a", "qubit",
"-t", self.threadInput.text, "-o", self.urlInput.text,
"-u", self.userAddress.text, "-p", "x"],
stdout=PIPE,
stderr=STDOUT,
bufsize=1)
t = Thread(target=read_output, args=(self.p, self.p.stdout, self.q))
t.daemon = True # thread dies with the program
t.start()
Clock.schedule_interval(self.read_queue, 0.1)
else:
popup = Popup(title='Too Many Threads Popup',
content=Label(text='Please choose a value <= 32.'),
size_hint=(0.7, 0.7))
popup.open()
except ValueError:
popup = Popup(title='Not An Integer Popup',
content=Label(text='Please enter an integer <= 32.'),
size_hint=(0.7, 0.7))
popup.open()
t = Thread(target=enqueue_output, args=(self.p.stdout, self.q))
t.daemon = True # thread dies with the program
t.start()
Clock.schedule_interval(self.read_queue, 0.1)
def stop_miner(self):
system("taskkill /im QubitCPU32.exe /f")
self.p.kill()
self.outputLabel.text = ''
self.hashrateLabel.text = '0.0 khash/s'
# exit(0)
def read_queue(self, dt):
try:
line = self.q.get_nowait()
print line+line
self.outputLabel.text = line
newLine = self.q.get_nowait()
if 'khash' in newLine:
hashrate = float(sub("[^0123456789\.]","",newLine.split(',')[1]))
self.hashrateLabel.text = str(hashrate*self.nThreads) + " khash/s"
self.minerdOutput.pop(0)
self.minerdOutput.append(newLine)
outputText = ''
for line in self.minerdOutput:
outputText = outputText + line + '\n'
# print outputText
self.outputLabel.text = outputText
except Empty:
pass
@@ -63,4 +98,7 @@ class KivyMiner(App):
if __name__ == '__main__':
Config.set('kivy', 'exit_on_escape', 0)
KivyMiner().run()
system("taskkill /im QubitCPU32.exe /f")
try:
system("taskkill /im QubitCPU32.exe /f")
except:
pass