This file is indexed.

/usr/share/pyshared/burnlib/interactive_configure.py is in burn 0.4.6-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# -*- coding: utf-8 -*-

# burnlib/interactive_configure.py
#
# Copyright © 2009 Ben Finney <ben+python@benfinney.id.au>.
# Copyright © 2004–2009 Gaetano Paolone <bigpaul@hacknight.org>.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.

""" Interactive configuration for ‘burn’.

    main()
        Generates the ‘burn’ configuration file, from defaults and via
        interactive console dialogue.

    """

import sys
import os
import os.path
import gettext
import optparse
import pwd
import textwrap

import burnlib.version
import configure
import console
import device


#gettext
gettext.bindtextdomain('burn_configure', '/usr/share/locale/it/LC_MESSAGES/')
gettext.textdomain('burn_configure')
_ = gettext.gettext


class OptionParser(optparse.OptionParser, object):
    """ Command-line parser for this program. """

    default_program_name = "burn-configure"

    default_usage = "%prog [options]"

    default_description = _(
        "Generate configuration for Burn.")

    default_epilog = _(
        "This tool reads the default configuration from a template,"
        " queries interactively for settings specific to this system,"
        " then generates the configuration for Burn"
        " (Burn until recorded, now!) to a new file.")

    def __init__(
        self,
        prog=default_program_name,
        version=burnlib.version.version,
        usage=default_usage,
        description=default_description,
        epilog=default_epilog,
        *args, **kwargs):
        super(OptionParser, self).__init__(
            prog=prog, version=version,
            usage=usage, description=description, epilog=epilog,
            *args, **kwargs)

        self.add_option(
            "-t", "--template-file",
            action='store', dest='template_file_path',
            default="/usr/share/burn/example/burn.conf",
            metavar="PATH", help=_(
                "Read the configuration template from file PATH"
                " (default '%default')."))
        self.add_option(
            "-o", "--output-file",
            action='store', dest='output_file_path',
            default="burn.conf.new",
            metavar="PATH", help=_(
                "Write the generated configuration to file PATH"
                " (default '%default')."))

    def check_values(self, values, args):
        """ Check the parsed values and arguments. """
        max_args = 0
        if len(args) > max_args:
            args_text = " ".join(args)
            message = _("unexpected arguments: %(args_text)s") % vars()
            self.error(message)

        return (values, args)


def prog_intro(path):
    """ Introductive program output. Also checks if superuser. """
    print _(
        'Burn-configure v.%(version)s'
        + '  Written by %(author_name)s.') % vars(burnlib.version)
    print _(
        'This tool helps writing configuration file for'
        ' burn - Burn until recorded, now!')
    print _(
        'This software comes with absolutely no warranty!'
        ' Use at your own risk!')
    print _('Burn-configure is free software.')
    print _('See software updates at <URL:%(_url)s>.') % vars(burnlib)
    print
    print _('This utility will generate: '), path
    print _('Place this file as ~/.burnrc or /etc/burn.conf .')
    print
    print
    if not pwd.getpwuid(os.geteuid())[0] == "root":
        print _('You are not superuser (root).')
        print _(
            'You can still go through this configuration process'
            ' but remember that you should be root (or have permissions'
            ' on programs and devices) in order to use burn.')
        if not console.ask_yesno(
            _('Continue without superuser privilege'), True):
            sys.exit()


def giveme_realpath(path):
    """ Checks if path exists and return absolute path. """
    if os.path.exists(path):
        if os.path.islink(path):
            return os.path.realpath(path)


