Merge lp:~mvo/software-center/support-size-from-agent into lp:software-center

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3276
Proposed branch: lp:~mvo/software-center/support-size-from-agent
Merge into: lp:software-center
Diff against target: 133 lines (+37/-1)
5 files modified
softwarecenter/db/application.py (+6/-0)
softwarecenter/db/update.py (+9/-0)
softwarecenter/enums.py (+3/-0)
softwarecenter/ui/gtk3/views/appdetailsview.py (+11/-0)
tests/test_reinstall_purchased.py (+8/-1)
To merge this branch: bzr merge lp:~mvo/software-center/support-size-from-agent
Reviewer Review Type Date Requested Status
dobey Approve
software-store-developers Pending
Review via email: mp+139475@code.launchpad.net

Description of the change

Support showing the download size if the software-center-agent provides it.

To post a comment you must log in.
Revision history for this message
dobey (dobey) wrote :

Looks ok to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/application.py'
2--- softwarecenter/db/application.py 2012-11-28 17:36:38 +0000
3+++ softwarecenter/db/application.py 2012-12-12 14:43:27 +0000
4@@ -23,6 +23,7 @@
5 import logging
6 import os
7 import re
8+import xapian
9
10 import softwarecenter.distro
11
12@@ -696,6 +697,11 @@
13 return self._pkg.candidate.size
14 else:
15 return self._pkg.installed.size
16+ elif self._doc:
17+ size = self._doc.get_value(XapianValues.DOWNLOAD_SIZE)
18+ if size:
19+ return xapian.sortable_unserialise(
20+ self._doc.get_value(XapianValues.DOWNLOAD_SIZE))
21
22 @property
23 def tags(self):
24
25=== modified file 'softwarecenter/db/update.py'
26--- softwarecenter/db/update.py 2012-12-06 16:16:49 +0000
27+++ softwarecenter/db/update.py 2012-12-12 14:43:27 +0000
28@@ -148,6 +148,7 @@
29 AppInfoFields.CHANNEL: XapianValues.ARCHIVE_CHANNEL,
30 AppInfoFields.DEB_LINE: XapianValues.ARCHIVE_DEB_LINE,
31 AppInfoFields.DESCRIPTION: XapianValues.SC_DESCRIPTION,
32+ AppInfoFields.DOWNLOAD_SIZE: XapianValues.DOWNLOAD_SIZE,
33 AppInfoFields.CATEGORIES: XapianValues.CATEGORIES,
34 AppInfoFields.CURRENCY: XapianValues.CURRENCY,
35 AppInfoFields.DATE_PUBLISHED: XapianValues.DATE_PUBLISHED,
36@@ -383,6 +384,12 @@
37 # ever changes we can update
38 doc.add_value(XapianValues.CURRENCY, "US$")
39
40+ # add donwload size as string (its send as int)
41+ download_size = self.get_value(AppInfoFields.DOWNLOAD_SIZE)
42+ if download_size is not None:
43+ doc.add_value(XapianValues.DOWNLOAD_SIZE,
44+ xapian.sortable_serialise((download_size)))
45+
46 # write out categories
47 for cat in self.get_categories():
48 doc.add_term("AC" + cat.lower())
49@@ -534,6 +541,7 @@
50 AppInfoFields.PACKAGE: 'package_name',
51 AppInfoFields.PRICE: 'price',
52 AppInfoFields.DESCRIPTION: 'description',
53+ AppInfoFields.DOWNLOAD_SIZE: 'binary_filesize',
54 AppInfoFields.SUPPORTED_DISTROS: 'series',
55 AppInfoFields.SCREENSHOT_URLS: 'screenshot_url',
56 AppInfoFields.SUMMARY: 'comment',
57@@ -792,6 +800,7 @@
58 AppInfoFields.DATE_PUBLISHED: 'X-AppInstall-Date-Published',
59 AppInfoFields.DEB_LINE: 'X-AppInstall-Deb-Line',
60 AppInfoFields.DESCRIPTION: 'X-AppInstall-Description',
61+ AppInfoFields.DOWNLOAD_SIZE: 'X-AppInstall-DownloadSize',
62 AppInfoFields.GENERIC_NAME: 'GenericName',
63 AppInfoFields.GETTEXT_DOMAIN: 'X-Ubuntu-Gettext-Domain',
64 AppInfoFields.ICON: 'Icon',
65
66=== modified file 'softwarecenter/enums.py'
67--- softwarecenter/enums.py 2012-11-28 16:58:59 +0000
68+++ softwarecenter/enums.py 2012-12-12 14:43:27 +0000
69@@ -169,6 +169,8 @@
70 # this is used to provide a cataloged time if there is no a-x-i in use
71 # or if a-x-i is not available yet
72 DB_CATALOGED_TIME = 202
73+ # download size as the agent provides it
74+ DOWNLOAD_SIZE = 203
75
76
77 class AppInfoFields:
78@@ -176,6 +178,7 @@
79 CHANNEL = 'CHANNEL'
80 DEB_LINE = 'DEB_LINE'
81 DEB_LINE_ORIG = 'DEB_LINE_ORIG'
82+ DOWNLOAD_SIZE = 'DOWNLOAD_SIZE'
83 CATEGORIES = 'CATEGORIES'
84 DATE_PUBLISHED = 'DATE_PUBLISHED'
85 DESCRIPTION = 'DESCRIPTION'
86
87=== modified file 'softwarecenter/ui/gtk3/views/appdetailsview.py'
88--- softwarecenter/ui/gtk3/views/appdetailsview.py 2012-12-06 16:16:49 +0000
89+++ softwarecenter/ui/gtk3/views/appdetailsview.py 2012-12-12 14:43:27 +0000
90@@ -2004,6 +2004,17 @@
91 if not self.totalsize_info.get_property('visible'):
92 return False
93
94+ # if we need to purchase/enable the report use the agent info
95+ if self.app_details.pkg_state in (
96+ PkgStates.NEEDS_SOURCE,
97+ PkgStates.NEEDS_PURCHASE,
98+ PkgStates.PURCHASED_BUT_REPO_MUST_BE_ENABLED,
99+ ):
100+ if self.app_details.size:
101+ self.totalsize_info.set_value(
102+ GLib.format_size(self.app_details.size))
103+ return
104+
105 self.totalsize_info.set_value(_("Calculating..."))
106
107 while Gtk.events_pending():
108
109=== modified file 'tests/test_reinstall_purchased.py'
110--- tests/test_reinstall_purchased.py 2012-11-28 15:52:31 +0000
111+++ tests/test_reinstall_purchased.py 2012-12-12 14:43:27 +0000
112@@ -96,7 +96,8 @@
113 "categories": "AudioVideo",
114 "description": "Play DVD-Videos\\r\\n\\r\\nFluendo DVD Player is a software application specially designed to\\r\\nreproduce DVD on Linux/Unix platforms, which provides end users with\\r\\nhigh quality standards.\\r\\n\\r\\nThe following features are provided:\\r\\n* Full DVD Playback\\r\\n* DVD Menu support\\r\\n* Fullscreen support\\r\\n* Dolby Digital pass-through\\r\\n* Dolby Digital 5.1 output and stereo downmixing support\\r\\n* Resume from last position support\\r\\n* Subtitle support\\r\\n* Audio selection support\\r\\n* Multiple Angles support\\r\\n* Support for encrypted discs\\r\\n* Multiregion, works in all regions\\r\\n* Multiple video deinterlacing algorithms",
115 "website": null,
116- "version": "1.2.1"
117+ "version": "1.2.1",
118+ "binary_filesize": 12345
119 },
120 {
121 "website": "",
122@@ -163,6 +164,12 @@
123 self.assertEqual('Fluendo DVD Player',
124 parser.get_value(AppInfoFields.NAME))
125
126+ def test_binary_filesize(self):
127+ parser = self._make_application_parser()
128+
129+ self.assertEqual(12345,
130+ parser.get_value(AppInfoFields.DOWNLOAD_SIZE))
131+
132 def test_keys_not_provided_by_api(self):
133 parser = self._make_application_parser()
134

Subscribers

People subscribed via source and target branches