Add a --debug switch on the command line
[panucci.git] / bin / panucci
blob230bcbef7f0c6f5f1dec276cee58271892871dd5
1 #!/usr/bin/env python
3 import dbus
4 import dbus.glib
5 import os.path
6 import sys
8 session_bus = dbus.SessionBus()
10 local_module_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', 'src')
11 if os.path.isdir(local_module_dir):
12 sys.path.append(local_module_dir)
14 if os.path.exists(sys.argv[-1]) and len(sys.argv) > 1:
15 filename = sys.argv[-1]
16 else:
17 filename = None
19 try:
20 remote_object = session_bus.get_object('org.panucci', '/player')
21 print 'Found panucci instance already running, will try to use it...'
22 except dbus.exceptions.DBusException:
23 remote_object = None
25 if remote_object is None:
26 from panucci import panucci
27 # This could eventually be made fancy with optparse
28 debug = '--debug' in sys.argv
29 panucci.run(filename=filename, debug=debug)
30 else:
31 if filename is None:
32 remote_object.show_main_window(dbus_interface='org.panucci.interface')
33 else:
34 remote_object.play_file(filename, dbus_interface='org.panucci.interface')