6
SegPhault (Ryan Paul) - 05/29/2007
10
import sys, gtk, optparse, dbus, wnck, time
11
from os.path import join, dirname, exists, realpath, abspath
12
from dbus.mainloop.glib import DBusGMainLoop
13
from dbus import DBusException
15
from gettext import lgettext as _
16
if hasattr(gettext, 'bind_textdomain_codeset'):
17
gettext.bind_textdomain_codeset('gwibber','UTF-8')
18
gettext.textdomain('gwibber')
20
######################################################################
21
# Don't run again if we are already running
23
screen = wnck.screen_get_default()
24
while gtk.events_pending():
26
for w in screen.get_windows():
27
if w.get_application().get_name() == progname:
28
w.activate(int(time.time()))
29
w.move_to_workspace(screen.get_active_workspace())
32
######################################################################
35
LAUNCH_DIR = abspath(sys.path[0])
36
SOURCE_DIR = join(LAUNCH_DIR, "..", "gwibber")
38
DBusGMainLoop(set_as_default=True)
40
# If we were invoked from a Gwibber source directory add that as the
41
# preferred module path ...
42
if exists(join(SOURCE_DIR, "client.py")):
43
sys.path.insert(0, realpath(dirname(SOURCE_DIR)))
45
from gwibber.microblog.util import log
46
log.logger.name = "Gwibber GNOME Client"
47
log.logger.info("Running from the source tree")
48
from gwibber import client
52
from gwibber.microblog.util import log
53
log.logger.name = "Gwibber GNOME Client"
54
log.logger.info("Running from the system path")
55
from gwibber import client
57
######################################################################
59
from optparse import OptionParser
60
parser = OptionParser()
61
parser.add_option("-d", "--debug", action="store_true",
62
dest="debug", default=False,
63
help=_("Log debug messages"))
64
parser.add_option("-o", action="store_true",
65
dest="stdout", default=False,
67
(options, args) = parser.parse_args()
70
log.logger.setLevel(log.logging.DEBUG)
72
log.logger.setLevel(log.logging.INFO)
74
# define a Handler which writes INFO messages or higher to the sys.stderr
75
console = log.logging.StreamHandler()
77
console.setLevel(log.logging.DEBUG)
79
console.setLevel(log.logging.INFO)
80
# set a format which is simpler for console use
81
formatter = log.logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
82
console.setFormatter(formatter)
83
log.logger.addHandler(console)
85
######################################################################