Merge lp:~didrocks/ubiquity/intall-metrics into lp:ubiquity
- intall-metrics
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 6596 |
Proposed branch: | lp:~didrocks/ubiquity/intall-metrics |
Merge into: | lp:ubiquity |
Diff against target: |
390 lines (+150/-21) 8 files modified
debian/changelog (+4/-0) ubiquity/frontend/debconf_ui.py (+5/-1) ubiquity/frontend/gtk_ui.py (+8/-1) ubiquity/frontend/kde_components/PartAuto.py (+7/-5) ubiquity/frontend/kde_ui.py (+7/-1) ubiquity/frontend/noninteractive.py (+5/-1) ubiquity/plugins/ubi-partman.py (+18/-12) ubiquity/telemetry.py (+96/-0) |
To merge this branch: | bzr merge lp:~didrocks/ubiquity/intall-metrics |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jean-Baptiste Lallement | Approve | ||
Iain Lane | Approve | ||
Review via email:
|
Commit message
Description of the change
Add telemetry function
Always report install metrics for optional reporting later on.
Tested on both Kubuntu and Ubuntu, with:
- side-by-side install
- use biggest free space
- reinstall over existing installation, keeping files
- reinstall and replace existing installation
- full disk used
- lvm
- crypto
- manual
- oem
- automatic installation
It should also work in debconf UI mode, but I'm unsure how to test it.
- 6593. By Jean-Baptiste Lallement
-
[ Sebastien Bacher ]
* gui/gtk/stepPrepare. ui:
- updated the non-free-software text to not include the mention to the
MP3 fluendo codecs since those have been superseeded in the recent
gstreamer version. - 6594. By Jean-Baptiste Lallement
-
[ Sebastien Bacher ]
* Rename the "Preparing to install Ubuntu" installer step to "Updates and
other software" according to the design, thanks Matthew for pointing out
the inconsistency - 6595. By Jean-Baptiste Lallement
-
* debian/control: fixed dependency on sensible-utils
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
Waiting for your comments on my answer before going further :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
ok, sounds like I can't make it a singleton easily without breaking the MVC semantic in place.
I have changed the global as a class variable and made the time measurement relative + adding a "start time"
Let me know what you think about class singleton vs code consistency and "Steps" naming
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Iain Lane (laney) wrote : | # |
some replies to your comments but I had to do them on the old version of the diff
thanks for considering. As commented I think we should discuss what the requirements for timing data are as this seems a bit strange to me. After getting that settled and maybe adding some protection to the file saving I'm OK with this once jibel has tested and given his thumbs up. Cheers!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
Done of protecting telemetry. Let's wait on finishing our discussion on what to collect :)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Sebastien Bacher (seb128) wrote : | # |
Ok, I've replied on the "recording the steps" comments, those seem like they could be useful to validate design changes and see their impact on the users
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Didier Roche-Tolomelli (didrocks) wrote : | # |
Tested latest rebased version with the GTK installer, all working!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Iain Lane (laney) wrote : | # |
ok from my side, waiting for QA to approve too
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jean-Baptiste Lallement (jibel) wrote : | # |
LGTM too. Thanks!
- 6596. By Jean-Baptiste Lallement
-
* Added telemetry feature to collect installation metrics and optional reporting later on. Thanks didrocks
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2018-03-09 10:43:07 +0000 | |||
3 | +++ debian/changelog 2018-03-13 11:08:32 +0000 | |||
4 | @@ -12,6 +12,10 @@ | |||
5 | 12 | other software" according to the design, thanks Matthew for pointing | 12 | other software" according to the design, thanks Matthew for pointing |
6 | 13 | out the inconsistency | 13 | out the inconsistency |
7 | 14 | 14 | ||
8 | 15 | [ Didier Roche ] | ||
9 | 16 | * Collect and dump telemetry info as a log file: (LP: #1755456) | ||
10 | 17 | Those installation telemetry info are for optional upload later on. | ||
11 | 18 | |||
12 | 15 | -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 28 Feb 2018 14:36:54 -0500 | 19 | -- Mathieu Trudel-Lapierre <cyphermox@ubuntu.com> Wed, 28 Feb 2018 14:36:54 -0500 |
13 | 16 | 20 | ||
14 | 17 | ubiquity (18.04.3) bionic; urgency=medium | 21 | ubiquity (18.04.3) bionic; urgency=medium |
15 | 18 | 22 | ||
16 | === modified file 'ubiquity/frontend/debconf_ui.py' | |||
17 | --- ubiquity/frontend/debconf_ui.py 2013-02-19 11:33:07 +0000 | |||
18 | +++ ubiquity/frontend/debconf_ui.py 2018-03-13 11:08:32 +0000 | |||
19 | @@ -33,7 +33,7 @@ | |||
20 | 33 | 33 | ||
21 | 34 | import debconf | 34 | import debconf |
22 | 35 | 35 | ||
24 | 36 | from ubiquity import i18n | 36 | from ubiquity import i18n, telemetry |
25 | 37 | from ubiquity.components import install, plugininstall | 37 | from ubiquity.components import install, plugininstall |
26 | 38 | from ubiquity.frontend.base import BaseFrontend, Controller | 38 | from ubiquity.frontend.base import BaseFrontend, Controller |
27 | 39 | from ubiquity.plugin import Plugin | 39 | from ubiquity.plugin import Plugin |
28 | @@ -94,6 +94,9 @@ | |||
29 | 94 | 'cannot continue without them.'), file=sys.stderr) | 94 | 'cannot continue without them.'), file=sys.stderr) |
30 | 95 | sys.exit(1) | 95 | sys.exit(1) |
31 | 96 | 96 | ||
32 | 97 | telemetry.get().set_installer_type('DebConf') | ||
33 | 98 | telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG) | ||
34 | 99 | |||
35 | 97 | self.pagesindex = 0 | 100 | self.pagesindex = 0 |
36 | 98 | self.pageslen = 0 | 101 | self.pageslen = 0 |
37 | 99 | self.pages = [] | 102 | self.pages = [] |
38 | @@ -152,6 +155,7 @@ | |||
39 | 152 | "Install failed with exit code %s; see " | 155 | "Install failed with exit code %s; see " |
40 | 153 | "/var/log/syslog" % ret) | 156 | "/var/log/syslog" % ret) |
41 | 154 | 157 | ||
42 | 158 | telemetry.get().done(self.db) | ||
43 | 155 | return 0 | 159 | return 0 |
44 | 156 | else: | 160 | else: |
45 | 157 | return 10 | 161 | return 10 |
46 | 158 | 162 | ||
47 | === modified file 'ubiquity/frontend/gtk_ui.py' | |||
48 | --- ubiquity/frontend/gtk_ui.py 2017-09-28 21:25:09 +0000 | |||
49 | +++ ubiquity/frontend/gtk_ui.py 2018-03-13 11:08:32 +0000 | |||
50 | @@ -54,7 +54,7 @@ | |||
51 | 54 | from ubiquity import gtkwidgets | 54 | from ubiquity import gtkwidgets |
52 | 55 | 55 | ||
53 | 56 | from ubiquity import ( | 56 | from ubiquity import ( |
55 | 57 | filteredcommand, gsettings, i18n, validation, misc, osextras) | 57 | filteredcommand, gsettings, i18n, validation, misc, osextras, telemetry) |
56 | 58 | from ubiquity.components import install, plugininstall, partman_commit | 58 | from ubiquity.components import install, plugininstall, partman_commit |
57 | 59 | import ubiquity.frontend.base | 59 | import ubiquity.frontend.base |
58 | 60 | from ubiquity.frontend.base import BaseFrontend | 60 | from ubiquity.frontend.base import BaseFrontend |
59 | @@ -757,6 +757,8 @@ | |||
60 | 757 | self.debconf_progress_cancellable(False) | 757 | self.debconf_progress_cancellable(False) |
61 | 758 | self.refresh() | 758 | self.refresh() |
62 | 759 | 759 | ||
63 | 760 | telemetry.get().set_installer_type('GTK') | ||
64 | 761 | |||
65 | 760 | self.set_current_page(0) | 762 | self.set_current_page(0) |
66 | 761 | self.live_installer.show() | 763 | self.live_installer.show() |
67 | 762 | 764 | ||
68 | @@ -821,6 +823,8 @@ | |||
69 | 821 | # postinstall will exit here by calling Gtk.main_quit in | 823 | # postinstall will exit here by calling Gtk.main_quit in |
70 | 822 | # find_next_step. | 824 | # find_next_step. |
71 | 823 | 825 | ||
72 | 826 | telemetry.get().done(self.db) | ||
73 | 827 | |||
74 | 824 | self.unlock_environment() | 828 | self.unlock_environment() |
75 | 825 | if self.oem_user_config: | 829 | if self.oem_user_config: |
76 | 826 | self.quit_installer() | 830 | self.quit_installer() |
77 | @@ -1555,6 +1559,7 @@ | |||
78 | 1555 | for i in range(len(self.pages))[index + 1:]: | 1559 | for i in range(len(self.pages))[index + 1:]: |
79 | 1556 | self.dot_grid.get_child_at(i, 0).set_fraction(0) | 1560 | self.dot_grid.get_child_at(i, 0).set_fraction(0) |
80 | 1557 | 1561 | ||
81 | 1562 | telemetry.get().add_stage(name) | ||
82 | 1558 | syslog.syslog('switched to page %s' % name) | 1563 | syslog.syslog('switched to page %s' % name) |
83 | 1559 | 1564 | ||
84 | 1560 | # Callbacks provided to components. | 1565 | # Callbacks provided to components. |
85 | @@ -1645,6 +1650,8 @@ | |||
86 | 1645 | return False | 1650 | return False |
87 | 1646 | 1651 | ||
88 | 1647 | def switch_to_install_interface(self): | 1652 | def switch_to_install_interface(self): |
89 | 1653 | if not self.installing: | ||
90 | 1654 | telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG) | ||
91 | 1648 | self.installing = True | 1655 | self.installing = True |
92 | 1649 | self.lockdown_environment() | 1656 | self.lockdown_environment() |
93 | 1650 | 1657 | ||
94 | 1651 | 1658 | ||
95 | === modified file 'ubiquity/frontend/kde_components/PartAuto.py' | |||
96 | --- ubiquity/frontend/kde_components/PartAuto.py 2016-08-26 07:13:37 +0000 | |||
97 | +++ ubiquity/frontend/kde_components/PartAuto.py 2018-03-13 11:08:32 +0000 | |||
98 | @@ -252,18 +252,20 @@ | |||
99 | 252 | disk_id = self.extra_options['use_device'][1][comboText][0] | 252 | disk_id = self.extra_options['use_device'][1][comboText][0] |
100 | 253 | disk_id = disk_id.rsplit('/', 1)[1] | 253 | disk_id = disk_id.rsplit('/', 1)[1] |
101 | 254 | option = self.extra_options['resize'][disk_id][0] | 254 | option = self.extra_options['resize'][disk_id][0] |
103 | 255 | return option, '%d B' % self.resizeSize | 255 | return option, '%d B' % self.resizeSize, 'resize_use_free' |
104 | 256 | elif choice == self.useDeviceChoice: | 256 | elif choice == self.useDeviceChoice: |
105 | 257 | return (self.extra_options['use_device'][0], | 257 | return (self.extra_options['use_device'][0], |
107 | 258 | str(self.part_auto_disk_box.currentText())) | 258 | str(self.part_auto_disk_box.currentText()), 'use_device') |
108 | 259 | elif choice == self.lvm_choice: | 259 | elif choice == self.lvm_choice: |
109 | 260 | return (choice, | 260 | return (choice, |
111 | 261 | str(self.part_auto_disk_box.currentText())) | 261 | str(self.part_auto_disk_box.currentText()), 'use_lvm') |
112 | 262 | elif choice == self.crypto_choice: | 262 | elif choice == self.crypto_choice: |
113 | 263 | return (choice, | 263 | return (choice, |
115 | 264 | str(self.part_auto_disk_box.currentText())) | 264 | str(self.part_auto_disk_box.currentText()), 'use_crypto') |
116 | 265 | elif choice == self.manualChoice: | ||
117 | 266 | return choice, None, 'manual' | ||
118 | 265 | else: | 267 | else: |
120 | 266 | return choice, None | 268 | return choice, None, 'unknown' |
121 | 267 | 269 | ||
122 | 268 | def on_disks_combo_changed(self, index): | 270 | def on_disks_combo_changed(self, index): |
123 | 269 | for e in self.bar_frames: | 271 | for e in self.bar_frames: |
124 | 270 | 272 | ||
125 | === modified file 'ubiquity/frontend/kde_ui.py' | |||
126 | --- ubiquity/frontend/kde_ui.py 2017-01-09 20:15:33 +0000 | |||
127 | +++ ubiquity/frontend/kde_ui.py 2018-03-13 11:08:32 +0000 | |||
128 | @@ -41,7 +41,7 @@ | |||
129 | 41 | sip.setapi("QVariant", 1) | 41 | sip.setapi("QVariant", 1) |
130 | 42 | from PyQt5 import QtCore, QtGui, QtWidgets, uic | 42 | from PyQt5 import QtCore, QtGui, QtWidgets, uic |
131 | 43 | 43 | ||
133 | 44 | from ubiquity import filteredcommand, i18n, misc | 44 | from ubiquity import filteredcommand, i18n, misc, telemetry |
134 | 45 | from ubiquity.components import partman_commit, install, plugininstall | 45 | from ubiquity.components import partman_commit, install, plugininstall |
135 | 46 | import ubiquity.frontend.base | 46 | import ubiquity.frontend.base |
136 | 47 | from ubiquity.frontend.base import BaseFrontend | 47 | from ubiquity.frontend.base import BaseFrontend |
137 | @@ -454,6 +454,8 @@ | |||
138 | 454 | self.get_string('ubiquity/install/title')) | 454 | self.get_string('ubiquity/install/title')) |
139 | 455 | self.refresh() | 455 | self.refresh() |
140 | 456 | 456 | ||
141 | 457 | telemetry.get().set_installer_type('KDE') | ||
142 | 458 | |||
143 | 457 | # Start the interface | 459 | # Start the interface |
144 | 458 | self.set_current_page(0) | 460 | self.set_current_page(0) |
145 | 459 | 461 | ||
146 | @@ -529,6 +531,8 @@ | |||
147 | 529 | self.start_slideshow() | 531 | self.start_slideshow() |
148 | 530 | self.run_main_loop() | 532 | self.run_main_loop() |
149 | 531 | 533 | ||
150 | 534 | telemetry.get().done(self.db) | ||
151 | 535 | |||
152 | 532 | quitText = '<qt>%s</qt>' % self.get_string("finished_label") | 536 | quitText = '<qt>%s</qt>' % self.get_string("finished_label") |
153 | 533 | rebootButtonText = self.get_string("reboot_button") | 537 | rebootButtonText = self.get_string("reboot_button") |
154 | 534 | shutdownButtonText = self.get_string("shutdown_button") | 538 | shutdownButtonText = self.get_string("shutdown_button") |
155 | @@ -1121,6 +1125,7 @@ | |||
156 | 1121 | self.ui.content_widget.show() | 1125 | self.ui.content_widget.show() |
157 | 1122 | self.current_page = newPageID | 1126 | self.current_page = newPageID |
158 | 1123 | name = self.step_name(newPageID) | 1127 | name = self.step_name(newPageID) |
159 | 1128 | telemetry.get().add_stage(name) | ||
160 | 1124 | syslog.syslog('switched to page %s' % name) | 1129 | syslog.syslog('switched to page %s' % name) |
161 | 1125 | if 'UBIQUITY_GREETER' in os.environ: | 1130 | if 'UBIQUITY_GREETER' in os.environ: |
162 | 1126 | if name == 'language': | 1131 | if name == 'language': |
163 | @@ -1291,6 +1296,7 @@ | |||
164 | 1291 | elif finished_step == 'ubi-partman': | 1296 | elif finished_step == 'ubi-partman': |
165 | 1292 | # Flush changes to the database so that when the parallel db | 1297 | # Flush changes to the database so that when the parallel db |
166 | 1293 | # starts, it does so with the most recent changes. | 1298 | # starts, it does so with the most recent changes. |
167 | 1299 | telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG) | ||
168 | 1294 | self.stop_debconf() | 1300 | self.stop_debconf() |
169 | 1295 | self.start_debconf() | 1301 | self.start_debconf() |
170 | 1296 | self._show_progress_bar(True) | 1302 | self._show_progress_bar(True) |
171 | 1297 | 1303 | ||
172 | === modified file 'ubiquity/frontend/noninteractive.py' | |||
173 | --- ubiquity/frontend/noninteractive.py 2014-06-30 13:09:16 +0000 | |||
174 | +++ ubiquity/frontend/noninteractive.py 2018-03-13 11:08:32 +0000 | |||
175 | @@ -32,7 +32,7 @@ | |||
176 | 32 | 32 | ||
177 | 33 | from gi.repository import GLib | 33 | from gi.repository import GLib |
178 | 34 | 34 | ||
180 | 35 | from ubiquity import filteredcommand, i18n, misc | 35 | from ubiquity import filteredcommand, i18n, misc, telemetry |
181 | 36 | from ubiquity.components import install, plugininstall, partman_commit | 36 | from ubiquity.components import install, plugininstall, partman_commit |
182 | 37 | import ubiquity.frontend.base | 37 | import ubiquity.frontend.base |
183 | 38 | from ubiquity.frontend.base import BaseFrontend | 38 | from ubiquity.frontend.base import BaseFrontend |
184 | @@ -77,6 +77,9 @@ | |||
185 | 77 | file=self.console) | 77 | file=self.console) |
186 | 78 | sys.exit(1) | 78 | sys.exit(1) |
187 | 79 | 79 | ||
188 | 80 | telemetry.get().set_installer_type('NonInteractive') | ||
189 | 81 | telemetry.get().add_stage(telemetry.START_INSTALL_STAGE_TAG) | ||
190 | 82 | |||
191 | 80 | for x in self.pages: | 83 | for x in self.pages: |
192 | 81 | if issubclass(x.filter_class, Plugin): | 84 | if issubclass(x.filter_class, Plugin): |
193 | 82 | ui = x.ui | 85 | ui = x.ui |
194 | @@ -110,6 +113,7 @@ | |||
195 | 110 | if ret == 0: | 113 | if ret == 0: |
196 | 111 | self.run_success_cmd() | 114 | self.run_success_cmd() |
197 | 112 | print('Installation complete.', file=self.console) | 115 | print('Installation complete.', file=self.console) |
198 | 116 | telemetry.get().done(self.db) | ||
199 | 113 | if self.get_reboot(): | 117 | if self.get_reboot(): |
200 | 114 | misc.execute("reboot") | 118 | misc.execute("reboot") |
201 | 115 | if ret != 0: | 119 | if ret != 0: |
202 | 116 | 120 | ||
203 | === modified file 'ubiquity/plugins/ubi-partman.py' | |||
204 | --- ubiquity/plugins/ubi-partman.py 2016-12-02 13:20:16 +0000 | |||
205 | +++ ubiquity/plugins/ubi-partman.py 2018-03-13 11:08:32 +0000 | |||
206 | @@ -25,7 +25,8 @@ | |||
207 | 25 | 25 | ||
208 | 26 | import debconf | 26 | import debconf |
209 | 27 | 27 | ||
211 | 28 | from ubiquity import misc, osextras, parted_server, plugin, validation | 28 | from ubiquity import (misc, osextras, parted_server, plugin, |
212 | 29 | telemetry, validation) | ||
213 | 29 | from ubiquity.install_misc import archdetect | 30 | from ubiquity.install_misc import archdetect |
214 | 30 | 31 | ||
215 | 31 | 32 | ||
216 | @@ -673,22 +674,24 @@ | |||
217 | 673 | 674 | ||
218 | 674 | def get_autopartition_choice(self): | 675 | def get_autopartition_choice(self): |
219 | 675 | if self.reuse_partition.get_active(): | 676 | if self.reuse_partition.get_active(): |
221 | 676 | return self.extra_options['reuse'][0][0], None | 677 | return self.extra_options['reuse'][0][0], None, 'reuse_partition' |
222 | 677 | 678 | ||
223 | 678 | if self.replace_partition.get_active(): | 679 | if self.replace_partition.get_active(): |
225 | 679 | return self.extra_options['replace'][0], None | 680 | return (self.extra_options['replace'][0], None, |
226 | 681 | 'reinstall_partition') | ||
227 | 680 | 682 | ||
228 | 681 | elif self.custom_partitioning.get_active(): | 683 | elif self.custom_partitioning.get_active(): |
230 | 682 | return self.extra_options['manual'], None | 684 | return self.extra_options['manual'], None, 'manual' |
231 | 683 | 685 | ||
232 | 684 | elif self.resize_use_free.get_active(): | 686 | elif self.resize_use_free.get_active(): |
233 | 685 | if 'biggest_free' in self.extra_options: | 687 | if 'biggest_free' in self.extra_options: |
234 | 686 | choice = self.extra_options['biggest_free'][0] | 688 | choice = self.extra_options['biggest_free'][0] |
236 | 687 | return choice, None | 689 | return choice, None, 'resize_use_free' |
237 | 688 | else: | 690 | else: |
238 | 689 | disk_id = self.get_current_disk_partman_id() | 691 | disk_id = self.get_current_disk_partman_id() |
239 | 690 | choice = self.extra_options['resize'][disk_id][0] | 692 | choice = self.extra_options['resize'][disk_id][0] |
241 | 691 | return choice, '%s B' % self.resizewidget.get_size() | 693 | return (choice, '%s B' % self.resizewidget.get_size(), |
242 | 694 | 'resize_use_free') | ||
243 | 692 | 695 | ||
244 | 693 | elif self.use_device.get_active(): | 696 | elif self.use_device.get_active(): |
245 | 694 | def choose_recipe(): | 697 | def choose_recipe(): |
246 | @@ -702,13 +705,15 @@ | |||
247 | 702 | 705 | ||
248 | 703 | if not ((want_crypto and have_crypto) or | 706 | if not ((want_crypto and have_crypto) or |
249 | 704 | (want_lvm and have_lvm)): | 707 | (want_lvm and have_lvm)): |
251 | 705 | return self.extra_options['use_device'][0] | 708 | return self.extra_options['use_device'][0], 'use_device' |
252 | 706 | 709 | ||
253 | 707 | if want_crypto: | 710 | if want_crypto: |
255 | 708 | return self.extra_options['some_device_crypto'] | 711 | return (self.extra_options['some_device_crypto'], |
256 | 712 | 'use_crypto') | ||
257 | 709 | 713 | ||
258 | 710 | if want_lvm: | 714 | if want_lvm: |
260 | 711 | return self.extra_options['some_device_lvm'] | 715 | return (self.extra_options['some_device_lvm'], |
261 | 716 | 'use_lvm') | ||
262 | 712 | 717 | ||
263 | 713 | # Something went horribly wrong, we should have returned | 718 | # Something went horribly wrong, we should have returned |
264 | 714 | # earlier | 719 | # earlier |
265 | @@ -717,9 +722,9 @@ | |||
266 | 717 | i = self.part_auto_select_drive.get_active_iter() | 722 | i = self.part_auto_select_drive.get_active_iter() |
267 | 718 | m = self.part_auto_select_drive.get_model() | 723 | m = self.part_auto_select_drive.get_model() |
268 | 719 | disk = m.get_value(i, 0) | 724 | disk = m.get_value(i, 0) |
270 | 720 | choice = choose_recipe() | 725 | choice, method = choose_recipe() |
271 | 721 | # Is the encoding necessary? | 726 | # Is the encoding necessary? |
273 | 722 | return choice, misc.utf8(disk, errors='replace') | 727 | return choice, misc.utf8(disk, errors='replace'), method |
274 | 723 | 728 | ||
275 | 724 | else: | 729 | else: |
276 | 725 | raise AssertionError("Couldn't get autopartition choice") | 730 | raise AssertionError("Couldn't get autopartition choice") |
277 | @@ -3249,10 +3254,11 @@ | |||
278 | 3249 | self.preseed('grub-installer/bootdev', self.ui.get_grub_choice()) | 3254 | self.preseed('grub-installer/bootdev', self.ui.get_grub_choice()) |
279 | 3250 | 3255 | ||
280 | 3251 | if self.current_question.endswith('automatically_partition'): | 3256 | if self.current_question.endswith('automatically_partition'): |
282 | 3252 | (autopartition_choice, self.extra_choice) = \ | 3257 | (autopartition_choice, self.extra_choice, method) = \ |
283 | 3253 | self.ui.get_autopartition_choice() | 3258 | self.ui.get_autopartition_choice() |
284 | 3254 | self.preseed_as_c(self.current_question, autopartition_choice, | 3259 | self.preseed_as_c(self.current_question, autopartition_choice, |
285 | 3255 | seen=False) | 3260 | seen=False) |
286 | 3261 | telemetry.get().set_partition_method(method) | ||
287 | 3256 | # Don't exit partman yet. | 3262 | # Don't exit partman yet. |
288 | 3257 | else: | 3263 | else: |
289 | 3258 | self.finish_partitioning = True | 3264 | self.finish_partitioning = True |
290 | 3259 | 3265 | ||
291 | === added file 'ubiquity/telemetry.py' | |||
292 | --- ubiquity/telemetry.py 1970-01-01 00:00:00 +0000 | |||
293 | +++ ubiquity/telemetry.py 2018-03-13 11:08:32 +0000 | |||
294 | @@ -0,0 +1,96 @@ | |||
295 | 1 | # -*- coding: utf-8; Mode: Python; indent-tabs-mode: nil; tab-width: 4 -*- | ||
296 | 2 | |||
297 | 3 | # Copyright (C) 2018 Canonical Ltd. | ||
298 | 4 | # | ||
299 | 5 | # Functions useful for the final install.py script and for ubiquity | ||
300 | 6 | # plugins to use | ||
301 | 7 | # | ||
302 | 8 | # This program is free software; you can redistribute it and/or modify | ||
303 | 9 | # it under the terms of the GNU General Public License as published by | ||
304 | 10 | # the Free Software Foundation; either version 2 of the License, or | ||
305 | 11 | # (at your option) any later version. | ||
306 | 12 | # | ||
307 | 13 | # This program is distributed in the hope that it will be useful, | ||
308 | 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
309 | 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
310 | 16 | # GNU General Public License for more details. | ||
311 | 17 | # | ||
312 | 18 | # You should have received a copy of the GNU General Public License | ||
313 | 19 | # along with this program; if not, write to the Free Software | ||
314 | 20 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
315 | 21 | |||
316 | 22 | |||
317 | 23 | import json | ||
318 | 24 | import os | ||
319 | 25 | import stat | ||
320 | 26 | import syslog | ||
321 | 27 | import time | ||
322 | 28 | |||
323 | 29 | from ubiquity.misc import raise_privileges | ||
324 | 30 | |||
325 | 31 | START_INSTALL_STAGE_TAG = 'start_install' | ||
326 | 32 | |||
327 | 33 | |||
328 | 34 | def get(): | ||
329 | 35 | """Return a singleton _Telemetry instance.""" | ||
330 | 36 | if _Telemetry._telemetry is None: | ||
331 | 37 | _Telemetry._telemetry = _Telemetry() | ||
332 | 38 | return _Telemetry._telemetry | ||
333 | 39 | |||
334 | 40 | |||
335 | 41 | class _Telemetry(): | ||
336 | 42 | |||
337 | 43 | _telemetry = None | ||
338 | 44 | |||
339 | 45 | def __init__(self): | ||
340 | 46 | self._metrics = {} | ||
341 | 47 | self._stages_hist = {} | ||
342 | 48 | self._start_time = time.time() | ||
343 | 49 | self.add_stage('start') | ||
344 | 50 | self._dest_path = '/target/var/log/installer/telemetry' | ||
345 | 51 | try: | ||
346 | 52 | with open('/cdrom/.disk/info') as f: | ||
347 | 53 | self._metrics['Media'] = f.readline() | ||
348 | 54 | except FileNotFoundError: | ||
349 | 55 | self._metrics['Media'] = 'unknown' | ||
350 | 56 | |||
351 | 57 | def add_stage(self, stage_name): | ||
352 | 58 | """Record installer stage with current time""" | ||
353 | 59 | self._stages_hist[int(time.time() - self._start_time)] = stage_name | ||
354 | 60 | |||
355 | 61 | def set_installer_type(self, installer_type): | ||
356 | 62 | """Record installer type""" | ||
357 | 63 | self._metrics['Type'] = installer_type | ||
358 | 64 | |||
359 | 65 | def set_partition_method(self, method): | ||
360 | 66 | """Record anynomized partition method""" | ||
361 | 67 | self._metrics['PartitionMethod'] = method | ||
362 | 68 | |||
363 | 69 | @raise_privileges | ||
364 | 70 | def done(self, db): | ||
365 | 71 | """Close telemetry collection | ||
366 | 72 | |||
367 | 73 | Set as installation done, add additional info and save to | ||
368 | 74 | destination file""" | ||
369 | 75 | self.add_stage('done') | ||
370 | 76 | |||
371 | 77 | self._metrics['DownloadUpdates'] = db.get('ubiquity/download_updates') | ||
372 | 78 | self._metrics['Language'] = db.get('localechooser/languagelist') | ||
373 | 79 | self._metrics['Minimal'] = db.get('ubiquity/minimal_install') | ||
374 | 80 | self._metrics['RestrictedAddons'] = db.get('ubiquity/use_nonfree') | ||
375 | 81 | self._metrics['Stages'] = self._stages_hist | ||
376 | 82 | |||
377 | 83 | target_dir = os.path.dirname(self._dest_path) | ||
378 | 84 | try: | ||
379 | 85 | if not os.path.exists(target_dir): | ||
380 | 86 | os.makedirs(target_dir) | ||
381 | 87 | with open(self._dest_path, 'w') as f: | ||
382 | 88 | json.dump(self._metrics, f) | ||
383 | 89 | os.chmod(self._dest_path, | ||
384 | 90 | stat.S_IRUSR | stat.S_IWUSR | | ||
385 | 91 | stat.S_IRGRP | stat.S_IROTH) | ||
386 | 92 | except OSError as e: | ||
387 | 93 | syslog.syslog(syslog.LOG_ERR, | ||
388 | 94 | "Exception while storing telemetry data: " + str(e)) | ||
389 | 95 | |||
390 | 96 | # vim:ai:et:sts=4:tw=80:sw=4: |
Thanks, this is great. I have some comments inline, nothing too major. :)
After fixing those, I don't think that you'd need to re-test the full matrix: if it works for one it should work equally for all the others.
Just for the record, as jibel said on IRC, it would be good to test if this works with preseeding. Even if not, that could be fixed later on though.