Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: client/utils/file_path.py

Issue 2024313003: Send authorization headers when calling Swarming backend. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « appengine/swarming/swarming_bot/config/bot_config.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The LUCI Authors. All rights reserved. 1 # Copyright 2013 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 """Provides functions: get_native_path_case(), isabs() and safe_join(). 5 """Provides functions: get_native_path_case(), isabs() and safe_join().
6 6
7 This module assumes that filesystem is not changing while current process 7 This module assumes that filesystem is not changing while current process
8 is running and thus it caches results of functions that depend on FS state. 8 is running and thus it caches results of functions that depend on FS state.
9 """ 9 """
10 10
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 up. 791 up.
792 """ 792 """
793 assert path and path[-1] != os.sep, path 793 assert path and path[-1] != os.sep, path
794 path = os.path.abspath(path) 794 path = os.path.abspath(path)
795 dir_name, base_name = os.path.split(path) 795 dir_name, base_name = os.path.split(path)
796 796
797 fd, tmp_name = tempfile.mkstemp(dir=dir_name, prefix=base_name+'_') 797 fd, tmp_name = tempfile.mkstemp(dir=dir_name, prefix=base_name+'_')
798 try: 798 try:
799 with os.fdopen(fd, 'wb') as f: 799 with os.fdopen(fd, 'wb') as f:
800 f.write(body) 800 f.write(body)
801 f.flush()
802 os.fsync(fd)
801 if sys.platform != 'win32': 803 if sys.platform != 'win32':
802 os.rename(tmp_name, path) 804 os.rename(tmp_name, path)
803 else: 805 else:
804 # Flags are MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH. 806 # Flags are MOVEFILE_REPLACE_EXISTING|MOVEFILE_WRITE_THROUGH.
805 MoveFileEx(unicode(tmp_name), unicode(path), 0x1|0x8) 807 MoveFileEx(unicode(tmp_name), unicode(path), 0x1|0x8)
806 tmp_name = None # no need to remove it in 'finally' block anymore 808 tmp_name = None # no need to remove it in 'finally' block anymore
807 finally: 809 finally:
808 if tmp_name: 810 if tmp_name:
809 try: 811 try:
810 os.remove(tmp_name) 812 os.remove(tmp_name)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 errors = [] 1027 errors = []
1026 fs.rmtree(root, onerror=lambda *args: errors.append(args)) 1028 fs.rmtree(root, onerror=lambda *args: errors.append(args))
1027 if errors: 1029 if errors:
1028 # There's no hope. 1030 # There's no hope.
1029 sys.stderr.write( 1031 sys.stderr.write(
1030 'Failed to delete %s. The following files remain:\n' % root) 1032 'Failed to delete %s. The following files remain:\n' % root)
1031 for _, path, _ in errors: 1033 for _, path, _ in errors:
1032 sys.stderr.write('- %s\n' % path) 1034 sys.stderr.write('- %s\n' % path)
1033 raise errors[0][2][0], errors[0][2][1], errors[0][2][2] 1035 raise errors[0][2][0], errors[0][2][1], errors[0][2][2]
1034 return False 1036 return False
OLDNEW
« no previous file with comments | « appengine/swarming/swarming_bot/config/bot_config.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698