help request using python_twitter api with django and errno 25

22 views
Skip to first unread message

Hani

unread,
Jun 28, 2008, 12:02:55 AM6/28/08
to Django users
Hi,

First, please know that I am a novice to django and python so please
be patient.

Am trying to use the python-twitter api with a little django app. When
I test the commands from the terminal, they run perfectly, however,
when run from django, they produce an errno 25 as follows:

[Errno 25] Inappropriate ioctl for device
Request Method: GET
Request URL: http://192.168.2.6/loa/
Exception Type: OSError
Exception Value: [Errno 25] Inappropriate ioctl for device
Exception Location: build/bdist.linux-i686/egg/twitter.py in
_GetUsername, line 1498
Python Executable: /usr/bin/python
Python Version: 2.5.1

The code that produces this error is as follows:

def sendtwit(twit):
twitter_api=twitter.Api(username='user', password='pw')
twitter_api.PostUpdate(twit)
return

Anyway, it seems the issue has been documented here:
http://code.google.com/p/python-twitter/issues/detail?id=16 with a
patch attached.

My questions are:
1. can anyone explain the error a little better to me?
2. Is it a bug in the python-twitter api, or in django, or in my code?
3. Is there a fix that does not involve using the patch?
4. If I have to use the patch, could someone provide easy to follow
steps for me to apply it (absolutely no clue here)?

Thanks tons in advance,

Hani

James Bennett

unread,
Jun 28, 2008, 1:03:04 AM6/28/08
to django...@googlegroups.com
On Fri, Jun 27, 2008 at 11:02 PM, Hani <hanita...@gmail.com> wrote:
> My questions are:
> 1. can anyone explain the error a little better to me?
> 2. Is it a bug in the python-twitter api, or in django, or in my code?
> 3. Is there a fix that does not involve using the patch?
> 4. If I have to use the patch, could someone provide easy to follow
> steps for me to apply it (absolutely no clue here)?

Question 1 (this is going to gloss over a lot of things, but hopefully
will help):

Basically, on Unix and Unix-like systems, there is a concept of a
"controlling terminal" -- for example, if you're on Mac OS X (which is
BSD-ish Unix under the hood), you can open a Terminal and launch a
Python interpreter; in this case, the instance of Terminal.app you're
using will be the "controlling terminal" of the process the Python
interpreter is running in.

It's often useful to get information about your controlling process,
because this can answer some fairly practical question; in the case of
the Twitter API, it was looking for the username of the logged-in user
who launch the Python process, which is available if, for example, it
was launched directly from a command line. Python's standard 'os'
module allows you to do this sort of thing fairly easily. However,
there are cases where the controlling process doesn't support this
sort of thing, and in those cases the Python functions will raise an
IOError (you can also take some steps to determine in advance whether
your controlling process supports these functions).

Question 2: Yes, it is (or was) a bug in the Twitter module.

Question 3: the ticket you're looking at is a duplicate of one I filed
earlier, and which was marked fixed some time ago:
http://code.google.com/p/python-twitter/issues/detail?id=14

The relevant patch catches the IOError and falls back to a default
value when the necessary information isn't available:
http://code.google.com/p/python-twitter/source/detail?r=113#

So if you do an svn up on your copy of the Twitter module, it should work.


--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

Hani

unread,
Jun 28, 2008, 7:02:54 AM6/28/08
to Django users
Hi James,

Thanks. Perfect response and very helpful. Greatly appreciate it.

Hani

On Jun 28, 1:03 am, "James Bennett" <ubernost...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages