Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-13 Thread Celil Rufat
Thanks!

I can confirm the patches fixes the issue on my computer.

Celil

On Thu, Nov 12, 2009 at 9:33 AM, Jouni K. Seppänen j...@iki.fi wrote:

 Celil Rufat celil.ru...@gmail.com writes:

  However, when I try one of the Qt4 examles:
 [...]
File
 
 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
  line 303, in get_fontconfig_fonts
  status, output = commands.getstatusoutput(fc-list file)
File
 
 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/commands.py,
  line 56, in getstatusoutput
  text = pipe.read()
  IOError: [Errno 4] Interrupted system call

 I believe the attached patch (already committed to the trunk) should fix
 this on Python 2.6, but I don't have a Qt installation to try it out
 with. Can you try this on your system?

 --
 Jouni K. Seppänen
 http://www.iki.fi/jks



 --
 Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
 trial. Simplify your report design, integration and deployment - and focus
 on
 what you do best, core application coding. Discover what's new with
 Crystal Reports now.  http://p.sf.net/sfu/bobj-july
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-12 Thread Jouni K . Seppänen
Celil Rufat celil.ru...@gmail.com writes:

 However, when I try one of the Qt4 examles:
[...]
   File
 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
 line 303, in get_fontconfig_fonts
 status, output = commands.getstatusoutput(fc-list file)
   File
 /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/commands.py,
 line 56, in getstatusoutput
 text = pipe.read()
 IOError: [Errno 4] Interrupted system call

I believe the attached patch (already committed to the trunk) should fix
this on Python 2.6, but I don't have a Qt installation to try it out
with. Can you try this on your system?

-- 
Jouni K. Seppänen
http://www.iki.fi/jks

Index: lib/matplotlib/font_manager.py
===
--- lib/matplotlib/font_manager.py	(revision 7951)
+++ lib/matplotlib/font_manager.py	(working copy)
@@ -42,7 +42,7 @@
 see license/LICENSE_TTFQUERY.
 
 
-import os, sys, glob
+import os, sys, glob, subprocess
 try:
 set
 except NameError:
@@ -292,16 +292,12 @@
 grab all of the fonts the user wants to be made available to
 applications, without needing knowing where all of them reside.
 
-try:
-import commands
-except ImportError:
-return {}
-
 fontext = get_fontext_synonyms(fontext)
 
 fontfiles = {}
