summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authornags <nags@nags-desktop.(none)>2009-03-01 10:50:59 -0800
committernags <nags@nags-desktop.(none)>2009-03-01 10:50:59 -0800
commitea77b8cfdf199699b7a25e344bc3a41945dc925d (patch)
treea54baa1e724e099a67511adc4efdf0328d013c2d /python
parent4dd11aeecd42ad81120415ddef39fbacb423c622 (diff)
2009-03-01 Eitan Isaacson <eitan@ascender.com>
* ldtputils.py: Use wnck library to get the window id list, rather than LTFX digwin.
Diffstat (limited to 'python')
-rw-r--r--python/ChangeLog5
-rw-r--r--python/ldtputils.py49
2 files changed, 23 insertions, 31 deletions
diff --git a/python/ChangeLog b/python/ChangeLog
index 51a59bb..54df2fe 100644
--- a/python/ChangeLog
+++ b/python/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-01 Eitan Isaacson <eitan@ascender.com>
+
+ * ldtputils.py: Use wnck library to get the window id list, rather
+ than LTFX digwin.
+
2009-02-09 Nagappan A <nagappan@gmail.com>
* ldtp.py: Log all verification results as warnings in log file
diff --git a/python/ldtputils.py b/python/ldtputils.py
index ce37ee1..26ac6d9 100644
--- a/python/ldtputils.py
+++ b/python/ldtputils.py
@@ -32,6 +32,7 @@ import os
import re
import sys
import time
+import wnck
import string
import commands
import tempfile
@@ -64,9 +65,9 @@ def tuplelist2list (lst):
return d
def getFullPath (path):
- if path[0] == "~":
+ if path [0] == "~":
path = os.path.expanduser (path)
- elif path[0] == ".":
+ elif path [0] == ".":
path = os.path.abspath (path)
return path
@@ -103,23 +104,6 @@ def imagecompare (imgfile1, imgfile2):
ldtp.log ('Input file does not exist', 'error')
raise ldtp.LdtpExecutionError ('Input file does not exist')
-def winname_to_winid (winname):
- fp = os.popen ('digwin -c')
- lines = fp.readlines ()
- fp.close ()
- winid = ''
- for i in lines:
- if re.search (winname, i, re.I):
- winid = i
- break
- if winid == '':
- ldtp.log ('%s - window doesnot exist' % winname, 'error')
- raise ldtp.LdtpExecutionError, '%s - window doesnot exist' % winname
- winid = string.split (winid, ' ')[0]
- winid = string.split (winid, '(')[1]
- winid = string.split (winid, ')')[0]
- return winid
-
def imagecapture (winName = None, outFile = None, resolution1 = None,
resolution2 = None, x = 0, y = 0):
# winname == None, let us capture the entire screen
@@ -127,15 +111,15 @@ def imagecapture (winName = None, outFile = None, resolution1 = None,
# /tmp and it will be returned
winid = None
if winName:
- status = commands.getstatusoutput ('which digwin')
- if status [0] != 0:
- ldtp.log ('To capture invidual window, you need to install digwin of LTFX',
- 'error')
- raise ldtp.LdtpExecutionError ('To capture invidual window,' + \
- ' you need to install digwin of LTFX')
- else:
- winid = winname_to_winid (winName)
- winid = '0x' + winid
+ screen = wnck.screen_get_default()
+ # Process pending gtk+ events so that wnck can find out about
+ # existing windows.
+ while gtk.events_pending():
+ gtk.main_iteration()
+ for window in screen.get_windows():
+ if winName == window.get_name():
+ winid = window.get_xid()
+ break
if outFile == None:
fp = tempfile.NamedTemporaryFile ()
tmpFile = fp.name + '.png'
@@ -147,10 +131,13 @@ def imagecapture (winName = None, outFile = None, resolution1 = None,
# Based on http://ubuntuforums.org/showthread.php?t=448160
window = gtk.gdk.get_default_root_window ()
size = window.get_size ()
- pb = gtk.gdk.Pixbuf (gtk.gdk.COLORSPACE_RGB,
- False, 8, size [0], size [1])
+ pb = gtk.gdk.Pixbuf (gtk.gdk.COLORSPACE_RGB, False, 8,
+ resolution1 or size [0],
+ resolution2 or size [1])
pb = pb.get_from_drawable (window, window.get_colormap (),
- 0, 0, 0, 0, size [0], size [1])
+ x, y, 0, 0,
+ resolution1 or size [0],
+ resolution2 or size [1])
if pb:
pb.save (tmpFile, "png")
# based on http://faq.pygtk.org/index.py?req=show&file=faq08.004.htp