Nagios Plugins
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

z_server.py 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import config
  2. import devdi.devices as devices
  3. import logging
  4. import mqtt
  5. import report
  6. import z_protocol
  7. import socket_protocol
  8. import tcp_socket
  9. import time
  10. logger = logging.getLogger(config.APP_NAME)
  11. if __name__ == "__main__":
  12. #
  13. # Logging
  14. #
  15. if config.DEBUG:
  16. report.appLoggingConfigure(None, 'stdout', ((config.APP_NAME, logging.DEBUG), ),
  17. target_level=logging.WARNING, fmt=report.SHORT_FMT, host='localhost', port=19996)
  18. else:
  19. report.stdoutLoggingConfigure(((config.APP_NAME, config.LOGLEVEL), ), report.SHORT_FMT)
  20. #
  21. # MQTT Client
  22. #
  23. mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
  24. password=config.MQTT_PASSWORD, name=config.APP_NAME)
  25. #
  26. # Smarthome physical Devices
  27. #
  28. pd = devices.physical_devices(mc)
  29. #
  30. # Socket Protocol
  31. #
  32. s = tcp_socket.tcp_server_stp('127.0.0.1', config.SOCK_PROT_PORT)
  33. sp = z_protocol.server(s, channel_name='example_server', devices=pd)
  34. while (True):
  35. time.sleep(5)