ECToo / pygooglevoice

Automatically exported from code.google.com/p/pygooglevoice
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Message id not a SHA1 hash #67

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have a script that I adopted from 
http://webapps.stackexchange.com/questions/9412/marking-all-google-voice-message
s-as-read

Nearly all of the time, it fails with the error: Message id not a SHA1 hash

Here is the stack trace i receive:

Traceback (most recent call last):
  File "/home/chuck/bin/voice_mark_as_read", line 13, in <module>
    for message in folder.messages:
  File "/usr/local/lib/python2.7/dist-packages/googlevoice/util.py", line 242, in messages
    return [Message(self, *i) for i in self['messages'].items()]
  File "/usr/local/lib/python2.7/dist-packages/googlevoice/util.py", line 181, in __init__
    assert is_sha1(id), 'Message id not a SHA1 hash'

I'm running on Ubuntu 12.04.1 64 bit against a Google Voice account linked to 
Google apps if that makes any difference.

Original issue reported on code.google.com by char...@charliemeyer.net on 12 Sep 2012 at 6:33

GoogleCodeExporter commented 9 years ago
I encountered the same problem. I commented out the following lines of code in 
order to run the script.

util.py line 181
assert is_sha1(msg), 'Message id not a SHA1 hash'

voice.py line 241
assert is_sha1(msg), 'Message id not a SHA1 hash'

Original comment by abrahamn...@gmail.com on 22 Sep 2012 at 7:37

GoogleCodeExporter commented 9 years ago
Honestly, that sounds like a terrible solution.  There has to be another way to 
do this.

Original comment by sugarde...@gmail.com on 15 Dec 2012 at 3:46

GoogleCodeExporter commented 9 years ago
That's the only solution at the moment, as the library doesn't understand that 
the Google API has changed to not *always* provide a valid SHA1 hash. It 
appears to return two *different* forms of hashes; but BOTH of them work just 
fine with the API. As long as the library doesn't check the IDs it's receiving 
from the API, and just passes them directly back into the API, it seems to work 
fine.

Of note, I'm using exactly the same script from Alex Brown on that 
StackExchange site; and it works absolutely fine if you comment out the 
temporarily-broken SHA1 checking.

Original comment by me@ell.io on 3 Jan 2013 at 8:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
/usr/local/lib/python2.7/dist-packages/googlevoice/voice.py:

line 215:        assert is_sha1(msg), 'Message id not a SHA1 hash'

I wrapped the assert statement like so:

        try:
            if not is_sha1(msg):
                raise Exception('Message id not a SHA1 hash')
        except Exception as e:
            print(e)
            pass

I think the culprit here is that the strings for the id's no longer match the 
regex. Perhaps no longer sha1?

sha1_re = re.compile(r'^[a-fA-F0-9]{40}$')
def is_sha1(s):
    """
    Returns ``True`` if the string is a SHA1 hash
    """
    return bool(sha1_re.match(s))

An example id:

XGMJIXPKKXQUYHJOYUGUXZVRWKMTHGXGWUIKLUMT

So perhaps updating the sha1_re to something else would be the right way to fix 
the issue? As mentioned above, but I really have no idea what format this is.

err... relevant:

http://stackoverflow.com/questions/1668619/is-there-a-google-voice-api

Which after some perusing the closest thing that I could find is this?

https://developers.google.com/+/hangouts/api/gapi.hangout.data#gapi.hangout.data
.getKeys

Which ... just a <string>? 

Original comment by James.a....@gmail.com on 12 Feb 2015 at 3:09