gui.py 2.5 KB

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