Left: | ||
Right: |
OLD | NEW |
---|---|
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2018 Google Inc. All Rights Reserved. | 2 # Copyright 2018 Google Inc. All Rights Reserved. |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 from ctypes import c_wchar_p | 46 from ctypes import c_wchar_p |
47 from ctypes import windll | 47 from ctypes import windll |
48 from ctypes import POINTER | 48 from ctypes import POINTER |
49 from ctypes import WINFUNCTYPE | 49 from ctypes import WINFUNCTYPE |
50 from ctypes import WinError | 50 from ctypes import WinError |
51 IS_CP1252 = locale.getdefaultlocale()[1] == WINDOWS_1252 | 51 IS_CP1252 = locale.getdefaultlocale()[1] == WINDOWS_1252 |
52 else: | 52 else: |
53 IS_CP1252 = False | 53 IS_CP1252 = False |
54 | 54 |
55 | 55 |
56 def RunningOnAlpineLinux(): | |
57 if IS_WINDOWS: | |
58 return False | |
59 with open('/etc/os-release', 'r') as f: | |
houglum
2018/10/12 08:28:13
It's possible that this might raise an exception (
Mike Schwartz
2018/10/12 18:50:14
Done.
| |
60 return 'Alpine Linux' in f.read() | |
61 | |
62 | |
56 def CheckFreeSpace(path): | 63 def CheckFreeSpace(path): |
57 """Return path/drive free space (in bytes).""" | 64 """Return path/drive free space (in bytes).""" |
58 if IS_WINDOWS: | 65 if IS_WINDOWS: |
59 try: | 66 try: |
60 # pylint: disable=invalid-name | 67 # pylint: disable=invalid-name |
61 get_disk_free_space_ex = WINFUNCTYPE(c_int, c_wchar_p, | 68 get_disk_free_space_ex = WINFUNCTYPE(c_int, c_wchar_p, |
62 POINTER(c_uint64), | 69 POINTER(c_uint64), |
63 POINTER(c_uint64), | 70 POINTER(c_uint64), |
64 POINTER(c_uint64)) | 71 POINTER(c_uint64)) |
65 get_disk_free_space_ex = get_disk_free_space_ex( | 72 get_disk_free_space_ex = get_disk_free_space_ex( |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
233 def IsRunningInteractively(): | 240 def IsRunningInteractively(): |
234 """Returns True if currently running interactively on a TTY.""" | 241 """Returns True if currently running interactively on a TTY.""" |
235 return sys.stdout.isatty() and sys.stderr.isatty() and sys.stdin.isatty() | 242 return sys.stdout.isatty() and sys.stderr.isatty() and sys.stdin.isatty() |
236 | 243 |
237 | 244 |
238 def StdinIterator(): | 245 def StdinIterator(): |
239 """A generator function that returns lines from stdin.""" | 246 """A generator function that returns lines from stdin.""" |
240 for line in sys.stdin: | 247 for line in sys.stdin: |
241 # Strip CRLF. | 248 # Strip CRLF. |
242 yield line.rstrip() | 249 yield line.rstrip() |
OLD | NEW |