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

Unified Diff: client/common_lib/sys_power.py

Issue 3516004: Exported utility functions for RTC and system sleep (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/common_lib/rtc.py ('k') | client/site_tests/power_Resume/power_Resume.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/sys_power.py
diff --git a/client/common_lib/sys_power.py b/client/common_lib/sys_power.py
new file mode 100644
index 0000000000000000000000000000000000000000..3ddcfee237b217f93dfc04e85c0bd6a497f0222d
--- /dev/null
+++ b/client/common_lib/sys_power.py
@@ -0,0 +1,32 @@
+import os
+
+
+def set_state(state):
+ """
+ Set the system power state to 'state'.
+ """
+ file('/sys/power/state', 'w').write("%s\n" % state)
+
+
+def suspend_to_ram():
+ """
+ Suspend the system to RAM (S3)
+ """
+ if os.path.exists('/usr/bin/powerd_suspend'):
+ os.system('/usr/bin/powerd_suspend')
+ else:
+ set_power_state('mem')
+
+
+def suspend_to_disk():
+ """
+ Suspend the system to disk (S4)
+ """
+ set_power_state('disk')
+
+def standby():
+ """
+ Power-on suspend (S1)
+ """
+ set_power_state('standby')
+
« no previous file with comments | « client/common_lib/rtc.py ('k') | client/site_tests/power_Resume/power_Resume.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698