gui.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 yaml
  33. # add the source dir to the path, python finds the beewatch module.
  34. sys.path.insert(0,"src")
  35. # My Libraries
  36. import beewatch
  37. import beewatch.gui
  38. import digilib.gui
  39. import digilib.misc
  40. lgui = logging.getLogger(__name__+".gui")
  41. parser = argparse.ArgumentParser(
  42. # usage="use this to play",
  43. description="BeeWatch Client",
  44. )
  45. parser.add_argument(
  46. "host",
  47. type=str,
  48. help="hostname/ip address/filename (only if --use-file was specified)"
  49. )
  50. parser.add_argument(
  51. "port",
  52. type=int,
  53. default=8054,
  54. nargs="?",
  55. help="the port on wich the client will connect to. ignored if --use-file \
  56. is given"
  57. )
  58. parser.add_argument(
  59. "-d","--debug",
  60. default=False,
  61. action="store_true",
  62. help="enables logging"
  63. )
  64. group_af_family = parser.add_mutually_exclusive_group(required=True)
  65. group_af_family.add_argument(
  66. "-u","--af-unix",
  67. dest="af_family",
  68. # default=False,
  69. action="store_const",
  70. const="AF_UNIX",
  71. help="""use an AF_UNIX socket (a file). can't be used in combination with
  72. --af-inet."""
  73. # " will be used \
  74. # instead of an AF_INET socket (hostname/ip address + port)."
  75. )
  76. group_af_family.add_argument(
  77. "-i","--af_inet",
  78. default="AF_INET",
  79. dest="af_family",
  80. action="store_const",
  81. const="AF_INET",
  82. help="""use an AF_INET socket (hostname/ip address + port). can't be used
  83. with --af-unix"""
  84. )
  85. args = parser.parse_args()
  86. if args.debug:
  87. digilib.misc.load_files("config/logging.yaml",logging.config.dictConfig)
  88. win = beewatch.gui.BeeWindow(
  89. host=args.host,
  90. port=args.port,
  91. af_family=args.af_family
  92. )
  93. win.start()
  94. #