m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

6 months ago
  1. # -*- coding: utf-8 -*-
  2. #*****************************************************************************
  3. # Copyright (C) 2006 Jorgen Stenarson. <jorgen.stenarson@bostream.nu>
  4. #
  5. # Distributed under the terms of the BSD License. The full license is in
  6. # the file COPYING, distributed as part of this software.
  7. #*****************************************************************************
  8. from __future__ import print_function, unicode_literals, absolute_import
  9. import logging
  10. import logging.handlers
  11. import struct, socket
  12. from pyreadline.unicode_helper import ensure_unicode
  13. try:
  14. import msvcrt
  15. except ImportError:
  16. msvcrt = None
  17. print("problem")
  18. port = logging.handlers.DEFAULT_TCP_LOGGING_PORT
  19. host = 'localhost'
  20. def check_key():
  21. if msvcrt is None:
  22. return False
  23. else:
  24. if msvcrt.kbhit():
  25. q = ensure_unicode(msvcrt.getch())
  26. return q
  27. return ""
  28. singleline=False
  29. def main():
  30. print("Starting TCP logserver on port:", port)
  31. print("Press q to quit logserver", port)
  32. print("Press c to clear screen", port)
  33. s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  34. s.bind(("", port))
  35. s.settimeout(1)
  36. while 1:
  37. try:
  38. data, addr = s.recvfrom(100000)
  39. print(data, end="")
  40. except socket.timeout:
  41. key = check_key().lower()
  42. if "q" == key:
  43. print("Quitting logserver")
  44. break
  45. elif "c" == key:
  46. print("\n" * 100)
  47. if __name__ == "__main__":
  48. main()