blob: c771638601fd27c6ae3f13e9626250871f525a26 [file] [log] [blame]
# Copyright 2018 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
'''Login with test account and display chart file using telemetry.'''
# This sets up import paths for autotest.
import common
import argparse
import contextlib
import logging
import os
import signal
import time
from autotest_lib.client.bin import utils
from autotest_lib.client.common_lib.cros import chrome
from autotest_lib.client.cros.input_playback import keyboard
def set_display_brightness(display_level):
SET_BRIGHTNESS_CMD = 'backlight_tool --set_brightness_percent=%s'
original_display_level = utils.system_output(
'backlight_tool --get_brightness_percent')'Save original display brightness %r '
'and fix display brightness to %r', original_display_level,
utils.system(SET_BRIGHTNESS_CMD % display_level)
utils.system('stop powerd', ignore_status=True)
yield'Restore display brightness %r', original_display_level)
utils.system('start powerd', ignore_status=True)
utils.system(SET_BRIGHTNESS_CMD % original_display_level)
def display(filepath):
"""Display chart with filepath on device by using telemetry."""
assert os.path.isfile(filepath), 'filepath %r not found.' % filepath
filepath = os.path.abspath(filepath)'Setup SIGINT listener for stop displaying.')
displaying = [True]
def handler(signum, frame):
"""Wait signal to clear running flag."""
if signum == signal.SIGINT:
signal.signal(signal.SIGINT, handler)
with chrome.Chrome() as cr, set_display_brightness(DISPLAY_LEVEL):'Display chart file of path %r.', filepath)
tab = cr.browser.tabs[0]
tab.Navigate('file://' + filepath)'Set chart tab fullscreen.')
kb = keyboard.Keyboard()
while displaying:
if __name__ == '__main__':
argparser = argparse.ArgumentParser(
description='Display chart file on chrome by using telemetry.'
' Send SIGINT or keyboard interrupt to stop displaying.')
argparser.add_argument('filepath', help='Path of displayed chart file.')
args = argparser.parse_args()