Guest User

Untitled

a guest
Nov 30th, 2025
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. GNU nano 8.4 /home/pi/dc_outgoing.py
  2. #!/usr/bin/env python3
  3. import sys
  4. import urllib.request
  5. import urllib.error
  6.  
  7. SERVICE_URL_BASE = "http://127.0.0.1:8765"
  8.  
  9.  
  10. def main():
  11. if len(sys.argv) < 2:
  12. print("Usage: dc_outgoing.py <extension>")
  13. sys.exit(1)
  14.  
  15. ext = sys.argv[1].strip()
  16. url = f"{SERVICE_URL_BASE}/call/{ext}"
  17. print(f"[WRAPPER] Requesting call for {ext} via {url}")
  18.  
  19. try:
  20. with urllib.request.urlopen(url, timeout=10) as resp:
  21. body = resp.read().decode("utf-8", errors="ignore")
  22. print(f"[WRAPPER] Service response: {resp.status} {body.strip()}")
  23. except urllib.error.URLError as e:
  24. print(f"[WRAPPER] Error contacting service: {e}")
  25. sys.exit(1)
  26.  
  27.  
  28. if __name__ == "__main__":
  29. main()
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment