fix: ensure mobile location check is committed

main
swanie98635 2 months ago
parent 40adc20281
commit 743bd66753

@ -31,12 +31,26 @@ class AudioHandler:
raise e
def play_on_nodes(self, filepath: str, nodes: List[str]):
# Asterisk uses file path WITHOUT extension usually for play commands.
# KD5FMU script uses absolute path successfully (e.g. /tmp/current-time)
# Asterisk usually wants paths relative to the sounds directory if they are inside it.
# e.g. "rpt localplay <node> asl3_wx_announce/report"
path_no_ext = os.path.splitext(filepath)[0]
# Standard sounds root
sounds_root = "/var/lib/asterisk/sounds/"
if path_no_ext.startswith(sounds_root):
# Strip root: /var/lib/asterisk/sounds/dir/file -> dir/file
play_path = path_no_ext[len(sounds_root):]
# Ensure no leading slash
if play_path.startswith("/"):
play_path = play_path[1:]
else:
# Outside standard dir, use absolute
play_path = path_no_ext
for node in nodes:
asterisk_cmd = f'asterisk -rx "rpt localplay {node} {path_no_ext}"'
asterisk_cmd = f'asterisk -rx "rpt localplay {node} {play_path}"'
self.logger.info(f"Playing on {node}: {asterisk_cmd}")
try:
subprocess.run(asterisk_cmd, shell=True, check=True)

@ -0,0 +1,5 @@
https://github.com/KD5FMU/Play-Audio-Locally
https://github.com/KD5FMU/Time-Weather-Announce
https://github.com/KD5FMU/Play-Audio-ASL3-Node
https://github.com/KD5FMU/Convert-Audio-File-to-ulaw
https://github.com/KD5FMU/Saytime-Weather-FIX-for-HamVoip

Binary file not shown.
Loading…
Cancel
Save

Powered by TurnKey Linux.