-status, output = commands.getstatusoutput(fc-list file)
-if status == 0:
+pipe = subprocess.Popen(['fc-list', '', 'file'], stdout=subprocess.PIPE)
+output = pipe.communicate()[0]
+if pipe.returncode == 0:
 for line in output.split('\n'):
 fname = line.split(':')[0]
 if (os.path.splitext(fname)[1][1:] in fontext and
@@ -1244,11 +1240,11 @@
 import re
 
 def fc_match(pattern, fontext):
-import commands
 fontexts = get_fontext_synonyms(fontext)
 ext = . + fontext
-status, output = commands.getstatusoutput('fc-match -sv %s' % pattern)
-if status == 0:
+pipe = subprocess.Popen(['fc-match', '-sv', pattern], stdout=subprocess.PIPE)
+output = pipe.communicate()[0]
+if pipe.returncode == 0:
 for match in _fc_match_regex.finditer(output):
 file = match.group(1)
 if os.path.splitext(file)[1][1:] in fontexts:
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-12 Thread Andrew Straw
Celil Rufat wrote:
 I just installed matplotlib on Snow Leopard 10.6 with the Qt4 backend 
 (via macports). However, when I try one of the Qt4 examles:

 python 
 /opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py


 IOError: [Errno 4] Interrupted system call

 Any ideas on what could be causing this?
Out of curiosity, does anyone know where the signal interrupting the 
system call is originating? Is this a standard communication mechanism 
within Qt4? (I have never used Qt4.) I'm interested in knowing about OSS 
that use signals as a means of across-thread or across-process 
communication.

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-12 Thread Robert Kern
On 2009-11-12 12:05 PM, Andrew Straw wrote:
 Celil Rufat wrote:
 I just installed matplotlib on Snow Leopard 10.6 with the Qt4 backend
 (via macports). However, when I try one of the Qt4 examles:

 python
 /opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py


 IOError: [Errno 4] Interrupted system call

 Any ideas on what could be causing this?
 Out of curiosity, does anyone know where the signal interrupting the
 system call is originating? Is this a standard communication mechanism
 within Qt4? (I have never used Qt4.) I'm interested in knowing about OSS
 that use signals as a means of across-thread or across-process
 communication.

This problem arises when signal handlers are installed, not necessarily when a 
signal itself is sent (dtrace doesn't detect any). PyQt4 doesn't do it, but I 
think something in QApplication does. I really don't know what, though. Here 
are 
the files that call signal(3) or sigaction(3):

./src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
./src/3rdparty/phonon/qt7/quicktimevideoplayer.mm
./src/3rdparty/sqlite/shell.c
./src/3rdparty/webkit/JavaScriptCore/jsc.cpp
./src/corelib/io/qfilesystemwatcher_dnotify.cpp
./src/corelib/io/qprocess_unix.cpp
./src/corelib/kernel/qcrashhandler.cpp
./src/corelib/kernel/qeventdispatcher_unix.cpp
./src/gui/embedded/qwindowsystem_qws.cpp
./src/gui/embedded/qwssignalhandler.cpp
./tools/qvfb/main.cpp

It's not obvious to me that any of these are activated on OS X (the 
qcrashhandler.cpp file is intriguing, but it only seems to be used in the X11 
QApplication). dtrace doesn't actually show either signal(3) or sigaction(3) 
being called at all. Actually, running a program under dtrace while probing 
those functions makes the problem go away. Sometimes.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth.
   -- Umberto Eco


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-12 Thread Andrew Straw
Robert Kern wrote:
 On 2009-11-12 12:05 PM, Andrew Straw wrote:
   
 Celil Rufat wrote:
 
 I just installed matplotlib on Snow Leopard 10.6 with the Qt4 backend
 (via macports). However, when I try one of the Qt4 examles:

 python
 /opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py


 IOError: [Errno 4] Interrupted system call

 Any ideas on what could be causing this?
   
 Out of curiosity, does anyone know where the signal interrupting the
 system call is originating? Is this a standard communication mechanism
 within Qt4? (I have never used Qt4.) I'm interested in knowing about OSS
 that use signals as a means of across-thread or across-process
 communication.
 

 This problem arises when signal handlers are installed, not necessarily when 
 a 
 signal itself is sent (dtrace doesn't detect any).
Hmm, but a system call isn't going to get interrupted and return EINTR 
by any means other than a signal. So the OP must have had a signal 
interrupting the call and it must have come from somewhere. Or... am I 
wrong?

  PyQt4 doesn't do it, but I 
 think something in QApplication does. I really don't know what, though. Here 
 are 
 the files that call signal(3) or sigaction(3):

 ./src/3rdparty/freetype/src/tools/ftrandom/ftrandom.c
 ./src/3rdparty/phonon/qt7/quicktimevideoplayer.mm
 ./src/3rdparty/sqlite/shell.c
 ./src/3rdparty/webkit/JavaScriptCore/jsc.cpp
 ./src/corelib/io/qfilesystemwatcher_dnotify.cpp
 ./src/corelib/io/qprocess_unix.cpp
 ./src/corelib/kernel/qcrashhandler.cpp
 ./src/corelib/kernel/qeventdispatcher_unix.cpp
 ./src/gui/embedded/qwindowsystem_qws.cpp
 ./src/gui/embedded/qwssignalhandler.cpp
 ./tools/qvfb/main.cpp

 It's not obvious to me that any of these are activated on OS X (the 
 qcrashhandler.cpp file is intriguing, but it only seems to be used in the X11 
 QApplication). dtrace doesn't actually show either signal(3) or sigaction(3) 
 being called at all. Actually, running a program under dtrace while probing 
 those functions makes the problem go away. Sometimes.
   
Ahh, a fun Heisenbug. OK, well if I decide to look for programs that use 
signals as a means of communication, I'll investigate Qt further.

I asked because there's a proprietary library I'm forced to use that 
does communicate internally with signals. It's a real pain, however, 
because it means anything else in that process also gets hit with 
signals and so system calls must be EINTR safe.

-Andrew

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] matplotlib with Qt4 backend

