当我的程序尝试登录 GoogleVoice ( from googlevoice import Voice, util
) 以发送 SMS 消息时,我收到以下错误回溯。
File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\MainFrame.py", line 38, in call_mainframe
ah.compare_status() # compares current status with historical status. alerts alarm team if necessary
File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\alarm_handler.py", line 61, in compare_status
self.megaphone = megaphone.MegaPhone() # Am I going to have problems putting this here? I am getting relentless login fails due to the shitty googlevoice login
File "C:\Users\ble1usb\Dropbox\Git\ers-dataanalyzzer\megaphone.py", line 18, in __init__
self.voice.login(bl_google_credentials[0], bl_google_credentials[1])
File "C:\Python27\lib\site-packages\googlevoice\voice.py", line 70, in login
galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
我的程序在过去几周内一直成功运行。每隔一段时间,就会抛出上述错误,错误处理会再次尝试。现在,它在数百次尝试中都没有成功登录。
我认为可能很重要的一个问题是,无论是否发送 SMS,程序每十 (10) 分钟登录一次(在极少数情况下,最多每隔几天)。
在上面的回溯中,您可以看到我仅在需要时才将执行 GoogleVoice 登录的函数调用移至循环内。它仍然有问题,因为需要发出警报通知。
我尝试登录和退出我的 Google 帐户,但无济于事。
这是一条线索——>以下代码是从回溯的最后一行标识的文件中复制出来的(错误来源):
def login(self, email=None, passwd=None):
"""
Login to the service using your Google Voice account
Credentials will be prompted for if not given as args or in the ``~/.gvoice`` config file
"""
if hasattr(self, '_special') and getattr(self, '_special'):
return self
if email is None:
email = config.email
if email is None:
email = input('Email address: ')
if passwd is None:
passwd = config.password
if passwd is None:
from getpass import getpass
passwd = getpass()
content = self.__do_page('login').read()
# holy hackjob
galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
self.__do_page('login', {'Email': email, 'Passwd': passwd, 'GALX': galx})
del email, passwd
try:
assert self.special
except (AssertionError, AttributeError):
raise LoginError
return self
我们应该注意到
galx = re.search(r"name=\"GALX\"\s+value=\"(.+)\"", content).group(1)
是错误的来源,并且(这很重要)它上面的行说
# holy hackjob