3 new revisions:
Revision: a4bc4b35887f
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 00:52:22 2012
Log: Screenshot lib: use robot.api.logger for logging
http://code.google.com/p/robotframework/source/detail?r=a4bc4b35887f
Revision: 2ba3bd0ccc0a
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 01:27:29 2012
Log: removed extra whitespace from docstring
http://code.google.com/p/robotframework/source/detail?r=2ba3bd0ccc0a
Revision: 827878d5eb03
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 01:39:21 2012
Log: Screenshot: Handle exceptions in taking screenshot with IPY
gracefully...
http://code.google.com/p/robotframework/source/detail?r=827878d5eb03
==============================================================================
Revision: a4bc4b35887f
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 00:52:22 2012
Log: Screenshot lib: use robot.api.logger for logging
http://code.google.com/p/robotframework/source/detail?r=a4bc4b35887f
Modified:
/src/robot/libraries/Screenshot.py
=======================================
--- /src/robot/libraries/Screenshot.py Wed Sep 12 15:51:18 2012
+++ /src/robot/libraries/Screenshot.py Fri Sep 14 00:52:22 2012
@@ -39,9 +39,10 @@
except ImportError:
ImageGrab = None
-from robot.version import get_version
from robot import utils
+from robot.api import logger
from robot.libraries.BuiltIn import BuiltIn
+from robot.version import get_version
class Screenshot(object):
@@ -226,8 +227,8 @@
def _screenshot_to_file(self, path):
path = utils.abspath(self._norm_path(path))
self._validate_screenshot_path(path)
- print '*DEBUG* Using %s modules for taking screenshot.' \
- % self._screenshot_taker.module
+ logger.debug('Using %s modules for taking screenshot.'
+ % self._screenshot_taker.module)
self._screenshot_taker(path)
return path
@@ -249,12 +250,13 @@
def _embed_screenshot(self, path, width):
link = utils.get_link_path(path, self._log_dir)
- print '*HTML* <a href="%s"><img src="%s" width="%s"></a>' \
- % (link, link, width)
+ logger.info('<a href="%s"><img src="%s" width="%s"></a>'
+ % (link, link, width), html=True)
def _link_screenshot(self, path):
link = utils.get_link_path(path, self._log_dir)
- print "*HTML* Screenshot saved to '<a href=\"%s\">%s</a>'." %
(link, path)
+ logger.info("Screenshot saved to '<a href=\"%s\">%s</a>'."
+ % (link, path), html=True)
class ScreenshotTaker(object):
==============================================================================
Revision: 2ba3bd0ccc0a
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 01:27:29 2012
Log: removed extra whitespace from docstring
http://code.google.com/p/robotframework/source/detail?r=2ba3bd0ccc0a
Modified:
/src/robot/utils/robotpath.py
=======================================
--- /src/robot/utils/robotpath.py Tue Mar 13 06:43:27 2012
+++ /src/robot/utils/robotpath.py Fri Sep 14 01:27:29 2012
@@ -45,8 +45,7 @@
1) Converts non-Unicode paths to Unicode using file system encoding
2) At least Jython 2.5.1 on Windows returns wrong path with 'c:'.
3) Python until 2.6.5 and at least Jython 2.5.1 don't handle non-ASCII
- characters in the working directory:
http://bugs.python.org/issue3426
-
+ characters in the working directory:
http://bugs.python.org/issue3426
"""
if not isinstance(path, unicode):
path = decode_from_system(path)
==============================================================================
Revision: 827878d5eb03
Branch: default
Author: Pekka Klärck
Date: Fri Sep 14 01:39:21 2012
Log: Screenshot: Handle exceptions in taking screenshot with IPY
gracefully.
Update issue 1225
Added code to handle the exception. Now the error is reported as a warning.
I believe that's a better solution than failing the whole test, and that's
also more consistent with JVM giving us black images if there is no display.
http://code.google.com/p/robotframework/source/detail?r=827878d5eb03
Modified:
/src/robot/libraries/Screenshot.py
=======================================
--- /src/robot/libraries/Screenshot.py Fri Sep 14 00:52:22 2012
+++ /src/robot/libraries/Screenshot.py Fri Sep 14 01:39:21 2012
@@ -225,17 +225,23 @@
return self._screenshot_to_file(path)
def _screenshot_to_file(self, path):
- path = utils.abspath(self._norm_path(path))
- self._validate_screenshot_path(path)
+ path = self._validate_screenshot_path(path)
logger.debug('Using %s modules for taking screenshot.'
% self._screenshot_taker.module)
- self._screenshot_taker(path)
+ try:
+ self._screenshot_taker(path)
+ except:
+ logger.warn('Taking screenshot failed: %s\n'
+ 'Make sure tests are run with a physical or
virtual display.'
+ % utils.get_error_message())
return path
def _validate_screenshot_path(self, path):
+ path = utils.abspath(self._norm_path(path))
if not os.path.exists(os.path.dirname(path)):
- raise RuntimeError("Directory '%s' where to save the
screenshot does "
- "not exist" % os.path.dirname(path))
+ raise RuntimeError("Directory '%s' where to save the
screenshot "
+ "does not exist" % os.path.dirname(path))
+ return path
def _get_screenshot_path(self, basename, directory):
directory = self._norm_path(directory) if directory else
self._screenshot_dir
@@ -296,9 +302,11 @@
def _cli_screenshot(self, path):
bmp = Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height)
- g = Graphics.FromImage(bmp)
- g.CopyFromScreen(0, 0, 0, 0, bmp.Size)
- g.Dispose()
+ graphics = Graphics.FromImage(bmp)
+ try:
+ graphics.CopyFromScreen(0, 0, 0, 0, bmp.Size)
+ finally:
+ graphics.Dispose()
bmp.Save(path, Imaging.ImageFormat.Jpeg)
def _wx_screenshot(self, path):