| OLD | NEW |
| 1 #!/usr/bin/python |
| 2 |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. |
| 6 |
| 7 """Provides utility methods for controlling powerd in ChromiumOS. |
| 8 """ |
| 9 |
| 1 import os | 10 import os |
| 11 from autotest_lib.client.common_lib import utils |
| 2 | 12 |
| 13 SUSPEND_CMD='/usr/bin/powerd_suspend' |
| 3 | 14 |
| 4 def set_state(state): | 15 def set_state(state): |
| 5 """ | 16 """ |
| 6 Set the system power state to 'state'. | 17 Set the system power state to 'state'. |
| 7 """ | 18 """ |
| 8 file('/sys/power/state', 'w').write("%s\n" % state) | 19 file('/sys/power/state', 'w').write("%s\n" % state) |
| 9 | 20 |
| 10 | 21 |
| 11 def suspend_to_ram(): | 22 def suspend_to_ram(): |
| 12 """ | 23 """ |
| 13 Suspend the system to RAM (S3) | 24 Suspend the system to RAM (S3) |
| 14 """ | 25 """ |
| 15 if os.path.exists('/usr/bin/powerd_suspend'): | 26 if os.path.exists(SUSPEND_CMD): |
| 16 os.system('/usr/bin/powerd_suspend') | 27 utils.system(SUSPEND_CMD) |
| 17 else: | 28 else: |
| 18 set_power_state('mem') | 29 set_power_state('mem') |
| 19 | 30 |
| 20 | 31 |
| 21 def suspend_to_disk(): | 32 def suspend_to_disk(): |
| 22 """ | 33 """ |
| 23 Suspend the system to disk (S4) | 34 Suspend the system to disk (S4) |
| 24 """ | 35 """ |
| 25 set_power_state('disk') | 36 set_power_state('disk') |
| 26 | 37 |
| 27 def standby(): | 38 def standby(): |
| 28 """ | 39 """ |
| 29 Power-on suspend (S1) | 40 Power-on suspend (S1) |
| 30 """ | 41 """ |
| 31 set_power_state('standby') | 42 set_power_state('standby') |
| 32 | 43 |
| OLD | NEW |