Fix setting of title for bookmarks (not items)
[panucci.git] / bin / panucci
blobad764174bb1994b16451bf65bf751de6dfbbe6eb
1 #!/usr/bin/env python
3 # This file is part of Panucci.
4 # Copyright (c) 2008-2009 The Panucci Audiobook and Podcast Player Project
6 # Panucci 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.
11 # Panucci 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.
16 # You should have received a copy of the GNU General Public License
17 # along with Panucci. If not, see <http://www.gnu.org/licenses/>.
20 app_version = '0.3'
22 import dbus
23 import dbus.glib
24 import logging
25 import os.path
26 import sys
27 from optparse import OptionParser
29 _ = lambda s: s
31 usage = 'usage: %prog [options] FILE'
32 parser = OptionParser(usage=usage, version='%prog ' + app_version)
33 parser.add_option('-q', '--queue', action='store', type='string',
34 dest='queue_filename', help='Add FILE to the queue', metavar='FILE')
35 parser.add_option('-d', '--debug', action='store_true', default=False,
36 dest='debug', help='Enable verbose logging')
37 opts, args = parser.parse_args()
39 if len(args) > 1 or ( opts.queue_filename and len(args) ):
40 parser.print_help()
41 sys.exit(1)
43 local_module_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', 'src')
44 if os.path.isdir(local_module_dir):
45 sys.path.append(local_module_dir)
47 from panucci import util
48 filepath = util.build_full_path(args[0] if len(args) else opts.queue_filename)
50 session_bus = dbus.SessionBus()
51 try:
52 remote_object = session_bus.get_object(
53 'org.panucci.panucciInterface', '/panucciInterface' )
54 print _('Found panucci instance already running, will try to use it...')
55 except dbus.exceptions.DBusException:
56 remote_object = None
58 if remote_object is None:
59 from panucci import panucci
60 log_level = logging.DEBUG if opts.debug else logging.ERROR
61 logging.basicConfig(level=log_level)
62 panucci.app_version = app_version
63 panucci.run( filename=filepath )
64 else:
65 if filepath is not None:
66 if opts.queue_filename is not None:
67 remote_object.queue_file( filepath )
68 else:
69 remote_object.play_file( filepath )
71 remote_object.show_main_window()