#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Atlantic City, NJ
    Posts
    327
    Rep Power
    13

    Anybody Tried libgmail?


    Code:
    #!/usr/bin/env python
    
    import libgmail
    
    ga = libgmail.GmailAccount('myname@gmail.com', 'mypassword')
    ga.login()
    folder = ga.getMessagesByFolder('inbox')
    At the final line it borks in the python interpreter spitting out all sorts of text and ending with KeyError: 'v'.

    Is libgmail broken? I noticed on the official site that it suggests using the latest CVS version and that the current version may not work at all.

    Any experience with libgmail?
    I'll learn this stuff someday.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    155
    That's very interesting. No clue why it does that. Did you try searching around in google?
    Although I don't know how to fix the problem, I found some information:
    Code:
    The following code logs into an account, retrieves a list of threads, displays information about them and displays the source of the individual messages.
    
    import libgmail
    
    ga = libgmail.GmailAccount("google@gmail.com", "mymailismypass")
    ga.login()
    folder = ga.getMessagesByFolder('inbox')
    
    for thread in folder:
      print thread.id, len(thread), thread.subject
      for msg in thread:
        print "  ", msg.id, msg.number, msg.subject
        print msg.source
    Also: The following error is what I received, is that the same thing you got?
    Code:
    Traceback (most recent call last):
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript
        debugger.run(codeObject, __main__.__dict__, start_stepping=0)
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
        _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 592, in run
        exec cmd in globals, locals
      File "C:\Documents and Settings\Master\Desktop\Script1.py", line 7, in ?
        folder = ga.getMessagesByFolder('inbox')
      File "C:\Python23\lib\libgmail.py", line 390, in getMessagesByFolder
        return self._parseThreadSearch(folderName, allPages = allPages)
      File "C:\Python23\lib\libgmail.py", line 344, in _parseThreadSearch
        items = self._parseSearchResult(searchType, start, **kwargs)
      File "C:\Python23\lib\libgmail.py", line 329, in _parseSearchResult
        return self._parsePage(_buildURL(**params))
      File "C:\Python23\lib\libgmail.py", line 300, in _parsePage
        items = _parsePage(self._retrievePage(urlOrRequest))
      File "C:\Python23\lib\libgmail.py", line 107, in _parsePage
        if itemsDict[D_VERSION] != js_version and not versionWarned:
    KeyError: 'v'
    Last edited by †Yegg†; June 16th, 2005 at 10:35 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Atlantic City, NJ
    Posts
    327
    Rep Power
    13
    Originally Posted by †Yegg†
    That's very interesting. No clue why it does that. Did you try searching around in google?
    Although I don't know how to fix the problem, I found some information:
    Code:
    The following code logs into an account, retrieves a list of threads, displays information about them and displays the source of the individual messages.
    
    import libgmail
    
    ga = libgmail.GmailAccount("google@gmail.com", "mymailismypass")
    ga.login()
    folder = ga.getMessagesByFolder('inbox')
    
    for thread in folder:
      print thread.id, len(thread), thread.subject
      for msg in thread:
        print "  ", msg.id, msg.number, msg.subject
        print msg.source
    Also: The following error is what I received, is that the same thing you got?
    Code:
    Traceback (most recent call last):
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 307, in RunScript
        debugger.run(codeObject, __main__.__dict__, start_stepping=0)
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\debugger\__init__.py", line 60, in run
        _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
      File "C:\PYTHON23\lib\site-packages\Pythonwin\pywin\debugger\debugger.py", line 592, in run
        exec cmd in globals, locals
      File "C:\Documents and Settings\Master\Desktop\Script1.py", line 7, in ?
        folder = ga.getMessagesByFolder('inbox')
      File "C:\Python23\lib\libgmail.py", line 390, in getMessagesByFolder
        return self._parseThreadSearch(folderName, allPages = allPages)
      File "C:\Python23\lib\libgmail.py", line 344, in _parseThreadSearch
        items = self._parseSearchResult(searchType, start, **kwargs)
      File "C:\Python23\lib\libgmail.py", line 329, in _parseSearchResult
        return self._parsePage(_buildURL(**params))
      File "C:\Python23\lib\libgmail.py", line 300, in _parsePage
        items = _parsePage(self._retrievePage(urlOrRequest))
      File "C:\Python23\lib\libgmail.py", line 107, in _parsePage
        if itemsDict[D_VERSION] != js_version and not versionWarned:
    KeyError: 'v'

    Yup. Same error. Ends with the KeyError: 'v'. Strange huh.
    I'll learn this stuff someday.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Atlantic City, NJ
    Posts
    327
    Rep Power
    13
    Well, I read this on the libgmail page but disregarded it since it seemed so ridiculous:

    Please note: Always download and test the CVS version of libgmail if you are having problems. The most recent packaged version no longer works correctly. The current development status means critical errors caused by changes at Gmail will be corrected as soon as possible in CVS, if the author is notified about the issue.
    Well they were right. The latest release does not work but the cvs version does. I don't understand this at all but hey what do I know.

    Thanks.
    I'll learn this stuff someday.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    gmail probably is still being changed around and such. So the lib gets broken when something on gmails site changes.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    Atlantic City, NJ
    Posts
    327
    Rep Power
    13
    Originally Posted by CyBerHigh
    gmail probably is still being changed around and such. So the lib gets broken when something on gmails site changes.
    Yeah your probably right. Its just strange that the official releases say they don't work at all. Why release them then? I don't know. I filed a bug report for the current gentoo ebuild on it since its worthless.
    Last edited by Shiner_Man; June 19th, 2005 at 08:55 PM.
    I'll learn this stuff someday.

IMN logo majestic logo threadwatch logo seochat tools logo