Exemplo n.º 1
0
    def __init__(self, log=log):
        self.log = log
        self._zclient = ZeitgeistClient()
        self._zdclient = ZeitgeistDBusInterface()
        self._database = DesktopDatabase(DATABASE_NAME, create=True)

        self._user = os.environ.get('USERNAME')
        self._machine = os.uname()
Exemplo n.º 2
0
 def __init__(self, ui):
     PluginClass.__init__(self, ui)
     try:
         self.zeitgeist_client = ZeitgeistClient()
         self.zeitgeist_client.register_data_source(
             'application://zim.desktop', 'Zim', _('Zim Desktop Wiki'),
             [])  # T: short description of zim
     except RuntimeError, e:
         logger.exception(
             'Loading zeitgeist client failed, will not log events')
         self.zeitgeist_client = None
Exemplo n.º 3
0
class CardapioPlugin(CardapioPluginInterface):

	author             = _('Cardapio Team')
	name               = _('Recent documents (simple)')
	description        = _('Search for your most recently used files.')
	icon               = 'document-open-recent'

	url                = ''
	help_text          = ''
	version            = '0.996'

	plugin_api_version = 1.40

	search_delay_type  = 'local'

	default_keyword    = 'zgeist'

	category_count     = 1
	category_name      = _('Recent Documents')
	category_icon      = 'document-open-recent'
	category_tooltip   = _('Files that you have used recently')
	hide_from_sidebar  = False


	def __init__(self, cardapio_proxy, category): 

		self.c = cardapio_proxy

		self.loaded = False

		try:
			import urllib2, os
			from zeitgeist.client import ZeitgeistClient
			from zeitgeist import datamodel

		except Exception, exception:
			self.c.write_to_log(self, 'Could not import certain modules', is_error = True)
			self.c.write_to_log(self, exception, is_error = True)
			return
		
		self.urllib2   = urllib2
		self.os        = os
		self.datamodel = datamodel

		if 'ZeitgeistClient' not in locals():
			self.c.write_to_log(self, 'Could not import Zeitgeist', is_error = True)
			return

		try:
			self.zg = ZeitgeistClient()
		except Exception, exception:
			self.c.write_to_log(self, 'Could not start Zeitgeist', is_error = True)
			self.c.write_to_log(self, exception, is_error = True)
			return 
Exemplo n.º 4
0
    def initialize(self):
        '''
        Inicializes the Zeitgeist client and registers itself as a Zeitgeist
        data source.
        '''
        self.logger.info('Initialiazing zeitgeist plugin')
        editor = self.locator.get_service('editor')
        editor.fileOpened.connect(self._zeitgeist_log_file_open)
        editor.fileSaved.connect(self._zeitgeist_log_file_modified)

        #initialize zeitgeist client
        self.zeitgeist = ZeitgeistClient()
        self._register_data_source()
Exemplo n.º 5
0
    def log_install_event(self, desktop_file):
        """Logs an install event on Zeitgeist"""
        if not HAVE_MODULE:
            LOG.warn("No zeitgeist support, impossible to log event")
            return False

        if not desktop_file or not len(desktop_file):
            LOG.warn("Invalid desktop file provided, impossible to log event")
            return False

        subject = self.__create_app_subject(desktop_file)

        subject.text = "Installed with " + self.distro.get_app_name()
        event = self.__create_user_event()
        event.interpretation = ZeitgeistDataModel.Interpretation.EVENT_INTERPRETATION.CREATE_EVENT
        event.append_subject(subject)
        ZeitgeistClient().insert_event(event)

        subject.text = "Accessed by " + self.distro.get_app_name()
        event = self.__create_user_event()
        event.interpretation = ZeitgeistDataModel.Interpretation.EVENT_INTERPRETATION.ACCESS_EVENT
        event.append_subject(subject)
        ZeitgeistClient().insert_event(event)
        return True
Exemplo n.º 6
0
 def _get_client(self, bus_name, app_uri, app_name, app_description,
                 event_template):
     client = None
     try:
         client = ZeitgeistClient()
         if hasattr(self.client, "register_data_source"):
             client.register_data_source(
                 bus_name,
                 app_name or bus_name,
                 app_description or bus_name,
                 event_template or \
                 [Event.new_for_values(actor=app_uri)])
         self.log(logging.DEBUG, 'your client was set')
     except Exception as e:
         self.log(logging.ERROR, 'S.O.S: %s', e)
         raise
     return client
Exemplo n.º 7
0
    def setUp(self, database_path=None):
        assert self.daemon is None
        assert self.client is None
        self.env = os.environ.copy()
        self.datapath = tempfile.mkdtemp(prefix="zeitgeist.datapath.")
        self.env.update({
            "ZEITGEIST_DATABASE_PATH": database_path or ":memory:",
            "ZEITGEIST_DATA_PATH": self.datapath,
            "XDG_CACHE_HOME": os.path.join(self.datapath, "cache"),
        })
        self.spawn_daemon()

        # hack to clear the state of the interface
        ZeitgeistDBusInterface._ZeitgeistDBusInterface__shared_state = {}

        # Replace the bus connection with a private one for each test case,
        # so that they don't share signals or other state
        _set_bus(dbus.SessionBus(private=True))
        get_bus().set_exit_on_disconnect(False)

        self.client = ZeitgeistClient()
