gui.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/usr/bin/env python3.5
  2. # Copyright 2017 Digital
  3. #
  4. # This file is part of BeeWatch.
  5. #
  6. # BeeWatch is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # BeeWatch is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with BeeWatch. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. ## Imports
  20. # Python Libraries
  21. import argparse
  22. import gi
  23. gi.require_version('Gtk', '3.0')
  24. from gi.repository import Gtk
  25. from gi.repository import Gdk
  26. import logging
  27. import random
  28. import string
  29. import sys
  30. import time
  31. import traceback
  32. import mylibnetwork
  33. import yaml
  34. # My Libraries
  35. import beewatch
  36. import beewatch.gui
  37. import digilib.gui
  38. import digilib.misc
  39. lgui = logging.getLogger(__name__+".gui")
  40. parser = argparse.ArgumentParser(
  41. # usage="use this to play",
  42. description="BeeWatch Client",
  43. )
  44. parser.add_argument(
  45. "host",
  46. type=str,
  47. help="hostname/ip address/filename (only if --use-file was specified)"
  48. )
  49. parser.add_argument(
  50. "port",
  51. type=int,
  52. default=8054,
  53. nargs="?",
  54. help="the port on wich the client will connect to. ignored if --use-file \
  55. is given"
  56. )
  57. parser.add_argument(
  58. "-d","--debug",
  59. default=False,
  60. action="store_true",
  61. help="enables logging"
  62. )
  63. group_af_family = parser.add_mutually_exclusive_group(required=True)
  64. group_af_family.add_argument(
  65. "-u","--af-unix",
  66. dest="af_family",
  67. # default=False,
  68. action="store_const",
  69. const="AF_UNIX",
  70. help="""use an AF_UNIX socket (a file). can't be used in combination with
  71. --af-inet."""
  72. # " will be used \
  73. # instead of an AF_INET socket (hostname/ip address + port)."
  74. )
  75. group_af_family.add_argument(
  76. "-i","--af_inet",
  77. default="AF_INET",
  78. dest="af_family",
  79. action="store_const",
  80. const="AF_INET",
  81. help="""use an AF_INET socket (hostname/ip address + port). can't be used
  82. with --af-unix"""
  83. )
  84. args = parser.parse_args()
  85. if args.debug:
  86. digilib.misc.load_files("config/logging.yaml",logging.config.dictConfig)
  87. win = beewatch.gui.BeeWindow(
  88. host=args.host,
  89. port=args.port,
  90. af_family=args.af_family
  91. )
  92. win.start()
  93. #