summarylogtreecommitdiffstats
path: root/burn-cd.patch
blob: 05fa29f2dfcda9c5ec56e647aae81d5211cbe8da (plain)
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
--- burn-cd-1.8.1	2021-03-06 06:25:02.105401102 +0100
+++ burn-cd	2021-03-06 06:26:14.918591379 +0100
@@ -1,6 +1,6 @@
-#!/usr/bin/python2 -O
+#!/usr/bin/python3 -O
 # vim: fileencoding=utf-8:et:tw=0:ts=4:sts=4:sw=4:fdm=marker
-import sys, os, stat, getopt, string, time, signal, types, random, atexit, termios, tty
+import sys, os, stat, getopt, time, signal, types, random, atexit, termios, tty
 
 # config class to read and write simple config files
 class   config( object ):  #{{{
@@ -63,7 +63,7 @@
     def __setattr__( self, key, value ):
         k = str( key ).lower()
         dict = self._dict
-        if not dict.has_key( k ):
+        if k not in dict:
             self._orderlist.append( (True,k) )
         dict[ k ] = value
 
@@ -118,7 +118,7 @@
             yield s
 
     def handle_not_string( self, number, obj ):
-        sys.stderr.write( '[CONFIG WARNING] line %d: input "%s" is not a string\n' % (number,`obj`) )
+        sys.stderr.write( '[CONFIG WARNING] line %d: input "%s" is not a string\n' % (number,repr(obj)) )
 
     def handle_unknown_key( self, number, string, key ):
         sys.stderr.write( '[CONFIG WARNING] line %d: unknown key "%s"\n' % (number,key) )
@@ -138,7 +138,7 @@
         comment = param['comment']
         ignore_unknown = param['ignore_unknown']
         preserve_type = param['preserve_type']
-        str_types = types.StringTypes
+        str_types = (str,)
         number = 0
         for s in source:
             number += 1
@@ -156,7 +156,7 @@
                 continue
             key = s[0].strip().lower()
             value = s[1].strip()
-            dict_has_key = dict.has_key( key )
+            dict_has_key = key in dict
             if ignore_unknown and not dict_has_key:
                 self.handle_unknown_key( number, orig, key )
                 continue
@@ -421,8 +421,8 @@
     if signum == signal.SIGINT:
         name = 'SIGINT (Ctrl-C)'
     else:   name = 'SIGTERM'
-    print '%s[%ssignal%s]\n%sGot a signal %s, terminating...%s' % \
-        (COLOR_5, COLOR_8, COLOR_5, COLOR_4, name, COLOR_0)
+    print('%s[%ssignal%s]\n%sGot a signal %s, terminating...%s' % \
+        (COLOR_5, COLOR_8, COLOR_5, COLOR_4, name, COLOR_0))
 
     sys.exit(10)
 #}}}
@@ -466,7 +466,7 @@
                 flush()
         else:
             new_cmd.append( op )
-    return string.join( new_cmd )
+    return ' '.join( new_cmd )
 #}}}
 def get_valid_opts( prog_out ): #{{{
     valid_opts = []
@@ -499,7 +499,7 @@
         mode[ CC ][ termios.VMIN ] = 1
         mode[ CC ][ termios.VTIME ] = 0
         termios.tcsetattr( fd, termios.TCSADRAIN, mode )
-    except Exception, why:
+    except Exception as why:
         pass
 
     return old
@@ -511,7 +511,7 @@
 
     fd = sys.stdin.fileno()
     try:    termios.tcsetattr( fd, termios.TCSADRAIN, old )
-    except Exception, why:
+    except Exception as why:
         pass
 #}}}
 def getch():    #{{{
@@ -565,10 +565,10 @@
 #}}}
 def print_task( s ):    #{{{
     write( '%s %s%-50s%s' % (ASTERISK, COLOR_1, s, COLOR_0) )
-    if debug:  print
+    if debug:  print()
 #}}}
 def print_error( s ):   #{{{
-    print COLOR_5+'['+COLOR_8+ s +COLOR_5+']'+COLOR_0
+    print(COLOR_5+'['+COLOR_8+ s +COLOR_5+']'+COLOR_0)
 #}}}
 def print_warning( msg, tag=None ):  #{{{
     tag_str = tag and (tag+': ') or ''
@@ -604,7 +604,7 @@
 
     bar_len = 39
     write( '\r%s%s[' % (' '*first_pad,COLOR_9) )
-    eq_len = long( round( percent*(bar_len-2) / 100.0 ) )
+    eq_len = int( round( percent*(bar_len-2) / 100.0 ) )
     sp_len = bar_len - 2 - eq_len
     write( COLOR_5+ '='*eq_len )
     if 0 < eq_len < bar_len-2:
