@@ -54,7 +54,8 @@ def get_temp(zone=0, debug=False):
54
54
print (str (e ))
55
55
return GENERAL_ERROR_MESSAGE
56
56
57
- def time_control (mode = "uptime" ,debug = False ):
57
+
58
+ def time_control (mode = "uptime" , debug = False ):
58
59
"""
59
60
Return system time.
60
61
@@ -65,7 +66,7 @@ def time_control(mode="uptime",debug=False):
65
66
:return: system time as string
66
67
"""
67
68
index = 0
68
- if mode in ["idle" ,"idletime" ]:
69
+ if mode in ["idle" , "idletime" ]:
69
70
index = 1
70
71
try :
71
72
command = open ("/proc/uptime" )
@@ -76,6 +77,7 @@ def time_control(mode="uptime",debug=False):
76
77
print (str (e ))
77
78
return GENERAL_ERROR_MESSAGE
78
79
80
+
79
81
def uptime (debug = False ):
80
82
"""
81
83
Return system uptime.
@@ -84,7 +86,7 @@ def uptime(debug=False):
84
86
:type debug:bool
85
87
:return: system uptime as string
86
88
"""
87
- return time_control (mode = "uptime" ,debug = debug )
89
+ return time_control (mode = "uptime" , debug = debug )
88
90
89
91
90
92
def idletime (debug = False ):
@@ -108,7 +110,7 @@ def version():
108
110
tprint ("v" + ORANGETOOL_VERSION , font = "bulbhead" )
109
111
110
112
111
- def wakeup (day = 0 , hour = 0 , minute = 0 , debug = False ):
113
+ def wakeup (day = 0 , hour = 0 , minute = 0 , sync = True , debug = False ):
112
114
"""
113
115
Set wakeup time for kernel RTC (need sudo).
114
116
@@ -118,11 +120,19 @@ def wakeup(day=0, hour=0, minute=0, debug=False):
118
120
:type hour:int
119
121
:param minute: minute for wakeup
120
122
:type minute:int
123
+ :param sync: RTC sync flag
124
+ :type sync: bool
121
125
:param debug: flag for using debug mode
122
126
:type debug:bool
123
127
:return: bool
124
128
"""
125
129
try :
130
+ if sync :
131
+ _ = sub .Popen (
132
+ ["hwclock" ,"-w" ],
133
+ stderr = sub .PIPE ,
134
+ stdout = sub .PIPE ,
135
+ stdin = sub .PIPE )
126
136
total_time = day * 24 * 60 + hour * 60 + minute
127
137
epoch = time .time () + total_time * 60
128
138
file = open ("/sys/class/rtc/rtc0/wakealarm" , "w" )
0 commit comments