Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: client/common_lib/rtc.py

Issue 3412036: Basis for cryptohome+power_SuspendResume stress test. (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: tweaks to test params Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can
3 # be # found in the LICENSE file.
4
5 """Provides utility methods for the Real Time Clock device.
6 """
7
1 import errno 8 import errno
2 9
10
3 def get_seconds(utc=True): 11 def get_seconds(utc=True):
4 """ 12 """
5 Read the current time out of the RTC 13 Read the current time out of the RTC
6 """ 14 """
7 return int(file('/sys/class/rtc/rtc0/since_epoch').readline()) 15 return int(file('/sys/class/rtc/rtc0/since_epoch').readline())
8 16
9 17
10 def write_wake_alarm(alarm_time): 18 def write_wake_alarm(alarm_time):
11 """ 19 """
12 Write a value to the wake alarm 20 Write a value to the wake alarm
13 """ 21 """
14 f = file('/sys/class/rtc/rtc0/wakealarm', 'w') 22 f = file('/sys/class/rtc/rtc0/wakealarm', 'w')
15 f.write('%s\n' % str(alarm_time)) 23 f.write('%s\n' % str(alarm_time))
16 f.close() 24 f.close()
17 25
18 def set_wake_alarm(alarm_time): 26 def set_wake_alarm(alarm_time):
19 """ 27 """
20 Set the hardware RTC-based wake alarm to 'alarm_time'. 28 Set the hardware RTC-based wake alarm to 'alarm_time'.
21 """ 29 """
22 try: 30 try:
23 write_wake_alarm(alarm_time) 31 write_wake_alarm(alarm_time)
24 except IOError as (errnum, strerror): 32 except IOError as (errnum, strerror):
25 if errnum != errno.EBUSY: 33 if errnum != errno.EBUSY:
26 raise 34 raise
27 write_wake_alarm('clear') 35 write_wake_alarm('clear')
28 write_wake_alarm(alarm_time) 36 write_wake_alarm(alarm_time)
29 37
OLDNEW
« no previous file with comments | « no previous file | client/common_lib/sys_power.py » ('j') | client/site_tests/platform_CryptohomeFio/platform_CryptohomeFio.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698