@@ -685,21 +685,21 @@
               'zero',   'nero',     'image=',   'video', 'interactive=', 'label=', 'simulate' ]
         )
     except getopt.GetoptError:
-        print
+        print()
         print_error('Error: wrong arguments')
-        print
-        print USAGE
-        print DESCRIPTION
-        print HELP
+        print()
+        print(USAGE)
+        print(DESCRIPTION)
+        print(HELP)
         sys.exit(1)
 
     for opt, val in opts:
         if opt in ['-h','--help']:
-            print USAGE
-            print HELP
+            print(USAGE)
+            print(HELP)
             sys.exit(0)
         elif opt in ['--version']:
-            print VERSION
+            print(VERSION)
             sys.exit(0)
         elif opt in ['-v','--verbose']:
             verbose = True
@@ -744,12 +744,12 @@
             label = val
 
     if not filenames and not (info or zero or image):
-        print
+        print()
         print_error('Error: you should specify files and/or dirs to burn')
-        print
-        print USAGE
-        print DESCRIPTION
-        print HELP
+        print()
+        print(USAGE)
+        print(DESCRIPTION)
+        print(HELP)
         sys.exit(2)
 
     root = '/' + escape_str( root ).lstrip('/')
@@ -786,7 +786,7 @@
     growisofs_out, growisofs_exit_code = run_cmd( cmd )
 
     if mkisofs_exit_code == None and cdrecord_exit_code == None:
-        print OK
+        print(OK)
         exit_flag = False
     else:
         print_error('not found')
@@ -873,7 +873,7 @@
             break
 
     if not is_mounted:
-        print OK
+        print(OK)
         if verbose:
             print_key_value( 'mount point', '(not mounted)' )
             print_key_value( 'file system', '(unknown)' )
@@ -885,7 +885,7 @@
 
     out, exit_code = run_cmd( cmd )
     if exit_code == None:
-        print OK
+        print(OK)
         if verbose:
             parts = s.split()
             print_key_value( 'mount point', parts[1] )
@@ -914,7 +914,7 @@
             error_str = 'wrong device'
         elif 'Current:' in s:
             media = s.split()[1]
-            if mmc_profiles.has_key( media ):
+            if media in mmc_profiles:
                 media = mmc_profiles[ media ]
             if media == 'none':
                 media = None
@@ -927,7 +927,7 @@
             print_error('not a DVD')
             exit_flag = True
         else:
-            print OK
+            print(OK)
             exit_flag = False
     else:
         print_error( error_str )
@@ -998,7 +998,7 @@
         if 'ATIP info from disk' in s:
             atip = True
         elif 'ATIP start of lead out' in s:
-            try:    total_space = long( s.split(':',1)[1].strip().split()[0] )
+            try:    total_space = int( s.split(':',1)[1].strip().split()[0] )
             except: pass
         elif 'Manufacturer' in s:
             try:    manufacturer = s.split(':',1)[1].strip()
@@ -1030,7 +1030,7 @@
                 out += [ 'This media is not blank, exiting...\n' ]
             exit_flag = True
         else:
-            print OK
+            print(OK)
             exit_flag = False
     else:
         if 'RW' in media:
@@ -1050,7 +1050,7 @@
         disk_type += ' (blank)'
     elif appendable:
         s = out[-1]
-        try:    last_start, new_start = map( long, s.split(',',1) )
+        try:    last_start, new_start = list(map( int, s.split(',',1) ))
         except: pass
         free_space = total_space - new_start
         disk_type += ' (multisession)'
@@ -1077,10 +1077,10 @@
         if get_yes_or_no( default=True ):
             zero = blank = appendable = True
             free_space = total_space
-            print YES
+            print(YES)
             return
         else:
-            print NO
+            print(NO)
 
     if verbose:
         print_prog_out( out )
@@ -1182,7 +1182,7 @@
             if 'RW' in media:
                 ask_for_zero = interactive
         else:
-            print OK
+            print(OK)
             exit_flag = False
     else:
         if 'RW' in media:
@@ -1212,7 +1212,7 @@
         used_space = 0
         for s in out:
             if not 'Volume size is:' in s:  continue
-            try:    used_space = long( s.split(':')[1] )
+            try:    used_space = int( s.split(':')[1] )
             except: pass
         free_space = total_space - used_space
         disk_type += ' (multisession)'
@@ -1252,10 +1252,10 @@
         if get_yes_or_no( default=True ):
             zero = blank = appendable = True
             free_space = total_space
-            print YES
+            print(YES)
             return
         else:
-            print NO
+            print(NO)
 
     if verbose:
         print_prog_out( out )
