Skip to content

Commit cb5afb5

Browse files
Merge pull request #49 from Moduland/sync
Sync
2 parents e37d254 + 89fed71 commit cb5afb5

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Changed
9+
- `sync` parameter added to `wakeup` function
810
## [0.45] - 2020-12-26
911
### Added
1012
- `__main__.py`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ orangetool.restart() # restart system
237237

238238
#5- wakeup
239239

240-
orangetool.wakeup(day=1,hour=0,minute=1) # set rtc wakeuptime
240+
orangetool.wakeup(day=1,hour=0,minute=1,sync=True) # set rtc wakeuptime
241241

242242
#6- get_temp
243243

orangetool/orangetool_ram.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .orangetool_params import GENERAL_ERROR_MESSAGE
55
from .orangetool_utils import convert_bytes
66

7+
78
def ram_total(convert=True):
89
"""
910
Return total ram of board.

orangetool/orangetool_storage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ def unmount_all(debug=False):
104104
print(str(e))
105105
return GENERAL_ERROR_MESSAGE
106106

107+
107108
def mount(device_name, mount_address=None, debug=False):
108109
"""
109110
Mount memory devices by addresses.

orangetool/orangetool_system.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def get_temp(zone=0, debug=False):
5454
print(str(e))
5555
return GENERAL_ERROR_MESSAGE
5656

57-
def time_control(mode="uptime",debug=False):
57+
58+
def time_control(mode="uptime", debug=False):
5859
"""
5960
Return system time.
6061
@@ -65,7 +66,7 @@ def time_control(mode="uptime",debug=False):
6566
:return: system time as string
6667
"""
6768
index = 0
68-
if mode in ["idle","idletime"]:
69+
if mode in ["idle", "idletime"]:
6970
index = 1
7071
try:
7172
command = open("/proc/uptime")
@@ -76,6 +77,7 @@ def time_control(mode="uptime",debug=False):
7677
print(str(e))
7778
return GENERAL_ERROR_MESSAGE
7879

80+
7981
def uptime(debug=False):
8082
"""
8183
Return system uptime.
@@ -84,7 +86,7 @@ def uptime(debug=False):
8486
:type debug:bool
8587
:return: system uptime as string
8688
"""
87-
return time_control(mode="uptime",debug=debug)
89+
return time_control(mode="uptime", debug=debug)
8890

8991

9092
def idletime(debug=False):
@@ -108,7 +110,7 @@ def version():
108110
tprint("v" + ORANGETOOL_VERSION, font="bulbhead")
109111

110112

111-
def wakeup(day=0, hour=0, minute=0, debug=False):
113+
def wakeup(day=0, hour=0, minute=0, sync=True, debug=False):
112114
"""
113115
Set wakeup time for kernel RTC (need sudo).
114116
@@ -118,11 +120,19 @@ def wakeup(day=0, hour=0, minute=0, debug=False):
118120
:type hour:int
119121
:param minute: minute for wakeup
120122
:type minute:int
123+
:param sync: RTC sync flag
124+
:type sync: bool
121125
:param debug: flag for using debug mode
122126
:type debug:bool
123127
:return: bool
124128
"""
125129
try:
130+
if sync:
131+
_ = sub.Popen(
132+
["hwclock","-w"],
133+
stderr=sub.PIPE,
134+
stdout=sub.PIPE,
135+
stdin=sub.PIPE)
126136
total_time = day * 24 * 60 + hour * 60 + minute
127137
epoch = time.time() + total_time * 60
128138
file = open("/sys/class/rtc/rtc0/wakealarm", "w")

orangetool/orangetool_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
if __name__ == "__main__":
66
version()
7-
check_update()
7+
check_update()

orangetool/orangetool_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Orangetool utils."""
33
import random
44

5+
56
def zero_insert(input_string):
67
"""
78
Get a string as input if input is one digit add a zero.
@@ -49,6 +50,7 @@ def random_generator(number):
4950
response += str(random.randint(0, 9))
5051
return response
5152

53+
5254
def convert_bytes(num):
5355
"""
5456
Convert num to idiomatic byte unit.

0 commit comments

Comments
 (0)