Merge lp:~manishsinha/cheers/insertion into lp:~cheers/cheers/trunk

Status: Merged
Merged at revision: 17
Proposed branch: lp:~manishsinha/cheers/insertion
Merge into: lp:~cheers/cheers/trunk
Diff against target: 464 lines (+222/-51)
10 files modified
LICENSE (+21/-0)
MAINTAINERS (+1/-0)
README (+38/-0)
aa.trophy (+1/-0)
cheers-daemon (+29/-0)
cheers-daemon.py (+0/-27)
cheers/client.py (+14/-15)
cheers/config.py (+11/-0)
cheers/datastore.py (+96/-4)
cheers/server.py (+11/-5)
To merge this branch: bzr merge lp:~manishsinha/cheers/insertion
Reviewer Review Type Date Requested Status
Cheers Pending
Review via email: mp+39438@code.launchpad.net

Description of the change

Implemented the insertion of trophies and fixed the client python bindings

To post a comment you must log in.
lp:~manishsinha/cheers/insertion updated
17. By Manish Sinha (मनीष सिन्हा)

Updated README, LICENSE, MAINTAINERS and fixed the name of the daemon file

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'LICENSE'
--- LICENSE 2010-10-03 18:20:14 +0000
+++ LICENSE 2010-10-27 12:43:44 +0000
@@ -0,0 +1,21 @@
1# The MIT/X11/Expat License
2
3# Copyright (c) 2010 Manish Sinha<mail@manishsinha.net>
4
5# Permission is hereby granted, free of charge, to any person obtaining a copy
6# of this software and associated documentation files (the "Software"), to deal
7# in the Software without restriction, including without limitation the rights
8# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9# copies of the Software, and to permit persons to whom the Software is
10# furnished to do so, subject to the following conditions:
11
12# The above copyright notice and this permission notice shall be included in
13# all copies or substantial portions of the Software.
14
15# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21# THE SOFTWARE.
022
=== modified file 'MAINTAINERS'
--- MAINTAINERS 2010-10-03 18:20:14 +0000
+++ MAINTAINERS 2010-10-27 12:43:44 +0000
@@ -0,0 +1,1 @@
1Manish Sinha <mail@manishsinha.net>
02
=== modified file 'README'
--- README 2010-10-03 18:20:14 +0000
+++ README 2010-10-27 12:43:44 +0000
@@ -0,0 +1,38 @@
1Cheers is a trophya warding framework. It runs as a daemon activating a DBus Session bus over which applications can talk to it.
2
3It is written using python, sqlite, dbus
4
5Prerequisties
6---------------
7To get cheers up and running, you need the following packages. Please check your distribution for the exact name of the packages
8* python
9* python-dbus
10* python-sqlite
11* python-gio
12* python-glib
13* python-gtk
14
15
16
17Running
18---------
19Execute cheers-daemon using the command
20
21./cheers-daemon.py
22
23
24Registering a trophy
25---------------------
26
27Cheers keeps a watch on three folders for new trophies when the server is running. These two folders are
28* /usr/share/cheers/trophies
29* /usr/local/share/cheers/trophies
30* ~/.local/share/cheers/trophies
31
32A sample trophy aa.trophy is provided. Put it under the folder ~/.local/share/cheers/trophies to register the trophy
33
34
35Debugging
36------------
37
38Use D-feet DBus debugger to have a look at the DBus API
039
=== added file 'aa.trophy'
--- aa.trophy 1970-01-01 00:00:00 +0000
+++ aa.trophy 2010-10-27 12:43:44 +0000
@@ -0,0 +1,1 @@
1{"id":"Name","setname":"Music", "seticon": "", "app":"application://banshee.desktop", "appname":"Banshee Music Player", "title":"FM Junkie", "iconpath":"", "priority": 1, "unlocked": "False", "stockicon":"", "desc": {"1": {"lang":"en-us", "desc": "Listen to Music alot"}, "2": {"lang":"en-uk", "desc": "Listen to Music a lot, a lot"}}}
02
=== added file 'cheers-daemon'
--- cheers-daemon 1970-01-01 00:00:00 +0000
+++ cheers-daemon 2010-10-27 12:43:44 +0000
@@ -0,0 +1,29 @@
1#! /usr/bin/env python
2
3# The MIT/X11/Expat License
4# Copyright (c) 2010 Manish Sinha<mail@manishsinha.net>
5
6# Permission is hereby granted, free of charge, to any person obtaining a copy
7# of this software and associated documentation files (the "Software"), to deal
8# in the Software without restriction, including without limitation the rights
9# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10# copies of the Software, and to permit persons to whom the Software is
11# furnished to do so, subject to the following conditions:
12
13# The above copyright notice and this permission notice shall be included in
14# all copies or substantial portions of the Software.
15
16# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22# THE SOFTWARE.
23
24
25from cheers import server
26
27if __name__ == "__main__":
28
29 server.TrophyServer()
030
=== removed file 'cheers-daemon.py'
--- cheers-daemon.py 2010-10-17 20:31:25 +0000
+++ cheers-daemon.py 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1# The MIT/X11/Expat License
2# Copyright (c) 2010 Manish Sinha<mail@manishsinha.net>
3
4# Permission is hereby granted, free of charge, to any person obtaining a copy
5# of this software and associated documentation files (the "Software"), to deal
6# in the Software without restriction, including without limitation the rights
7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8# copies of the Software, and to permit persons to whom the Software is
9# furnished to do so, subject to the following conditions:
10
11# The above copyright notice and this permission notice shall be included in
12# all copies or substantial portions of the Software.
13
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20# THE SOFTWARE.
21
22
23from cheers import server
24
25
26if __name__ == "__main__":
27 cheers_server = server.TrophyServer()
280
=== modified file 'cheers/client.py'
--- cheers/client.py 2010-10-03 19:24:44 +0000
+++ cheers/client.py 2010-10-27 12:43:44 +0000
@@ -30,7 +30,7 @@
3030
31 def __init__(self):31 def __init__(self):
32 bus = dbus.SessionBus()32 bus = dbus.SessionBus()
33 self.__interface = bus.get_object(OMG_BUS_NAME, OMG_OBJECT_PATH)33 self.__interface = bus.get_object(CHEERS_BUS_NAME, CHEERS_OBJECT_PATH)
3434
35 def AwardTrophy(self, id, setname):35 def AwardTrophy(self, id, setname):
36 """ Awards the trophy specified by it's id and the setName. 36 """ Awards the trophy specified by it's id and the setName.
@@ -39,23 +39,19 @@
39 If the trophy has been registered, then it is awarded a small notify-osd(libnotify) notification is shown.39 If the trophy has been registered, then it is awarded a small notify-osd(libnotify) notification is shown.
40 If the trophy is not registered or has already been awarded, then nothing happens. Call GetTrophy(id,set) to check whether it trophy exists or has already been awarded.40 If the trophy is not registered or has already been awarded, then nothing happens. Call GetTrophy(id,set) to check whether it trophy exists or has already been awarded.
41 """41 """
42 self.__interface.AwardTrophy(id, setname)42 self.__interface.AwardTrophy(id)
4343
44 def DeleteTrophy(self, id, setname):44 def DeleteTrophy(self, id, setname):
45 """ Deletes the trophy permanently from the trophy store. 45 """ Deletes the trophy permanently from the trophy store.
46 46
47 This is reverse of registering a trophy. This action is irreversible. Use with caution """47 This is reverse of registering a trophy. This action is irreversible. Use with caution """
4848
49 res = self.__interface.DeleteTrophy(id, setname)49 self.__interface.DeleteTrophy(id)
5050
51 return Response(res[0], res[1], res[2])51 def UnAwardTrophy(self, id):
52
53 def UnAwardTrophy(self, id, setname):
54 """ Do the reverse of awarding the trophy. Useful for debugging purposes """52 """ Do the reverse of awarding the trophy. Useful for debugging purposes """
55 53
56 res = self.__interface.UnAwardTrophy(id, setname)54 self.__interface.UnAwardTrophy(id)
57
58 return Response(res[0], res[1], res[2])
59 55
6056
61 def GetTrophies(self):57 def GetTrophies(self):
@@ -64,10 +60,10 @@
64 trophy_list = self.__interface.GetTrophies()60 trophy_list = self.__interface.GetTrophies()
65 return [self.__UnwrapTrophy(trp) for trp in trophy_list]61 return [self.__UnwrapTrophy(trp) for trp in trophy_list]
6662
67 def GetTrophy(self, id, setname):63 def GetTrophy(self, id):
68 """ Get a trophy given it's id and setname """64 """ Get a trophy given it's id and setname """
6965
70 trophy = self.__interface.GetTrophy(str(id), str(setname))66 trophy = self.__interface.GetTrophy(str(id))
71 return self.__UnwrapTrophy(trophy)67 return self.__UnwrapTrophy(trophy)
7268
73 def GetTrophyBySet(self, setname):69 def GetTrophyBySet(self, setname):
@@ -82,7 +78,7 @@
82 trophy_list = self.__interface.GetTrophyByApp(str(appname))78 trophy_list = self.__interface.GetTrophyByApp(str(appname))
83 return [self.__UnwrapTrophy(trp) for trp in trophy_list]79 return [self.__UnwrapTrophy(trp) for trp in trophy_list]
8480
85 def GetTrophyById(self, id):81 def GetTrophy(self, id):
86 """ Get the trophie registered by it's ID"""82 """ Get the trophie registered by it's ID"""
8783
88 trophy_list = self.__interface.GetTrophyById(str(id))84 trophy_list = self.__interface.GetTrophyById(str(id))
@@ -97,12 +93,15 @@
9793
98 def Quit(self):94 def Quit(self):
99 """ Exits the OMG Daemon """95 """ Exits the OMG Daemon """
100 96 try:
101 self.__interface.Quit()97 self.__interface.Quit()
98 except dbus.DBusException:
99 pass
102100
103 def __UnwrapTrophy(self, trophy):101 def __UnwrapTrophy(self, trophy):
104 """ Unwraps the trophy instances as per the positions """102 """ Unwraps the trophy instances as per the positions """
105103
104 print(trophy)
106 return Trophy(trophy[0], trophy [1], trophy [2], trophy [4], \105 return Trophy(trophy[0], trophy [1], trophy [2], trophy [4], \
107 trophy[5], trophy[6], trophy[7], trophy[3], \106 trophy[5], trophy[6], trophy[7], trophy[3], \
108 trophy[8], trophy[9], trophy[10], trophy[11])107 trophy[8], trophy[9], trophy[10], trophy[11])
109108
=== modified file 'cheers/config.py'
--- cheers/config.py 2010-10-12 19:29:39 +0000
+++ cheers/config.py 2010-10-27 12:43:44 +0000
@@ -31,6 +31,7 @@
3131
32trophy_dump_path = os.path.join(cheers_data_path, "trophies")32trophy_dump_path = os.path.join(cheers_data_path, "trophies")
33global_trophy_path = "/usr/share/cheers/trophies"33global_trophy_path = "/usr/share/cheers/trophies"
34global_trophy_path_local = "/usr/local/share/cheers/trophies"
3435
35DATA_STORE_TYPE = "sqlite"36DATA_STORE_TYPE = "sqlite"
3637
@@ -47,10 +48,20 @@
47create_desc_command = "CREATE TABLE description (id TEXT, language TEXT, desc TEXT)"48create_desc_command = "CREATE TABLE description (id TEXT, language TEXT, desc TEXT)"
48create_app_command = "CREATE TABLE app(appid INTEGER, app TEXT, appname TEXT)"49create_app_command = "CREATE TABLE app(appid INTEGER, app TEXT, appname TEXT)"
49create_set_command = "CREATE TABLE appset(setid INTEGER, setname TEXT, seticon TEXT)"50create_set_command = "CREATE TABLE appset(setid INTEGER, setname TEXT, seticon TEXT)"
51create_history_command = "CREATE TABLE history(id TEXT, timestamp INTEGER)"
52
53insert_history_command = "INSERT INTO history VALUES(?,?)"
54insert_trophy_command = "INSERT INTO trophy VALUES(?,?,?,?,?,?,?,?,?)"
55insert_desc_command = "INSERT INTO description VALUES(?,?,?)"
56insert_app_command = "INSERT INTO app VALUES(?,?,?)"
57insert_set_command = "INSERT INTO appset VALUES(?,?,?)"
5058
51fetch_trophy_where = "SELECT trophy.id, trophy.title, trophy.iconpath, app.app, app.appname, appset.setname, appset.seticon, trophy.priority, trophy.unlocked, trophy.timestamp, trophy.stockicon FROM trophy, app,appset WHERE trophy.app=app.appid and trophy.appset=appset.setid and %s=:value"59fetch_trophy_where = "SELECT trophy.id, trophy.title, trophy.iconpath, app.app, app.appname, appset.setname, appset.seticon, trophy.priority, trophy.unlocked, trophy.timestamp, trophy.stockicon FROM trophy, app,appset WHERE trophy.app=app.appid and trophy.appset=appset.setid and %s=:value"
52fetch_trophy_all = "select trophy.id, trophy.title, trophy.iconpath, app.app, app.appname, appset.setname, appset.seticon, trophy.priority, trophy.unlocked, trophy.timestamp, trophy.stockicon FROM trophy, app,appset WHERE trophy.app=app.appid and trophy.appset=appset.setid"60fetch_trophy_all = "select trophy.id, trophy.title, trophy.iconpath, app.app, app.appname, appset.setname, appset.seticon, trophy.priority, trophy.unlocked, trophy.timestamp, trophy.stockicon FROM trophy, app,appset WHERE trophy.app=app.appid and trophy.appset=appset.setid"
53fetch_description = "SELECT language, desc FROM description WHERE id=:Id"61fetch_description = "SELECT language, desc FROM description WHERE id=:Id"
62fetch_history = "SELECT * FROM history WHERE id=?"
63fetch_set_byname = "SELECT * FROM appset WHERE setname=?"
64fetch_app_byapp = "SELECT * FROM app where app=?"
5465
55award_trophy_command = "UPDATE trophy SET unlocked=1 WHERE id=?"66award_trophy_command = "UPDATE trophy SET unlocked=1 WHERE id=?"
56unaward_trophy_command = "UPDATE trophy SET unlocked=0 WHERE id=?"67unaward_trophy_command = "UPDATE trophy SET unlocked=0 WHERE id=?"
5768
=== modified file 'cheers/datastore.py'
--- cheers/datastore.py 2010-10-12 19:29:39 +0000
+++ cheers/datastore.py 2010-10-27 12:43:44 +0000
@@ -22,6 +22,8 @@
22import os22import os
23import sqlite323import sqlite3
24import config24import config
25import random
26import datetime
2527
26class SqliteStore():28class SqliteStore():
27 """ Implement the data storage based using sqlite as backend29 """ Implement the data storage based using sqlite as backend
@@ -46,27 +48,116 @@
46 # Try creating the tables48 # Try creating the tables
47 try:49 try:
48 self.__cur.execute(config.create_trophy_command)50 self.__cur.execute(config.create_trophy_command)
51 except sqlite3.OperationalError:
52 print("Trophy Table existed")
53
54 try:
49 self.__cur.execute(config.create_desc_command)55 self.__cur.execute(config.create_desc_command)
56 except sqlite3.OperationalError:
57 print("Description Table existed")
58
59 try:
50 self.__cur.execute(config.create_app_command)60 self.__cur.execute(config.create_app_command)
61 except sqlite3.OperationalError:
62 print("App Table existed")
63
64 try:
51 self.__cur.execute(config.create_set_command)65 self.__cur.execute(config.create_set_command)
52 print("All tables create successfully")66 except sqlite3.OperationalError:
53 except sqlite3.OperationalError:67 print("Set Table existed")
54 print("Table existed")68
69 try:
70 self.__cur.execute(config.create_history_command)
71 except sqlite3.OperationalError:
72 print("History Table existed")
73
55 74
56 self.__res_cursor=None75 self.__res_cursor=None
5776
77 def AddTrophy(self, json_data):
78 """ Add the trophy to the database from the JSON data passed """
79
80 res_history = self.__cur.execute(config.fetch_history, (json_data["id"],))
81 fetch_trp = config.fetch_trophy_where %("id",)
82 res_trophy = self.__cur.execute(fetch_trp, { "value":json_data["id"] })
83 if(len(res_history.fetchall()) == 0 and len(res_trophy.fetchall()) == 0):
84
85 # Searching and Inserting Sets
86 set_list = self.__cur.execute(config.fetch_set_byname, (json_data["setname"],))
87 matched_set = set_list.fetchone()
88 if matched_set is None:
89 # Does not exist, create one
90 print("Set '%s' does not exist. Creating." %(json_data["setname"],))
91 setid = int(random.random()*10000000)
92 self.__cur.execute(config.insert_set_command, (setid, json_data["setname"], json_data["seticon"]))
93 else:
94 # Exists. Use it
95 print("Set '%s' already exists. Will be reused" %(matched_set[1],))
96 setid = matched_set[0]
97
98 # Searching and Inserting Apps
99 app_list = self.__cur.execute(config.fetch_app_byapp, (json_data["app"],))
100 matched_app = app_list.fetchone()
101 if matched_app is None:
102 # Does not exist, create one
103 print("App '%s' does not exist. Creating." %(json_data["app"],))
104 appid = int(random.random()*10000000)
105 self.__cur.execute(config.insert_app_command, (appid, json_data["app"], json_data["appname"]))
106 else:
107 # Exists. Use it
108 print("App '%s' already exists. Will be reused" %(matched_app[1],))
109 appid = matched_app[0]
110
111
112 # Remove all description for this Id if present
113 desc_list = self.__cur.execute(config.remove_desc_command, (json_data["id"],))
114 # Inserting Description
115 desc_list = json_data["desc"]
116 for desc in desc_list.values():
117 self.__cur.execute(config.insert_desc_command, (json_data["id"], desc["lang"], desc["desc"]))
118
119 timestamp = int(datetime.datetime(1970,01,01).today().strftime("%s"))
120
121 try:
122 # Inserting Trophy
123 is_present = self.Search("trophy.id", json_data["id"])
124 if len(is_present) > 0:
125 print("The trophy '%s' already exists" %(json_data["id"], ))
126 else:
127 self.__cur.execute(config.insert_trophy_command, ( json_data["id"], \
128 json_data["title"], \
129 json_data["iconpath"], \
130 appid, \
131 setid, \
132 int(json_data["priority"]), \
133 bool(json_data["unlocked"]), \
134 timestamp, \
135 json_data["stockicon"]))
136
137 # Inserting History
138 self.__cur.execute(config.insert_history_command, (json_data["id"], timestamp))
139
140 self.__conn.commit()
141 pass
142 except:
143 raise
144
145
58 def AwardTrophy(self, id):146 def AwardTrophy(self, id):
59 """ Award the trophy """147 """ Award the trophy """
148
60 self.__cur.execute(config.award_trophy_command, (id,))149 self.__cur.execute(config.award_trophy_command, (id,))
61 self.__conn.commit()150 self.__conn.commit()
62 151
63 def UnAwardTrophy(self, id):152 def UnAwardTrophy(self, id):
64 """ Un-Award the trophy """153 """ Un-Award the trophy """
154
65 self.__cur.execute(config.unaward_trophy_command, (id,))155 self.__cur.execute(config.unaward_trophy_command, (id,))
66 self.__conn.commit()156 self.__conn.commit()
67 157
68 def DeleteTrophy(self, id):158 def DeleteTrophy(self, id):
69 """ Un-Award the trophy """159 """ Un-Award the trophy """
160
70 self.__cur.execute(config.remove_trophy_command, (id,))161 self.__cur.execute(config.remove_trophy_command, (id,))
71 self.__cur.execute(config.remove_desc_command, (id,))162 self.__cur.execute(config.remove_desc_command, (id,))
72 self.__conn.commit()163 self.__conn.commit()
@@ -94,6 +185,7 @@
94185
95 for val in self.__res_cursor:186 for val in self.__res_cursor:
96 desc_cursor = self.__cur.execute(config.fetch_description, {"Id": val[0]})187 desc_cursor = self.__cur.execute(config.fetch_description, {"Id": val[0]})
188 print(desc_cursor)
97 # Create the Localization Description189 # Create the Localization Description
98 desc_list = [[desc[0], desc[1]] for desc in desc_cursor]190 desc_list = [[desc[0], desc[1]] for desc in desc_cursor]
99 191
@@ -102,13 +194,13 @@
102 194
103 trophy_list.append(trp)195 trophy_list.append(trp)
104 196
105 print(trophy_list)
106 return trophy_list197 return trophy_list
107 198
108 def _CreateTrophyDBus(self, desc_list, trp):199 def _CreateTrophyDBus(self, desc_list, trp):
109 """ Create the DBus representation of Trophy which is to be sent200 """ Create the DBus representation of Trophy which is to be sent
110 over DBus matching the signature a(ssaasssssisbxs) 201 over DBus matching the signature a(ssaasssssisbxs)
111 """202 """
203
112 if trp[8] == 0:204 if trp[8] == 0:
113 unlocked = 0205 unlocked = 0
114 else:206 else:
115207
=== modified file 'cheers/server.py'
--- cheers/server.py 2010-10-17 20:31:25 +0000
+++ cheers/server.py 2010-10-27 12:43:44 +0000
@@ -63,15 +63,20 @@
63 global_monitor = global_dump.monitor_directory(gio.FILE_MONITOR_NONE, None)63 global_monitor = global_dump.monitor_directory(gio.FILE_MONITOR_NONE, None)
64 global_monitor.connect("changed", self.directory_changed)64 global_monitor.connect("changed", self.directory_changed)
65 65
66 if os.path.exists(config.global_trophy_path_local):
67 global_dump_local = gio.File(config.global_trophy_path_local)
68 global_monitor_local = global_dump_local.monitor_directory(gio.FILE_MONITOR_NONE, None)
69 global_monitor_local.connect("changed", self.directory_changed)
70
66 # Start the MainLoop71 # Start the MainLoop
67 glib.MainLoop().run()72 glib.MainLoop().run()
68 73
69 def directory_changed(self, monitor, file1, file2, evt_type):74 def directory_changed(self, monitor, file1, file2, evt_type):
70 """ The callback for handling the directory changes notification """75 """ The callback for handling the directory changes notification """
71 76
72 if (evt_type in (gio.FILE_MONITOR_EVENT_CREATED,)):77 if (evt_type in (gio.FILE_MONITOR_EVENT_CREATED,)):
73 print "Changed:", file1, file2, evt_type78 print "Changed:", file1, file2, evt_type
74 self.AddTrophy(file1.get_path())79 self.AddTrophy(file1.get_path())
75 80
76 def AddTrophy(self, trophy_file):81 def AddTrophy(self, trophy_file):
77 """ Read the JSON trophy files and register it """82 """ Read the JSON trophy files and register it """
@@ -81,6 +86,7 @@
81 json_data = json.load(fs)86 json_data = json.load(fs)
82 fs.close()87 fs.close()
8388
89 self.__store.AddTrophy(json_data)
8490
85 @dbus.service.method(config.CHEERS_BUS_NAME, in_signature='s')91 @dbus.service.method(config.CHEERS_BUS_NAME, in_signature='s')
86 def DeleteTrophy(self, id):92 def DeleteTrophy(self, id):
@@ -135,8 +141,8 @@
135 141
136 142
137 143
138 @dbus.service.method(config.CHEERS_BUS_NAME, in_signature='ss')144 @dbus.service.method(config.CHEERS_BUS_NAME, in_signature='s')
139 def UnAwardTrophy(self, id, setname):145 def UnAwardTrophy(self, id):
140 """ Find the trophy to be unawarded, unaward it and send a async reply via event """146 """ Find the trophy to be unawarded, unaward it and send a async reply via event """
141 147
142 trophies = self.__store.Search("trophy.id", id)148 trophies = self.__store.Search("trophy.id", id)

Subscribers

People subscribed via source and target branches