I asked a similar question prior but i finally got further along in solving it, but now i am stuck.
I am running python on a webserver on dreamhost. I shell into it using putty and run my python script and it works great. But when i run it from php using exec, it crashes.
Using the passthru() function in php i get returned with this error:
Traceback (most recent call last): File "newwork.py", line 20,
in api=lastfm.Api(api_key) File "lastfm/api.py", line 22,
in __init__ File "lastfm/filecache.py", line 19,
in __init__ File "lastfm/filecache.py", line 76,
in _InitializeRootDirectory File "lastfm/filecache.py", line 70,
in _GetTmpCachePath File "lastfm/filecache.py", line 66,
in _GetUsername OSError: [Errno 22] Invalid argument
i have no clue what that means or where i should start. for more info i am using the python lastfm module found here: http://code.google.com/p/python-lastfm/
and my python script simply does this:
import sys
import lastfm
import MySQLdb
sys.stderr=sys.stdout
value="testuser"
api_key='---my api key is here'
api=lastfm.Api(api_key)
user=api.getUser(value)
top_artists=user.topArtists
any help would be greatly appreciated, or any ideas whatsoever. I dont even know where to start.
Edit: i did a little more work and found the full last line is:
line 66, in _GetUsername os.getlogin() or \ OSError: [Errno 22] Invalid argument
and the GetUsername function simply is this:
def _GetUsername(self):
'''Attempt to find the username in a cross-platform fashion.'''
return os.getenv('USER') or \
os.getenv('LOGNAME') or \
os.getenv('USERNAME') or \
os.getlogin() or \
'nobody'
with indentation corrected not here.