~zeitgeist/zeitgeist/magic

374 by Siegfried-Angel Gevatter Pujals
Add a Makefile and do the necessary adaptions so that everything runs from an installation.
1
#! /usr/bin/env python
1050 by Siegfried-Angel Gevatter Pujals
Fix headers, it's -.- coding: utf-8 -.-, coding, not encoding.
2
# -.- coding: utf-8 -.-
374 by Siegfried-Angel Gevatter Pujals
Add a Makefile and do the necessary adaptions so that everything runs from an installation.
3
1014 by Siegfried-Angel Gevatter Pujals
Add copyright headers to zeitgeist-daemon and zeitgeist-datahub files.
4
# Zeitgeist
5
#
6
# Copyright © 2009 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
7
#
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU Lesser General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU Lesser General Public License for more details.
17
#
18
# You should have received a copy of the GNU Lesser General Public License
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
376 by Siegfried-Angel Gevatter Pujals
Do not use the datasink directly in --no-dbus mode, but instead use the D-Bus interface class calling it directly.
21
import sys
22
import os
413 by Siegfried-Angel Gevatter Pujals
Move the trayicon to zeitgeist_gui and start it in a separate process to make it more responsive.
23
import gobject
24
import subprocess
253 by Siegfried-Angel Gevatter Pujals
Initial D-Bus work... For now only get_bookmarks is exported (and sends an array of structs containing the name and the URI if the items), and ./test-daemon.py shows how to get that data.
25
import dbus.mainloop.glib
469.1.3 by Siegfried-Angel Gevatter Pujals
gettextize
26
import gettext
890 by Siegfried-Angel Gevatter Pujals
Switch over from prints to using the 'logging' module (LP: #388327). It would make sense to add options to set the verbosity level or to direct the output to a file once we implement proper option handling.
27
import logging
1248 by Siegfried-Angel Gevatter Pujals
Add Bash tab-completion.
28
import optparse
376 by Siegfried-Angel Gevatter Pujals
Do not use the datasink directly in --no-dbus mode, but instead use the D-Bus interface class calling it directly.
29
1015.1.1 by Siegfried-Angel Gevatter Pujals
Separate source into a public and a private module.
30
from zeitgeist import _config
31
_config.setup_path()
615.1.1 by Siegfried-Angel Gevatter Pujals
Merge patch.
32
1015.1.1 by Siegfried-Angel Gevatter Pujals
Separate source into a public and a private module.
33
gettext.install("zeitgeist", _config.localedir, unicode=1)
891 by Siegfried-Angel Gevatter Pujals
Forgot to set logging level to 'debug' in zeitgeist-daemon.
34
logging.basicConfig(level=logging.DEBUG)
890 by Siegfried-Angel Gevatter Pujals
Switch over from prints to using the 'logging' module (LP: #388327). It would make sense to add options to set the verbosity level or to direct the output to a file once we implement proper option handling.
35
1248 by Siegfried-Angel Gevatter Pujals
Add Bash tab-completion.
36
parser = optparse.OptionParser(version = _config.VERSION)
37
parser.add_option(
38
	"-r", "--replace",
39
	action = "store_true", default=False, dest = "replace",
40
	help = _("if another Zeitgeist instance is already running, replace it"))
41
parser.add_option(
1363 by Seif Lotfy
chaned --no-passive-loggers to --no-datahub
42
	"--no-datahub",
1248 by Siegfried-Angel Gevatter Pujals
Add Bash tab-completion.
43
	action = "store_false", default=True, dest = "start_datahub",
44
	help = _("do not start zeitgeist-datahub automatically"))
45
parser.add_option(
46
	"--quit",
47
	action = "store_true", default=False, dest = "quit",
48
	help = _("if another Zeitgeist instance is already running, replace it"))
49
parser.add_option(
50
	"--shell-completion",
51
	action = "store_true", default=False, dest = "shell_completion",
52
	help = optparse.SUPPRESS_HELP)
1247 by Siegfried-Angel Gevatter Pujals
Update zeitgeist-daemon to use OptionParser.
53
54
(_config.options, _config.arguments) = parser.parse_args()
1146.46.1 by Siegfried Gevatter
Seif mag Ostern
55
1248 by Siegfried-Angel Gevatter Pujals
Add Bash tab-completion.
56
if _config.options.shell_completion:
57
	options = set()
58
	for option in (str(option) for option in parser.option_list):
59
		options.update(option.split("/"))
60
	print ' '.join(options)
61
	sys.exit(0)
62
1015.1.1 by Siegfried-Angel Gevatter Pujals
Separate source into a public and a private module.
63
from _zeitgeist.engine.remote import RemoteInterface
266 by Siegfried-Angel Gevatter Pujals
Propagate the reload signal (zeitgeist_datasink.py [gobject] -> zeitgeist_daemon.py [dbus] -> GUI/etc [dbus]).
64
397 by Siegfried-Angel Gevatter Pujals
Move the trayicon stuff into a new file, add a '--no-trayicon' option to the daemon and avoid the About dialogue from being corrupted when closing it using the window manager.
65
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
413 by Siegfried-Angel Gevatter Pujals
Move the trayicon to zeitgeist_gui and start it in a separate process to make it more responsive.
66
mainloop = gobject.MainLoop()
67
1014.1.15 by Markus Korn
* some fixes according to the comments of Siegfried Gevatter, thanks alot
68
try:
1146.9.2 by Siegfried Gevatter
Remove EngineStart/EngineExit leftovers.
69
	RemoteInterface(mainloop = mainloop)
1014.1.15 by Markus Korn
* some fixes according to the comments of Siegfried Gevatter, thanks alot
70
except RuntimeError, e:
1247 by Siegfried-Angel Gevatter Pujals
Update zeitgeist-daemon to use OptionParser.
71
	logging.error(unicode(e))
1014.1.15 by Markus Korn
* some fixes according to the comments of Siegfried Gevatter, thanks alot
72
	sys.exit(1)
397 by Siegfried-Angel Gevatter Pujals
Move the trayicon stuff into a new file, add a '--no-trayicon' option to the daemon and avoid the About dialogue from being corrupted when closing it using the window manager.
73
1247 by Siegfried-Angel Gevatter Pujals
Update zeitgeist-daemon to use OptionParser.
74
passive_loggers = os.path.join(_config.bindir, "zeitgeist-datahub.py")
75
if _config.options.start_datahub:
831 by Mikkel Kamstrup Erlandsen
Remove the zeitgeist/shared module as the functionality in it did not need such a big setup. Everything DBus related is now in zeitgeist/dbusutils.py
76
	if os.path.isfile(passive_loggers):
77
		subprocess.Popen(passive_loggers)
78
	else:
1247 by Siegfried-Angel Gevatter Pujals
Update zeitgeist-daemon to use OptionParser.
79
		logging.warning(
80
			_("File \"%s\" not found, not starting datahub") % passive_loggers)
652.1.1 by Siegfried-Angel Gevatter Pujals
End the datahub with a D-Bus signal.
81
1065.1.1 by Siegfried-Angel Gevatter Pujals
Update PO files.
82
logging.info(_(u"Starting Zeitgeist service..."))
397 by Siegfried-Angel Gevatter Pujals
Move the trayicon stuff into a new file, add a '--no-trayicon' option to the daemon and avoid the About dialogue from being corrupted when closing it using the window manager.
83
mainloop.run()