2009-11-12 Thread Robert Kern
On 2009-11-12 16:44 PM, Andrew Straw wrote:
 Robert Kern wrote:
 On 2009-11-12 12:05 PM, Andrew Straw wrote:

 Celil Rufat wrote:

 I just installed matplotlib on Snow Leopard 10.6 with the Qt4 backend
 (via macports). However, when I try one of the Qt4 examles:

 python
 /opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py


 IOError: [Errno 4] Interrupted system call

 Any ideas on what could be causing this?

 Out of curiosity, does anyone know where the signal interrupting the
 system call is originating? Is this a standard communication mechanism
 within Qt4? (I have never used Qt4.) I'm interested in knowing about OSS
 that use signals as a means of across-thread or across-process
 communication.


 This problem arises when signal handlers are installed, not necessarily when 
 a
 signal itself is sent (dtrace doesn't detect any).
 Hmm, but a system call isn't going to get interrupted and return EINTR
 by any means other than a signal. So the OP must have had a signal
 interrupting the call and it must have come from somewhere. Or... am I
 wrong?

Well, SIGCHLD is sent by the OS when the child process completes. There is a 
SIGCHLD handler registered in ./src/corelib/io/qprocess_unix.cpp . I'm not sure 
how to avoid it, though.

I think I can verify this now:

$ really dtrace -n 'proc:::signal-handle /pid==$target/ { ustack(); 
printf(Signal: %d\n, arg0);}' -c python application.py
dtrace: description 'proc:::signal-handle ' matched 2 probes
Traceback (most recent call last):
   File application.py, line 247, in module
 commands.getstatusoutput( otool -L %s | grep libedit % _rl.__file__ )
   File 
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/commands.py, 
line 54, in getstatusoutput
 text = pipe.read()
IOError: [Errno 4] Interrupted system call
dtrace: pid 47973 has exited
CPU IDFUNCTION:NAME
   1  18577sendsig:signal-handle
   libSystem.B.dylib`read+0xa
   libSystem.B.dylib`__srefill+0x127
   libSystem.B.dylib`fread+0x9f
   0x1c2d9b
   0x23affa
   0x23bde1
   0x23c7fa
   0x23c907
   0x260d37
   0x2610e3
   0x26f855
   python`0x1f82
   python`0x1ea9
   0x2
Signal: 20

$ python -c import signal;print signal.SIGCHLD
20


So it is getting SIGCHLD. I think my previous probes weren't getting signals 
from the OS itself.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth.
   -- Umberto Eco


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib with Qt4 backend

2009-11-11 Thread Celil Rufat
I just installed matplotlib on Snow Leopard 10.6 with the Qt4 backend (via
macports). However, when I try one of the Qt4 examles:

python
/opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py

I get the following error message:

Traceback (most recent call last):
  File
/opt/local/share/py26-matplotlib/examples/user_interfaces/embedding_in_qt4.py,
line 70, in update_figure
self.draw()
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_qt4agg.py,
line 130, in draw
FigureCanvasAgg.draw(self)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py,
line 314, in draw
self.figure.draw(self.renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py,
line 46, in draw_wrapper
draw(artist, renderer, *kl)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py,
line 773, in draw
for a in self.axes: a.draw(renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py,
line 46, in draw_wrapper
draw(artist, renderer, *kl)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py,
line 1735, in draw
a.draw(renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py,
line 46, in draw_wrapper
draw(artist, renderer, *kl)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py,
line 742, in draw
tick.draw(renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/artist.py,
line 46, in draw_wrapper
draw(artist, renderer, *kl)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py,
line 196, in draw
self.label1.draw(renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/text.py,
line 515, in draw
bbox, info = self._get_layout(renderer)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/text.py,
line 272, in _get_layout
'lp', self._fontproperties, ismath=False)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py,
line 158, in get_text_width_height_descent
font = self._get_agg_font(prop)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py,
line 195, in _get_agg_font
fname = findfont(prop)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
line 1308, in findfont
_rebuild()
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
line 1292, in _rebuild
fontManager = FontManager()
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
line 984, in __init__
self.ttffiles = findSystemFonts(paths) + findSystemFonts()
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
line 341, in findSystemFonts
for f in get_fontconfig_fonts(fontext):
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py,
line 303, in get_fontconfig_fonts
status, output = commands.getstatusoutput(fc-list file)
  File
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/commands.py,
line 56, in getstatusoutput
text = pipe.read()
IOError: [Errno 4] Interrupted system call

Any ideas on what could be causing this?

celil
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users