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

Unified Diff: server/site_system_suspend.py

Issue 3471015: Suspend- function for site_wifitest (Closed) Base URL: ssh://gitrw.chromium.org/autotest.git
Patch Set: Fixed linespacing 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 | « no previous file | server/site_wifitest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: server/site_system_suspend.py
diff --git a/server/site_system_suspend.py b/server/site_system_suspend.py
new file mode 100644
index 0000000000000000000000000000000000000000..cf2d058ed149efafcaa04b9079b112df2863707f
--- /dev/null
+++ b/server/site_system_suspend.py
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+"""Tell system to suspend, and resume some number of seconds later.
+
+Use the RTC to generate a wakeup some number of seconds into the
+future, then go to sleep. Note that this module is not aware of
+the actual time when the system will suspend. Depending on other
+system activities, there may be several seconds between when this
+script runs until when the system actually goes to sleep. In fact
+that time may be after the wakeup has been scheduled, and the
+system may never wake up! It is up to the caller to make prudent
+decisions as to upper bound of delay before going to sleep, and to
+choose a wakeup time greater than this interval.
+"""
+
+import os, re, subprocess, sys
+import rtc, sys_power
+
+time_to_sleep = 30
+if len(sys.argv) > 1:
+ time_to_sleep = int(sys.argv[1])
+
+if len(sys.argv) > 2:
+ after_command = ' '.join(sys.argv[2:])
+else:
+ after_command = None
+
+rtc.set_wake_alarm(rtc.get_seconds() + time_to_sleep)
+sys_power.suspend_to_ram()
+
+if after_command:
+ os.system(after_command)
« no previous file with comments | « no previous file | server/site_wifitest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698