Question regarding DNS resolution in urllib2

2011-06-14 Thread saurabh verma
hi ,

I trying to use urllib2 in my script , but the problem is lets say a domains 
resolves to multiple IPs , If the URL is served by plain http , I can add 
“Host: domain” header and check whether all IPs are returning proper responses 
or not , but in case of https , I have to trust on my local machines dns 
resolver and I can’t apply host header in the request . 

Is it possible to override dns resolver in urllib2 or something else ? 

>>> req = urllib2.Request(url='https://google.com/')
>>> f = urllib2.urlopen(req)
>>> print f.read()

I wanted to control the IPs which urllib2 is trying to connect . 


I Hope I am some sense out of my question , 

Thanks in advance. 

~saurabh 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-14 Thread saurabh verma

On 15-Jun-2011, at 6:13 AM, Chris Angelico wrote:

> On Wed, Jun 15, 2011 at 4:34 AM, saurabh verma  wrote:
>> hi ,
>> 
>> I trying to use urllib2 in my script , but the problem is lets say a domains 
>> resolves to multiple IPs , If the URL is served by plain http , I can add 
>> “Host: domain” header and check whether all IPs are returning proper 
>> responses or not , but in case of https , I have to trust on my local 
>> machines dns resolver and I can’t apply host header in the request .
> 
> Regarding Host: headers, experimentation showed that urllib2 did
> indeed send one (I tested using Python 2.7.1 on Windows, talking to a
> snooping HTTPS server running on a Linux box beside me - source code
> available if you're curious, but it's not Python).

Ok thats informative , thanks :)  . But my problem lies in testing https based 
virtual served by nginx when the domain is load balanced by DNS . 

Example , 

I have “http://something.com” and “https://something.com” both served by two 
servers and something.com resolves to two ips IPA,IPB . lets say i want to test 
both servers on http i can do the following 

curl “http://IPA/” -H “Host: something.com"
curl “http://IPB/” -H “Host: something.com”


But in the case of https , I can do above because https handshake is based on 
the domain i am trying to connect , so lets say I want to following inside a 
python  script using libcurl2 but without touching /etc/hosts , 

curl “https://something.com” , now something.com will try to connect to either 
IPA or IPB which I don’t have control over , I know internally it must be 
calling a DNS resolver libarary of python , I want to control over that , may 
be libcurl2 exposing a function to do some DNS altering . 

Is it worth hacking libcurl2 code for something like , Also i’m just not more 
than 1 week exprienced in python , but i do enjoy your mailing list , awesome 
participation . 


Thanks , 

Saurabh Verma 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-15 Thread saurabh verma
>
>
>
> If you edit your hosts file, it will affect where something.com points
> - you can force it to be IPA and then test, then force it to IPB and
> test. You'll still be downloading https://something.com so the HTTPS
> handshake should work exactly the same way.
>
>
there are issues with editing /etc/hosts , what if i don't have sudo access
on the target server ? I need a way out programmatically to fix this problem
.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-15 Thread saurabh verma
> 
> You don't need to edit it on the server; just use any handy computer.
> You need only tinker with the configuration on the client, not the
> server.
> 

Hmm true , Ok i can widen the problem statement  but editing /etc/hosts still 
looks Ok for my test server . ( Thinking of putting this as a nagios plugin on 
the servers .. that will not be a viable right now ) 

Thanks chris. 

~saurabh 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Question regarding DNS resolution in urllib2

2011-06-24 Thread saurabh verma

Michael Hrivnak wrote:

The latest libcurl includes the CURLOPTS_RESOLVE option
(http://curl.haxx.se/libcurl/c/curl_easy_setopt.html) that will do
what you want.  It may not have made its way into pycurl yet, but you
could just call the command-line curl binary with the --resolve
option.  This feature was introduced in version 7.21.3.

Michael
  


Hey Michael , Thanks for the response . Thats exactly what i was looking 
for.


"curl binary with the --resolve" ?

--(0)> curl --resolve
curl: option --resolve: is unknown
curl: try 'curl --help' or 'curl --manual' for more information
--(saurabhve@sa-mac-saurabh)-(~)--
--(2)> curl -V
curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l 
zlib/1.2.3



Couldn't find it .

~saurabh
--
http://mail.python.org/mailman/listinfo/python-list


Want to build an app for linux

2011-06-24 Thread saurabh verma

Hi all ,

May be I'm just asking a silly/old question .

I have some open web APIs which i can use , on it  I want to develop an 
desktop application , probably cross platform but mostly I'm aiming at 
*unix platforms . 

I've got no experience in programming desktop application , but thats 
not a issue , I can do it . But i need to know right technology stack i 
could thinking of using. python or may be java or python/QT or google 
chrome platform.


May be someone can suggest me some online tutorials/references , or any 
help appreciated.


Thanks in advance 


~saurabh


--
http://mail.python.org/mailman/listinfo/python-list


Re: Want to build an app for linux

2011-06-24 Thread saurabh verma

Adam Tauno Williams wrote:

On Fri, 2011-06-24 at 15:55 +0530, saurabh verma wrote:
  

Hi all ,
May be I'm just asking a silly/old question .
I have some open web APIs which i can use , on it  I want to develop an 
desktop application , probably cross platform but mostly I'm aiming at 
*unix platforms . 
I've got no experience in programming desktop application , but thats 
not a issue , I can do it . But i need to know right technology stack i 
could thinking of using. python or may be java or python/QT or google 
chrome platform.
May be someone can suggest me some online tutorials/references , or any 
help appreciated.



I've found Python + Gtk (which includes Glade) to be a very productive
solution.
<http://pygtk.org/>
<http://www.pygtk.org/articles/application-pygtk-glade/Building_an_Application_with_PyGTK_and_Glade.htm>

  

Hmm thanks for the response adam , I'll definitely check it out.

Quick question : Is creating jazzy UI feasible with python + gtk ? like 
round shaped corners , color schemes etc etc.


~saurabh
--
http://mail.python.org/mailman/listinfo/python-list


Re: Want to build an app for linux

2011-06-24 Thread saurabh verma
On Fri, Jun 24, 2011 at 4:24 PM, Anthony Papillion wrote:

> Hi Saurabh,
>
> I'm an experienced developer with quite a few years invested in both
> desktop and web development. But up until a few weeks ago, I'd really
> never touched Python much less developed a desktop app in it.
>
> I can tell you that the absolute easiest way to get started is this stack:
>
> PyGTK
> Glade
> Python
>
> Using those tools you'll be able to quickly learn to build desktop
> apps in Python with *very* little stress.
>
> Hope this helps and welcome to the list!
>
>
> hey anthony thanks for the help , Yes its definitely helpful . I have got
two recommendations for pygtk/glade :)  . I surely will be taking a deep
dive in it very soon.

~saurabh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Want to build an app for linux

2011-06-24 Thread saurabh verma



I prefer QT and you have qt-creator:
http://qt.nokia.com/products/developer-tools
and PyQT/SIP:
http://www.riverbankcomputing.co.uk/software/pyqt/intro

IMHO you will get a better looking thing than with gtk2.

  

Thanks Aho , Will surely look into it .
--
http://mail.python.org/mailman/listinfo/python-list


Re: Want to build an app for linux

2011-06-24 Thread saurabh verma

J.O. Aho wrote:

saurabh verma wrote:

  

Quick question : Is creating jazzy UI feasible with python + gtk ? like
round shaped corners , color schemes etc etc.



Button shapes and colors are generally done in themes and luckily people using
QT/gtk2 are allowed to change themes themselves which makes that the apps they
use looks as they wish and not how a dictator want them to look (mainly
thinking of mr gates and & co).


  

Thats really informative tip.

~saurabh
--
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing a graph image

2011-05-13 Thread saurabh verma

On 13-May-2011, at 5:54 PM, Bastian Ballmann wrote:

> Hi,
> 
> Am Fri, 13 May 2011 14:01:48 +0200
> schrieb Ulrich Eckhardt :
> 
>> I'm not sure I understand 100% what you want. If you want to extract 
>> ("parse") the data that is contained in an image file, I have no clue
>> how to do that.
> 
> Yes, I want to extract the data that is contained in an image file.
> Greets
> 

I guess it requires some kind of image processing , where you can move around 
image pixel by pixel and somehow figure out what color is present in that pixel 
. If there isn’t much noise in the image you should sharp contrast and would be 
able to differentiate between two colors ? if yes ( I don’t know matlab might 
provide some tools ..  just guessing ) then its easy i think to pick (X,Y) as 
time and value ? 

~saurabh verma 


-- 
http://mail.python.org/mailman/listinfo/python-list