Exemplo n.º 8
0
    def zclient(
            self,
            bus_name='im.pidgin.purple.PurpleInterface',
            app_uri='application://pidgin.desktop',
            app_name='Pidgin',
            app_description="Pidgin is an easy to use and free chat client used by millions. Connect to AIM, MSN, Yahoo, and more chat networks all at once.",
            event_template=None):

        if self._client:
            return self._client

        try:
            self._client = ZeitgeistClient()
            if hasattr(self._client, "register_data_source"):
                self.client.register_data_source(
                    bus_name,
                    app_name or bus_name,
                    app_description or bus_name,
                    event_template or \
                    [Event.new_for_values(actor=app_uri)])
        except:
            pass

        return self._client
Exemplo n.º 9
0
import os
import subprocess
import sys
import time

CLIENT = None

try:
    from zeitgeist.client import ZeitgeistClient
    from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation
except ImportError:
    pass
else:
    try:
        CLIENT = ZeitgeistClient()
    except RuntimeError as e:
        print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" % e)


def get_repo():
    """Get uri of remote repository and its name"""
    repo = None
    uri = subprocess.Popen(['git', 'config', '--get', 'remote.origin.url'],
                           stdout=subprocess.PIPE).communicate()[0]

    if uri:
        uri = uri.strip().decode(sys.getfilesystemencoding())
        if '/' in uri:
            sep = '/'
        else:
Exemplo n.º 10
0
class CardapioPlugin(CardapioPluginInterface):

    author = _('Cardapio Team')
    name = _('Recent documents (categorized)')
    description = _(
        'Search for your most recently used files, divided into categories depending on <i>when</i> they were last accessed.'
    )
    icon = 'document-open-recent'

    url = ''
    help_text = ''
    version = '0.996'

    plugin_api_version = 1.40

    search_delay_type = 'local'

    default_keyword = 'zgeist'

    category_count = 4
    category_name = [
        _('Today'), _('This week'),
        _('This month'),
        _('All time')
    ]
    category_icon = ['document-open-recent'] * 4
    category_tooltip = [
        _('Files you used today'),
        _('Files you used this week'),
        _('Files you used this month'),
        _('All other files')
    ]
    hide_from_sidebar = [False] * 4

    def __init__(self, cardapio_proxy, category):

        # NOTE: Right now Cardapio creates a separate instance for each
        # category. This is very wasteful! We should instead create a single
        # instance and pass the category to the search() method instead.

        self.c = cardapio_proxy

        self.loaded = False

        try:
            import urllib2, os
            from zeitgeist.client import ZeitgeistClient
            from zeitgeist import datamodel
            import time

        except Exception, exception:
            self.c.write_to_log(self,
                                'Could not import certain modules',
                                is_error=True)
            self.c.write_to_log(self, exception, is_error=True)
            return

        self.urllib2 = urllib2
        self.os = os
        self.datamodel = datamodel

        if 'ZeitgeistClient' not in locals():
            self.c.write_to_log(self,
                                'Could not import Zeitgeist',
                                is_error=True)
            return

        try:
            self.zg = ZeitgeistClient()
        except Exception, exception:
            self.c.write_to_log(self,
                                'Could not start Zeitgeist',
                                is_error=True)
            self.c.write_to_log(self, exception, is_error=True)
            return
Exemplo n.º 11
0
 def enabled(self):
     self.client = ZeitgeistClient()
     self.__stopped_by_user = False
Exemplo n.º 12
0
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.

import time
import rb

from gi.repository import GObject, Gio, GLib, Peas
from gi.repository import RB

from zeitgeist.client import ZeitgeistClient
from zeitgeist.datamodel import Event, Subject, Interpretation, Manifestation

try:
    IFACE = ZeitgeistClient()
except RuntimeError, e:
    print "Unable to connect to Zeitgeist, won't send events. Reason: '%s'" % e
    IFACE = None


class ZeitgeistPlugin(GObject.Object, Peas.Activatable):
    __gtype_name__ = 'ZeitgeistPlugin'
    object = GObject.property(type=GObject.Object)

    def __init__(self):
        GObject.Object.__init__(self)

    def do_activate(self):
        print "Loading Zeitgeist plugin..."
        if IFACE is not None:
Exemplo n.º 13
0
def get_interface():
    global _zg
    if _zg is None:
        _zg = ZeitgeistClient()
    _zg.register_event_subclass(CustomEvent)
    return _zg
 def __init__(self):
     try:
         self.zg_client = ZeitgeistClient()
     except Exception as e:
         logging.warn("can not get zeitgeist client: '%s'" % e)
         self.zg_client = None