/azucar.py

https://github.com/lesthack/azucar · Python · 81 lines · 52 code · 11 blank · 18 comment · 15 complexity · b503e7607eb5e1c1d0400b85a3fbb546 MD5 · raw file

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # main.py
  5. # Copyright (C) Jorge Luis Hernandez 2011 <lesthack@gmail.com>
  6. #
  7. # xmms2me is free software: you can redistribute it and/or modify it
  8. # under the terms of the GNU General Public License as published by the
  9. # Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # xmms2me is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. # See the GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program. If not, see <http://www.gnu.org/licenses/>.
  19. import sys
  20. import os
  21. import gobject
  22. import gtk
  23. try:
  24. __file__
  25. except NameError:
  26. pass
  27. else:
  28. libdir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'src'))
  29. sys.path.insert(0, libdir)
  30. from player import player
  31. try:
  32. import gtk
  33. except ImportError:
  34. sys.exit("pygtk not found.")
  35. try:
  36. import keybinder
  37. except:
  38. sys.exit("python-keybinder not found.")
  39. try:
  40. import xmmsclient
  41. import xmmsclient.glib
  42. except ImportError:
  43. sys.exit("xmmsclient not found.")
  44. ml = gobject.MainLoop(None, False)
  45. xmms = xmmsclient.XMMS("azucar")
  46. try:
  47. xmms.connect(os.getenv("XMMS_PATH"))
  48. status = True
  49. except IOError, detail:
  50. status = False
  51. if not status:
  52. try:
  53. os.system("xmms2-launcher")
  54. xmms.connect(os.getenv("XMMS_PATH"))
  55. except:
  56. sys.exit("xmms2 server not found")
  57. try:
  58. import logging
  59. except ImportError:
  60. sys.exit("loggin not found")
  61. def main():
  62. conn = xmmsclient.glib.GLibConnector(xmms)
  63. app = player(xmms)
  64. app.window.show()
  65. gtk.gdk.threads_init()
  66. gtk.gdk.threads_enter()
  67. gtk.main()
  68. gtk.gdk.threads_leave()
  69. if __name__ == "__main__":
  70. sys.exit(main())