def main():
    """ Mainline routine for the burn-configure program. """

    option_parser = OptionParser()
    (options, args) = option_parser.parse_args()

    #Checking if there is a configuration file generated by this program
    target_conf_file_path = options.output_file_path

    prog_intro(path=target_conf_file_path)

    if os.path.exists(target_conf_file_path):
        print
        print _(
            'Target configuration file (%(target_conf_file_path)s)'
            ' already exists.') % vars()
        if console.ask_yesno(_('Remove existing target file'), False):
            print _(
                'Removing last configuration file created with burn-configure'
                '...')
            os.remove(target_conf_file_path)
        else:
            print _(
                'Exiting... Please remove or rename last configuration file: '
                '%(target_conf_file_path)s') % vars()

    # Set up a target config, populated from template.
    target_config = configure.make_config_from_template(
        options.template_file_path)

    configure_sections = target_config.sections()
    section = ''
    #beginning confuguration
    if 'general' in configure_sections:
        section = 'general'
        options = target_config.options(section)
        if 'external_decoding' in options:
            print
            current = console.make_boolean_response(
                target_config.get(section, 'external_decoding'))
            print _('Keep native audio decoding?')
            print _(
                '\tBurn is able to transform compressed audio files'
                ' (MP3, Ogg Vorbis) in WAV.')
            print _('\tChoose \'y\' if you want to keep native decoding. ')
            print _(
                '\tChoose \'n\' if you want to use external decoders'
                ' such as mpg321, ogg123, lame, etc.')
            print _(
                '\t(You will need further editing of burn configuration file)')
            response = console.ask_yesno(
                _("Keep native audio decoding"), current)
            target_config.set(
                section, 'external_decoding',
                console.make_yesno_response(response))
        if 'ask_root' in options:
            print
            current = console.make_boolean_response(
                target_config.get(section, 'ask_root'))
            print _('Prompt user if he is not root?')
            print _('\tBurn can prompt the user if he is not root.')
            print _('\tChoose \'y\' if you want to keep burn prompting you. ')
            print _('\tChoose \'n\' if you don\'t want this question anymore.')
            print _(
                '\t(disable this option if your user has'
                ' permissions to write with cd-writer)')
            response = console.ask_yesno(
                _("Prompt user if he is not root"), current)
            target_config.set(
                section, 'ask_root',
                console.make_yesno_response(response))
    if 'ISO' in configure_sections:
        section = 'ISO'
        options = target_config.options(section)
        if 'tempdir' in options:
            print
            current = target_config.get(section, 'tempdir')
            print _('Which is your temporary directory?')
            while True:
                tmpdr = console.ask_value(
                    _("Temporary directory path"), current)
                if tmpdr == '':
                    break
                if os.path.exists(tmpdr) and os.path.isdir(tmpdr):
                    target_config.set(section, 'tempdir', tmpdr)
                    break
                else:
                    print tmpdr, _('invalid path... skipped.')
                    break
        if 'image' in options:
            print
            current = target_config.get(section, 'image')
            print _('Temporary ISO name?')
            while True:
                image_filename = console.ask_value(
                    _("Temporary ISO image filename"), current)
                if image_filename == '':
                    break
                else:
                    target_config.set(section, 'image', image_filename)
                    break
        if 'windows_read' in options:
            print
            current = console.make_boolean_response(
                target_config.get(section, 'windows_read'))
            print _('Enable Joliet?')
            print _(
                '\tYou should enable this option if you want'
                ' to use your CDs on a Windows system too.')
            response = console.ask_yesno(
                _("Enable Joliet data (for Windows compatibility)"),
                current)
            target_config.set(
                section, 'windows_read',
                console.make_yesno_response(response))
        if 'mount_dir' in options:
            print
            current = target_config.get(section, 'mount_dir')
            print _('Which is your preferred mount point?')
            print _('\tBurn allows you to see image contents.')
            print _('\tWhere do you want to mount the image?')
            while True:
                tmpdr = console.ask_value(
                    _("Mount point directory path"), current)
                if tmpdr == '':
                    break
                if os.path.exists(tmpdr) and os.path.isdir(tmpdr):
                    target_config.set(section, 'mount_dir', tmpdr)
                    break
                else:
                    print tmpdr, _('invalid path... skipped.')
                    break
    if 'CD-writer' in configure_sections:
        section = 'CD-writer'
        options = target_config.options(section)
        if 'device' in options:
            hypothesis_count = 1
            current = target_config.get(section, 'device')
            print _(
                '\nWhich is your cd-dvd writer device?'
                '\n\tEnter either the device file (e.g. /dev/hdc) or '
                'the symbolic link to it (e.g. /dev/cdrom or /dev/cdrw).\n'
                '\tTraditional SCSI descriptions of devicetype:bus/target/lun '
                'specification (e.g. 1,0,0) are accepted too.\n')
            print _('\n\n\tPress a key to start guessing your device.\n')
            console.getch()
            if giveme_realpath('/dev/cdrw'):
                print _(
                    '\n\t* Hypotesis #'
                    ), hypothesis_count, _( ': '), giveme_realpath('/dev/cdrw')
                print _(
                    '\t\t("/dev/cdrw", which usually identifies a '
                    'cd-writer unit, points to this device.)')
                hypothesis_count += 1
            if giveme_realpath('/dev/dvdrw'):
                print _(
                    '\t* Hypotesis #'
                    ),hypothesis_count, _( ': '),giveme_realpath('/dev/dvdrw')
                print _(
                    '\t\t("/dev/dvdrw", which usually identifies a dvd-writer '
                    'unit, points to this device.)')
                hypothesis_count += 1
            if giveme_realpath('/dev/cdrom'):
                print _(
                    '\t* Hypotesis #'
                    ), hypothesis_count, _( ': '),giveme_realpath('/dev/cdrom')
                print _(
                    '\t\t("/dev/cdrom" points to this device. If your '
                    'cd-reader\n\t\t unit is the same of your cd-writer '
                    'unit this should be your device)')
                hypothesis_count += 1
            if giveme_realpath('/dev/dvd'):
                print _(
                    '\t* Hypotesis #'
                    ), hypothesis_count, _( ': '),giveme_realpath('/dev/dvd')
                print _(
                    '\t\t("/dev/dvd" points to this device. If your dvd-reader'
                    '\n\t\t unit is the same of your cd-writer '
                    'unit this should be your device)')
                hypothesis_count += 1
            print '\n\tPress a key to see wodim\'s device list output.\n'
            console.getch()
            print device.device_list_output()
            if console.ask_yesno(_(
                '\tDo you also want to see bus/target/lun scsi '
                'specifications'), False):
                print device.bus_list_output()
            while True:
                print _('\n')
                tmpdr = console.ask_value(
                    _("Optical media recording device"), current)
                if tmpdr == '':
                    break
                else:
                    target_config.set(section, 'device', tmpdr)
                    break
        if 'speed' in options:
            print
            current = target_config.get(section, 'speed')
            print _('At which speed do you want to burn?')
            print _('\tRemember: higher speed may lead to buffer underrun.')
            while True:
                spd = console.ask_value(
                    _("Recording speed"), current)
                if spd == '':
                    break
                else:
                    target_config.set(section, 'speed', spd)
                    break
        if 'driver' in options:
            print
            current = target_config.get(section, 'driver')
            print _('Does your CD-writer use a specific driver?')
            print _('\tPossible values are: ')
            values = [
                "tcdd2600", "plextor", "plextor-scan",
                "generic-mmc", "generic-mmc-raw",
                "ricoh-mp6200", "yamaha-cdr10x", "teac-cdr55",
                "sony-cdu920", "sony-cdu948", "taiyo-yuden", "toshiba",
                ]
            print textwrap.fill(
                ", ".join(values),
                initial_indent="\t\t", subsequent_indent="\t\t",
                break_long_words=False)

            while True:
                drvr = console.ask_value(
                    _("Driver value for media writer device"), current)
                if drvr == '':
                    break
                else:
                    target_config.set(section, 'driver', drvr)
                    break
        if 'burnfree' in options:
            print
            current = console.make_boolean_response(
                target_config.get(section, 'burnfree'))
            print _(
                'Do you want to turn the support for'
                ' Buffer Underrun Free writing on?')
            print _(
                '\tThis only works for drives that support'
                ' Buffer Underrun Free technology')
            response = console.ask_yesno(
                _("Enable support for Buffer Underrun Free"), current)
            target_config.set(
                section, 'burnfree',
                console.make_yesno_response(response))
    if 'CD-reader' in configure_sections:
        section = 'CD-reader'
        print
        if console.ask_yesno(
            _('Do you have a second unit as a CD-reader'), False):
            options = target_config.options(section)
            hypothesis_count = 1
            current = target_config.get(section, 'device')
            print _(
                '\nWhich is your cd-dvd reader device?'
                '\n\tEnter either the device file (e.g. /dev/hdc) or the '
                'symbolic link to it (e.g. /dev/cdrom or /dev/cdrw).\n'
                '\tTraditional SCSI descriptions of '
                'devicetype:bus/target/lun specification (e.g. 1,0,0) '
                'are accepted too.\n'
                '\n\n\tPress a key to start guessing your device.\n')
            console.getch()
            if giveme_realpath('/dev/cdrom'):
                print _('\t* Hypotesis #'), hypothesis_count, _(
                    ': '), giveme_realpath('/dev/cdrom')
                print _(
                    '\t\t("/dev/cdrom" points to this device.')
                hypothesis_count += 1
            if giveme_realpath('/dev/dvd'):
                print _('\t* Hypotesis #'), hypothesis_count, _(
                ': '), giveme_realpath('/dev/dvd')
                print _(
                    '\t\t("/dev/dvd" points to this device.')
                hypothesis_count += 1
            print '\n\tPress a key to see wodim\'s device list output.\n'
            console.getch()
            print device.device_list_output()
            if console.ask_yesno(_(
                '\tDo you also want to see bus/target/lun '
                'scsi specifications'), False):
                print device.bus_list_output()
                while True:
                    tmpdr = console.ask_value(
                        _("Optical media reading device"), current)
                    if tmpdr == '':
                        break
                    else:
                        target_config.set(section, 'device', tmpdr)
                        break
            if 'driver' in options:
                print
                current = target_config.get(section, 'driver')
                print _('Does your CD-reader use a specific driver?')
                print _('\tPossible values are: ')
                values = [
                    "tcdd2600", "plextor", "plextor-scan",
                    "generic-mmc", "generic-mmc-raw",
                    "ricoh-mp6200", "yamaha-cdr10x", "teac-cdr55",
                    "sony-cdu920", "sony-cdu948", "taiyo-yuden", "toshiba",
                    ]
                print textwrap.fill(
                    ", ".join(values),
                    initial_indent="\t\t", subsequent_indent="\t\t",
                    break_long_words=False)
                while True:
                    drvr = console.ask_value(
                        _("Driver value for media writer device"), current)
                    if drvr == '':
                        break
                    else:
    #                   target_config.set(section, 'driver', drvr)
                        break
    if 'Media' in configure_sections:
        section = 'Media'
        options = target_config.options(section)
        if 'size' in options:
            print
            current = target_config.get(section, 'size')
            print _('Which is the most common capacity of your target CDs?')
            while True:
                tmpdr = console.ask_value(
                    _("Media capacity (MB)"), current)
                if tmpdr == '':
                    break
                else:
                    target_config.set(section, 'size', tmpdr)
                    break
        if 'media-check' in options:
            print
            current = console.make_boolean_response(
                target_config.get(section, 'media-check'))
            print _('Do you want burn to auto-check target CD capacity?')
            print _('\tThis function uses cdrdao.')
            response = console.ask_yesno(
                _("Check target media capacity"), current)
            target_config.set(
                section, 'media-check',
                console.make_yesno_response(response))

    configure.write_to_file(target_config, target_conf_file_path)
    print
    print
    print _('Congratulations!')
    print _('Now you have your new configuration file:')
    print target_conf_file_path
    print _('Please rename it and place it as ~/.burnrc or /etc/burn.conf')


if __name__ == '__main__':
    exit_status = main()
    sys.exit(exit_status)


# Local variables:
# mode: python
# coding: utf-8
# End:
# vim: filetype=python fileencoding=utf-8 :