-
Notifications
You must be signed in to change notification settings - Fork 13
/
template.py
48 lines (40 loc) · 1.02 KB
/
template.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Template for user programs for smolOS
(c)2023/07 Krzysztof Krystian Jankowski
Homepage: https://smol.p1x.in/os/
"""
import time
# Define constants
MESSAGE_INTERVAL = 10
class Template:
"""
A template for user programs for smolOS.
"""
def __init__(self):
"""
Initialize the Template object.
"""
self.name = "Template Program"
self.msg("Program initialized")
def loop(self):
"""
Loop where the main logic of the program goes.
"""
t = 0
self.msg("Press Ctrl+C to quit.\n")
while True:
try:
if t % MESSAGE_INTERVAL == 0:
self.msg(f"Hello... {t} second in!")
time.sleep(1)
t += 1
except KeyboardInterrupt:
break
def msg(self, message):
"""
Print a message from the program.
"""
print(f"{self.name} : {message}")
if __name__ == '__main__':
template = Template()
template.loop()