-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsystem_functions.py
99 lines (84 loc) · 3.7 KB
/
system_functions.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/python3.7
###############################################################################
# Copyright (C) 2019 Eric Craw, KF7EEL <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
###############################################################################
# Version "1.2.1", by Eric, KF7EEL
# System Functions.
# https://github.com/kf7eel/shark-py-sms
# Feel free to modify and improve.
# Simple commands that do not require filtering
def initialize():
import time, os
from core import sms_type, sms_format, sms_source, sms_message, sms_modem
global sms_type, sms_format, sms_source, sms_message, sms_modem
# Send user system uptime
def uptime():
import time, os, core
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
print('Getting uptime...')
uptime = os.popen('uptime').read()
reply_sms(str(uptime))
# Replies to user by sending what was received
def echo():
import time, os, core
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
reply_sms(sms_message)
print("Echoing SMS")
# Return current time
def time():
import time, os, core
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
print('Getting time...')
current_time = time.strftime('%H:%M %A %B %d, %Y - Timezone: %z')
reply_sms(current_time)
def ping():
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
import time, os, core
print("Received ping...")
time.sleep(0.5)
print("Pong")
reply_sms('Pong '+time.strftime('%H:%M:%S - %m/%d/%Y'))
def reply_dmr_id():
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
import time, os, core
print('DMR ID: '+ sms_source)
reply_sms('Your DMR ID is ' + sms_source)
def command_help():
from core import reply_sms, sms_type, sms_format, sms_source, sms_message, sms_modem
import time, os, core
print('\n' + "--------------------------------------" + '\n')
print('Here are the available commands: ')
print('\n')
print('HELP - prints current message')
print('ECHO - replies eniter message back to user')
print('TIME - current local time')
print('UPTIME - uptime of host system')
print('PING - replies with pong')
print('ID - returns your DMR ID')
print('If "TO-" and "@" are in message, will send email to address.')
print('\n' + "--------------------------------------" + '\n')
reply_sms('1 of 4. All commands are in CAPS. ECHO - replies entier message back to user.')
reply_sms('2 of 4. TIME - current local time. UPTIME - uptime of host system.')
reply_sms('3 of 4. PING - replies with pong. ID - returns your DMR ID.')
reply_sms(' 4 of 4. If "TO-" and "@" are in message, will send email to address')
def send_dmr_to_aprs_mapped():
import time, os, core
from core import dmr_to_aprs_send
try:
dmr_to_aprs_send('TEST', 'This is a test')
except:
print('execute aprs_send here')