[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

urllib2 disable proxy

Dimitrios Apostolou

1/2/2008 9:04:00 PM

Hello list,

I've been looking for a way to explicitly disable the use of proxies with
urllib2, no matter what the environment dictates. Unfortunately I can't find
a way in the documentation, and reading the source leads me to believe that
something like the following does the job:

req.set_proxy(None,None)

Where req is a urllib2.Request instance. So is there an official way of doing
this? Perhaps it should be added in the documentation?


Thanks in advance,
Dimitris
7 Answers

Rob Wolfe

1/2/2008 9:36:00 PM

0

Dimitrios Apostolou <jimis@gmx.net> writes:

> Hello list,
>
> I've been looking for a way to explicitly disable the use of proxies with
> urllib2, no matter what the environment dictates. Unfortunately I can't find
> a way in the documentation, and reading the source leads me to believe that
> something like the following does the job:
>
> req.set_proxy(None,None)
>
> Where req is a urllib2.Request instance. So is there an official way of doing
> this? Perhaps it should be added in the documentation?

I believe that the recommended way is to use `urllib2.ProxyHandler`.
Take a look at:
http://www.voidspace.org.uk/python/articles/url...

HTH,
Rob

Dimitrios Apostolou

1/3/2008 5:23:00 PM

0

Rob Wolfe

1/3/2008 7:13:00 PM

0

Dimitrios Apostolou <jimis@gmx.net> writes:

> On Wed, 2 Jan 2008, Rob Wolfe wrote:
>
>> Dimitrios Apostolou <jimis@gmx.net> writes:
>>
>>> Hello list,
>>>
>>> I've been looking for a way to explicitly disable the use of proxies with
>>> urllib2, no matter what the environment dictates. Unfortunately I can't find
>>> a way in the documentation, and reading the source leads me to believe that
>>> something like the following does the job:
>>>
>>> req.set_proxy(None,None)
>>>
>>> Where req is a urllib2.Request instance. So is there an official way of doing
>>> this? Perhaps it should be added in the documentation?
>>
>> I believe that the recommended way is to use `urllib2.ProxyHandler`.
>> Take a look at:
>> http://www.voidspace.org.uk/python/articles/url...
>
> Thanks for the pointer, I will use that way. However it seems rather
> non-elegant way to do something so simple and I was hoping not to mess
> with ProxyHandler, especially since I want *no* proxy... IMHO
> something like the following would be more elegant:
>
> req.set_proxy('','http')
>
> or
>
> req.set_proxy(None,'http')
>
>
> However these ways *don't* work. You think I should file a feature
> request somewhere or send this to the python-dev list?

Actually, I like this idea of handlers and openers
and find it simple and _elegant_, so I can't second that request.
Besides disabling proxies despite environmental settings
is a special case, so imho using `instal_opener` is justified.

Regards,
Rob

The Peeler

1/22/2014 5:19:00 PM

0

On Wed, 22 Jan 2014 14:30:28 +0100, Dumb Heini, the heavily medicated Dutch
resident Nazi troll and laughing stock of sci and scj, wrote:


>>>employ them, do not adopt them.
>>
>> They're all basically USELESS...just like Griks, jews, gooks and
>> Canadians.
>
> I fully agree with you

An idiot agreeing with a retard! So, what's new on Usenet! LOL

--
Dumb Heini about himself and The Rectum:
"but at least the rev.and i still have their foreskins"
MID: <5283c1c5$0$15276$2e0edba0@news.tweakdsl.nl>

The Revd

1/22/2014 5:52:00 PM

0

On Wed, 22 Jan 2014 14:30:28 +0100, "Heinrich"
<Heinrich@Ruhrgasnet.de> wrote:

>
>
>"The Revd" <peeling@degenerate.Grik> schreef in bericht
>news:gghvd9tp15mncloecr73dproa0bi35nef1@4ax.com...
>> On Wed, 22 Jan 2014 07:08:39 +0100, "Heinrich"
>> <Heinrich@Ruhrgasnet.de> wrote:
>>
>>>OK, so I've lived in Africa since I was born in 1979 in South Africa.
>>>During my childhood, I had a few black friends as we were living in
>>>different places because my dad was in the police. So usually all the
>>>kids,
>>>of all colors would play together, no idea as to what apartheid was, and
>>>that there was segregation of the races.
>>>I grew up, we settled and I eventually went to primary school and in 1990,
>>>FW de Klerk released Mandela from prison. That same year violence broke
>>>out
>>>with faction fighting all over. My father was called in a few times to
>>>command sticky situations and then all hell broke loose. In 1991 the
>>>informal settlements around our town were drenched in violence between
>>>ethnic Zulus and Xhosas, between ANC members, and whoever they considered
>>>"traitors to the cause".
>>>
>>>I saw a black policeman's family killed, and his house and car, of which
>>>he
>>>was incredibly proud, burnt to ashes. This was about the time that I
>>>realized, that these were not humans but animals. Ferocious and vicious
>>>animals bent on destroying everything in it's path to self destruction.
>>>I went to high school in 1993, and in 1994, the first so called
>>>"democratic"
>>>elections were held. Whites were afraid that we might be exterminated as
>>>we
>>>were in a vast minority. Then came the "Affirmative Action" laws, used by
>>>the black government, to expel whites from their jobs, and to force
>>>uneducated blacks into those jobs.
>>>
>>>Why do I say uneducated? Well, certainly not because they were not given
>>>an
>>>education. The white government built them free schools, clinics,
>>>hospitals
>>>and universities of their own. In primary schools, they were instructed in
>>>their own language, but when it came to high school, they were educated in
>>>Afrikaans and English as these were the only two languages in South Africa
>>>with science and technology concepts as these concepts did not exist in
>>>African languages. Therein however lies the problem. The Africans
>>>revolted,
>>>marched and made demands to be taught in their own languages. They
>>>demanded
>>>that segregation be dismantled, yet none of them could provide a reason as
>>>to why it has to be done. They refused to attend school, and when they did
>>>attend, they burnt their school books, and at times, the school itself.
>>>How
>>>does someone become educated, when they do something like this?
>>>
>>>
>>>So back to my point, the black government started their policies of
>>>dumping
>>>blacks into positions held by whites. The problem was however that the
>>>blacks could not perform like the whites, were booked off sick more than
>>>once a month at the behest of witch doctors and could not process logic or
>>>mathematical problems.
>>>
>>>So a lot of these black people got fired for not being able to do the job,
>>>and yet again, their government implemented new laws to prevent companies
>>>from firing someone who was incapable of doing the job. So companies were
>>>yet again forced to employ useless black people, that could not be fired
>>>if
>>>they were incompetent. And so started a trend that would see companies
>>>employ ever increasing amounts of blacks to do the job of one or two white
>>>people.
>>>
>>>For a while, this carried on as just a forced trend, and then the black
>>>demands started flying again. Black people were demanding the same amount
>>>of
>>>compensation as their far more efficient white counterparts. Some even
>>>went
>>>as far as to demand double digit increases as they valued themselves far
>>>more than their actual worth to the company. Companies realized that this
>>>trend could not continue as it would result in a total collapse of the
>>>company.
>>>
>>>
>>>The companies then started demanding that prospective employees have
>>>finished high school with math and science as subjects, knowing that these
>>>were subject way above the intellectual station of black people. For a
>>>while, everything went well again, the companies started showing good
>>>profits again, and strikes were minimized. The Blacks realizing that their
>>>people are unemployed, then devised new and more cunning laws.
>>>
>>>They proposed that black students can graduate from university on
>>>attendance
>>>alone, no matter what their actual exams score were. They also devised
>>>cunning new subject that would be to the benefit of the blacks, "math
>>>literacy", which in essence encompass the use of a calculator and nothing
>>>else. Now companies were also threatened with fines for not employing
>>>enough
>>>black people. Eventually companies started employing people with "math
>>>literacy" under threat of legal action and fines, but to their own
>>>determent. These people could hardly count, let alone use a calculator.
>>>It then came to light that the Dept. of Education had instituted
>>>regulations
>>>banning pupils from flunking, in effect making it possible to go from
>>>primary school to high school without ever knowing how to read and write.
>>>This scenario has played out multiple times over the past 20 years, and
>>>there is nothing that we whites can be done about this apartheid, for the
>>>forces that made apartheid a crime against humanity, now also turn a blind
>>>eye.
>>>This is what Africa is, this is what blacks are. Do not trust them, do not
>>>employ them, do not adopt them.
>>
>> They're all basically USELESS...just like Griks, jews, gooks and
>> Canadians.
>
>I fully agree with you

They ALWAY [sic] find themselves at the bottom of the pile, wherever
they end up! TOTALLY useless.
<tsk> [sic]

raireme

1/24/2014 3:58:00 PM

0

On Wednesday, January 22, 2014 3:22:39 PM UTC+2, The Revd wrote:
> On Wed, 22 Jan 2014 07:08:39 +0100, "Heinrich"
>
> <Heinrich@Ruhrgasnet.de> wrote:
>
>
>
> >OK, so I've lived in Africa since I was born in 1979 in South Africa.
>
> >During my childhood, I had a few black friends as we were living in
>
> >different places because my dad was in the police. So usually all the kids,
>
> >of all colors would play together, no idea as to what apartheid was, and
>
> >that there was segregation of the races.
>
> >I grew up, we settled and I eventually went to primary school and in 1990,
>
> >FW de Klerk released Mandela from prison. That same year violence broke out
>
> >with faction fighting all over. My father was called in a few times to
>
> >command sticky situations and then all hell broke loose. In 1991 the
>
> >informal settlements around our town were drenched in violence between
>
> >ethnic Zulus and Xhosas, between ANC members, and whoever they considered
>
> >"traitors to the cause".
>
> >
>
> >I saw a black policeman's family killed, and his house and car, of which he
>
> >was incredibly proud, burnt to ashes. This was about the time that I
>
> >realized, that these were not humans but animals. Ferocious and vicious
>
> >animals bent on destroying everything in it's path to self destruction.
>
> >I went to high school in 1993, and in 1994, the first so called "democratic"
>
> >elections were held. Whites were afraid that we might be exterminated as we
>
> >were in a vast minority. Then came the "Affirmative Action" laws, used by
>
> >the black government, to expel whites from their jobs, and to force
>
> >uneducated blacks into those jobs.
>
> >
>
> >Why do I say uneducated? Well, certainly not because they were not given an
>
> >education. The white government built them free schools, clinics, hospitals
>
> >and universities of their own. In primary schools, they were instructed in
>
> >their own language, but when it came to high school, they were educated in
>
> >Afrikaans and English as these were the only two languages in South Africa
>
> >with science and technology concepts as these concepts did not exist in
>
> >African languages. Therein however lies the problem. The Africans revolted,
>
> >marched and made demands to be taught in their own languages. They demanded
>
> >that segregation be dismantled, yet none of them could provide a reason as
>
> >to why it has to be done. They refused to attend school, and when they did
>
> >attend, they burnt their school books, and at times, the school itself. How
>
> >does someone become educated, when they do something like this?
>
> >
>
> >
>
> >So back to my point, the black government started their policies of dumping
>
> >blacks into positions held by whites. The problem was however that the
>
> >blacks could not perform like the whites, were booked off sick more than
>
> >once a month at the behest of witch doctors and could not process logic or
>
> >mathematical problems.
>
> >
>
> >So a lot of these black people got fired for not being able to do the job,
>
> >and yet again, their government implemented new laws to prevent companies
>
> >from firing someone who was incapable of doing the job. So companies were
>
> >yet again forced to employ useless black people, that could not be fired if
>
> >they were incompetent. And so started a trend that would see companies
>
> >employ ever increasing amounts of blacks to do the job of one or two white
>
> >people.
>
> >
>
> >For a while, this carried on as just a forced trend, and then the black
>
> >demands started flying again. Black people were demanding the same amount of
>
> >compensation as their far more efficient white counterparts. Some even went
>
> >as far as to demand double digit increases as they valued themselves far
>
> >more than their actual worth to the company. Companies realized that this
>
> >trend could not continue as it would result in a total collapse of the
>
> >company.
>
> >
>
> >
>
> >The companies then started demanding that prospective employees have
>
> >finished high school with math and science as subjects, knowing that these
>
> >were subject way above the intellectual station of black people. For a
>
> >while, everything went well again, the companies started showing good
>
> >profits again, and strikes were minimized. The Blacks realizing that their
>
> >people are unemployed, then devised new and more cunning laws.
>
> >
>
> >They proposed that black students can graduate from university on attendance
>
> >alone, no matter what their actual exams score were. They also devised
>
> >cunning new subject that would be to the benefit of the blacks, "math
>
> >literacy", which in essence encompass the use of a calculator and nothing
>
> >else. Now companies were also threatened with fines for not employing enough
>
> >black people. Eventually companies started employing people with "math
>
> >literacy" under threat of legal action and fines, but to their own
>
> >determent. These people could hardly count, let alone use a calculator.
>
> >It then came to light that the Dept. of Education had instituted regulations
>
> >banning pupils from flunking, in effect making it possible to go from
>
> >primary school to high school without ever knowing how to read and write.
>
> >This scenario has played out multiple times over the past 20 years, and
>
> >there is nothing that we whites can be done about this apartheid, for the
>
> >forces that made apartheid a crime against humanity, now also turn a blind
>
> >eye.
>
> >This is what Africa is, this is what blacks are. Do not trust them, do not
>
> >employ them, do not adopt them.
>
>
>
> They're all basically USELESS...just like Griks, jews, gooks and
>
> Canadians.

And Serbs.

The Revd

1/24/2014 4:35:00 PM

0

On Fri, 24 Jan 2014 07:57:45 -0800 (PST), Rere <raireme@hotmail.com>
wrote:

>On Wednesday, January 22, 2014 3:22:39 PM UTC+2, The Revd wrote:
>> On Wed, 22 Jan 2014 07:08:39 +0100, "Heinrich"
>>
>> <Heinrich@Ruhrgasnet.de> wrote:
>>
>>
>>
>> >OK, so I've lived in Africa since I was born in 1979 in South Africa.
>>
>> >During my childhood, I had a few black friends as we were living in
>>
>> >different places because my dad was in the police. So usually all the kids,
>>
>> >of all colors would play together, no idea as to what apartheid was, and
>>
>> >that there was segregation of the races.
>>
>> >I grew up, we settled and I eventually went to primary school and in 1990,
>>
>> >FW de Klerk released Mandela from prison. That same year violence broke out
>>
>> >with faction fighting all over. My father was called in a few times to
>>
>> >command sticky situations and then all hell broke loose. In 1991 the
>>
>> >informal settlements around our town were drenched in violence between
>>
>> >ethnic Zulus and Xhosas, between ANC members, and whoever they considered
>>
>> >"traitors to the cause".
>>
>> >
>>
>> >I saw a black policeman's family killed, and his house and car, of which he
>>
>> >was incredibly proud, burnt to ashes. This was about the time that I
>>
>> >realized, that these were not humans but animals. Ferocious and vicious
>>
>> >animals bent on destroying everything in it's path to self destruction.
>>
>> >I went to high school in 1993, and in 1994, the first so called "democratic"
>>
>> >elections were held. Whites were afraid that we might be exterminated as we
>>
>> >were in a vast minority. Then came the "Affirmative Action" laws, used by
>>
>> >the black government, to expel whites from their jobs, and to force
>>
>> >uneducated blacks into those jobs.
>>
>> >
>>
>> >Why do I say uneducated? Well, certainly not because they were not given an
>>
>> >education. The white government built them free schools, clinics, hospitals
>>
>> >and universities of their own. In primary schools, they were instructed in
>>
>> >their own language, but when it came to high school, they were educated in
>>
>> >Afrikaans and English as these were the only two languages in South Africa
>>
>> >with science and technology concepts as these concepts did not exist in
>>
>> >African languages. Therein however lies the problem. The Africans revolted,
>>
>> >marched and made demands to be taught in their own languages. They demanded
>>
>> >that segregation be dismantled, yet none of them could provide a reason as
>>
>> >to why it has to be done. They refused to attend school, and when they did
>>
>> >attend, they burnt their school books, and at times, the school itself. How
>>
>> >does someone become educated, when they do something like this?
>>
>> >
>>
>> >
>>
>> >So back to my point, the black government started their policies of dumping
>>
>> >blacks into positions held by whites. The problem was however that the
>>
>> >blacks could not perform like the whites, were booked off sick more than
>>
>> >once a month at the behest of witch doctors and could not process logic or
>>
>> >mathematical problems.
>>
>> >
>>
>> >So a lot of these black people got fired for not being able to do the job,
>>
>> >and yet again, their government implemented new laws to prevent companies
>>
>> >from firing someone who was incapable of doing the job. So companies were
>>
>> >yet again forced to employ useless black people, that could not be fired if
>>
>> >they were incompetent. And so started a trend that would see companies
>>
>> >employ ever increasing amounts of blacks to do the job of one or two white
>>
>> >people.
>>
>> >
>>
>> >For a while, this carried on as just a forced trend, and then the black
>>
>> >demands started flying again. Black people were demanding the same amount of
>>
>> >compensation as their far more efficient white counterparts. Some even went
>>
>> >as far as to demand double digit increases as they valued themselves far
>>
>> >more than their actual worth to the company. Companies realized that this
>>
>> >trend could not continue as it would result in a total collapse of the
>>
>> >company.
>>
>> >
>>
>> >
>>
>> >The companies then started demanding that prospective employees have
>>
>> >finished high school with math and science as subjects, knowing that these
>>
>> >were subject way above the intellectual station of black people. For a
>>
>> >while, everything went well again, the companies started showing good
>>
>> >profits again, and strikes were minimized. The Blacks realizing that their
>>
>> >people are unemployed, then devised new and more cunning laws.
>>
>> >
>>
>> >They proposed that black students can graduate from university on attendance
>>
>> >alone, no matter what their actual exams score were. They also devised
>>
>> >cunning new subject that would be to the benefit of the blacks, "math
>>
>> >literacy", which in essence encompass the use of a calculator and nothing
>>
>> >else. Now companies were also threatened with fines for not employing enough
>>
>> >black people. Eventually companies started employing people with "math
>>
>> >literacy" under threat of legal action and fines, but to their own
>>
>> >determent. These people could hardly count, let alone use a calculator.
>>
>> >It then came to light that the Dept. of Education had instituted regulations
>>
>> >banning pupils from flunking, in effect making it possible to go from
>>
>> >primary school to high school without ever knowing how to read and write.
>>
>> >This scenario has played out multiple times over the past 20 years, and
>>
>> >there is nothing that we whites can be done about this apartheid, for the
>>
>> >forces that made apartheid a crime against humanity, now also turn a blind
>>
>> >eye.
>>
>> >This is what Africa is, this is what blacks are. Do not trust them, do not
>>
>> >employ them, do not adopt them.
>>
>>
>>
>> They're all basically USELESS...just like Griks, jews, gooks and
>>
>> Canadians.
>
>And Serbs.

And especially drunnkkenn Finns!