I can't seem to figure out where the problem is,
error:
Traceback (most recent call last):
File "./miningScreensaver", line 171, in <module>
miningScreensaver().loop.run()
File "./miningScreensaver", line 81, in __init__
self.rxAddress = self.getRxAddress
AttributeError: miningScreensaver instance has no attribute 'getRxAddress'
code:
#! Python
class miningScreensaver:
def __init__(self):
DBusGMainLoop(set_as_default=True)
self.mem='ActiveChanged'
self.dest='org.gnome.ScreenSaver'
self.bus=SessionBus()
self.loop=MainLoop()
self.bus.add_signal_receiver(self.catch,self.mem,self.dest)
self.pipe = ""
#if you would like to specify a different rx address
# change rxAddress to the desired rx address
self.rxAddress = self.getRxAddress() #<--------------------ERROR HERE line 81
#self.rxaddress = "18X3TEigc6PVTsF9Atx5br7rEXfuZRqXEz"
def catch(self,ssOn):
if ssOn == 1: #Screensaver turned on
self.start()
else: #Screensaver turned off
self.stop()
def start(self):
self.pipe = Popen(["cgminer -o stratum+tcp://stratum.mining.eligius.st:3334 -u " + self.rxAddress + " -p x -I 9"], shell=True)
def stop(self):
self.pipe.kill()
def getRxAddress(self):
#check if bitcoin.conf exists
cmd = "ls $HOME/.bitcoin/bitcoin.conf"
pipe = Popen(cmd,stdout=PIPE,stderr=STDOUT)
pout = pipe.stdout.read()
pout = pout.split()
if pout[len(pout)-5]=='No' and \
pout[len(pout)-4]=='such' and \
pout[len(pout)-3]=='file' and \
pout[len(pout)-2]=='or' and \
pout[len(pout)-1]=='directory\n':
password = self.createBitConf()
else:
#check password
password = self.checkPassword()
#Launch bitcoin-qt -server
Popen(["bitcoin-qt","-server"])
#Access
access = ServiceProxy("http://darkPenguin:"+password+"@127.0.0.1:8332")
#access.getinfo()
return access.listreceivedbyaddress(0)
#access.sendtoaddress("12yBwyDJHABCvohdT8qBTeMJEYDqpXnVYV", 0.01)
def createBitConf(self):
randomPW = self.createRandomPW()
path = expanduser("~") + "/"
defFile = open("bitosbitcoinconf", "r")
newFile = open(path + ".bitcoin/bitcoin.conf","w")
for line in range(1,55):
newFile.write(defFile.readline())
password = "rpcpassword="+randomPW+"\n"
for line in range(56,110):
newFile.write(defFile.readline())
defFile.close()
newFile.close()
return randomPW
def createRandomPW(self):
myrg = random.SystemRandom()
length = 44
alphabet = string.ascii_letters + string.digits
pw = str().join(myrg.choice(alphabet) for _ in range(length))
return pw
def checkPassword(self):
path = expanduser("~") + "/"
bitConfFile = open(path + ".bitcoin/bitcoin.conf","r")
password = bitConfFile.readline(56)
bitConfFile.close()
return password[12:12+44-1] # "rpcpassword="+randomPW+"\n"
miningScreensaver().loop.run()
This is driving me batty, both the method call and method are spelled exactly the same and solutions to other peoples problems have been no help.
You have mixed tabs and spaces. Set your editor to show whitespace, and you'll see the problem. Running python with the -tt
option can help.