getaddrinfo error due to proxy settings



>>> import urllib2
>>>
>>> data = urllib2.urlopen('http://www.google.com')
Traceback (most recent call last):
File "", line 1, in ?
File "C:\Python24\lib\urllib2.py", line 130, in urlopen
return _opener.open(url, data)
File "C:\Python24\lib\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\lib\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\lib\urllib2.py", line 1021, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "C:\Python24\lib\urllib2.py", line 996, in do_open
raise URLError(err)
URLError:
>>> import socket
>>> print socket.gethostname()
WXP-GQ86K1S
>>> print socket.gethostbyname(socket.gethostname())
121.241.134.194




This was really weird. I was thinking if that was a problem with the network or my machine. Tried on a different Linux machine and found it worked properly.

See the documentation for urllib.urlopen:

"""
In a Windows environment, if no proxy environment variables are set,
proxy settings are obtained from the registry's Internet Settings
section.
"""
Remove Proxy configuration under IE and try again
(don't use Ie anymore ;0)

Yes, that was the issue. Reset the proxy settings in the IE and found it working again. Is it a good idea to take the environment settings from the registry?
- If we are taking the settings from the registry, Should not the active browser ( firefox) update the registry settings? should it depend on IE only?

Guido and Bruce Eckel discuss Python 3000

Leading author and programmer, Bruce Eckel, posted some of his concerns on Python 3000 stating that python community is missing to address some of the important issues with this major, backward incompatible release. Problems he mentions are concurrency support on multi-core cpus, easy deployment support, a standardized user interface amongst others. He expresses his dissatisfaction at the post titled "Python 3K or Python 2.9?. Guido van Rossum, in a very pragmatic way addresses the concerns with his response to Bruce Eckel and calling out more for developers to contribute to Python to improve it further. Bruce Eckel concludes with his thoughts that he wants his favorite language to be better with his reply to Guido's reply.

vim howto - write and save to RO only

While working as a normal user, many a times need comes to edit a system file and save it. Instead of closing and redoing it.
the following can help.

:w !sudo tee % > /dev/null

Programming related thought

While reading through Mark Pilgrim's Dive into Python, stumbled upon this
interesting thought, wherein he says that, when you 'plan' to develop a full
-fledged feature for a software which will help in certain tasks, and if you
end up coding a small version, make it just work rather than a completed polished 'as-per-plan' thing, then you are not only being inefficient, but you are
being rude (to your customers).

That's a very good thought. Most of times, I think of designing a software and
when it reaches to level where it works, I stop there and move to next. The
working thing, sometimes never goes past my computer.

Patch Howto

1) diff -ruP original modified > patch
2) patch -p0 < patch

M x viper-mode

This is a emacs, viper mode. If vim fans are threathened and forced to user
emacs, then they might find this M x viper-mode as a consolation somewhat akin to a family photo a prisoner has in jail. He will be missing his family for sure though.

:-)

Yet another Ubuntu Fan

I was almost about to give up on Ubuntu, because after I installed the Fiesty, I was not able to download the packages from Repositories due to some proxy authentication issue. Tried various things for a week and when could not go any step further, I had thought let me get back to Fedora and was thinking about how new users of Linux will be feeling when they dont get support on what they need to get wishes satisfied with Linux. In my case, it was a particular distribution.
After a week, I setup my box again and wanted to give a final try. Instead of going to Synaptic and meddling with Repository sources, I thought let me try Add/Remove application to Install software and see what happens.
The basic install of ubuntu (from the CD) did not have things which a regular Linux user would desire. Well, what the heck, gvim was not there! Browsing through the software list I checked Emacs 21 for Installation and pressed Apply. Something interesting started to happen. It started downloading automatically from http://archive.ubuntu.com/ubuntu/dists/feisty/main/
I felt a kind of relief that I will be able to spend more time with ubuntu now.

There is a tricky bug with Ubuntu package manager, I think. The following was my setup with package installation from repos worked.
1) Firefox configured with proxy and proxy authentication details.
2) Gnome Network Preferences, Proxy NOT configured.
3) Without adding any repos, archive.ubuntu.com which is kind of a default repo is only working thing.

If I configure, Gnome Network Preferences with proxy details, the package manager fails with Proxy Authentication message.

The following tests might help.
1) Without Firefox Proxy, try with package manager.
2) Test Gnome Network Preferences for other applications. Epiphany can be used.
3) Try other repositories.
I shall try that and figure out the exact issue.

Now that I was able to configure the package manager, I got a wealth of neatly arranged package to choose from and Install. The Installation procedure was totally homogeneous. Neat, easy is what I can say of Ubuntu. Hey, you might hear those two words from many of the Ubuntu users, but you will appreciate only when you "feel" it.
Even Picassa download in deb format was handled properly by gnome deb package installer. I had never used deb and always thought deb format is difficult than rpm.

I had transfered my camera shot movies of Bungee jump to Ubuntu machine, first surprised to see the thumbnail of avi file and next totem player played that avi file. I felt wow!. Because, its first time Totem player had worked for me (apart from the live cd demo)

Then I spent looking at all the interesting programs that default, multiverse, and universe repositories could offer. There are tons of python language packages to install directly from the repos.

But the sweetest of all surprises came, when I thought let me search for rapple and nanoblogger. I know, there were debian maintainers for these to two projects. But it was really nice, to see a the project I have contributed to as being listed from the repository and choosing them to install it!

Why settle for..

Python - why settle for snake oil when you can have the whole snake? —From Usenet posting by Mark Jackson, June 1998
Mentioned at the Python Development page :- http://www.python.org/dev/. Its a good fun! :-)

Random C Stuff.

While browing through comp.lang.c found this interesting discussion.



/* Without using /, % or * operator, write a function to divide a number by 3.
* */
#include

int divideby3(int);

int main(int argc,char **argv)
{
int res;
res = divideby3(9);
printf("%d",res);
return 0;
}

int divideby3(int aNumber)
{
div_t d = div(aNumber, 3);
return d.quot;
}



Never have explored the capablities of stdlib. Infact, with C Programming
Language out of touch for so many months, I was thinking this program will
seriously fail, thinking kind of how come div_t datatype, d.quote
(object.property ?) etc. gcc will crib saying dont using c++. But it worked
perfectly fine.

N-Puzzle Problem solver using Python

Completed and submitted my project "N-Puzzle problem solver". Wrote it in Python programming language and it was good fun. Learned about the similarities of lisp and python. Why lisp is so powerful and how easy things will become once you get a hang of the language called Python.
Solving the N-Puzzle problem, I had tried without any base algorithms and it was damn hard to derive any solution. Once I saw the problem solving strategy using Manhattan Distances at norvig 's site. Coding the solution was enjoyable. You get a feel of what AI problems are when trying these Toy-AI problems.