2018-04-20 14:21:59 +01:00
|
|
|
# Copyright 2018 ARM Limited
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2019-12-03 16:46:26 +00:00
|
|
|
from devlib.collector.screencapture import ScreenCaptureCollector
|
2018-04-20 14:21:59 +01:00
|
|
|
|
|
|
|
from wa import Instrument, Parameter
|
|
|
|
|
|
|
|
|
|
|
|
class ScreenCaptureInstrument(Instrument):
|
|
|
|
|
|
|
|
name = 'screen_capture'
|
|
|
|
description = """
|
|
|
|
A simple instrument which captures the screen on the target devices with a user-specified period.
|
|
|
|
|
|
|
|
Please note that if a too short period is specified, then this
|
|
|
|
instrument will capture the screen as fast as possible, rather
|
|
|
|
than at the specified periodicity.
|
|
|
|
"""
|
|
|
|
|
|
|
|
parameters = [
|
|
|
|
Parameter('period', kind=int, default=10,
|
|
|
|
description="""
|
|
|
|
Period (in seconds) at which to capture the screen on the target.
|
|
|
|
"""),
|
|
|
|
]
|
|
|
|
|
|
|
|
def __init__(self, target, **kwargs):
|
|
|
|
super(ScreenCaptureInstrument, self).__init__(target, **kwargs)
|
|
|
|
self.collector = None
|
|
|
|
|
|
|
|
def setup(self, context):
|
|
|
|
# We need to create a directory for the captured screenshots
|
|
|
|
output_path = os.path.join(context.output_directory, "screen-capture")
|
|
|
|
os.mkdir(output_path)
|
|
|
|
self.collector = ScreenCaptureCollector(self.target,
|
|
|
|
self.period)
|
2019-12-03 16:46:26 +00:00
|
|
|
self.collector.set_output(output_path)
|
|
|
|
self.collector.reset()
|
2018-04-20 14:21:59 +01:00
|
|
|
|
2018-07-04 17:44:55 +01:00
|
|
|
def start(self, context): # pylint: disable=unused-argument
|
2018-04-20 14:21:59 +01:00
|
|
|
self.collector.start()
|
|
|
|
|
2018-07-04 17:44:55 +01:00
|
|
|
def stop(self, context): # pylint: disable=unused-argument
|
2018-04-20 14:21:59 +01:00
|
|
|
self.collector.stop()
|