~mvo/command-not-found/gdm-experiment-for-speed-compare

« back to all changes in this revision

Viewing changes to CommandNotFound/CommandNotFound.py

  • Committer: Michael Vogt
  • Date: 2018-03-12 07:59:35 UTC
  • Revision ID: michael.vogt@ubuntu.com-20180312075935-895qzvf2re7ed032
extract header writer

Show diffs side-by-side

added added

removed removed

Lines of Context:
202
202
        print("", file=self.output_fd)
203
203
        self.output_fd.flush()
204
204
 
 
205
    def _print_exact_header(self, command):
 
206
        print(file=self.output_fd)
 
207
        print(_("Command '%(command)s' not found, but can be installed as:") % {
 
208
            'command': command}, file=self.output_fd)
 
209
        print(file=self.output_fd)
 
210
 
205
211
    def advice_single_snap_package(self, command, packages, snaps):
206
 
        # use something like jinja (just more lightweight)
207
 
        print("", file=self.output_fd)
208
 
        print(_("Command '%s' not found, but can be installed as:") % command, file=self.output_fd)
209
 
        print("", file=self.output_fd)
 
212
        self._print_exact_header(command)
210
213
        snap = snaps[0]
211
214
        if posix.geteuid() == 0:
212
215
            print("snap install %s" % snap[0], file=self.output_fd)
219
222
        self.output_fd.flush()
220
223
        
221
224
    def advice_single_deb_package(self, command, packages, snaps):
222
 
        print("", file=self.output_fd)
223
 
        print(_("Command '%s' not found, but can be installed as:") % command, file=self.output_fd)
224
 
        print("", file=self.output_fd)
 
225
        self._print_exact_header(command)
225
226
        if posix.geteuid() == 0:
226
227
            print("apt install %s" % packages[0][0], file=self.output_fd)
227
228
            self.install_prompt(packages[0][0])
237
238
        self.output_fd.flush()
238
239
 
239
240
    def advice_multi_deb_package(self, command, packages, snaps):
240
 
        print("", file=self.output_fd)
241
 
        print(_("Command '%s' not found, but can be installed as:") % command, file=self.output_fd)
242
 
        print("", file=self.output_fd)
 
241
        self._print_exact_header(command)
243
242
        for package in packages:
244
243
            ver = ""
245
244
            if package[1]:
259
258
        self.output_fd.flush()
260
259
 
261
260
    def advice_multi_snap_packages(self, command, packages, snaps):
262
 
        # use something like jinja (just more lightweight)
263
 
        print("", file=self.output_fd)
264
 
        print(_("Command '%s' not found, but can be installed as:") % command, file=self.output_fd)
265
 
        print("", file=self.output_fd)
 
261
        self._print_exact_header(command)
266
262
        for snap in snaps:
267
263
            ver = " (snap)"
268
264
            if snap[2]: