Kiln » largefiles » Unity
Clone URL:  

lfutil: fix OS-sniffing awkwardness by simply using python builtin open() and then chmod()

Changeset bc714da66961

Parent 182f1db4e5ba

by Profile picture of User 521Andrew Pritchard <andrewp@fogcreek.com>

Changes to one file · Browse files at bc714da66961 Showing diff from parent 182f1db4e5ba Diff from another changeset...

Change 1 of 1 Show Entire File lfutil.py Stacked
 
427
428
429
430
431
432
433
434
435
436
437
438
 
439
440
441
442
443
444
 
 
445
446
447
 
427
428
429
 
 
 
 
 
 
 
 
 
430
431
432
433
434
435
436
437
438
439
440
441
@@ -427,21 +427,15 @@
  util.makedirs(os.path.dirname(filename))   if os.path.exists(filename):   os.unlink(filename) - if os.name == 'posix': - # Yuck: on Unix, go through open(2) to ensure that the caller's mode is - # filtered by umask() in the kernel, where it's supposed to be done. - wfile = os.fdopen(os.open(filename, os.O_WRONLY|os.O_CREAT, - getmode(executable)), 'wb') - else: - # But on Windows, use open() directly, since passing mode='wb' to - # os.fdopen() does not work. (Python bug?) - wfile = open(filename, 'wb') + wfile = open(filename, 'wb')     try:   wfile.write(hash)   wfile.write('\n')   finally:   wfile.close() + if os.path.exists(filename): + os.chmod(filename, getmode(executable))    def getexecutable(filename):   mode = os.stat(filename).st_mode