/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/win32/brz_postinstall.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
    if start_brz:
160
160
        fname = os.path.join(brz_dir, "start_brz.bat")
161
161
        if os.path.isfile(fname):
162
 
            with file(fname, "r") as f:
163
 
                content = f.readlines()
 
162
            f = file(fname, "r")
 
163
            content = f.readlines()
 
164
            f.close()
164
165
        else:
165
166
            content = ["brz.exe help\n"]
166
167
 
181
182
            print("*** File content:")
182
183
            print(''.join(content))
183
184
        else:
184
 
            with file(fname, 'w') as f:
185
 
                f.write(''.join(content))
 
185
            f = file(fname, 'w')
 
186
            f.write(''.join(content))
 
187
            f.close()
186
188
 
187
189
    if (add_path or delete_path) and winver == 'Windows NT':
188
190
        # find appropriate registry key:
266
268
        pattern = 'SET PATH=%PATH%;' + brz_dir_8_3
267
269
 
268
270
        # search pattern
269
 
        with file(abat, 'r') as f:
270
 
            lines = f.readlines()
 
271
        f = file(abat, 'r')
 
272
        lines = f.readlines()
 
273
        f.close()
271
274
        found = False
272
275
        for i in lines:
273
276
            if i.rstrip('\r\n') == pattern:
277
280
        if delete_path and found:
278
281
            backup_autoexec_bat(abat, abak, dry_run)
279
282
            if not dry_run:
280
 
                with file(abat, 'w') as f:
281
 
                    for i in lines:
282
 
                        if i.rstrip('\r\n') != pattern:
283
 
                            f.write(i)
 
283
                f = file(abat, 'w')
 
284
                for i in lines:
 
285
                    if i.rstrip('\r\n') != pattern:
 
286
                        f.write(i)
 
287
                f.close()
284
288
            else:
285
289
                print('*** Remove line <%s> from autoexec.bat' % pattern)
286
290
                    
287
291
        elif add_path and not found:
288
292
            backup_autoexec_bat(abat, abak, dry_run)
289
293
            if not dry_run:
290
 
                with file(abat, 'a') as f:
291
 
                    f.write(pattern)
292
 
                    f.write('\n')
 
294
                f = file(abat, 'a')
 
295
                f.write(pattern)
 
296
                f.write('\n')
 
297
                f.close()
293
298
            else:
294
299
                print('*** Add line <%s> to autoexec.bat' % pattern)
295
300