@@ -1354,7 +1354,7 @@
         for f in valid_filenames:
             print_debug( '    ' + f )
 
-        empty_ext = [ e for e,v in video_extensions.items() if not v ]
+        empty_ext = [ e for e,v in list(video_extensions.items()) if not v ]
         # exit if something was not found
         if empty_ext:
             write( '%sNo valid DVD-Video structure could be found, exiting...%s\n' % (COLOR_4,COLOR_0) )
@@ -1364,14 +1364,14 @@
         atexit.register( rm_tmp_dir )   # registering cleaning handler
         tmp_dir = '/tmp/burn-cd--%s--%s' % (os.getpid(), random.randint(1000,9999))
         try:
-            os.mkdir( tmp_dir, 0700 )
-            os.mkdir( tmp_dir + '/AUDIO_TS', 0700 )
-            os.mkdir( tmp_dir + '/VIDEO_TS', 0700 )
+            os.mkdir( tmp_dir, 0o700 )
+            os.mkdir( tmp_dir + '/AUDIO_TS', 0o700 )
+            os.mkdir( tmp_dir + '/VIDEO_TS', 0o700 )
 
             for f in valid_filenames:
                 base = os_basename( f ).upper()
                 os.symlink( f, '%s/VIDEO_TS/%s' % (tmp_dir, base) )
-        except Exception, why:
+        except Exception as why:
             write( '%sError creating a DVD-Video structure in %s:\n%s%s\n' % (COLOR_4, tmp_dir, why, COLOR_0) )
             sys.exit(7)
 
@@ -1397,7 +1397,7 @@
             if ok:
                 if root == '' and not dir_flag:  prefix = ''
                 fnames.append( prefix + f )
-        fnames = string.join( fnames )
+        fnames = ' '.join( fnames )
 
     flush()
 #}}}
@@ -1455,7 +1455,7 @@
     exit_code = ch_out.close()
 
     if exit_code == None:
-        print OK
+        print(OK)
         exit_flag = False
         if verbose:  print_key_value( 'Blanking time', blank_time or 'n/a' )
     else:
@@ -1494,7 +1494,7 @@
             (COLOR_8,COLOR_0) )
         sys.exit(5)
     size = f_stat[ stat.ST_SIZE ]
-    new_size = long( size/2048.0 + 0.9999999 )
+    new_size = int( size/2048.0 + 0.9999999 )
     image = escape_str( f )
 
     single_session = True
@@ -1513,7 +1513,7 @@
         print_error( 'too big' )
         exit_flag = True
     else:
-        print OK
+        print(OK)
 
     if verbose:
         sess_size = '%.1f MB' % ( size / (1024.0*1024.0) )
@@ -1575,7 +1575,7 @@
         print_error( 'something wrong' )
         exit_flag = True
     else:
-        try:    new_size = long( ch_out[-1] )
+        try:    new_size = int( ch_out[-1] )
         except: new_size = 0
 
         delta_size = free_space - new_size
@@ -1602,7 +1602,7 @@
             if not blank and 'RW' in media and new_size <= total_space:
                 ask_for_zero = interactive
         else:
-            print OK
+            print(OK)
 
     if ask_for_zero:
         if dvd: s = 'Do you want to overwrite RW media to fit the data?'
@@ -1612,7 +1612,7 @@
             zero = blank = appendable = True
             free_space = total_space
             exit_flag = False
-            print YES
+            print(YES)
 
             multi_overhead = 11702
             mode_str = 'start multi-session'
@@ -1624,7 +1624,7 @@
                 mode_str = 'single session'
                 multi_overhead = 0
         else:
-            print NO
+            print(NO)
 
     if verbose:
         try:    sess_size = '%.1f MB (%.1f MB)' % ((new_size+multi_overhead)/512.0,new_size/512.0)
@@ -1762,7 +1762,7 @@
     #dbg.close()
 
     if exit_code == None:
-        print OK
+        print(OK)
         exit_flag = False
         if verbose:  print_key_value( 'Time', fixating_time )
     else:
@@ -1871,7 +1871,7 @@
     finalizing_start = finalizing_start or time.time()
 
     if exit_code == None:
-        print OK
+        print(OK)
         exit_flag = False
         if verbose:
             finalizing_time = '%d sec' % round( time.time()-finalizing_start )
@@ -1905,7 +1905,7 @@
 
     ch_out, exit_code = run_cmd( cmd )
     if exit_code == None:
-        print OK
+        print(OK)
         flush()
         return
 
@@ -1927,7 +1927,7 @@
     load_config()
     parse_cmd_line()
 
-    cmd = string.join( sys.argv )
+    cmd = ' '.join( sys.argv )
     print_debug( cmd )
 
     check_programs()