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

Side by Side Diff: client/tests/trace_inputs/touch_only.py

Issue 2093593002: luci-py: Making __file__ usage unicode safe. (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: Small fixes. 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 | « client/tests/threading_utils_test.py ('k') | client/tests/trace_inputs_smoke_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2012 The LUCI Authors. All rights reserved. 2 # Copyright 2012 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Uses different APIs to touch a file.""" 6 """Uses different APIs to touch a file."""
7 7
8 import os 8 import os
9 import sys 9 import sys
10 10
11 11
12 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) 12 BASE_DIR = os.path.dirname(os.path.abspath(
13 __file__.decode(sys.getfilesystemencoding())))
13 14
14 15
15 def main(): 16 def main():
16 print 'Only look if a file exists but do not open it.' 17 print 'Only look if a file exists but do not open it.'
17 assert len(sys.argv) == 2 18 assert len(sys.argv) == 2
18 path = os.path.join(BASE_DIR, 'test_file.txt') 19 path = os.path.join(BASE_DIR, 'test_file.txt')
19 command = sys.argv[1] 20 command = sys.argv[1]
20 if command == 'access': 21 if command == 'access':
21 return not os.access(path, os.R_OK) 22 return not os.access(path, os.R_OK)
22 elif command == 'isfile': 23 elif command == 'isfile':
23 return not os.path.isfile(path) 24 return not os.path.isfile(path)
24 elif command == 'stat': 25 elif command == 'stat':
25 return not os.stat(path).st_size 26 return not os.stat(path).st_size
26 return 1 27 return 1
27 28
28 29
29 if __name__ == '__main__': 30 if __name__ == '__main__':
30 sys.exit(main()) 31 sys.exit(main())
OLDNEW
« no previous file with comments | « client/tests/threading_utils_test.py ('k') | client/tests/trace_inputs_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698