~robtaylor/zeitgeist/tracker

« back to all changes in this revision

Viewing changes to _zeitgeist/engine/extensions/tracker.py

  • Committer: Rob Taylor
  • Date: 2010-05-12 18:44:19 UTC
  • Revision ID: robtaylor@luitsiana-20100512184419-18x2nzhjbtyktg31
First steps towards pushing events to tracker

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import os
21
21
import dbus
22
22
import dbus.service
 
23
import uuid
23
24
from _zeitgeist.engine.datamodel import Event
24
25
from _zeitgeist.engine.extension import Extension
25
26
 
37
38
                
38
39
                bus = dbus.SessionBus ()
39
40
                self.tracker = bus.get_object(TRACKER_NAME, TRACKER_OBJ)
40
 
                self.iface = dbus.Interface(self.tracker, TRACKER_IFACE)
 
41
                self.resources = dbus.Interface(self.tracker, TRACKER_IFACE)
 
42
                # Set up zeitgeists' Event Interpretation and Manifestation objects
 
43
                # these are basically used as enums...
 
44
                self.resources.SparqlUpdate("""
 
45
                        insert {
 
46
                                <uri:zg:eventinterpretation:createevent> a zg:CreateEvent .
 
47
                                <uri:zg:eventinterpretation:accessevent> a zg:AccessEvent .
 
48
                                <uri:zg:eventinterpretation:leaveevent> a zg:LeaveEvent .
 
49
                                <uri:zg:eventinterpretation:modifyevent> a zg:ModifyEvent .
 
50
                                <uri:zg:eventinterpretation:deleteevent> a zg:DeleteEvent .
 
51
                                <uri:zg:eventinterpretation:receiveevent> a zg:ReceiveEvent .
 
52
                                <uri:zg:eventinterpretation:sendevent> a zg:SendEvent .
 
53
                                <uri:zg:eventmanifestation:useractivity> a zg:UserActivity .
 
54
                                <uri:zg:eventmanifestation:heuristicactivity> a zg:HeuristicActivity .
 
55
                                <uri:zg:eventmanifestation:scheduledactivity> a zg:ScheduledActivity .
 
56
                                <uri:zg:eventmanifestation:worldactivity> a zg:WorldActivity .
 
57
                        }
 
58
                        """)
 
59
                
41
60
                
42
61
        def dummy_tracker_method(self, event):
43
62
                print event
44
63
        
45
64
        def insert_event_hook(self, event, sender):
46
 
                pass
 
65
                print event
47
66
                # Event
48
67
                # --------
49
68
                # timestamp
59
78
                # mimetype
60
79
                # interpretation
61
80
                # manifestation
62
 
        
63
 
        
64
 
        
 
 
b'\\ No newline at end of file'
 
81
                uuid = uuid.uuid4()
 
82
                zgevent = {
 
83
                        'uuid': uuid.hex,
 
84
                        'timestamp': event.timestamp,
 
85
                        'application' : event.actor.strip('application://'),
 
86
                        'interpretation' : event.interpretation,
 
87
                        'manifestation' : event.manifestation,
 
88
                        'id' : event.id }
 
89
 
 
90
                print zgevent
 
91
                return event
 
92
                                
 
93
#               self.resources.SparqlUpdate("""
 
94
#                       insert {
 
95
#                               <uri:uuid:%s> a zg:Event ;
 
96
#                               zg:timestamp 1234 ; zg:hasActor ?a ; zg:hasEventInterpretation <urn:zg:eventinterpretation:leaveevent>; zg:hasEventManifestation <urn:zg:eventmanifestation:useractivity>; zg:hasSubject <urn:album:Thriller%20%28SpecialEdition%29> ; zg:eventId 1234 } WHERE { ?a a nfo:SoftwareApplication; nfo:fileName 'rhythmbox.desktop' }"
 
97
        
 
98