How to fetch an XML file using an HTTPS query

2009-08-04 Thread Ido Levy
Hello All 

I am quite new to Python and I would appreciate your advice on the 
following issue.

I am trying to fetch an XML file from a remote server using an HTTPS 
query.

When testing the HTTPS query from the browser after I entered the URL I 
got a pop-up box asking me if I want to "save a file" or "open with".
>From a Python script I tried using urllib but it fails.

I validated that my Python release support https request by using the 
following code and a different URL:
import urllib
print urllib.urlopen('https://...').read()
and got the expected result.


When I tried the above code or the following one with the URL that should 
return an XML file 
import sys
import urllib
import urllib2

headers = {'User-Agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; 
rv:1.7.12) Gecko/20050923 Firefox/1.0.7', 'Cookie': 
'JSESSIONID=000:1;Path=/',}
url = "https://...";
req = urllib2.Request(url, None, headers)
urlFH = urllib2.urlopen(req)
headers = urlFH.info()
page_content = urlFH.readlines()
urlFH.close()

for line in page_content:
print 'line: %s' % line


I got the following result in both cases:


Invalid filter passed.



Thanks in Advance

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


Re: How to fetch an XML file using an HTTPS query

2009-08-04 Thread Ido Levy
Hi Tycho,

Thank you for your advice.

My problem was in the query itself, I replaced every space character with 
'%20' and it works.
You are right, the Python code below does do the work.

Ido



From:
Tycho Andersen 
To:
python-list@python.org
Date:
04/08/2009 04:42 PM
Subject:
Re: How to fetch an XML file using an HTTPS query



Blah, forgot to include the list. When is python-list going to get 
Reply-To?

\t

On Tue, Aug 4, 2009 at 8:38 AM, Tycho Andersen wrote:
> Hi Ido,
>
> On Tue, Aug 4, 2009 at 6:25 AM, Ido Levy wrote:
>> [snip]
>> I got the following result in both cases:
>> 
>> 
>> Invalid filter passed.
>> 
>
> To me, this doesn't look like a python problem: the application was
> successfully connected to and returned a result. The problem you're
> experiencing is that it wasn't the result you expected. Are you sure
> you're setting the right headers, posting the right form values, etc.
> and giving the app exactly what it wants?
>
> \t
>
-- 
http://mail.python.org/mailman/listinfo/python-list


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


pygtk - What is the best way to change the mouse pointer

2009-08-26 Thread Ido Levy
Hello All,

I am writing a dialog which one of its widget is a gtk.ComboBoxEntry ( 
let's assume widget in the example below is its instance )
When the user select one of the values from the gtk.ComboBoxEntry I need 
to run some calculations that takes a few seconds.
In order to reflect calculation time to the user I want to switch the 
mouse pointer to an hour glass and back to arrow what it finish the 
calculation.

I use the following code but it doesn't seems to work in a deterministic 
way. From time to time it skips the last line and keep the mouse pointer 
as an hour glass.

watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
widget.window.set_cursor(watch)

calculation code

widget.window.set_cursor(None)

I would appreciate your advice on the right way to implement this.

Thanks

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


Re: pygtk - What is the best way to change the mouse pointer

2009-08-27 Thread Ido Levy
> From:
> 
> MRAB 
> 
> To:
> 
> python-list@python.org
> 
> Date:
> 
> 26/08/2009 11:04 PM
> 
> Subject:
> 
> Re: pygtk - What is the best way to change the mouse pointer
> 
> Ido Levy wrote:
> > Hello All,
> > 
> > I am writing a dialog which one of its widget is a gtk.ComboBoxEntry ( 

> > let's assume widget in the example below is its instance )
> > When the user select one of the values from the gtk.ComboBoxEntry I 
need 
> > to run some calculations that takes a few seconds.
> > In order to reflect calculation time to the user I want to switch the 
> > mouse pointer to an hour glass and back to arrow what it finish the 
> > calculation.
> > 
> > I use the following code but it doesn't seems to work in a 
deterministic 
> > way. From time to time it skips the last line and keep the mouse 
pointer 
> > as an hour glass.
> > 
> > watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
> > widget.window.set_cursor(watch)
> > 
> > calculation code
> > 
> > widget.window.set_cursor(None)
> > 
> > I would appreciate your advice on the right way to implement this.
> > 
> Could the calculation code be raising an exception? Try adding some
> logging to see whether the last lien is actually being called. You could
> also use a try...finally... block to ensure that the last line is
> called:
> 
>  watch = gtk.gdk.Cursor(gtk.gdk.WATCH)
>  widget.window.set_cursor(watch)
>  try:
>  calculation code
>  finally:
>  widget.window.set_cursor(None)
> 

Thank you for your input.

I used logging and it seems that the last line is called.
I also used try...finally... block but it didn't solve the issue.

Then I have noticed that the line before the last one is widget.connect() 
I insert time.sleep() in between the lines and it seems to solve the 
issue.

I assume it's not suppose to work this way but it can be considered as a 
workaround 
-- 
http://mail.python.org/mailman/listinfo/python-list