Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -upbr phoenix-1.50/ConsoleLogger.py phoenix-1.50m/ConsoleLogger.py
- --- phoenix-1.50/ConsoleLogger.py 2011-06-14 17:41:40.000000000 -0400
- +++ phoenix-1.50m/ConsoleLogger.py 2011-06-17 12:48:14.643674801 -0400
- @@ -22,6 +22,7 @@
- import sys
- from time import time
- from datetime import datetime
- +from threading import Lock
- def formatNumber(n):
- """Format a positive integer in a more readable fashion."""
- @@ -55,6 +56,8 @@ class ConsoleLogger(object):
- self.accepted = 0
- self.invalid = 0
- self.lineLength = 0
- + self.workCount = 0
- + self.lock = Lock()
- self.connectionType = None
- def reportRate(self, rate, update=True):
- @@ -100,48 +103,30 @@ class ConsoleLogger(object):
- if self.verbose:
- self.log(message)
- + def reportWork(self):
- + self.workCount += 1
- +
- def updateStatus(self, force=False):
- #only update if last update was more than a second ago
- dt = time() - self.lastUpdate
- if force or dt > self.UPDATE_TIME:
- rate = self.rate if (not self.miner.idle) else 0
- type = " [" + str(self.connectionType) + "]" if self.connectionType is not None else ''
- - status = (
- - "[" + formatNumber(rate) + "hash/sec] "
- - "[" + str(self.accepted) + " Accepted] "
- - "[" + str(self.invalid) + " Rejected]" + type)
- - self.say(status)
- + eff = round(float(self.accepted) / float(self.workCount) * 100.00, 2) if self.workCount is not 0 else 0
- + self.say("[%shash/s] [%d ACC] [%d REJ] [%.2f%% EFF]%s", hideTimestamp=True, args=(formatNumber(rate), self.accepted, self.invalid, eff, type))
- self.lastUpdate = time()
- - def say(self, message, newLine=False, hideTimestamp=False):
- - #add new line if requested
- - if newLine:
- - message += '\n'
- - if hideTimestamp:
- - timestamp = ''
- - else:
- - timestamp = datetime.now().strftime(self.TIME_FORMAT) + ' '
- -
- - message = timestamp + message
- -
- - #erase the previous line
- - if self.lineLength > 0:
- - sys.stdout.write('\b \b' * self.lineLength)
- - sys.stdout.write(' ' * self.lineLength)
- - sys.stdout.write('\b \b' * self.lineLength)
- -
- - #print the line
- - sys.stdout.write(message)
- + def say(self, message, newLine=False, hideTimestamp=False, args=()):
- + with self.lock:
- + if (not hideTimestamp):
- + message = '%s %s' % (datetime.now().strftime(self.TIME_FORMAT), message)
- + if (newLine):
- + message = '%s\n' % (message)
- + sys.stdout.write('\r \r' + message % args)
- sys.stdout.flush()
- - #cache the current line length
- - if newLine:
- - self.lineLength = 0
- - else:
- - self.lineLength = len(message)
- -
- def log(self, message, update=True, hideTimestamp=False):
- - self.say(message, True, hideTimestamp)
- + self.say(message, newLine=True, hideTimestamp=hideTimestamp)
- if update:
- self.updateStatus(True)
- \ No newline at end of file
- diff -upbr phoenix-1.50/Miner.py phoenix-1.50m/Miner.py
- --- phoenix-1.50/Miner.py 2011-06-14 17:41:40.000000000 -0400
- +++ phoenix-1.50m/Miner.py 2011-06-15 20:57:27.000000000 -0400
- @@ -59,6 +59,7 @@ class Miner(object):
- self.logger.reportMsg(msg)
- def onWork(self, work):
- self.logger.reportDebug('Server gave new work; passing to WorkQueue')
- + self.logger.reportWork()
- self.queue.storeWork(work)
- def onLongpoll(self, lp):
- self.logger.reportType('RPC' + (' (+LP)' if lp else ''))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement