Merge lp:~ilidrissi.amine/software-center/zeitgeist-unused-applications into lp:software-center

Proposed by Mohamed Amine Ilidrissi
Status: Rejected
Rejected by: Michael Vogt
Proposed branch: lp:~ilidrissi.amine/software-center/zeitgeist-unused-applications
Merge into: lp:software-center
Diff against target: 192 lines (+107/-4)
5 files modified
debian/changelog (+4/-1)
softwarecenter/apt/aptcache.py (+6/-0)
softwarecenter/backend/zeitgeist_simple.py (+28/-2)
softwarecenter/db/database.py (+10/-0)
softwarecenter/view/catview_gtk.py (+59/-1)
To merge this branch: bzr merge lp:~ilidrissi.amine/software-center/zeitgeist-unused-applications
Reviewer Review Type Date Requested Status
Matthew Paul Thomas Disapprove
Review via email: mp+39236@code.launchpad.net

Description of the change

This branch adds support for unused applications via Zeitgeist.
Design feedback is welcome.

To post a comment you must log in.
Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Consider the case of a disk recovery utility. Ideally you will use this rarely, once every few years. That does not mean USC should constantly be nagging you to uninstall it. :-)

I think more useful would be a way to show -- in the "Installed Software" list -- frequency of use, or date last used, or both, and to sort by those columns.

review: Disapprove

Unmerged revisions

1267. By Mohamed Amine Ilidrissi

Code now checks if the app is installed and not a core application (i.e doesn't remove pkgs in IMPORTANT_METAPACKAGES)

1266. By Mohamed Amine Ilidrissi

merge with trunk

1265. By Mohamed Amine Ilidrissi

Added support for removing unused applications via Zeitgeist

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2010-10-19 20:48:05 +0000
+++ debian/changelog 2010-10-24 22:41:36 +0000
@@ -13,7 +13,10 @@
13 * softwarecenter/backend/config.py:13 * softwarecenter/backend/config.py:
14 - don't crash on a corrupted config file (LP: #662414) 14 - don't crash on a corrupted config file (LP: #662414)
1515
16 -- Gary Lasker <gary.lasker@canonical.com> Tue, 19 Oct 2010 16:41:40 -040016 [ Mohamed Amine IL Idrissi ]
17 * Added support for unused application via Zeitgeist
18
19 -- Mohamed Amine IL Idrissi <ilidrissiamine@gmail.com> Sun, 24 Oct 2010 22:04:38 +0000
1720
18software-center (3.1.0) natty; urgency=low21software-center (3.1.0) natty; urgency=low
1922
2023
=== modified file 'softwarecenter/apt/aptcache.py'
--- softwarecenter/apt/aptcache.py 2010-09-14 20:07:34 +0000
+++ softwarecenter/apt/aptcache.py 2010-10-24 22:41:36 +0000
@@ -471,6 +471,12 @@
471 addons_sug = filter(_addons_filter_slow, addons_sug)471 addons_sug = filter(_addons_filter_slow, addons_sug)
472 472
473 return (addons_rec, addons_sug)473 return (addons_rec, addons_sug)
474
475 def pkg_is_important(self, pkg, distro):
476 for m in distro.IMPORTANT_METAPACKAGES:
477 if m in self.get_depends(pkg):
478 return True
479 return False
474480
475if __name__ == "__main__":481if __name__ == "__main__":
476 c = AptCache()482 c = AptCache()
477483
=== modified file 'softwarecenter/backend/zeitgeist_simple.py'
--- softwarecenter/backend/zeitgeist_simple.py 2010-10-12 08:56:06 +0000
+++ softwarecenter/backend/zeitgeist_simple.py 2010-10-24 22:41:36 +0000
@@ -23,7 +23,7 @@
2323
24try:24try:
25 from zeitgeist.client import ZeitgeistClient25 from zeitgeist.client import ZeitgeistClient
26 from zeitgeist.datamodel import Event, Interpretation, ResultType26 from zeitgeist.datamodel import Event, Interpretation, ResultType, TimeRange
27except ImportError:27except ImportError:
28 LOG.exception("zeitgeist import failed")28 LOG.exception("zeitgeist import failed")
29 ZEITGEIST_AVAILABLE = False29 ZEITGEIST_AVAILABLE = False
@@ -89,12 +89,38 @@
89 self.zg_client.find_events_for_template(89 self.zg_client.find_events_for_template(
90 [], _callback, num_events=1000, 90 [], _callback, num_events=1000,
91 result_type=ResultType.MostRecentEvents)91 result_type=ResultType.MostRecentEvents)
92
93 def get_unused_applications(self, callback, timerange=None):
94 """ Get applications that weren't used for a specific timerange
95 (defaults to 1 month) and call "callback" with a list of
96 applications as an argument
97 """
98
99 def _callback(events):
100 if timerange is not None:
101 timestamp = int(time.time() - timerange)
102 else:
103 timestamp = int(time.time() - (86400000*30)) # one month
104
105 unused_apps = []
106 for e in events:
107 if int(e.timestamp) < timestamp:
108 unused_apps.append(e.actor)
109
110 callback(unused_apps)
111
112 self.zg_client.find_events_for_template(None, _callback,
113 timerange=TimeRange.always(), num_events=0,
114 result_type=ResultType.MostRecentActor)
115
92116
93class SoftwareCenterZeitgeistDummy():117class SoftwareCenterZeitgeistDummy():
94 def get_usage_counter(self, application, callback, timerange=None):118 def get_usage_counter(self, application, callback, timerange=None):
95 callback(0)119 callback(0)
96 def get_popular_mimetypes(self, callback):120 def get_popular_mimetypes(self, callback):
97 callback([])121 callback([])
122 def get_unused_applications(self, callback, timerange=None):
123 callback([])
98124
99# singleton125# singleton
100if ZEITGEIST_AVAILABLE:126if ZEITGEIST_AVAILABLE:
@@ -119,7 +145,7 @@
119 def _callback_popular(mimetypes):145 def _callback_popular(mimetypes):
120 print "test _callback: "146 print "test _callback: "
121 for tuple in mimetypes:147 for tuple in mimetypes:
122 print tuple148 print tuple
123 zeitgeist_singleton.get_popular_mimetypes(_callback_popular)149 zeitgeist_singleton.get_popular_mimetypes(_callback_popular)
124150
125 import gtk151 import gtk
126152
=== modified file 'softwarecenter/db/database.py'
--- softwarecenter/db/database.py 2010-10-12 08:37:12 +0000
+++ softwarecenter/db/database.py 2010-10-24 22:41:36 +0000
@@ -239,6 +239,16 @@
239 if len(apps) == num:239 if len(apps) == num:
240 break240 break
241 return apps241 return apps
242
243 def get_application_from_desktop_file(self, desktop_file):
244 enquire = xapian.Enquire(self.xapiandb)
245 query = xapian.Query("AP%s" % desktop_file[14:-8])
246 enquire.set_query(query)
247 matches = enquire.get_mset(0, 100)
248 for match in matches:
249 doc = match.get_document()
250 app = Application(self.get_appname(doc), self.get_pkgname(doc))
251 return app
242252
243 def get_summary(self, doc):253 def get_summary(self, doc):
244 """ get human readable summary of the given document """254 """ get human readable summary of the given document """
245255
=== modified file 'softwarecenter/view/catview_gtk.py'
--- softwarecenter/view/catview_gtk.py 2010-10-12 10:30:11 +0000
+++ softwarecenter/view/catview_gtk.py 2010-10-24 22:41:36 +0000
@@ -326,6 +326,7 @@
326 self._append_departments()326 self._append_departments()
327 self._append_featured_and_new()327 self._append_featured_and_new()
328 self._append_recommendations()328 self._append_recommendations()
329 self._append_unused_applications()
329 return330 return
330331
331 def _append_recommendations(self):332 def _append_recommendations(self):
@@ -389,7 +390,64 @@
389 390
390 zeitgeist_singleton.get_popular_mimetypes(_popular_mimetypes_callback)391 zeitgeist_singleton.get_popular_mimetypes(_popular_mimetypes_callback)
391 392
392393 def _append_unused_applications(self):
394 def _show_unused_apps_widget(query, r_apps):
395 # build UI
396 self.hbox = gtk.HBox()
397 unused = gettext.ngettext("There is",
398 "There are",
399 len(r_apps))
400 self.hbox.pack_start(gtk.Label(unused), False, False)
401 label = gettext.ngettext("%(len)i unused applications",
402 "%(len)i unused applications",
403 len(r_apps)) % { 'len' : len(r_apps) }
404 linkbutton = mkit.HLinkButton(label)
405 linkbutton.set_underline(True)
406 linkbutton.set_subdued(True)
407 self.hbox.pack_start(linkbutton, False, False)
408 self.hbox.pack_start(gtk.Label("you can remove."), False, False)
409 self.vbox.pack_start(self.hbox, False, False)
410 self.vbox.reorder_child(self.hbox, -1)
411 # build fake category
412 name = gobject.markup_escape_text(_("Unused applications"))
413 rec_btn = CategoryButton(name, "category-unused", self.icons)
414 rec_cat = Category("Unused applications", _("Unused Applications"),
415 "category-unused", query, sortmode=SORT_BY_SEARCH_RANKING)
416 rec_btn.connect('clicked', self._on_category_clicked, rec_cat)
417 self.departments.append(rec_btn)
418
419 linkbutton.connect('clicked', self._on_category_clicked, rec_cat)
420
421 self.show_all()
422
423 def _unused_applications_callback(unused):
424 def _find_applications(names):
425 apps = []
426 for name in names:
427 app = self.db.get_application_from_desktop_file(name)
428 if app is not None and \
429 app.get_details(self.db).pkg_state == PKG_STATE_INSTALLED and \
430 not self.cache.pkg_is_important(app.get_details(self.db).pkg, get_distro()):
431 apps.append(app)
432
433 results = []
434 for app in apps:
435 results.append("AP" + app.pkgname)
436 return results
437
438 def _make_query(r_apps):
439 if len(r_apps) > 0:
440 return xapian.Query(xapian.Query.OP_OR, r_apps)
441 return None
442
443 # get the unused apps
444 r_apps =_find_applications(unused)
445 if r_apps:
446 # build the widget
447 _show_unused_apps_widget(_make_query(r_apps), r_apps)
448
449 zeitgeist_singleton.get_unused_applications(_unused_applications_callback)
450
393 def _append_featured_and_new(self):451 def _append_featured_and_new(self):
394 # carousel hbox452 # carousel hbox
395 self.hbox_inner = gtk.HBox(spacing=mkit.SPACING_MED)453 self.hbox_inner = gtk.HBox(spacing=mkit.SPACING_MED)

Subscribers

People subscribed via source and target branches