danielpronych / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

AttributeError when it attempts to create a temporary directory in Windows/IIS #221

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Using the twitter api, in a windows machine, through IIS (Internet
   Information Service) to send a message

2. If we've not defined as environment variables neither "USER" 
   nor "LOGNAME" nor "USERNAME"

What is the expected output? What do you see instead?

The library fails when it attempts to create a temporary directory, raising
an AttributeError, because of the call to os.getlogin (at line 3862, in
version 0.8.2). it seems that os.getlogin works on unix/linux but 
not even exists in windows. 

What version of the product are you using? On what operating system?

0.8.2 on Windows NT (5.0) and python 2.7

Please provide any additional information below.

It's easy to fix the problem changing the method _GetUsername to:

  def _GetUsername(self):
    '''Attempt to find the username in a cross-platform fashion.'''
    try:
      return os.getenv('USER') or \
             os.getenv('LOGNAME') or \
             os.getenv('USERNAME') or \
             os.getlogin() or \
             'nobody'
    except (IOError, OSError, AttributeError), e:
      return 'nobody'

In others words, adding the AttributeError to the except clause.

Original issue reported on code.google.com by euriba...@gmail.com on 14 Dec 2011 at 2:08