mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961108 - make dumpScreen always write to a file in MOZ_UPLOAD_DIR. r=ted,jmaher
This commit is contained in:
parent
075aa7c887
commit
a01bb87e19
@ -634,50 +634,8 @@ class Automation(object):
|
||||
return
|
||||
|
||||
self.haveDumpedScreen = True;
|
||||
automationutils.dumpScreen(utilityPath)
|
||||
|
||||
# Need to figure out what tool and whether it write to a file or stdout
|
||||
if self.UNIXISH:
|
||||
utility = [os.path.join(utilityPath, "screentopng")]
|
||||
imgoutput = 'stdout'
|
||||
elif self.IS_MAC:
|
||||
utility = ['/usr/sbin/screencapture', '-C', '-x', '-t', 'png']
|
||||
imgoutput = 'file'
|
||||
elif self.IS_WIN32:
|
||||
utility = [os.path.join(utilityPath, "screenshot.exe")]
|
||||
imgoutput = 'file'
|
||||
|
||||
# Run the capture correctly for the type of capture
|
||||
try:
|
||||
if imgoutput == 'file':
|
||||
tmpfd, imgfilename = tempfile.mkstemp(prefix='mozilla-test-fail_')
|
||||
os.close(tmpfd)
|
||||
dumper = self.Process(utility + [imgfilename])
|
||||
elif imgoutput == 'stdout':
|
||||
dumper = self.Process(utility, bufsize=-1,
|
||||
stdout=subprocess.PIPE, close_fds=True)
|
||||
except OSError, err:
|
||||
self.log.info("Failed to start %s for screenshot: %s",
|
||||
utility[0], err.strerror)
|
||||
return
|
||||
|
||||
# Check whether the capture utility ran successfully
|
||||
dumper_out, dumper_err = dumper.communicate()
|
||||
if dumper.returncode != 0:
|
||||
self.log.info("%s exited with code %d", utility, dumper.returncode)
|
||||
return
|
||||
|
||||
try:
|
||||
if imgoutput == 'stdout':
|
||||
image = dumper_out
|
||||
elif imgoutput == 'file':
|
||||
with open(imgfilename, 'rb') as imgfile:
|
||||
image = imgfile.read()
|
||||
except IOError, err:
|
||||
self.log.info("Failed to read image from %s", imgoutput)
|
||||
|
||||
import base64
|
||||
encoded = base64.b64encode(image)
|
||||
self.log.info("SCREENSHOT: data:image/png;base64,%s", encoded)
|
||||
|
||||
def killAndGetStack(self, processPID, utilityPath, debuggerInfo):
|
||||
"""Kill the process, preferrably in a way that gets us a stack trace.
|
||||
|
@ -484,58 +484,40 @@ def environment(xrePath, env=None, crashreporter=True, debugger=False, dmdPath=N
|
||||
|
||||
return env
|
||||
|
||||
|
||||
def dumpScreen(utilityPath):
|
||||
"""dumps the screen to the log file as a data URI"""
|
||||
"""dumps a screenshot of the entire screen to a directory specified by
|
||||
the MOZ_UPLOAD_DIR environment variable"""
|
||||
import mozfile
|
||||
|
||||
# Need to figure out what tool and whether it write to a file or stdout
|
||||
# Need to figure out which OS-dependent tool to use
|
||||
if mozinfo.isUnix:
|
||||
utility = [os.path.join(utilityPath, "screentopng")]
|
||||
imgoutput = 'stdout'
|
||||
elif mozinfo.isMac:
|
||||
utility = ['/usr/sbin/screencapture', '-C', '-x', '-t', 'png']
|
||||
imgoutput = 'file'
|
||||
elif mozinfo.isWin:
|
||||
utility = [os.path.join(utilityPath, "screenshot.exe")]
|
||||
imgoutput = 'file'
|
||||
else:
|
||||
log.warn("Unable to dump screen on platform '%s'", sys.platform)
|
||||
|
||||
# Run the capture correctly for the type of capture
|
||||
kwargs = {'stdout': subprocess.PIPE}
|
||||
if imgoutput == 'file':
|
||||
tmpfd, imgfilename = tempfile.mkstemp(prefix='mozilla-test-fail_')
|
||||
os.close(tmpfd)
|
||||
utility.append(imgfilename)
|
||||
elif imgoutput == 'stdout':
|
||||
kwargs.update(dict(bufsize=-1, close_fds=True))
|
||||
# Get dir where to write the screenshot file
|
||||
parent_dir = os.environ.get('MOZ_UPLOAD_DIR', None)
|
||||
if not parent_dir:
|
||||
log.info('Failed to retrieve MOZ_UPLOAD_DIR env var')
|
||||
return
|
||||
|
||||
# Run the capture
|
||||
try:
|
||||
dumper = subprocess.Popen(utility, **kwargs)
|
||||
with mozfile.NamedTemporaryFile(suffix='.png',
|
||||
prefix='mozilla-test-fail-screenshot_',
|
||||
dir=parent_dir,
|
||||
delete=False) as f:
|
||||
returncode = subprocess.call(utility + [f.name])
|
||||
except OSError, err:
|
||||
log.info("Failed to start %s for screenshot: %s",
|
||||
utility[0], err.strerror)
|
||||
return
|
||||
|
||||
# Check whether the capture utility ran successfully
|
||||
stdout, _ = dumper.communicate()
|
||||
returncode = dumper.poll()
|
||||
if returncode:
|
||||
if returncode != 0:
|
||||
log.info("%s exited with code %d", utility, returncode)
|
||||
return
|
||||
|
||||
try:
|
||||
if imgoutput == 'stdout':
|
||||
image = stdout
|
||||
elif imgoutput == 'file':
|
||||
with open(imgfilename, 'rb') as imgfile:
|
||||
image = imgfile.read()
|
||||
except IOError, err:
|
||||
log.info("Failed to read image from %s", imgoutput)
|
||||
|
||||
encoded = base64.b64encode(image)
|
||||
uri = "data:image/png;base64,%s" % encoded
|
||||
log.info("SCREENSHOT: %s", uri)
|
||||
return uri
|
||||
|
||||
class ShutdownLeaks(object):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user